> -----Origin email-----
> From: Peter Maydell <peter.mayd...@linaro.org>
> Sent Time: Friday, November 21, 2014
> To: Kaiyuan <kaiyu...@tju.edu.cn>
> Cc: Greg Kurz <gk...@linux.vnet.ibm.com>, qemu-devel <qemu-devel@nongnu.org>
> Subject: Re: [Qemu-devel] Fw:Re:Re: How to access guest memory from qemu 
> device internal
> 
> On 21 November 2014 09:17, Kaiyuan <kaiyu...@tju.edu.cn> wrote:
> > Thanks, Greg. It's useful to me. cpu_physical_memory_read()
> > looks like a wrapper of translating guest addr to host addr
> > Is there a function that translates guest address to host
> > physical address?
> 
> No, QEMU never deals with host physical addresses at all.
> In general there are three address types that might be
> in use:
>  * guest virtual address
>  * guest physical address
>  * host virtual address (only relevant if talking to RAM,
>      rather than an emulated device)
> 
> For devices, the guest within the VM should deal with
> converting a virtual address to a guest physical address,
> and should write guest physical addresses to the device.
> [If you think about real hardware, where the device is
> separate from the CPU, there's no way the device can know
> about guest virtual addresses, which are handled by the
> CPU's built in MMU.]
> 
> So the function Greg suggests is the one you want.
> 
> -- PMM
Thanks for your explanation about guest physical/virtual address and host 
physical/virtual address, and I think I asked a wrong question. Is there a 
function that translates guest Physical address to host Virtual address so that 
I can access guest space by a host pointer?


Reply via email to