]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
x86: put_page_from_l2e() should honor _PAGE_RW
authorJan Beulich <jbeulich@suse.com>
Tue, 9 Oct 2018 14:27:59 +0000 (16:27 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 9 Oct 2018 14:27:59 +0000 (16:27 +0200)
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@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/mm.c

index ac8059a034e55ddec726406ffc34a1d5b5cb3737..c53bc86a682f29862669f106ebe47a6340b110af 100644 (file)
@@ -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 {