]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
x86: tighten MMU_*PT_UPDATE* check and combine error paths
authorJan Beulich <jbeulich@suse.com>
Tue, 5 Dec 2017 16:23:18 +0000 (17:23 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 5 Dec 2017 16:23:18 +0000 (17:23 +0100)
Don't accept anything other than r/w RAM pages as page table pages and
move the paged-out check into the (unlikely) error path following that
check.

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

index f61fe2507ee41f68779d8dfc85d610f22cae1f17..3c84ae87c129704db671bfe2844a53721b5e976b 100644 (file)
@@ -3627,18 +3627,18 @@ long do_mmu_update(
             gmfn = req.ptr >> PAGE_SHIFT;
             page = get_page_from_gfn(pt_owner, gmfn, &p2mt, P2M_ALLOC);
 
-            if ( p2m_is_paged(p2mt) )
-            {
-                ASSERT(!page);
-                p2m_mem_paging_populate(pt_owner, gmfn);
-                rc = -ENOENT;
-                break;
-            }
-
-            if ( unlikely(!page) )
+            if ( unlikely(!page) || p2mt != p2m_ram_rw )
             {
-                gdprintk(XENLOG_WARNING,
-                         "Could not get page for normal update\n");
+                if ( page )
+                    put_page(page);
+                if ( p2m_is_paged(p2mt) )
+                {
+                    p2m_mem_paging_populate(pt_owner, gmfn);
+                    rc = -ENOENT;
+                }
+                else
+                    gdprintk(XENLOG_WARNING,
+                             "Could not get page for normal update\n");
                 break;
             }