0

Im trying to understand how memory works inside a virtual machine, QEMU in particular. I see there are virtual memory, used in a context by CPU and a physical memory, the actual RAM memory. But i dont understand some concepts here, is physical emulated physical memory from the guest also physical memory for the host? Then, how does the MMU translate it? It would be needed to translate it once to get de emulated physical addres and then translated again to get the real one o the host, isnt it like that? my brain is burning right now. Thanks for your help

Angel Ruiz
  • 39
  • 5
  • Does this answer your question? [Qemu-KVM: Translation of guest physical address to host virtual/host physical address](https://stackoverflow.com/questions/41860920/qemu-kvm-translation-of-guest-physical-address-to-host-virtual-host-physical-ad) – Rob Jul 22 '23 at 15:16
  • Are you interested in when QEMU is being used to control KVM, i.e. using the host CPU's virtualization extensions so that the host MMU can do a two-stage guest-virtual-to-guest-physical-to-host-physical translation, or when QEMU is doing pure emulation (which works entirely differently, emulating a guest MMU, and using the host MMU only in the same way any other userspace process does) ? The two work rather differently... – Peter Maydell Jul 23 '23 at 14:33
  • Pure emulation, when QEMU uses softMMU – Angel Ruiz Jul 23 '23 at 17:17
  • For pure emulation, QEMU emulates the guest MMU, which is what does guest virtual to guest physical address translation. QEMU knows what host (virtual) memory it is using to back guest physical addresses, so it can do that conversion too (or find out what emulated hardware device registers are at that guest physical address, for non-RAM). There is a data structure that makes this faster by caching the whole guest-virtual-to-host-virtual mapping: see the answer to https://stackoverflow.com/questions/29070691/does-qemu-emulate-tlb – Peter Maydell Jul 24 '23 at 09:13

0 Answers0