系列文章目录

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



前言

本文以 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_ENABLE
    huedbg_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;
};
#endif

    HUEDBG("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_ENABLE
    huedbg_dump_AddressSpace(&address_space_memory, 2);
#endif

    system_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_ENABLE
    huedbg_dump_AddressSpace(&address_space_io, 2);
#endif
    HUEDBG("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 并启动机器做准备。

05-01 15:17