diff mbox series

[3/6] x86/hvm/domain: remove the 'hap_enabled' flag

Message ID 20190723160609.2177-4-paul.durrant@citrix.com (mailing list archive)
State Superseded
Headers show
Series stash domain create flags and then use them | expand

Commit Message

Paul Durrant July 23, 2019, 4:06 p.m. UTC
The hap_enabled() macro can determine whether the feature is available
using the domain 'createflags'; there is no need for a separate flag.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Wei Liu <wl@xen.org>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>
---
 xen/arch/x86/domain.c            | 7 +------
 xen/arch/x86/mm/paging.c         | 4 ++--
 xen/arch/x86/mm/shadow/common.c  | 4 ++--
 xen/include/asm-x86/hvm/domain.h | 9 +++------
 xen/include/asm-x86/paging.h     | 2 +-
 xen/include/asm-x86/shadow.h     | 2 +-
 6 files changed, 10 insertions(+), 18 deletions(-)

Comments

Roger Pau Monné July 25, 2019, 9:44 a.m. UTC | #1
On Tue, Jul 23, 2019 at 05:06:06PM +0100, Paul Durrant wrote:
> -#ifdef CONFIG_HVM
> -#define hap_enabled(d)  (is_hvm_domain(d) && (d)->arch.hvm.hap_enabled)
> -#else
> -#define hap_enabled(d)  ({(void)(d); false;})
> -#endif
> +#define hap_enabled(d) \
> +    (hvm_hap_supported() && is_hvm_domain(d) && \
> +     evaluate_nospec(d->createflags & XEN_DOMCTL_CDF_hap))

You could make this an inline function while at it AFAICT.

Thanks, Roger.
Paul Durrant July 25, 2019, 10:07 a.m. UTC | #2
> -----Original Message-----
> From: Roger Pau Monne <roger.pau@citrix.com>
> Sent: 25 July 2019 10:44
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; Jan Beulich <jbeulich@suse.com>; Andrew Cooper
> <Andrew.Cooper3@citrix.com>; Wei Liu <wl@xen.org>
> Subject: Re: [PATCH 3/6] x86/hvm/domain: remove the 'hap_enabled' flag
> 
> On Tue, Jul 23, 2019 at 05:06:06PM +0100, Paul Durrant wrote:
> > -#ifdef CONFIG_HVM
> > -#define hap_enabled(d)  (is_hvm_domain(d) && (d)->arch.hvm.hap_enabled)
> > -#else
> > -#define hap_enabled(d)  ({(void)(d); false;})
> > -#endif
> > +#define hap_enabled(d) \
> > +    (hvm_hap_supported() && is_hvm_domain(d) && \
> > +     evaluate_nospec(d->createflags & XEN_DOMCTL_CDF_hap))
> 
> You could make this an inline function while at it AFAICT.

Yeah, that's not a bad idea.

  Paul

> 
> Thanks, Roger.
Paul Durrant July 25, 2019, 12:48 p.m. UTC | #3
> -----Original Message-----
> From: Xen-devel <xen-devel-bounces@lists.xenproject.org> On Behalf Of Paul Durrant
> Sent: 25 July 2019 11:08
> To: Roger Pau Monne <roger.pau@citrix.com>
> Cc: xen-devel@lists.xenproject.org; Wei Liu <wl@xen.org>; Jan Beulich <jbeulich@suse.com>; Andrew
> Cooper <Andrew.Cooper3@citrix.com>
> Subject: Re: [Xen-devel] [PATCH 3/6] x86/hvm/domain: remove the 'hap_enabled' flag
> 
> > -----Original Message-----
> > From: Roger Pau Monne <roger.pau@citrix.com>
> > Sent: 25 July 2019 10:44
> > To: Paul Durrant <Paul.Durrant@citrix.com>
> > Cc: xen-devel@lists.xenproject.org; Jan Beulich <jbeulich@suse.com>; Andrew Cooper
> > <Andrew.Cooper3@citrix.com>; Wei Liu <wl@xen.org>
> > Subject: Re: [PATCH 3/6] x86/hvm/domain: remove the 'hap_enabled' flag
> >
> > On Tue, Jul 23, 2019 at 05:06:06PM +0100, Paul Durrant wrote:
> > > -#ifdef CONFIG_HVM
> > > -#define hap_enabled(d)  (is_hvm_domain(d) && (d)->arch.hvm.hap_enabled)
> > > -#else
> > > -#define hap_enabled(d)  ({(void)(d); false;})
> > > -#endif
> > > +#define hap_enabled(d) \
> > > +    (hvm_hap_supported() && is_hvm_domain(d) && \
> > > +     evaluate_nospec(d->createflags & XEN_DOMCTL_CDF_hap))
> >
> > You could make this an inline function while at it AFAICT.
> 
> Yeah, that's not a bad idea.
> 

Alas this turns out to be a can of worms. As an inline function I cannot call is_hvm_domain() from here which, I guess, is why it’s a macro at the moment. Also I cannot dereference d->createflags (a.k.a. options) as the definition of struct domain is not available.

  Paul

>   Paul
> 
> >
> > Thanks, Roger.
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel
diff mbox series

Patch

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index ea55160887..65f47a7627 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -564,12 +564,7 @@  int arch_domain_create(struct domain *d,
     HYPERVISOR_COMPAT_VIRT_START(d) =
         is_pv_domain(d) ? __HYPERVISOR_COMPAT_VIRT_START : ~0u;
 
-    /* Need to determine if HAP is enabled before initialising paging */
-    if ( is_hvm_domain(d) )
-        d->arch.hvm.hap_enabled =
-            hvm_hap_supported() && (config->flags & XEN_DOMCTL_CDF_hap);
-
-    if ( (rc = paging_domain_init(d, config->flags)) != 0 )
+    if ( (rc = paging_domain_init(d)) != 0 )
         goto fail;
     paging_initialised = true;
 
diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c
index 011089368a..69aa228e46 100644
--- a/xen/arch/x86/mm/paging.c
+++ b/xen/arch/x86/mm/paging.c
@@ -632,7 +632,7 @@  void paging_log_dirty_init(struct domain *d, const struct log_dirty_ops *ops)
 /*           CODE FOR PAGING SUPPORT            */
 /************************************************/
 /* Domain paging struct initialization. */
-int paging_domain_init(struct domain *d, unsigned int domcr_flags)
+int paging_domain_init(struct domain *d)
 {
     int rc;
 
@@ -653,7 +653,7 @@  int paging_domain_init(struct domain *d, unsigned int domcr_flags)
     if ( hap_enabled(d) )
         hap_domain_init(d);
     else
-        rc = shadow_domain_init(d, domcr_flags);
+        rc = shadow_domain_init(d);
 
     return rc;
 }
diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c
index fa18de0bb6..320ea0db21 100644
--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -46,7 +46,7 @@  static void sh_clean_dirty_bitmap(struct domain *);
 
 /* Set up the shadow-specific parts of a domain struct at start of day.
  * Called for every domain from arch_domain_create() */
-int shadow_domain_init(struct domain *d, unsigned int domcr_flags)
+int shadow_domain_init(struct domain *d)
 {
     static const struct log_dirty_ops sh_ops = {
         .enable  = sh_enable_log_dirty,
@@ -62,7 +62,7 @@  int shadow_domain_init(struct domain *d, unsigned int domcr_flags)
 
 #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC)
     d->arch.paging.shadow.oos_active = 0;
-    d->arch.paging.shadow.oos_off = domcr_flags & XEN_DOMCTL_CDF_oos_off;
+    d->arch.paging.shadow.oos_off = d->createflags & XEN_DOMCTL_CDF_oos_off;
 #endif
     d->arch.paging.shadow.pagetable_dying_op = 0;
 
diff --git a/xen/include/asm-x86/hvm/domain.h b/xen/include/asm-x86/hvm/domain.h
index 6c7c4f5aa6..b5292696d2 100644
--- a/xen/include/asm-x86/hvm/domain.h
+++ b/xen/include/asm-x86/hvm/domain.h
@@ -156,7 +156,6 @@  struct hvm_domain {
 
     struct viridian_domain *viridian;
 
-    bool_t                 hap_enabled;
     bool_t                 mem_sharing_enabled;
     bool_t                 qemu_mapcache_invalidate;
     bool_t                 is_s3_suspended;
@@ -195,11 +194,9 @@  struct hvm_domain {
     };
 };
 
-#ifdef CONFIG_HVM
-#define hap_enabled(d)  (is_hvm_domain(d) && (d)->arch.hvm.hap_enabled)
-#else
-#define hap_enabled(d)  ({(void)(d); false;})
-#endif
+#define hap_enabled(d) \
+    (hvm_hap_supported() && is_hvm_domain(d) && \
+     evaluate_nospec(d->createflags & XEN_DOMCTL_CDF_hap))
 
 #endif /* __ASM_X86_HVM_DOMAIN_H__ */
 
diff --git a/xen/include/asm-x86/paging.h b/xen/include/asm-x86/paging.h
index cf57ca708d..ab7887f23c 100644
--- a/xen/include/asm-x86/paging.h
+++ b/xen/include/asm-x86/paging.h
@@ -207,7 +207,7 @@  void paging_vcpu_init(struct vcpu *v);
 
 /* Set up the paging-assistance-specific parts of a domain struct at
  * start of day.  Called for every domain from arch_domain_create() */
-int paging_domain_init(struct domain *d, unsigned int domcr_flags);
+int paging_domain_init(struct domain *d);
 
 /* Handler for paging-control ops: operations from user-space to enable
  * and disable ephemeral shadow modes (test mode and log-dirty mode) and
diff --git a/xen/include/asm-x86/shadow.h b/xen/include/asm-x86/shadow.h
index f29f0f652b..8ebb89c027 100644
--- a/xen/include/asm-x86/shadow.h
+++ b/xen/include/asm-x86/shadow.h
@@ -49,7 +49,7 @@ 
 
 /* Set up the shadow-specific parts of a domain struct at start of day.
  * Called from paging_domain_init(). */
-int shadow_domain_init(struct domain *d, unsigned int domcr_flags);
+int shadow_domain_init(struct domain *d);
 
 /* Setup the shadow-specific parts of a vcpu struct. It is called by
  * paging_vcpu_init() in paging.c */