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

[Xen-devel] converting pfn to mfns



Hello

I'm trying to use paging mechanisms to find my PID, but i'm getting
confused with guest context and addresses, which means i do not really
understand in do_guest_trap from traps.c what modifications i have to
do to the adresses i see.

Here is what i'm doing:

i get the CPU user registers and 3rd control register:

user_regs = guest_cpu_user_regs();
cr3 = read_cr3();

My first question here: should i read cr3 with
v->arch.guest_context.ctrlreg[3] ?

I then determine the base address for the info relative to my process
with base_addr = (user_regs->esp & 0xFFFFE000);

If i'm not wrong, this should be the virtual address i have to
translate. What i was thinking of doing was determine the physical
address with the formula

paddr = (cr3 & 0xFFFFFFE0) + (vaddr >> 30) * PAGE_SIZE

The page frame number would then be

pfn = paddr >> PAGE_SHIFT

and the offset in that page

offset = (PAGE_SIZE - 1) & paddr

Then i have to map the pfn into an mfn. I'm looking on that now.

But what surprised me, is that when digging into the hypervisor code, i
found a primitive xen_cr3_to_pfn that uses only the cr3 register. What
is the right approach ?

Is there a similar primitive to map the pfn into mfn ? I did not look
much on that for now, but it seems that there are some tables in
different structures to do so.

Can someone clarify that ?

Thanks
Fred

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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