【QEMU系统分析之实例篇(七)】

2024-05-01 15:44
文章标签 实例 qemu 系统分析

本文主要是介绍【QEMU系统分析之实例篇(七)】,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

系列文章目录

第七章 QEMU系统仿真的机器创建分析实例


文章目录

  • 系列文章目录
    • 第七章 QEMU系统仿真的机器创建分析实例
  • 前言
  • 一、QEMU是什么?
  • 二、QEMU系统仿真的机器创建分析实例
    • 1.系统仿真的命令行参数
    • 2.目标机器创建过程
    • 3.cpu_exec_init_all()
      • io_mem_init()
      • memory_map_init()
  • 总结


前言

本文以 QEMU 8.2.2 为例,分析其作为系统仿真工具的工作过程,并为读者展示各种 QEMU 系统仿真的启动配置实例。
本文读者需要具备一定的 QEMU 系统仿真使用经验,并对 C 语言编程有一定了解。


一、QEMU是什么?

QEMU 是一个通用且开源的机器模拟器和虚拟机。
其官方主页是:https://www.qemu.org/


二、QEMU系统仿真的机器创建分析实例

1.系统仿真的命令行参数

QEMU 作为系统仿真工具,其入口代码在 system/main.c 文件中,初始化函数 qemu_init() 的实现在 system/vl.c 文件中。
本文将分析以下命令创建目标系统机器的运行过程,读者需要对 QEMU 系统启动过程的程序代码有所了解,相关内容可以参考《QEMU系统分析之启动篇》系列文章。

..\qemu\8.2.2-qkd\qemu-system-x86_64.exe -cpu "Penryn" -M  "q35,accel=whpx" -m "6G" -nodefaults

2.目标机器创建过程

这部分代码在 system/vl.c 文件中,实现如下:

int qemu_init(int argc, char **argv)
{
...qemu_create_machine(machine_opts_dict);
...
}

进入 qemu_create_machine() 获取到目标机器类型后,对目标机器属性做相关设置,代码如下:

static void qemu_create_machine(QDict *qdict)
{
...object_set_machine_compat_props(machine_class->compat_props);current_machine = MACHINE(object_new_with_class(OBJECT_CLASS(machine_class)));object_property_add_child(object_get_root(), "machine",OBJECT(current_machine));object_property_add_child(container_get(OBJECT(current_machine),"/unattached"),"sysbus", OBJECT(sysbus_get_default()));
...
}

接下来进入运行环境的初始化,主要是内存及 I/O 存储空间的设定,对应函数为 cpu_exec_init_all(),代码如下:

static void qemu_create_machine(QDict *qdict)
{
...if (machine_class->minimum_page_bits) {if (!set_preferred_target_page_bits(machine_class->minimum_page_bits)) {/* This would be a board error: specifying a minimum smaller than* a target's compile-time fixed setting.*/g_assert_not_reached();}}cpu_exec_init_all();
...
}

本文将跟踪调试函数 cpu_exec_init_all()。


3.cpu_exec_init_all()

函数 cpu_exec_init_all() 在 /system/physmem.c 文件中,定义如下:

void cpu_exec_init_all(void)
{HUEDBG("enter!\n");qemu_mutex_init(&ram_list.mutex);/* The data structures we set up here depend on knowing the page size,* so no more changes can be made after this point.* In an ideal world, nothing we did before we had finished the* machine setup would care about the target page size, and we could* do this much later, rather than requiring board models to state* up front what their requirements are.*/finalize_target_page_bits();io_mem_init();memory_map_init();qemu_mutex_init(&map_client_list_lock);HUEDBG("return!\n");
}

首先,初始化互斥信号量 ram_list.mutex,然后调用函数 finalize_target_page_bits() 确定目标机器的页位数,该操作在 ARM 和 MIPS 平台下有操作,在 x86 平台下无处理。

接着调用函数 io_mem_init() 完成 I/O 存储器的初始化,此函数生成一个全系统统一的访问存储区域。

再调用函数 memory_map_init() 对系统内存地址空间和 I/O 地址空间做映射,为后续设备访问做准备。

最后对互斥信号量 map_client_list_lock 初始化,完成执行的地址空间初始化操作。

io_mem_init()

函数 io_mem_init() 在 /system/physmem.c 文件中,定义如下:

static void io_mem_init(void)
{HUEDBG("enter!\n");memory_region_init_io(&io_mem_unassigned, NULL, &unassigned_mem_ops, NULL,NULL, UINT64_MAX);HUEDBG("exit!\n");
#ifdef HUEDBG_ENABLEhuedbg_dump_MemoryRegion(&io_mem_unassigned, 1);
#endif
}

此处我们已经添加调试信息,该函数初始化 io_mem_unassigned 存储区域,并设定该存储区域大小为 UINT64_MAX。通过调试函数 huedbg_dump_MemoryRegion(&io_mem_unassigned, 1) 我们把初始化后的 io_mem_unassigned 呈现出来。

函数 huedbg_dump_MemoryRegion() 定义如下:

void huedbg_dump_MemoryRegion(MemoryRegion *mr, int deep)
{
#if 0
// from include/exec/memory.h
/** MemoryRegion:** A struct representing a memory region.*/
struct MemoryRegion {Object parent_obj;/* private: *//* The following fields should fit in a cache line */bool romd_mode;bool ram;bool subpage;bool readonly; /* For RAM regions */bool nonvolatile;bool rom_device;bool flush_coalesced_mmio;bool unmergeable;uint8_t dirty_log_mask;bool is_iommu;RAMBlock *ram_block;Object *owner;/* owner as TYPE_DEVICE. Used for re-entrancy checks in MR access hotpath */DeviceState *dev;const MemoryRegionOps *ops;void *opaque;MemoryRegion *container;int mapped_via_alias; /* Mapped via an alias, container might be NULL */Int128 size;hwaddr addr;void (*destructor)(MemoryRegion *mr);uint64_t align;bool terminates;bool ram_device;bool enabled;bool warning_printed; /* For reservations */uint8_t vga_logging_count;MemoryRegion *alias;hwaddr alias_offset;int32_t priority;QTAILQ_HEAD(, MemoryRegion) subregions;QTAILQ_ENTRY(MemoryRegion) subregions_link;QTAILQ_HEAD(, CoalescedMemoryRange) coalesced;const char *name;unsigned ioeventfd_nb;MemoryRegionIoeventfd *ioeventfds;RamDiscardManager *rdm; /* Only for RAM *//* For devices designed to perform re-entrant IO into their own IO MRs */bool disable_reentrancy_guard;
};
#endifHUEDBG("romd_mode=[%u]\n", mr->romd_mode);HUEDBG("ram=[%u]\n", mr->ram);HUEDBG("subpage=[%u]\n", mr->subpage);HUEDBG("readonly=[%u]\n", mr->readonly);HUEDBG("nonvolatile=[%u]\n", mr->nonvolatile);HUEDBG("rom_device=[%u]\n", mr->rom_device);HUEDBG("flush_coalesced_mmio=[%u]\n", mr->flush_coalesced_mmio);HUEDBG("unmergeable=[%u]\n", mr->unmergeable);HUEDBG("dirty_log_mask=[%u]\n", mr->dirty_log_mask);HUEDBG("is_iommu=[%u]\n", mr->is_iommu);HUEDBG("ram_block=[%p]\n", mr->ram_block);HUEDBG("owner=[%p]\n", mr->owner);HUEDBG("dev=[%p]\n", mr->dev);HUEDBG("ops=[%p]\n", mr->ops);HUEDBG("opaque=[%p]\n", mr->opaque);HUEDBG("container=[%p]\n", mr->container);HUEDBG("mapped_via_alias=[%d]\n", mr->mapped_via_alias);//HUEDBG("size=[%016llx%016llx]\n", int128_gethi(mr->size), int128_getlo(mr->size));HUEDBG("size=[%016llx]\n", int128_getlo(mr->size));HUEDBG("addr=[%016llx]\n", mr->addr);HUEDBG("destructor=[%p]\n", mr->destructor);HUEDBG("align=[%016llx]\n", mr->align);HUEDBG("terminates=[%u]\n", mr->terminates);HUEDBG("ram_device=[%u]\n", mr->ram_device);HUEDBG("enabled=[%u]\n", mr->enabled);HUEDBG("vga_logging_count=[%u]\n", mr->vga_logging_count);HUEDBG("alias=[%p]\n", mr->alias);HUEDBG("alias_offset=[%llu]\n", mr->alias_offset);HUEDBG("priority=[%d]\n", mr->priority);//HUEDBG("subregions=[%p]\n", mr->subregions);//HUEDBG("subregions_link=[%p]\n", mr->subregions_link);//HUEDBG("coalesced=[%p]\n", mr->coalesced);HUEDBG("name=[%s]\n", mr->name);HUEDBG("ioeventfd_nb=[%u]\n", mr->ioeventfd_nb);HUEDBG("ioeventfds=[%p]\n", mr->ioeventfds);HUEDBG("rdm=[%p]\n", mr->rdm);HUEDBG("disable_reentrancy_guard=[%u]\n", mr->disable_reentrancy_guard);
}

调试输出的结果如下:

[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(70):romd_mode=[1]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(71):ram=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(72):subpage=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(73):readonly=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(74):nonvolatile=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(75):rom_device=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(76):flush_coalesced_mmio=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(77):unmergeable=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(78):dirty_log_mask=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(79):is_iommu=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(80):ram_block=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(81):owner=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(82):dev=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(83):ops=[00007ff736704ec0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(84):opaque=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(85):container=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(86):mapped_via_alias=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(87):size=[00000000000000010000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(88):addr=[00000000000000000000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(89):destructor=[00007ff7358f2220]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(90):align=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(91):terminates=[1]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(92):ram_device=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(93):enabled=[1]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(94):vga_logging_count=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(95):alias=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(96):alias_offset=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(97):priority=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(98):subregions=[00007ff736849858]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(99):subregions_link=[00007ff736849868]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(100):coalesced=[00007ff736849878]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(101):name=[(null)]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(102):ioeventfd_nb=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(103):ioeventfds=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(104):rdm=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(105):disable_reentrancy_guard=[0]

对完成初始化的存储区域,我们关注到:

[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(87):size=[00000000000000010000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(88):addr=[00000000000000000000000000000000]

该存储区域地址从
地址 0x00000000000000000000000000000000 开始,
大小 0x00000000000000010000000000000000

接下来调用函数 memory_map_init() 完成存储空间的映射。


memory_map_init()

函数 memory_map_init() 在 /system/physmem.c 文件中,定义如下:

static void memory_map_init(void)
{HUEDBG("enter!\n");system_memory = g_malloc(sizeof(*system_memory));memory_region_init(system_memory, NULL, "system", UINT64_MAX);address_space_init(&address_space_memory, system_memory, "memory");
#ifdef HUEDBG_ENABLEhuedbg_dump_AddressSpace(&address_space_memory, 2);
#endifsystem_io = g_malloc(sizeof(*system_io));memory_region_init_io(system_io, NULL, &unassigned_io_ops, NULL, "io",65536);address_space_init(&address_space_io, system_io, "I/O");
#ifdef HUEDBG_ENABLEhuedbg_dump_AddressSpace(&address_space_io, 2);
#endifHUEDBG("exit!\n");
}

从代码中可知,系统存储区域 system_memory 的大小设置为 UINT64_MAX,而系统 I/O 区域 system_io 的大小设置为 65536。

跟踪调试信息如下:

[43960]../system/memory.c/address_space_init(3142):name=[memory] as=0x00007ff736849620
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(164):rcu=[00007ff736849620]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(165):name=[memory]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(166):root=[000001be4f78bcb0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(70):romd_mode=[1]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(71):ram=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(72):subpage=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(73):readonly=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(74):nonvolatile=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(75):rom_device=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(76):flush_coalesced_mmio=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(77):unmergeable=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(78):dirty_log_mask=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(79):is_iommu=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(80):ram_block=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(81):owner=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(82):dev=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(83):ops=[00007ff736704ec0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(84):opaque=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(85):container=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(86):mapped_via_alias=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(87):size=[00000000000000010000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(88):addr=[00000000000000000000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(89):destructor=[00007ff7358f2220]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(90):align=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(91):terminates=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(92):ram_device=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(93):enabled=[1]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(94):vga_logging_count=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(95):alias=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(96):alias_offset=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(97):priority=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(98):subregions=[000001be4f78bd68]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(99):subregions_link=[000001be4f78bd78]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(100):coalesced=[000001be4f78bd88]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(101):name=[system]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(102):ioeventfd_nb=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(103):ioeventfds=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(104):rdm=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(105):disable_reentrancy_guard=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(171):current_map=[000001be4f75f730]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(126):rcu=[000001be4f75f730]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(127):ref=[3]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(128):ranges=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(132):nr=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(133):nr_allocated=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(134):dispatch=[000001be4f76d180]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(135):root=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(176):ioeventfd_nb=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(177):ioeventfd_notifiers=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(178):ioeventfds=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(179):listeners=[00007ff736849658]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(180):address_spaces_link=[00007ff736849668]...[43960]../system/memory.c/address_space_init(3142):name=[I/O] as=0x00007ff736849680
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(164):rcu=[00007ff736849680]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(165):name=[I/O]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(166):root=[000001be4f78c1e0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(70):romd_mode=[1]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(71):ram=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(72):subpage=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(73):readonly=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(74):nonvolatile=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(75):rom_device=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(76):flush_coalesced_mmio=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(77):unmergeable=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(78):dirty_log_mask=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(79):is_iommu=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(80):ram_block=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(81):owner=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(82):dev=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(83):ops=[00007ff736703200]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(84):opaque=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(85):container=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(86):mapped_via_alias=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(87):size=[00000000000000000000000000010000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(88):addr=[00000000000000000000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(89):destructor=[00007ff7358f2220]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(90):align=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(91):terminates=[1]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(92):ram_device=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(93):enabled=[1]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(94):vga_logging_count=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(95):alias=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(96):alias_offset=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(97):priority=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(98):subregions=[000001be4f78c298]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(99):subregions_link=[000001be4f78c2a8]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(100):coalesced=[000001be4f78c2b8]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(101):name=[io]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(102):ioeventfd_nb=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(103):ioeventfds=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(104):rdm=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(105):disable_reentrancy_guard=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(171):current_map=[000001be4f75f8b0]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(126):rcu=[000001be4f75f8b0]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(127):ref=[2]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(128):ranges=[000001be4f78c300]
[43960]D:/msys64/home/yuhui/gitee/mingw-qemu/util/huedbg_inline-flat_range.c/huedbg_dump_FlatRange(36):mr=[000001be4f78c1e0]
[43960]D:/msys64/home/yuhui/gitee/mingw-qemu/util/huedbg_inline-flat_range.c/huedbg_dump_FlatRange(40):offset_in_region=[0000000000000000]
[43960]D:/msys64/home/yuhui/gitee/mingw-qemu/util/huedbg_inline-flat_range.c/huedbg_dump_FlatRange(49):addr.start=[0000000000000000]
[43960]D:/msys64/home/yuhui/gitee/mingw-qemu/util/huedbg_inline-flat_range.c/huedbg_dump_FlatRange(50):addr.size =[0000000000010000]
[43960]D:/msys64/home/yuhui/gitee/mingw-qemu/util/huedbg_inline-flat_range.c/huedbg_dump_FlatRange(52):dirty_log_mask=[00]
[43960]D:/msys64/home/yuhui/gitee/mingw-qemu/util/huedbg_inline-flat_range.c/huedbg_dump_FlatRange(53):romd_mode=[1]
[43960]D:/msys64/home/yuhui/gitee/mingw-qemu/util/huedbg_inline-flat_range.c/huedbg_dump_FlatRange(54):readonly=[0]
[43960]D:/msys64/home/yuhui/gitee/mingw-qemu/util/huedbg_inline-flat_range.c/huedbg_dump_FlatRange(55):nonvolatile=[0]
[43960]D:/msys64/home/yuhui/gitee/mingw-qemu/util/huedbg_inline-flat_range.c/huedbg_dump_FlatRange(56):unmergeable=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(132):nr=[1]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(133):nr_allocated=[10]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(134):dispatch=[000001be4f76d720]
[43960]../util/huedbg-memory.c/huedbg_dump_FlatView(135):root=[000001be4f78c1e0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(70):romd_mode=[1]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(71):ram=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(72):subpage=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(73):readonly=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(74):nonvolatile=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(75):rom_device=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(76):flush_coalesced_mmio=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(77):unmergeable=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(78):dirty_log_mask=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(79):is_iommu=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(80):ram_block=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(81):owner=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(82):dev=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(83):ops=[00007ff736703200]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(84):opaque=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(85):container=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(86):mapped_via_alias=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(87):size=[00000000000000000000000000010000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(88):addr=[00000000000000000000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(89):destructor=[00007ff7358f2220]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(90):align=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(91):terminates=[1]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(92):ram_device=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(93):enabled=[1]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(94):vga_logging_count=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(95):alias=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(96):alias_offset=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(97):priority=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(98):subregions=[000001be4f78c298]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(99):subregions_link=[000001be4f78c2a8]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(100):coalesced=[000001be4f78c2b8]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(101):name=[io]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(102):ioeventfd_nb=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(103):ioeventfds=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(104):rdm=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(105):disable_reentrancy_guard=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(176):ioeventfd_nb=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(177):ioeventfd_notifiers=[0]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(178):ioeventfds=[0000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(179):listeners=[00007ff7368496b8]
[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(180):address_spaces_link=[00007ff7368496c8]

其中,system_memory 需要关注的信息如下:

[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(165):name=[memory]
...
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(87):size=[00000000000000010000000000000000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(88):addr=[00000000000000000000000000000000]

system_io 需要关注的信息如下:

[43960]../util/huedbg-memory.c/huedbg_dump_AddressSpace(165):name=[I/O]
...
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(87):size=[00000000000000000000000000010000]
[43960]../util/huedbg-memory.c/huedbg_dump_MemoryRegion(88):addr=[00000000000000000000000000000000]

至此,系统存储空间和 I/O 空间就建立好了。


总结

以上分析了系统执行地址空间的创建过程,为后续载入 BIOS 并启动机器做准备。

这篇关于【QEMU系统分析之实例篇(七)】的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/952055

相关文章

前端原生js实现拖拽排课效果实例

《前端原生js实现拖拽排课效果实例》:本文主要介绍如何实现一个简单的课程表拖拽功能,通过HTML、CSS和JavaScript的配合,我们实现了课程项的拖拽、放置和显示功能,文中通过实例代码介绍的... 目录1. 效果展示2. 效果分析2.1 关键点2.2 实现方法3. 代码实现3.1 html部分3.2

mysqld_multi在Linux服务器上运行多个MySQL实例

《mysqld_multi在Linux服务器上运行多个MySQL实例》在Linux系统上使用mysqld_multi来启动和管理多个MySQL实例是一种常见的做法,这种方式允许你在同一台机器上运行多个... 目录1. 安装mysql2. 配置文件示例配置文件3. 创建数据目录4. 启动和管理实例启动所有实例

Java function函数式接口的使用方法与实例

《Javafunction函数式接口的使用方法与实例》:本文主要介绍Javafunction函数式接口的使用方法与实例,函数式接口如一支未完成的诗篇,用Lambda表达式作韵脚,将代码的机械美感... 目录引言-当代码遇见诗性一、函数式接口的生物学解构1.1 函数式接口的基因密码1.2 六大核心接口的形态学

java图像识别工具类(ImageRecognitionUtils)使用实例详解

《java图像识别工具类(ImageRecognitionUtils)使用实例详解》:本文主要介绍如何在Java中使用OpenCV进行图像识别,包括图像加载、预处理、分类、人脸检测和特征提取等步骤... 目录前言1. 图像识别的背景与作用2. 设计目标3. 项目依赖4. 设计与实现 ImageRecogni

Java操作ElasticSearch的实例详解

《Java操作ElasticSearch的实例详解》Elasticsearch是一个分布式的搜索和分析引擎,广泛用于全文搜索、日志分析等场景,本文将介绍如何在Java应用中使用Elastics... 目录简介环境准备1. 安装 Elasticsearch2. 添加依赖连接 Elasticsearch1. 创

使用C#代码计算数学表达式实例

《使用C#代码计算数学表达式实例》这段文字主要讲述了如何使用C#语言来计算数学表达式,该程序通过使用Dictionary保存变量,定义了运算符优先级,并实现了EvaluateExpression方法来... 目录C#代码计算数学表达式该方法很长,因此我将分段描述下面的代码片段显示了下一步以下代码显示该方法如

Oracle Expdp按条件导出指定表数据的方法实例

《OracleExpdp按条件导出指定表数据的方法实例》:本文主要介绍Oracle的expdp数据泵方式导出特定机构和时间范围的数据,并通过parfile文件进行条件限制和配置,文中通过代码介绍... 目录1.场景描述 2.方案分析3.实验验证 3.1 parfile文件3.2 expdp命令导出4.总结

MySQL的索引失效的原因实例及解决方案

《MySQL的索引失效的原因实例及解决方案》这篇文章主要讨论了MySQL索引失效的常见原因及其解决方案,它涵盖了数据类型不匹配、隐式转换、函数或表达式、范围查询、LIKE查询、OR条件、全表扫描、索引... 目录1. 数据类型不匹配2. 隐式转换3. 函数或表达式4. 范围查询之后的列5. like 查询6

Python开发围棋游戏的实例代码(实现全部功能)

《Python开发围棋游戏的实例代码(实现全部功能)》围棋是一种古老而复杂的策略棋类游戏,起源于中国,已有超过2500年的历史,本文介绍了如何用Python开发一个简单的围棋游戏,实例代码涵盖了游戏的... 目录1. 围棋游戏概述1.1 游戏规则1.2 游戏设计思路2. 环境准备3. 创建棋盘3.1 棋盘类

【机器学习】高斯过程的基本概念和应用领域以及在python中的实例

引言 高斯过程(Gaussian Process,简称GP)是一种概率模型,用于描述一组随机变量的联合概率分布,其中任何一个有限维度的子集都具有高斯分布 文章目录 引言一、高斯过程1.1 基本定义1.1.1 随机过程1.1.2 高斯分布 1.2 高斯过程的特性1.2.1 联合高斯性1.2.2 均值函数1.2.3 协方差函数(或核函数) 1.3 核函数1.4 高斯过程回归(Gauss