Skip to contentSkip to conversation

clear shadow caches when vmx guest return to real mode

PATCH New Ling, Xiaofeng 1 participant 1 message Dec 15, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clear shadow caches when vmx guest return to real mode

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.

# HG changeset patch
# User Xiaofeng Ling <[email protected]>
# Node ID aadb771248f677c4a957731a59b22c90a747646f
# Parent b4d615464054390c88e4b62dc2f26d3adeb86443
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.

xen/arch/x86/shadow32.c +17 -0
diff -r b4d615464054 -r aadb771248f6 xen/arch/x86/shadow32.c
@@ -2982,6 +2982,23 @@
     }
 }
 
+void clear_all_shadow_status(struct domain *d)
+{
+    shadow_lock(d);
+    free_shadow_pages(d);
+    free_shadow_ht_entries(d);
+    d->arch.shadow_ht = 
+        xmalloc_array(struct shadow_status, shadow_ht_buckets);
+    if ( d->arch.shadow_ht == NULL ) {
+        printk("clear all shadow status:xmalloc fail\n");
+        domain_crash_synchronous();
+    }
+    memset(d->arch.shadow_ht, 0,
+           shadow_ht_buckets * sizeof(struct shadow_status));
+
+    free_out_of_sync_entries(d);
+    shadow_unlock(d);
+}
 
 /************************************************************************/
 /************************************************************************/
xen/arch/x86/shadow_public.c +18 -0
diff -r b4d615464054 -r aadb771248f6 xen/arch/x86/shadow_public.c
@@ -1748,6 +1750,24 @@
     shadow_unlock(d);
 }
 
+void clear_all_shadow_status(struct domain *d)
+{
+    shadow_lock(d);
+    free_shadow_pages(d);
+    free_shadow_ht_entries(d);
+    d->arch.shadow_ht = 
+        xmalloc_array(struct shadow_status, shadow_ht_buckets);
+    if ( d->arch.shadow_ht == NULL ) {
+        printk("clear all shadow status:xmalloc fail\n");
+        domain_crash_synchronous();
+    }
+    memset(d->arch.shadow_ht, 0,
+           shadow_ht_buckets * sizeof(struct shadow_status));
+
+    free_out_of_sync_entries(d);
+    shadow_unlock(d);
+}
+
 /*
  * Local variables:
  * mode: C
xen/arch/x86/vmx.c +1 -0
diff -r b4d615464054 -r aadb771248f6 xen/arch/x86/vmx.c
@@ -1210,6 +1210,7 @@
             }
         }
 
+        clear_all_shadow_status(v->domain);
         if (vmx_assist(v, VMX_ASSIST_INVOKE)) {
             set_bit(VMX_CPU_STATE_ASSIST_ENABLED, &v->arch.arch_vmx.cpu_state);
             __vmread(GUEST_RIP, &eip);
xen/include/asm-x86/shadow.h +2 -0
diff -r b4d615464054 -r aadb771248f6 xen/include/asm-x86/shadow.h
@@ -1707,6 +1707,8 @@
     }
 }
 
+void clear_all_shadow_status(struct domain *d);
+
 #if SHADOW_DEBUG
 extern int _check_pagetable(struct vcpu *v, char *s);
 extern int _check_all_pagetables(struct vcpu *v, char *s);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel