ia64/xen-unstable

changeset 2602:71985683e5f3

bitkeeper revision 1.1159.1.207 (416316f0LUjul9Vm9A0jre3yE2rcNg)

Shadow mode fix for the new (well, actually original) writable pagetable scheme.
author iap10@labyrinth.cl.cam.ac.uk
date Tue Oct 05 21:49:36 2004 +0000 (2004-10-05)
parents 04af8bd15884
children ff4e7a241335
files xen/arch/x86/memory.c
line diff
     1.1 --- a/xen/arch/x86/memory.c	Tue Oct 05 20:34:54 2004 +0000
     1.2 +++ b/xen/arch/x86/memory.c	Tue Oct 05 21:49:36 2004 +0000
     1.3 @@ -1640,14 +1640,15 @@ int ptwr_debug = 0x0;
     1.4  
     1.5  void ptwr_flush(const int which)
     1.6  {
     1.7 -    unsigned long pte, *ptep;
     1.8 +    unsigned long pte, *ptep, l1va;
     1.9      l1_pgentry_t *pl1e;
    1.10      l2_pgentry_t *pl2e, nl2e;
    1.11      int cpu = smp_processor_id();
    1.12      int i;
    1.13  
    1.14 +    l1va = ptwr_info[cpu].ptinfo[which].l1va;
    1.15      ptep = (unsigned long *)&linear_pg_table
    1.16 -        [ptwr_info[cpu].ptinfo[which].l1va>>PAGE_SHIFT];
    1.17 +        [l1va>>PAGE_SHIFT];
    1.18  
    1.19      /* make pt page write protected */
    1.20      if ( unlikely(__get_user(pte, ptep)) ) {
    1.21 @@ -1657,11 +1658,19 @@ void ptwr_flush(const int which)
    1.22      PTWR_PRINTK(PP_ALL, ("disconnected_l1va at %p is %08lx\n",
    1.23                           ptep, pte));
    1.24      pte &= ~_PAGE_RW;
    1.25 +
    1.26 +    if ( unlikely(current->mm.shadow_mode) ) {
    1.27 +	unsigned long spte;
    1.28 +	l1pte_no_fault(&current->mm, &pte, &spte);
    1.29 +	__put_user( spte, (unsigned long *)&shadow_linear_pg_table
    1.30 +		    [l1va>>PAGE_SHIFT] );
    1.31 +    }
    1.32 +
    1.33      if ( unlikely(__put_user(pte, ptep)) ) {
    1.34          MEM_LOG("ptwr: Could not update pte at %p\n", ptep);
    1.35          domain_crash();
    1.36      }
    1.37 -    __flush_tlb_one(ptwr_info[cpu].ptinfo[which].l1va);
    1.38 +    __flush_tlb_one(l1va);
    1.39      PTWR_PRINTK(PP_ALL, ("disconnected_l1va at %p now %08lx\n",
    1.40                           ptep, pte));
    1.41  
    1.42 @@ -1684,8 +1693,8 @@ void ptwr_flush(const int which)
    1.43      }
    1.44      unmap_domain_mem(pl1e);
    1.45  
    1.46 -    if (which == PTWR_PT_ACTIVE) {
    1.47 -	/* reconnect l1 page */
    1.48 +    if (which == PTWR_PT_ACTIVE && likely(!current->mm.shadow_mode)) {
    1.49 +	/* reconnect l1 page (no need if shadow mode)*/
    1.50  	pl2e = &linear_l2_table[ptwr_info[cpu].active_pteidx];
    1.51  	nl2e = mk_l2_pgentry(l2_pgentry_val(*pl2e) | _PAGE_PRESENT);
    1.52  	update_l2e(pl2e, *pl2e, nl2e);
    1.53 @@ -1693,7 +1702,6 @@ void ptwr_flush(const int which)
    1.54  
    1.55      if ( unlikely(current->mm.shadow_mode) )
    1.56      {
    1.57 -        unsigned long spte;
    1.58          unsigned long sstat = 
    1.59              get_shadow_status(&current->mm, pte >> PAGE_SHIFT);
    1.60  
    1.61 @@ -1714,9 +1722,6 @@ void ptwr_flush(const int which)
    1.62              put_shadow_status(&current->mm);
    1.63          } 
    1.64  
    1.65 -        l1pte_no_fault(&current->mm, &pte, &spte);
    1.66 -        __put_user(spte, (unsigned long *)&shadow_linear_pg_table
    1.67 -                   [ptwr_info[cpu].ptinfo[which].l1va>>PAGE_SHIFT]);
    1.68      }
    1.69  
    1.70      ptwr_info[cpu].ptinfo[which].l1va = 0;
    1.71 @@ -1771,9 +1776,9 @@ int ptwr_do_page_fault(unsigned long add
    1.72                  ptwr_flush(which);
    1.73              ptwr_info[cpu].ptinfo[which].l1va = addr | 1;
    1.74  
    1.75 -            if (which == PTWR_PT_ACTIVE) {
    1.76 +            if (which == PTWR_PT_ACTIVE && likely(!current->mm.shadow_mode)) {
    1.77                  ptwr_info[cpu].active_pteidx = va_mask;
    1.78 -		/* disconnect l1 page */
    1.79 +		/* disconnect l1 page (unnecessary in shadow mode) */
    1.80  		nl2e = mk_l2_pgentry((l2_pgentry_val(*pl2e) & ~_PAGE_PRESENT));
    1.81  		update_l2e(pl2e, *pl2e, nl2e);
    1.82  		flush_tlb();
    1.83 @@ -1796,7 +1801,7 @@ int ptwr_do_page_fault(unsigned long add
    1.84                  domain_crash();
    1.85              }
    1.86  
    1.87 -            /* maybe fall through to shadow mode to propagate */
    1.88 +            /* maybe fall through to shadow mode to propagate writeable L1 */
    1.89              return ( !current->mm.shadow_mode );
    1.90          }
    1.91      }