QEMU内存管理

QEMU内存管理

1 QEMU中管理的Memory有:

  • 普通的RAM。
  • MMIO。
  • 内存控制器(将物理内存动态的映射到不同的虚拟地址空间)

2 QEMU的Memory是以一个MemoryRegin为节点组成的非循环图的形式组织的。

  • 叶子节点代表RAM、MMIO。
  • 其它节点代表buses、内存控制器、以及被rerouted的memory regions。

3 Memory regions的类型包括:

  • RAM。
  • MMIO。
  • ROM。
  • ROM device(read like rom,but write like MMIO)。
  • IOMMU region。
  • container(可以包含其它memory regions,被包含的以不同offset记录;它的subregions是可以地址互相重叠的,比如一个memory controller与一个RAM的subregion地址重叠)。
  • alias(aliases允许一个region被分成几个不连续的regions,可以指向任何其它类型的regions包括其它alias,但不包括自身)。
  • container和alias都是帮助QEMU构建memory map不能被直接访问。

4 例子

For example, suppose we have a container A of size 0x8000 with two subregions B and C. B is a container mapped at 0x2000, size 0x4000, priority 2; C is an MMIO region mapped at 0x0, size 0x6000, priority 1. B currently has two of its own subregions: D of size 0x1000 at offset 0 and E of size 0x1000 at offset 0x2000. As a diagram:
        0      1000   2000   3000   4000   5000   6000   7000   8000 |------|------|------|------|------|------|------|------| A:    [                                                      ]
  C:    [CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC]
  B:                  [                          ]
  D:                  [DDDDD]
  E:                                [EEEEE]
The regions that will be seen within this address range then are: [CCCCCCCCCCCC][DDDDD][CCCCC][EEEEE][CCCCC]

Priority values are local to a container, because the priorities of two regions are only compared when they are both children of the same container.

5 搜索策略(memory地址匹配搜索)

    • 从根节点按照降序的优先级进行匹配
    • 如果当前的MR是叶子节点,搜索过程终止
    • 如果当前MR是Container,相同的算法在Container中搜索
    • 如果当前MR是Alias,搜索从Alias指向的MR继续进行

 

 

 

优秀参考文献:

https://blog.csdn.net/ustc_dylan/article/details/7326900

 

你可能感兴趣的:(Qemu,QEMU,QEMU内存管理)