ia64/xen-unstable

changeset 5831:390e4d63cdb1

Shadow mode's writable-PTs should only allow guest kernels access to PTs
author maf46@burn.cl.cam.ac.uk
date Tue Jul 19 10:40:26 2005 +0000 (2005-07-19)
parents 43564304cf94
children 581902ddd16f
files xen/arch/x86/shadow.c xen/arch/x86/shadow32.c xen/include/asm-x86/shadow.h
line diff
     1.1 --- a/xen/arch/x86/shadow.c	Mon Jul 18 20:22:11 2005 +0000
     1.2 +++ b/xen/arch/x86/shadow.c	Tue Jul 19 10:40:26 2005 +0000
     1.3 @@ -1684,7 +1684,7 @@ static int shadow_fault_32(unsigned long
     1.4  
     1.5          if ( unlikely(!(l1e_get_flags(gpte) & _PAGE_RW)) )
     1.6          {
     1.7 -            if ( shadow_mode_page_writable(d, l1e_get_pfn(gpte)) )
     1.8 +            if ( shadow_mode_page_writable(va, regs, l1e_get_pfn(gpte)) )
     1.9              {
    1.10                  allow_writes = 1;
    1.11                  l1e_add_flags(gpte, _PAGE_RW);
     2.1 --- a/xen/arch/x86/shadow32.c	Mon Jul 18 20:22:11 2005 +0000
     2.2 +++ b/xen/arch/x86/shadow32.c	Tue Jul 19 10:40:26 2005 +0000
     2.3 @@ -2612,7 +2612,7 @@ int shadow_fault(unsigned long va, struc
     2.4  
     2.5          if ( unlikely(!(l1e_get_flags(gpte) & _PAGE_RW)) )
     2.6          {
     2.7 -            if ( shadow_mode_page_writable(d, l1e_get_pfn(gpte)) )
     2.8 +            if ( shadow_mode_page_writable(va, regs, l1e_get_pfn(gpte)) )
     2.9              {
    2.10                  allow_writes = 1;
    2.11                  l1e_add_flags(gpte, _PAGE_RW);
     3.1 --- a/xen/include/asm-x86/shadow.h	Mon Jul 18 20:22:11 2005 +0000
     3.2 +++ b/xen/include/asm-x86/shadow.h	Tue Jul 19 10:40:26 2005 +0000
     3.3 @@ -1691,8 +1691,10 @@ shadow_set_l1e(unsigned long va, l1_pgen
     3.4  /************************************************************************/
     3.5  
     3.6  static inline int
     3.7 -shadow_mode_page_writable(struct domain *d, unsigned long gpfn)
     3.8 +shadow_mode_page_writable(unsigned long va, struct cpu_user_regs *regs, unsigned long gpfn)
     3.9  {
    3.10 +    struct vcpu *v = current;
    3.11 +    struct domain *d = v->domain;
    3.12      unsigned long mfn = __gpfn_to_mfn(d, gpfn);
    3.13      u32 type = frame_table[mfn].u.inuse.type_info & PGT_type_mask;
    3.14  
    3.15 @@ -1701,11 +1703,14 @@ shadow_mode_page_writable(struct domain 
    3.16          type = shadow_max_pgtable_type(d, gpfn, NULL);
    3.17  
    3.18      if ( VM_ASSIST(d, VMASST_TYPE_writable_pagetables) &&
    3.19 -         (type == PGT_l1_page_table) )
    3.20 +         (type == PGT_l1_page_table) &&
    3.21 +         (va < HYPERVISOR_VIRT_START) &&
    3.22 +         KERNEL_MODE(v, regs) )
    3.23          return 1;
    3.24  
    3.25      if ( shadow_mode_write_all(d) &&
    3.26 -         type && (type <= PGT_l4_page_table) )
    3.27 +         type && (type <= PGT_l4_page_table) &&
    3.28 +         KERNEL_MODE(v, regs) )
    3.29          return 1;
    3.30  
    3.31      return 0;