|Subject:||Is there a good method to convert guest machine's user virtual address to qemu host's virtual address?|
|Date:||Wed, 14 Jul 2021 19:00:36 +0900|
I can convert guest physical address to host virtual address using something like this.
vms->ram_ptr = memory_region_get_ram_ptr(machine->ram);
*host_virt_offset_p = (uint64_t)vms->ram_ptr - vms->memmap[AB21Q_MEM].base;
By adding *host_virt_offset_p to the guest physical addres, we get host virtual address.
When I’m running baremetal program on the virtual machine, the program directly writes guest physical address to a register and the peripheral model can access the corresponding host virtual address.
But what if now I have to run operating system and I should access the host memory using virtual address? I’m confused.
If a program on OS writes through a driver a virtual address value (not physical address) to a register, how should I convert it to host virtual address?
I guess (after CPU’s mmu processing) there should be an mmu-like function for guest physical to host virtual translation in qemu so that every physical access can be translated to host virtual address.
But in my case, through peripheral register, guest physical address value is passed and the peripheral model (a .so file) accesses host memory using an offset value determined as shown above.
Now with OS, I don’t know how I should handle this.
Please give me some advices. I’ll be grateful for any comment.
|[Prev in Thread]||Current Thread||[Next in Thread]|