qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Is there a good method to convert guest machine's user virtual addre


From: ckim
Subject: RE: Is there a good method to convert guest machine's user virtual address to qemu host's virtual address?
Date: Wed, 14 Jul 2021 21:11:25 +0900

On second thought, I guess the application should convert the virtual address to physical address (by reading the page table) and write the value to the register.

Chan Kim

 

From: ckim@etri.re.kr <ckim@etri.re.kr>
Sent: Wednesday, July 14, 2021 7:01 PM
To: 'qemu-discuss' <qemu-discuss@nongnu.org>
Subject: Is there a good method to convert guest machine's user virtual address to qemu host's virtual address?

 

Hello experts,

 

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 Im 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? Im 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 CPUs 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 dont know how I should handle this.

Please give me some advices. Ill be grateful for any comment.

Thank you!

 

Chan Kim

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]