WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] converting pfn to mfns

To: xen-devel@xxxxxxxxxxxxxxxxxxx <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] converting pfn to mfns
From: Frederic Beck <frederic.beck@xxxxxxxx>
Date: Fri, 27 Feb 2009 12:35:11 +0100
Delivery-date: Fri, 27 Feb 2009 03:35:40 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: INRIA-LORIA
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] converting pfn to mfns, Frederic Beck <=