+ Cc qemu-devel
> -----Origin email-----
> From: Greg Kurz <gk...@linux.vnet.ibm.com>
> Sent Time: Friday, November 21, 2014
> To: Kaiyuan <kaiyu...@tju.edu.cn>
> Cc: qemu-devel <qemu-devel@nongnu.org>
> Subject: Re: [Qemu-devel] How to access guest memory from qemu device internal
>
> On Thu, 20 Nov 2014 21:25:18 +0800 (GMT+08:00)
> Kaiyuan <kaiyu...@tju.edu.cn> wrote:
> > Hello, all
> >
> > I added a custom device to qemu. This device is attached to sysbus by mmio
> > and has an address register in which device should access the guest memory
> > the register point to.
> > I write a bare-metal program that pass an address like 0x1234ABCD to this
> > address register. Inside qemu device code I added, if device reads value
> > from register and directly accesses this value of 0x1234ABCD, it will
> > access host memory 0x1234ABCD rather than guest memory 0x1234ABCD.
> > Does qemu provide some functions that allow device to access guest memory
> > address?
> >
>
> Have a look at *_phys* functions in the <exec/cpu-common.h> QEMU header file
> (cpu_physical_memory_read() for
> exemple).
>
Thanks, Greg. It's useful to me. cpu_physical_memory_read() looks like a
wrapper of translating guest addr to host addrIs there a function that
translates guest address to host physical address?