x86 p2m superpage fix: Re-insert missing shadow code from the original
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 9 Jul 2008 10:02:37 +0000 (11:02 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 9 Jul 2008 10:02:37 +0000 (11:02 +0100)
patch that was  submitted to xen-devel, to remove mappings when we're
removing a p2m 2mb page.

Signed-off-by: Gianluca Guida <gianluca.guida@eu.citrix.com>
xen/arch/x86/mm/shadow/common.c

index 20252a2f91abe45473bf5a64ac20236a9e88ec55..0a9943560115880f59ae213092769dc6a91a9b27 100644 (file)
@@ -3354,6 +3354,26 @@ shadow_write_p2m_entry(struct vcpu *v, unsigned long gfn,
         }
     }
 
+    /* If we're removing a superpage mapping from the p2m, remove all the
+     * MFNs covered by it from the shadows too. */
+    if ( level == 2 && (l1e_get_flags(*p) & _PAGE_PRESENT) &&
+         (l1e_get_flags(*p) & _PAGE_PSE) )
+    {
+        unsigned int i;
+        mfn_t mfn = _mfn(l1e_get_pfn(*p));
+        p2m_type_t p2mt = p2m_flags_to_type(l1e_get_flags(*p));
+        if ( p2m_is_valid(p2mt) && mfn_valid(mfn) )
+        {
+            for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
+            {
+                sh_remove_all_shadows_and_parents(v, mfn);
+                if ( sh_remove_all_mappings(v, mfn) )
+                    flush_tlb_mask(d->domain_dirty_cpumask);
+                mfn = _mfn(mfn_x(mfn) + 1);
+            }
+        }
+    }
+
     /* Update the entry with new content */
     safe_write_pte(p, new);