ia64/xen-unstable

changeset 2468:7415ba387aaf

bitkeeper revision 1.1159.1.146 (4140f4e4MoMfo8OhzKj1hieTq2id2A)

Allow a p.t. to be mapped at multiple different virtual addresses. This is
a pretty benign situation right now (although writable pagetables will fail,
exiting the domain). In future it may well cause significant slowdown to
writable pagetables and/or shadow pagetables. So beware!!
author kaf24@freefall.cl.cam.ac.uk
date Fri Sep 10 00:27:16 2004 +0000 (2004-09-10)
parents 8d1bc9a571e0
children 538350dcb66f
files xen/arch/x86/memory.c xen/include/asm-x86/mm.h
line diff
     1.1 --- a/xen/arch/x86/memory.c	Thu Sep 09 23:33:20 2004 +0000
     1.2 +++ b/xen/arch/x86/memory.c	Fri Sep 10 00:27:16 2004 +0000
     1.3 @@ -913,10 +913,9 @@ int get_page_type(struct pfn_info *page,
     1.4              }
     1.5              else if ( unlikely((x & PGT_va_mask) != (type & PGT_va_mask)) )
     1.6              {
     1.7 -                /* The va backpointer wasn't mutable, and is different. */
     1.8 -                MEM_LOG("Unexpected va backpointer (saw %08x != exp %08x)"
     1.9 -                        " for pfn %08lx\n", x, type, page_to_pfn(page));
    1.10 -                return 0;
    1.11 +                /* This table is potentially mapped at multiple locations. */
    1.12 +                nx &= ~PGT_va_mask;
    1.13 +                nx |= PGT_va_unknown;
    1.14              }
    1.15          }
    1.16  	else if ( unlikely(!(x & PGT_validated)) )
    1.17 @@ -1786,12 +1785,21 @@ int ptwr_do_page_fault(unsigned long add
    1.18          page = &frame_table[pfn];
    1.19          if ( (page->u.inuse.type_info & PGT_type_mask) == PGT_l1_page_table )
    1.20          {
    1.21 -            pl2e = &linear_l2_table[(page->u.inuse.type_info &
    1.22 -                                     PGT_va_mask) >> PGT_va_shift];
    1.23 +            u32 va_mask = page->u.inuse.type_info & PGT_va_mask;
    1.24 +
    1.25 +            /*
    1.26 +             * XXX KAF: This version of writable pagetables doesn't need
    1.27 +             * to know the back pointer at all, as it is unnecessary to be
    1.28 +             * unlinking the page table --- FIXME!
    1.29 +             */
    1.30 +            if ( unlikely(va_mask >= PGT_va_unknown) )
    1.31 +                domain_crash();
    1.32 +            va_mask >>= PGT_va_shift;
    1.33 +
    1.34 +            pl2e = &linear_l2_table[va_mask];
    1.35              PTWR_PRINTK(PP_ALL, ("page_fault on l1 pt at va %08lx, pt for %08x"
    1.36                                   ", pfn %08lx\n", addr,
    1.37 -                                 ((page->u.inuse.type_info & PGT_va_mask) >>
    1.38 -                                  PGT_va_shift) << L2_PAGETABLE_SHIFT, pfn));
    1.39 +                                 va_mask << L2_PAGETABLE_SHIFT, pfn));
    1.40  
    1.41              if ( l2_pgentry_val(*pl2e) >> PAGE_SHIFT != pfn )
    1.42              {
    1.43 @@ -1832,8 +1840,7 @@ int ptwr_do_page_fault(unsigned long add
    1.44                  nl2e = mk_l2_pgentry((l2_pgentry_val(*pl2e) & ~_PAGE_PRESENT));
    1.45                  update_l2e(pl2e, *pl2e, nl2e);
    1.46  
    1.47 -                ptwr_info[cpu].disconnected_pteidx =
    1.48 -                    (page->u.inuse.type_info & PGT_va_mask) >> PGT_va_shift;
    1.49 +                ptwr_info[cpu].disconnected_pteidx = va_mask;
    1.50                  PTWR_PRINTK(PP_A, ("[A] now pl2e %p l2e %08lx              "
    1.51                                     "taf %08x/%08x\n", pl2e,
    1.52                                     l2_pgentry_val(*pl2e),
     2.1 --- a/xen/include/asm-x86/mm.h	Thu Sep 09 23:33:20 2004 +0000
     2.2 +++ b/xen/include/asm-x86/mm.h	Fri Sep 10 00:27:16 2004 +0000
     2.3 @@ -77,7 +77,10 @@ struct pfn_info
     2.4   /* The 10 most significant bits of virt address if this is a page table. */
     2.5  #define PGT_va_shift        17
     2.6  #define PGT_va_mask         (((1<<10)-1)<<PGT_va_shift)
     2.7 -#define PGT_va_mutable      PGT_va_mask /* va backpointer is mutable? */
     2.8 + /* Is the back pointer still mutable (i.e. not fixed yet)? */
     2.9 +#define PGT_va_mutable      (((1<<10)-1)<<PGT_va_shift)
    2.10 + /* Is the back pointer unknown (e.g., p.t. is mapped at multiple VAs)? */
    2.11 +#define PGT_va_unknown      (((1<<10)-2)<<PGT_va_shift)
    2.12   /* 17-bit count of uses of this frame as its current type. */
    2.13  #define PGT_count_mask      ((1<<17)-1)
    2.14