ia64/xen-unstable

changeset 8395:37cafca1539e

Clear all shadow caches when return to real mode from protect mode.
So that, if OS modify some page tables in real mode and then
return to protect mode, no outdated shadow table be used because
out of sync machanism do not work in real mode.

Signed-off-by: Xiaofeng Ling <xiaofeng.ling@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Dec 15 20:38:44 2005 +0100 (2005-12-15)
parents 7e419ba80326
children fb1f2498ce1e
files xen/arch/x86/shadow32.c xen/arch/x86/shadow_public.c xen/arch/x86/vmx.c xen/include/asm-x86/shadow.h
line diff
     1.1 --- a/xen/arch/x86/shadow32.c	Thu Dec 15 20:35:32 2005 +0100
     1.2 +++ b/xen/arch/x86/shadow32.c	Thu Dec 15 20:38:44 2005 +0100
     1.3 @@ -2982,6 +2982,23 @@ void __update_pagetables(struct vcpu *v)
     1.4      }
     1.5  }
     1.6  
     1.7 +void clear_all_shadow_status(struct domain *d)
     1.8 +{
     1.9 +    shadow_lock(d);
    1.10 +    free_shadow_pages(d);
    1.11 +    free_shadow_ht_entries(d);
    1.12 +    d->arch.shadow_ht = 
    1.13 +        xmalloc_array(struct shadow_status, shadow_ht_buckets);
    1.14 +    if ( d->arch.shadow_ht == NULL ) {
    1.15 +        printk("clear all shadow status:xmalloc fail\n");
    1.16 +        domain_crash_synchronous();
    1.17 +    }
    1.18 +    memset(d->arch.shadow_ht, 0,
    1.19 +           shadow_ht_buckets * sizeof(struct shadow_status));
    1.20 +
    1.21 +    free_out_of_sync_entries(d);
    1.22 +    shadow_unlock(d);
    1.23 +}
    1.24  
    1.25  /************************************************************************/
    1.26  /************************************************************************/
     2.1 --- a/xen/arch/x86/shadow_public.c	Thu Dec 15 20:35:32 2005 +0100
     2.2 +++ b/xen/arch/x86/shadow_public.c	Thu Dec 15 20:38:44 2005 +0100
     2.3 @@ -1747,6 +1747,24 @@ void shadow_sync_and_drop_references(
     2.4      shadow_unlock(d);
     2.5  }
     2.6  
     2.7 +void clear_all_shadow_status(struct domain *d)
     2.8 +{
     2.9 +    shadow_lock(d);
    2.10 +    free_shadow_pages(d);
    2.11 +    free_shadow_ht_entries(d);
    2.12 +    d->arch.shadow_ht = 
    2.13 +        xmalloc_array(struct shadow_status, shadow_ht_buckets);
    2.14 +    if ( d->arch.shadow_ht == NULL ) {
    2.15 +        printk("clear all shadow status:xmalloc fail\n");
    2.16 +        domain_crash_synchronous();
    2.17 +    }
    2.18 +    memset(d->arch.shadow_ht, 0,
    2.19 +           shadow_ht_buckets * sizeof(struct shadow_status));
    2.20 +
    2.21 +    free_out_of_sync_entries(d);
    2.22 +    shadow_unlock(d);
    2.23 +}
    2.24 +
    2.25  /*
    2.26   * Local variables:
    2.27   * mode: C
     3.1 --- a/xen/arch/x86/vmx.c	Thu Dec 15 20:35:32 2005 +0100
     3.2 +++ b/xen/arch/x86/vmx.c	Thu Dec 15 20:38:44 2005 +0100
     3.3 @@ -1223,6 +1223,7 @@ static int vmx_set_cr0(unsigned long val
     3.4              }
     3.5          }
     3.6  
     3.7 +        clear_all_shadow_status(v->domain);
     3.8          if (vmx_assist(v, VMX_ASSIST_INVOKE)) {
     3.9              set_bit(VMX_CPU_STATE_ASSIST_ENABLED, &v->arch.arch_vmx.cpu_state);
    3.10              __vmread(GUEST_RIP, &eip);
     4.1 --- a/xen/include/asm-x86/shadow.h	Thu Dec 15 20:35:32 2005 +0100
     4.2 +++ b/xen/include/asm-x86/shadow.h	Thu Dec 15 20:38:44 2005 +0100
     4.3 @@ -1707,6 +1707,8 @@ static inline void update_pagetables(str
     4.4      }
     4.5  }
     4.6  
     4.7 +void clear_all_shadow_status(struct domain *d);
     4.8 +
     4.9  #if SHADOW_DEBUG
    4.10  extern int _check_pagetable(struct vcpu *v, char *s);
    4.11  extern int _check_all_pagetables(struct vcpu *v, char *s);