Skip to contentSkip to conversation

x86/mm: don't override an existing shadow memory allocation

PATCH New Tim Deegan 1 participant 1 message Nov 18, 2010

lore
Share & tools
lore

Tim Deegan

author
#0 lore raw

PATCH 1/1 x86/mm: don't override an existing shadow memory allocation

x86/mm: don't override an existing shadow memory allocation when enabling log-dirty shadows on a PV guest.

xen/arch/x86/mm/shadow/common.c +10 -4
diff -r 9f1257be88ad xen/arch/x86/mm/shadow/common.c
@@ -3328,11 +3328,10 @@ static int shadow_one_bit_enable(struct 
 
     mode |= PG_SH_enable;
 
-    if ( d->arch.paging.mode == 0 )
+    if ( d->arch.paging.shadow.total_pages == 0 )
     {
-        /* Init the shadow memory allocation and the hash table */
-        if ( sh_set_allocation(d, 1, NULL) != 0 
-             || shadow_hash_alloc(d) != 0 )
+        /* Init the shadow memory allocation if the user hasn't done so */
+        if ( sh_set_allocation(d, 1, NULL) != 0 )
         {
             sh_set_allocation(d, 0, NULL);
             return -ENOMEM;
@@ -3343,6 +3342,13 @@ static int shadow_one_bit_enable(struct 
         d->arch.paging.free_page = shadow_free_p2m_page;
     }
 
+    if ( d->arch.paging.mode == 0 )
+    {
+        /* Init the shadow hash table */
+        if ( shadow_hash_alloc(d) != 0 )
+            return -ENOMEM;
+    }
+
     /* Update the bits */
     sh_new_mode(d, d->arch.paging.mode | mode);