ia64/xen-unstable

changeset 2669:6b58e5458fcd

bitkeeper revision 1.1159.117.1 (41769117YL0J9d2bEpMGocvDP1rMdQ)

Fix the writable pagetable error paths. Some of them are genuine Xen
bugs if they trigger. Otehrs now properly clean wrpt state before
crashing the domain, so we don't leave any refcnts inconsistent.
author kaf24@freefall.cl.cam.ac.uk
date Wed Oct 20 16:23:51 2004 +0000 (2004-10-20)
parents d10a9677a639
children 03612420798a
files xen/arch/x86/memory.c
line diff
     1.1 --- a/xen/arch/x86/memory.c	Wed Oct 20 14:44:56 2004 +0000
     1.2 +++ b/xen/arch/x86/memory.c	Wed Oct 20 16:23:51 2004 +0000
     1.3 @@ -1604,7 +1604,11 @@ void ptwr_flush(const int which)
     1.4      if ( unlikely(__get_user(pte, ptep)) )
     1.5      {
     1.6          MEM_LOG("ptwr: Could not read pte at %p\n", ptep);
     1.7 -        domain_crash();
     1.8 +        /*
     1.9 +         * Really a bug. We could read this PTE during the initial fault,
    1.10 +         * and pagetables can't have changed meantime. XXX Multi-proc guests?
    1.11 +         */
    1.12 +        BUG();
    1.13      }
    1.14      PTWR_PRINTK("[%c] disconnected_l1va at %p is %08lx\n",
    1.15                  PTWR_PRINT_WHICH, ptep, pte);
    1.16 @@ -1627,7 +1631,11 @@ void ptwr_flush(const int which)
    1.17      if ( unlikely(__put_user(pte, ptep)) )
    1.18      {
    1.19          MEM_LOG("ptwr: Could not update pte at %p\n", ptep);
    1.20 -        domain_crash();
    1.21 +        /*
    1.22 +         * Really a bug. We could write this PTE during the initial fault,
    1.23 +         * and pagetables can't have changed meantime. XXX Multi-proc guests?
    1.24 +         */
    1.25 +        BUG();
    1.26      }
    1.27  
    1.28      /* Ensure that there are no stale writable mappings in any TLB. */
    1.29 @@ -1668,6 +1676,12 @@ void ptwr_flush(const int which)
    1.30          if ( unlikely(!get_page_from_l1e(nl1e, d)) )
    1.31          {
    1.32              MEM_LOG("ptwr: Could not re-validate l1 page\n");
    1.33 +            /*
    1.34 +             * Make the remaining p.t's consistent before crashing, so the
    1.35 +             * reference counts are correct.
    1.36 +             */
    1.37 +            memcpy(&pl1e[i], &ptwr_info[cpu].ptinfo[which].page[i],
    1.38 +                   (ENTRIES_PER_L1_PAGETABLE - i) * sizeof(l1_pgentry_t));
    1.39              domain_crash();
    1.40          }
    1.41          
    1.42 @@ -1781,6 +1795,9 @@ int ptwr_do_page_fault(unsigned long add
    1.43      {
    1.44          MEM_LOG("ptwr: Could not update pte at %p\n", (unsigned long *)
    1.45                  &linear_pg_table[addr>>PAGE_SHIFT]);
    1.46 +        /* Toss the writable pagetable state and crash. */
    1.47 +        unmap_domain_mem(ptwr_info[cpu].ptinfo[which].pl1e);
    1.48 +        ptwr_info[cpu].ptinfo[which].l1va = 0;
    1.49          domain_crash();
    1.50      }
    1.51