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

Re: [Xen-devel] Mapping HVM guest memory from Dom0

I have, but libvmi doesn't fit my use case — it only works with Windows and Linux HVM guests. I will need my application to work with PV and HVM guests that are neither Windows nor Linux.

libvmi's implementation of this, `xen_get_memory()` in `libvmi/driver/xen/xen.c`, seems to assume that MFN = (addr >> page shift), which I've seen in a few places, but based on my testing as well as what's in `debug.c`, this appears not to be correct. I certainly don't end up mapping the correct pages using that formula, at least.

On Wed, Oct 10, 2018 at 5:39 AM Andrew Cooper <andrew.cooper3@xxxxxxxxxx> wrote:
On 09/10/18 20:34, Spencer Michaels wrote:
> Hello,
> I'm developing an application that runs in Dom0 and needs to read
> memory from a guest given a guest address (for instance, reading RIP
> from the guest CPU context and then reading the current instruction).
> I'm using xenforeignmemory_map() to map the guest memory, but this
> function takes the MFN of the guest address to read, not the address
> itself. Xen does not seem to have an API for doing the virtual address
> --> MFN conversion.
> I've figured out how to do this for PV guests: map the domain's
> meminfo struct and use the PFN for the guest address (i.e. address >>
> XC_PAGE_SHIFT) as an index into the P2M table.
> However, I am having trouble doing the same for HVM guests. Right now
> I am trying to follow the implementation of bg_hvm_va2mfn in
> xen/arch/x86/debug.c, but this function uses so many internal Xen
> functions it seems I would have to copy tons of code out from Xen, and
> I'm wondering if there's a better way. Is there some API I'm missing
> that lets me to do the vaddr --> MFN conversion for HVM guests? If
> not, what is the simplest way to do this conversion?

Have you come across libvmi?  It seems to be exactly what you are trying
to make here.

Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.