understanding_qemu
  • Introduction
  • 设备模型
    • 设备类型注册
    • 设备类型初始化
    • 设备实例化
    • DeviceClass实例化细节
    • 面向对象的设备模型
    • 接口
    • 类型、对象和接口之间的转换
    • PCDIMM
      • PCDIMM类型
      • PCDIMM实例
      • 插入系统
      • 创建ACPI表
      • NVDIMM
  • 地址空间
    • 从初始化开始
    • MemoryRegion
    • AddressSpace Part1
    • FlatView
    • RAMBlock
    • AddressSpace Part2
    • 眼见为实
    • 添加MemoryRegion
  • APIC
    • 纯Qemu模拟
    • Qemu/kernel混合模拟
    • APICV
  • Live Migration
    • 从用法说起
    • 整体架构
    • VMStateDescription
    • 内存热迁移
    • postcopy
  • FW_CFG
    • 规范解读
    • Linux Guest
    • SeaBios
  • Machine
    • MachineType
    • PCMachine
  • CPU
    • TYPE_CPU
    • X86_CPU
  • MemoryBackend
    • MemoryBackend类层次结构
    • MemoryBackend初始化流程
Powered by GitBook
On this page

Was this helpful?

  1. 地址空间

AddressSpace Part2

现在我们知道了AddressSpace, MemoryRegion, FlatView, RAMBlock。那就来看看这几个角色在一起的样子。

    AddressSpace               
    +-------------------------+
    |name                     |
    |   (char *)              |          FlatView (An array of FlatRange)
    +-------------------------+          +----------------------+
    |current_map              | -------->|nr                    |
    |   (FlatView *)          |          |nr_allocated          |
    +-------------------------+          |   (unsigned)         |         FlatRange             FlatRange
    |                         |          +----------------------+         
    |                         |          |ranges                | ------> +---------------------+---------------------+
    |                         |          |   (FlatRange *)      |         |offset_in_region     |offset_in_region     |
    |                         |          +----------------------+         |    (hwaddr)         |    (hwaddr)         |
    |                         |                                           +---------------------+---------------------+
    |                         |                                           |addr(AddrRange)      |addr(AddrRange)      |
    |                         |                                           |    +----------------|    +----------------+
    |                         |                                           |    |start (Int128)  |    |start (Int128)  |
    |                         |                                           |    |size  (Int128)  |    |size  (Int128)  |
    |                         |                                           +----+----------------+----+----------------+
    |                         |                                           |mr                   |mr                   |
    |                         |                                           | (MemoryRegion *)    | (MemoryRegion *)    |
    |                         |                                           +---------------------+---------------------+
    |                         |
    |                         |
    |                         |
    |                         |          MemoryRegion(system_memory/system_io)
    +-------------------------+          +------------------------+
    |root                     |          |name                    | root of a MemoryRegion
    |   (MemoryRegion *)      | -------->|  (const char *)        | tree
    +-------------------------+          +------------------------+
                                         |addr                    |
                                         |  (hwaddr)              |
                                         |size                    |
                                         |  (Int128)              |
                                         +------------------------+
                                         |subregions              |
                                         |    QTAILQ_HEAD()       |
                                         +------------------------+
                                                      |
                                                      |
                              ----+-------------------+---------------------+----
                                  |                                         |
                                  |                                         |
                                  |                                         |

                    struct MemoryRegion                            struct MemoryRegion
                    +------------------------+                     +------------------------+
                    |name                    |                     |name                    |
                    |  (const char *)        |                     |  (const char *)        |
                    +------------------------+                     +------------------------+
                    |addr                    |   GPA               |addr                    |
                    |  (hwaddr)              |                     |  (hwaddr)              |
                    |size                    |                     |size                    |
                    |  (Int128)              |                     |  (Int128)              |
                    +------------------------+                     +------------------------+
                    |ram_block               |                     |ram_block               |
                    |    (RAMBlock *)        |                     |    (RAMBlock *)        |
                    +------------------------+                     +------------------------+
                               |
                               |
                               |
                               |
                               v
                    RAMBlock                     
                    +---------------------------+
                    |next                       |
                    |    QLIST_ENTRY(RAMBlock)  |
                    +---------------------------+
                    |offset                     |
                    |used_length                |
                    |max_length                 |
                    |    (ram_addr_t)           |
                    +---------------------------+
                    |host                       |   HVA
                    |    (uint8_t *)            |
                    +---------------------------+
                    |mr                         |
                    |    (struct MemoryRegion *)|
                    +---------------------------+
PreviousRAMBlockNext眼见为实

Last updated 6 years ago

Was this helpful?