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

[Xen-devel] mm.c: function virt_to_xen_l2e

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());
       *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;

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

thanks for any insight.


Xen-devel mailing list



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