]> xenbits.xensource.com Git - people/jgross/xen.git/commitdiff
x86: don't override INVALID_M2P_ENTRY with SHARED_M2P_ENTRY
authorJan Beulich <jbeulich@suse.com>
Fri, 11 Sep 2020 12:14:43 +0000 (14:14 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 11 Sep 2020 12:14:43 +0000 (14:14 +0200)
While in most cases code ahead of the invocation of set_gpfn_from_mfn()
deals with shared pages, at least in set_typed_p2m_entry() I can't spot
such handling (it's entirely possible there's code missing there). Let's
try to play safe and add an extra check.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/x86_64/mm.c

index 1f32062c15f412a65b2e7f3f9fabe1d28b7cd1d1..0d1aadbfce86147a25e28e11135bd0386a41be7a 100644 (file)
@@ -1327,12 +1327,19 @@ destroy_frametable:
 
 void set_gpfn_from_mfn(unsigned long mfn, unsigned long pfn)
 {
-    const struct domain *d = page_get_owner(mfn_to_page(_mfn(mfn)));
-    unsigned long entry = (d && (d == dom_cow)) ? SHARED_M2P_ENTRY : pfn;
+    unsigned long entry = pfn;
 
     if ( unlikely(!machine_to_phys_mapping_valid) )
         return;
 
+    if ( entry != INVALID_M2P_ENTRY )
+    {
+        const struct domain *d = page_get_owner(mfn_to_page(_mfn(mfn)));
+
+        if ( d && (d == dom_cow) )
+            entry = SHARED_M2P_ENTRY;
+    }
+
     if ( opt_pv32 &&
          mfn < (RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START) / 4 )
         compat_machine_to_phys_mapping[mfn] = entry;