英文:
xv6 memory mapping during boot up time
问题
我正在阅读这本书,https://pdos.csail.mit.edu/6.828/2022/xv6/book-riscv-rev3.pdf
在第35页,“内核本身位于虚拟地址空间和物理内存中的KERNBASE=0x80000000处”。
我给了QEMU 128M内存,为什么内核位于0x80000000,即2GB的位置?
当内核被加载时,分页机制被禁用。
英文:
I am reading this book, https://pdos.csail.mit.edu/6.828/2022/xv6/book-riscv-rev3.pdf
At page 35, "the kernel itself is located at KERNBASE=0x80000000 in both the virtual address space and in physical memory".
I have give QEMU 128M memory, how comes kernel located at 0x80000000 which is 2GB?.
when kernel was loaded, paging mechanism was disabled.
答案1
得分: 1
在硬件设计中,通常没有要求RAM必须从物理地址零开始。KERNBASE变量表示“RAM从哪里开始”,而不表示“RAM有多大”。因此,RAM可以从0x8000_0000地址开始,有128MB的情况是完全可能的。在这种情况下,RAM会在0x8800_0000地址结束。在不同的硬件上,RAM可能从完全不同的地址开始。物理地址空间的其他区域将用于各种设备(如串口和中断控制器),或者可能根本没有东西。
你的PDF中的图3.3显示了内存板上的物理内存外观,正如右侧的图所示。所有这些(RAM的位置,设备的位置等)都由硬件(或者如果你在QEMU上运行则是模拟的硬件)决定。操作系统无法改变这一点 - 它必须使用它所拥有的资源。这只是一个幸运的巧合,这个板上RAM的起始地址与操作系统想要在虚拟地址空间中启动其内核内存的位置相匹配。
英文:
In general in a hardware design there is no requirement that RAM starts at physical address zero. The KERNBASE variable says "where does the RAM start"; it does not say "how big is the RAM". So it's quite possible to have 128MB of RAM that starts at address 0x8000_0000. In this case it would end at address 0x8800_0000. On a different piece of hardware the RAM might start at an entirely different address. Other areas of the physical address space will be used for various devices (like the serial port and the interrupt controller), or may have nothing there at all.
Figure 3.3 in your PDF has the diagram of what physical memory looks like on the board type this kernel wants to run on, as the right hand side diagram. All this (where is the RAM, where are devices, etc) is fixed by the hardware (or by the emulated hardware if you're running on QEMU). The OS can't change this -- it must work with what it has got. It's just a lucky coincidence that the start address of the RAM on this board matches where the OS wants to have its kernel memory start at in the virtual address space.
答案2
得分: 0
我明白了。以下是翻译好的部分:
在阅读了一些QEMU文档后,我认为我知道原因了。
在xv6操作系统中,“物理内存”并不是真正的物理内存。
它是QEMU的“物理内存”。
英文:
after reading some docs of QEMU.I think I know why.
In xv6 OS, the "physical memory" is not a real physical memory.
It is a QEMU "physical memory".
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论