[xen master] x86: tighten MMU_*PT_UPDATE* check and combine error paths

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen master] x86: tighten MMU_*PT_UPDATE* check and combine error paths

patchbot
commit f55d5c074676cf281b1e3e8f43f519a4f6cc7f58
Author:     Jan Beulich <[hidden email]>
AuthorDate: Tue Dec 5 17:23:18 2017 +0100
Commit:     Jan Beulich <[hidden email]>
CommitDate: Tue Dec 5 17:23:18 2017 +0100

    x86: tighten MMU_*PT_UPDATE* check and combine error paths
   
    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 <[hidden email]>
    Acked-by: Andrew Cooper <[hidden email]>
---
 xen/arch/x86/mm.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index f61fe25..3c84ae8 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -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;
             }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog