All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] xen: prevent PVH Dom0 from having pages with more than one ref
@ 2014-06-18 11:18 Roger Pau Monne
  2014-06-18 11:20 ` Andrew Cooper
  0 siblings, 1 reply; 2+ messages in thread
From: Roger Pau Monne @ 2014-06-18 11:18 UTC (permalink / raw)
  To: xen-devel; +Cc: Keir Fraser, Jan Beulich, Roger Pau Monne

On PV guests a reference is taken when a page gets added to the page
tables, which makes pages added to the page tables have two
references, but this is not suitable for PVH that doesn't use the
PVMMU. In the PVH case only one reference has to be taken or else the
page would not be freed when the memory of the domain is decreased.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Mukesh Rathor <mukesh.rathor@oracle.com>
---
Changes since v2:
 - Reword commit message.
 - Add paging_mode_translate as a condition check to the already
   exiting gate in the second instance.

Changes since v1:
 - Fix coding style.
 - Fix a second occurrence of the same issue.
 - Use paging_mode_translate instead of is_pvh_domain.
---
 xen/arch/x86/domain_build.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c
index ba42fc9..6666093 100644
--- a/xen/arch/x86/domain_build.c
+++ b/xen/arch/x86/domain_build.c
@@ -1137,10 +1137,13 @@ int __init construct_dom0(
                                     L1_PROT : COMPAT_L1_PROT));
         l1tab++;
 
-        page = mfn_to_page(mfn);
-        if ( (page->u.inuse.type_info == 0) &&
-             !get_page_and_type(page, d, PGT_writable_page) )
-            BUG();
+        if ( !paging_mode_translate(d) )
+        {
+            page = mfn_to_page(mfn);
+            if ( (page->u.inuse.type_info == 0) &&
+                 !get_page_and_type(page, d, PGT_writable_page) )
+                BUG();
+        }
     }
 
     if ( is_pv_32on64_domain(d) )
@@ -1300,7 +1303,7 @@ int __init construct_dom0(
         if ( get_gpfn_from_mfn(mfn) >= count )
         {
             BUG_ON(is_pv_32bit_domain(d));
-            if ( !page->u.inuse.type_info &&
+            if ( !paging_mode_translate(d) && !page->u.inuse.type_info &&
                  !get_page_and_type(page, d, PGT_writable_page) )
                 BUG();
 
-- 
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

* Re: [PATCH v3] xen: prevent PVH Dom0 from having pages with more than one ref
  2014-06-18 11:18 [PATCH v3] xen: prevent PVH Dom0 from having pages with more than one ref Roger Pau Monne
@ 2014-06-18 11:20 ` Andrew Cooper
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2014-06-18 11:20 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: xen-devel, Keir Fraser, Jan Beulich

On 18/06/14 12:18, Roger Pau Monne wrote:
> On PV guests a reference is taken when a page gets added to the page
> tables, which makes pages added to the page tables have two
> references, but this is not suitable for PVH that doesn't use the
> PVMMU. In the PVH case only one reference has to be taken or else the
> page would not be freed when the memory of the domain is decreased.
>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> Cc: Keir Fraser <keir@xen.org>
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Mukesh Rathor <mukesh.rathor@oracle.com>

Looks much better!

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

> ---
> Changes since v2:
>  - Reword commit message.
>  - Add paging_mode_translate as a condition check to the already
>    exiting gate in the second instance.
>
> Changes since v1:
>  - Fix coding style.
>  - Fix a second occurrence of the same issue.
>  - Use paging_mode_translate instead of is_pvh_domain.
> ---
>  xen/arch/x86/domain_build.c |   13 ++++++++-----
>  1 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c
> index ba42fc9..6666093 100644
> --- a/xen/arch/x86/domain_build.c
> +++ b/xen/arch/x86/domain_build.c
> @@ -1137,10 +1137,13 @@ int __init construct_dom0(
>                                      L1_PROT : COMPAT_L1_PROT));
>          l1tab++;
>  
> -        page = mfn_to_page(mfn);
> -        if ( (page->u.inuse.type_info == 0) &&
> -             !get_page_and_type(page, d, PGT_writable_page) )
> -            BUG();
> +        if ( !paging_mode_translate(d) )
> +        {
> +            page = mfn_to_page(mfn);
> +            if ( (page->u.inuse.type_info == 0) &&
> +                 !get_page_and_type(page, d, PGT_writable_page) )
> +                BUG();
> +        }
>      }
>  
>      if ( is_pv_32on64_domain(d) )
> @@ -1300,7 +1303,7 @@ int __init construct_dom0(
>          if ( get_gpfn_from_mfn(mfn) >= count )
>          {
>              BUG_ON(is_pv_32bit_domain(d));
> -            if ( !page->u.inuse.type_info &&
> +            if ( !paging_mode_translate(d) && !page->u.inuse.type_info &&
>                   !get_page_and_type(page, d, PGT_writable_page) )
>                  BUG();
>  


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

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

end of thread, other threads:[~2014-06-18 11:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-18 11:18 [PATCH v3] xen: prevent PVH Dom0 from having pages with more than one ref Roger Pau Monne
2014-06-18 11:20 ` Andrew Cooper

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.