[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen staging] x86: put_page_from_l2e() should honor _PAGE_RW



commit cd395b1d69a773556d2af206b4ecbf56b33057ea
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Oct 9 16:27:59 2018 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Oct 9 16:27:59 2018 +0200

    x86: put_page_from_l2e() should honor _PAGE_RW
    
    56fff3e5e9 ("x86: nuke PV superpage option and code") has introduced a
    (luckily latent only) bug here, in that it didn't make reference
    dropping dependent on whether the page was mapped writable. The only
    current source of large page mappings for PV domains is the Dom0
    builder, which only produces writeable ones.
    
    Take the opportunity and also convert to bool both put_data_page()'s
    respective parameter and the argument put_page_from_l3e() passes.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 xen/arch/x86/mm.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index ac8059a034..c53bc86a68 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -663,8 +663,7 @@ static int get_page_and_type_from_mfn(
     return rc;
 }
 
-static void put_data_page(
-    struct page_info *page, int writeable)
+static void put_data_page(struct page_info *page, bool writeable)
 {
     if ( writeable )
         put_page_and_type(page);
@@ -1289,10 +1288,13 @@ static int put_page_from_l2e(l2_pgentry_t l2e, unsigned 
long pfn)
     if ( l2e_get_flags(l2e) & _PAGE_PSE )
     {
         struct page_info *page = l2e_get_page(l2e);
+        bool writeable = l2e_get_flags(l2e) & _PAGE_RW;
         unsigned int i;
 
+        ASSERT(!(mfn_x(page_to_mfn(page)) &
+                 ((1UL << (L2_PAGETABLE_SHIFT - PAGE_SHIFT)) - 1)));
         for ( i = 0; i < (1u << PAGETABLE_ORDER); i++, page++ )
-            put_page_and_type(page);
+            put_data_page(page, writeable);
     }
     else
     {
@@ -1318,7 +1320,7 @@ static int put_page_from_l3e(l3_pgentry_t l3e, unsigned 
long pfn,
     if ( unlikely(l3e_get_flags(l3e) & _PAGE_PSE) )
     {
         unsigned long mfn = l3e_get_pfn(l3e);
-        int writeable = l3e_get_flags(l3e) & _PAGE_RW;
+        bool writeable = l3e_get_flags(l3e) & _PAGE_RW;
 
         ASSERT(!(mfn & ((1UL << (L3_PAGETABLE_SHIFT - PAGE_SHIFT)) - 1)));
         do {
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.