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

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

Interesting … sorry, I had read the docs a while ago and my interpretation at the time was that it didn't. I can try to get libvmi working, but nonetheless I do want to figure out how to this with the Xen API itself if at all possible, so I'd appreciate any help in doing so.

I've looked through libvmi's implementation some more; it looks like it does this via vmi_pagetable_lookup_cache, which in my case ends up calling v2p_pae (intel.c:327). As I understand it, in that function, the `dtb` parameter holds the pagetable base address, and you use that to walk the page table and get the physical address corresponding to the virtual addr. Based on the end of vmi_translate_kv2p (accessors.c:703), it looks like the value of dtb is `vmi->kpgd`, which at some point earlier is set to the value of the `cr3` register. Is my understanding, roughly speaking, correct?

I tried to replicate a simpler version of libvmi's page table walking code just now, and in doing so noticed that the value of CR0, as reported by Xen, has its 31st bit set to zero … i.e. virtual addressing is disabled entirely? (For reference, I'm using a 64-bit Ubuntu image set up initially by virt-manager but now just run via `xl create`. I don't know if I should expect it to have paging enabled or not.) On the other hand, if I understand correctly, what I mentioned earlier with regards to some HVM guests assuming (addr >> XC_PAGE_SHIFT) = MFN *is* assuming that guest page frame number = machine frame number, which sounds like it is what would be applicable in this case. 

Honestly, I'm not so sure what's happening here, and I'm not even sure my description is sensible at this point — I need to look into libvmi's implementation more and also figure out exactly what paging mode (or lack thereof) my HVM guest is running in. If, on the other hand, any of the above sounds familiar, suggestions/hints would be very helpful.

On Wed, Oct 10, 2018 at 11:25 AM Tamas K Lengyel <tamas.k.lengyel@xxxxxxxxx> wrote:
On Wed, Oct 10, 2018 at 8:47 AM Spencer Michaels
<spmichaels.work@xxxxxxxxx> wrote:
> 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 works with PV guests and you can initialize it without the OS
specific features. If you use vmi_init followed by vmi_init_paging you
can do v2p translation, reading/writing memory regardless of what OS
is running in the guest.

Xen-devel mailing list



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