All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: put_page_from_l2e() should honor _PAGE_RW
@ 2018-10-09  6:43 Jan Beulich
  2018-10-09 11:00 ` Andrew Cooper
  2018-10-09 13:29 ` Wei Liu
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Beulich @ 2018-10-09  6:43 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu

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>

--- 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_
     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_
     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 {





_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86: put_page_from_l2e() should honor _PAGE_RW
  2018-10-09  6:43 [PATCH] x86: put_page_from_l2e() should honor _PAGE_RW Jan Beulich
@ 2018-10-09 11:00 ` Andrew Cooper
  2018-10-09 13:29 ` Wei Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2018-10-09 11:00 UTC (permalink / raw)
  To: Jan Beulich, xen-devel; +Cc: Wei Liu

On 09/10/18 07:43, Jan Beulich wrote:
> 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>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86: put_page_from_l2e() should honor _PAGE_RW
  2018-10-09  6:43 [PATCH] x86: put_page_from_l2e() should honor _PAGE_RW Jan Beulich
  2018-10-09 11:00 ` Andrew Cooper
@ 2018-10-09 13:29 ` Wei Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Wei Liu @ 2018-10-09 13:29 UTC (permalink / raw)
  To: Jan Beulich; +Cc: xen-devel, Wei Liu, Andrew Cooper

On Tue, Oct 09, 2018 at 12:43:05AM -0600, Jan Beulich wrote:
> 56fff3e5e9 ("x86: nuke PV superpage option and code") has introduced a
> (luckily latent only) bug here, in that it didn't make reference

It seems that the bug was from the original superpage code -- see
put_spage_pages.

> 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: Wei Liu <wei.liu2@citrix.com>

> 
> --- 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_
>      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_
>      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 {
> 
> 
> 
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-09 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-09  6:43 [PATCH] x86: put_page_from_l2e() should honor _PAGE_RW Jan Beulich
2018-10-09 11:00 ` Andrew Cooper
2018-10-09 13:29 ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.