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] mm.c: function virt_to_xen_l2e

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] mm.c: function virt_to_xen_l2e
From: PUCCETTI Armand <armand.puccetti@xxxxxx>
Date: Thu, 20 Jul 2006 17:45:14 +0200
Delivery-date: Thu, 20 Jul 2006 08:44:59 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.4 (X11/20060615)
I am trying to understand the function virt_to_xen_l2e.
The actual code in xen V3.0.1 begins with:

l2_pgentry_t *virt_to_xen_l2e(unsigned long v)
{
   l4_pgentry_t *pl4e;
   l3_pgentry_t *pl3e;
   l2_pgentry_t *pl2e;

   pl4e = &idle_pg_table[l4_table_offset(v)];
   if ( !(l4e_get_flags(*pl4e) & _PAGE_PRESENT) )
   {
       pl3e = page_to_virt(alloc_xen_pagetable());
       clear_page(pl3e);
       *pl4e = l4e_from_paddr(__pa(pl3e), __PAGE_HYPERVISOR);
   }
pl3e = l4e_to_l3e(*pl4e) + l3_table_offset(v);
...

What puzzles me is pl3e. If I decompose the first expression
of the rhs of the last statement above, introducing some temporary vars, I get:

   intpte_t a, b;
   physaddr_t c;

   a=(*pl4e).l4;
b = (a & (PADDR_MASK & PAGE_MASK)); c = ((physaddr_t) b); pl3e= ((l3_pgentry_t *)__va(c)) + ...; // same line as original

pl3e is apparently made by some arithmetic transformations and then a cast to a pointer. How do we know if the final address pl3e is defined, and the address it refers to is correct??

Same question about pl2e, as similar transformations are made to calculate it some lines
later.

thanks for any insight.

Armand



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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] mm.c: function virt_to_xen_l2e, PUCCETTI Armand <=