All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] x86/msr: add Raw and Host domain policies
@ 2018-02-08 10:23 Sergey Dyasli
  2018-02-08 11:08 ` Andrew Cooper
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Sergey Dyasli @ 2018-02-08 10:23 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Jan Beulich, Sergey Dyasli

Raw policy contains the actual values from H/W MSRs. Add PLATFORM_INFO
msr to the policy during probe_cpuid_faulting().

Host policy might have certain features disabled if Xen decides not
to use them. For now, make Host policy equal to Raw policy.

Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>
---
v1: Decided to upstream this separately from VMX MSRs policy
---
 xen/arch/x86/cpu/common.c | 11 ++++++++++-
 xen/arch/x86/msr.c        | 19 ++++++++++++++++++-
 xen/include/asm-x86/msr.h |  8 ++++++++
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 4306e59650..0875b5478b 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -118,9 +118,18 @@ void (* __read_mostly ctxt_switch_masking)(const struct vcpu *next);
 
 bool __init probe_cpuid_faulting(void)
 {
+	struct msr_domain_policy *dp = &raw_msr_domain_policy;
 	uint64_t val;
+	int rc;
 
-	if (rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val) ||
+	if ((rc = rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val)) == 0)
+	{
+		dp->plaform_info.available = true;
+		if (val & MSR_PLATFORM_INFO_CPUID_FAULTING)
+			dp->plaform_info.cpuid_faulting = true;
+	}
+
+	if (rc ||
 	    !(val & MSR_PLATFORM_INFO_CPUID_FAULTING) ||
 	    rdmsr_safe(MSR_INTEL_MISC_FEATURES_ENABLES,
 		       this_cpu(msr_misc_features)))
diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index 7875d9c1e0..fbc8cd47a7 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -24,12 +24,27 @@
 #include <xen/sched.h>
 #include <asm/msr.h>
 
-struct msr_domain_policy __read_mostly hvm_max_msr_domain_policy,
+struct msr_domain_policy __read_mostly     raw_msr_domain_policy,
+                         __read_mostly    host_msr_domain_policy,
+                         __read_mostly hvm_max_msr_domain_policy,
                          __read_mostly  pv_max_msr_domain_policy;
 
 struct msr_vcpu_policy __read_mostly hvm_max_msr_vcpu_policy,
                        __read_mostly  pv_max_msr_vcpu_policy;
 
+static void __init calculate_raw_policy(void)
+{
+    /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
+    /* Was already added by probe_cpuid_faulting() */
+}
+
+static void __init calculate_host_policy(void)
+{
+    struct msr_domain_policy *dp = &host_msr_domain_policy;
+
+    *dp = raw_msr_domain_policy;
+}
+
 static void __init calculate_hvm_max_policy(void)
 {
     struct msr_domain_policy *dp = &hvm_max_msr_domain_policy;
@@ -68,6 +83,8 @@ static void __init calculate_pv_max_policy(void)
 
 void __init init_guest_msr_policy(void)
 {
+    calculate_raw_policy();
+    calculate_host_policy();
     calculate_hvm_max_policy();
     calculate_pv_max_policy();
 }
diff --git a/xen/include/asm-x86/msr.h b/xen/include/asm-x86/msr.h
index 928f1cc454..8401d376c3 100644
--- a/xen/include/asm-x86/msr.h
+++ b/xen/include/asm-x86/msr.h
@@ -220,6 +220,14 @@ struct msr_domain_policy
     } plaform_info;
 };
 
+/* RAW msr domain policy: contains the actual values from H/W MSRs */
+extern msr_domain_policy raw_msr_domain_policy;
+/*
+ * HOST msr domain policy: features that Xen actually decided to use,
+ * a subset of RAW policy.
+ */
+extern msr_domain_policy host_msr_domain_policy;
+
 /* MSR policy object for per-vCPU MSRs */
 struct msr_vcpu_policy
 {
-- 
2.14.1


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

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

* Re: [PATCH v1] x86/msr: add Raw and Host domain policies
  2018-02-08 10:23 [PATCH v1] x86/msr: add Raw and Host domain policies Sergey Dyasli
@ 2018-02-08 11:08 ` Andrew Cooper
  2018-02-08 11:21 ` Roger Pau Monné
  2018-02-15 13:33 ` Jan Beulich
  2 siblings, 0 replies; 12+ messages in thread
From: Andrew Cooper @ 2018-02-08 11:08 UTC (permalink / raw)
  To: Sergey Dyasli, xen-devel; +Cc: Jan Beulich

On 08/02/18 10:23, Sergey Dyasli wrote:
> Raw policy contains the actual values from H/W MSRs. Add PLATFORM_INFO
> msr to the policy during probe_cpuid_faulting().
>
> Host policy might have certain features disabled if Xen decides not
> to use them. For now, make Host policy equal to Raw policy.
>
> Signed-off-by: Sergey Dyasli <sergey.dyasli@citrix.com>

Ah thanks - I was about to ask you whether you had this patch to hand.

The deferral probe_cpuid_faulting() isn't great but I think is necessary
at the moment.  I've got some plans to reorder early startup somewhat,
but more infrastructure is required before that can work.

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] 12+ messages in thread

* Re: [PATCH v1] x86/msr: add Raw and Host domain policies
  2018-02-08 10:23 [PATCH v1] x86/msr: add Raw and Host domain policies Sergey Dyasli
  2018-02-08 11:08 ` Andrew Cooper
@ 2018-02-08 11:21 ` Roger Pau Monné
  2018-02-08 11:29   ` Sergey Dyasli
  2018-02-15 13:33 ` Jan Beulich
  2 siblings, 1 reply; 12+ messages in thread
From: Roger Pau Monné @ 2018-02-08 11:21 UTC (permalink / raw)
  To: Sergey Dyasli; +Cc: Andrew Cooper, Jan Beulich, xen-devel

On Thu, Feb 08, 2018 at 10:23:21AM +0000, Sergey Dyasli wrote:
> +static void __init calculate_host_policy(void)
> +{
> +    struct msr_domain_policy *dp = &host_msr_domain_policy;
> +
> +    *dp = raw_msr_domain_policy;

host_msr_domain_policy = raw_msr_domain_policy;

Should work AFAICT.

> diff --git a/xen/include/asm-x86/msr.h b/xen/include/asm-x86/msr.h
> index 928f1cc454..8401d376c3 100644
> --- a/xen/include/asm-x86/msr.h
> +++ b/xen/include/asm-x86/msr.h
> @@ -220,6 +220,14 @@ struct msr_domain_policy
>      } plaform_info;
>  };
>  
> +/* RAW msr domain policy: contains the actual values from H/W MSRs */
> +extern msr_domain_policy raw_msr_domain_policy;
> +/*
> + * HOST msr domain policy: features that Xen actually decided to use,
> + * a subset of RAW policy.
> + */
> +extern msr_domain_policy host_msr_domain_policy;

Aren't you missing a 'struct' here? I don't see any typedef for struct
msr_domain_policy.

Thanks, Roger.

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

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

* Re: [PATCH v1] x86/msr: add Raw and Host domain policies
  2018-02-08 11:21 ` Roger Pau Monné
@ 2018-02-08 11:29   ` Sergey Dyasli
  0 siblings, 0 replies; 12+ messages in thread
From: Sergey Dyasli @ 2018-02-08 11:29 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: Sergey Dyasli, Andrew Cooper, jbeulich, xen-devel

On Thu, 2018-02-08 at 11:21 +0000, Roger Pau Monné wrote:
> On Thu, Feb 08, 2018 at 10:23:21AM +0000, Sergey Dyasli wrote:
> > +static void __init calculate_host_policy(void)
> > +{
> > +    struct msr_domain_policy *dp = &host_msr_domain_policy;
> > +
> > +    *dp = raw_msr_domain_policy;
> 
> host_msr_domain_policy = raw_msr_domain_policy;
> 
> Should work AFAICT.

This is a template for the future. The code with *dp is much shorter
than with host_msr_domain_policy.

> 
> > diff --git a/xen/include/asm-x86/msr.h b/xen/include/asm-x86/msr.h
> > index 928f1cc454..8401d376c3 100644
> > --- a/xen/include/asm-x86/msr.h
> > +++ b/xen/include/asm-x86/msr.h
> > @@ -220,6 +220,14 @@ struct msr_domain_policy
> >      } plaform_info;
> >  };
> >  
> > +/* RAW msr domain policy: contains the actual values from H/W MSRs */
> > +extern msr_domain_policy raw_msr_domain_policy;
> > +/*
> > + * HOST msr domain policy: features that Xen actually decided to use,
> > + * a subset of RAW policy.
> > + */
> > +extern msr_domain_policy host_msr_domain_policy;
> 
> Aren't you missing a 'struct' here? I don't see any typedef for struct
> msr_domain_policy.

I don't know how I missed this. You are right, 'struct' is mandatory.

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

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

* Re: [PATCH v1] x86/msr: add Raw and Host domain policies
  2018-02-08 10:23 [PATCH v1] x86/msr: add Raw and Host domain policies Sergey Dyasli
  2018-02-08 11:08 ` Andrew Cooper
  2018-02-08 11:21 ` Roger Pau Monné
@ 2018-02-15 13:33 ` Jan Beulich
  2018-02-16 10:33   ` Sergey Dyasli
  2 siblings, 1 reply; 12+ messages in thread
From: Jan Beulich @ 2018-02-15 13:33 UTC (permalink / raw)
  To: Sergey Dyasli; +Cc: Andrew Cooper, xen-devel

>>> On 08.02.18 at 11:23, <sergey.dyasli@citrix.com> wrote:
> --- a/xen/arch/x86/cpu/common.c
> +++ b/xen/arch/x86/cpu/common.c
> @@ -118,9 +118,18 @@ void (* __read_mostly ctxt_switch_masking)(const struct vcpu *next);
>  
>  bool __init probe_cpuid_faulting(void)
>  {
> +	struct msr_domain_policy *dp = &raw_msr_domain_policy;

Unless you foresee the variable to be needed for further things
here, could this be moved into the more narrow scope it's used in
please?

>  	uint64_t val;
> +	int rc;
>  
> -	if (rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val) ||
> +	if ((rc = rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val)) == 0)
> +	{
> +		dp->plaform_info.available = true;
> +		if (val & MSR_PLATFORM_INFO_CPUID_FAULTING)
> +			dp->plaform_info.cpuid_faulting = true;
> +	}
> +
> +	if (rc ||
>  	    !(val & MSR_PLATFORM_INFO_CPUID_FAULTING) ||
>  	    rdmsr_safe(MSR_INTEL_MISC_FEATURES_ENABLES,
>  		       this_cpu(msr_misc_features)))

Below here we have

		setup_clear_cpu_cap(X86_FEATURE_CPUID_FAULTING);

Shouldn't this be reflected in the host policy?

Jan


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

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

* Re: [PATCH v1] x86/msr: add Raw and Host domain policies
  2018-02-15 13:33 ` Jan Beulich
@ 2018-02-16 10:33   ` Sergey Dyasli
  2018-02-16 11:06     ` Jan Beulich
  0 siblings, 1 reply; 12+ messages in thread
From: Sergey Dyasli @ 2018-02-16 10:33 UTC (permalink / raw)
  To: JBeulich, Andrew Cooper; +Cc: Sergey Dyasli, xen-devel, Roger Pau Monne

On Thu, 2018-02-15 at 06:33 -0700, Jan Beulich wrote:
> > > > On 08.02.18 at 11:23, <sergey.dyasli@citrix.com> wrote:
> > 
> > --- a/xen/arch/x86/cpu/common.c
> > +++ b/xen/arch/x86/cpu/common.c
> > @@ -118,9 +118,18 @@ void (* __read_mostly ctxt_switch_masking)(const struct vcpu *next);
> >  
> >  bool __init probe_cpuid_faulting(void)
> >  {
> > +	struct msr_domain_policy *dp = &raw_msr_domain_policy;
> 
> Unless you foresee the variable to be needed for further things
> here, could this be moved into the more narrow scope it's used in
> please?

Will do in v2.

> >  	uint64_t val;
> > +	int rc;
> >  
> > -	if (rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val) ||
> > +	if ((rc = rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val)) == 0)
> > +	{
> > +		dp->plaform_info.available = true;
> > +		if (val & MSR_PLATFORM_INFO_CPUID_FAULTING)
> > +			dp->plaform_info.cpuid_faulting = true;
> > +	}
> > +
> > +	if (rc ||
> >  	    !(val & MSR_PLATFORM_INFO_CPUID_FAULTING) ||
> >  	    rdmsr_safe(MSR_INTEL_MISC_FEATURES_ENABLES,
> >  		       this_cpu(msr_misc_features)))
> 
> Below here we have
> 
> 		setup_clear_cpu_cap(X86_FEATURE_CPUID_FAULTING);
> 
> Shouldn't this be reflected in the host policy?

I guess the correct thing to do for now for host_msr_domain_policy is:

    dp->plaform_info.cpuid_faulting = cpu_has_cpuid_faulting;
    
Looking at the code, calculate_pv_max_policy() will be simplified with
the above change: pv_max_msr_domain_policy will become a copy of host
policy.

This actually brings a question: what to do about per-pCPU MSRs in the
context of MSR policy?

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

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

* Re: [PATCH v1] x86/msr: add Raw and Host domain policies
  2018-02-16 10:33   ` Sergey Dyasli
@ 2018-02-16 11:06     ` Jan Beulich
  2018-02-16 11:31       ` Sergey Dyasli
  0 siblings, 1 reply; 12+ messages in thread
From: Jan Beulich @ 2018-02-16 11:06 UTC (permalink / raw)
  To: Sergey Dyasli; +Cc: Andrew Cooper, xen-devel, Roger Pau Monne

>>> On 16.02.18 at 11:33, <sergey.dyasli@citrix.com> wrote:
> On Thu, 2018-02-15 at 06:33 -0700, Jan Beulich wrote:
>> > > > On 08.02.18 at 11:23, <sergey.dyasli@citrix.com> wrote:
>> >  	uint64_t val;
>> > +	int rc;
>> >  
>> > -	if (rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val) ||
>> > +	if ((rc = rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val)) == 0)
>> > +	{
>> > +		dp->plaform_info.available = true;
>> > +		if (val & MSR_PLATFORM_INFO_CPUID_FAULTING)
>> > +			dp->plaform_info.cpuid_faulting = true;
>> > +	}
>> > +
>> > +	if (rc ||
>> >  	    !(val & MSR_PLATFORM_INFO_CPUID_FAULTING) ||
>> >  	    rdmsr_safe(MSR_INTEL_MISC_FEATURES_ENABLES,
>> >  		       this_cpu(msr_misc_features)))
>> 
>> Below here we have
>> 
>> 		setup_clear_cpu_cap(X86_FEATURE_CPUID_FAULTING);
>> 
>> Shouldn't this be reflected in the host policy?
> 
> I guess the correct thing to do for now for host_msr_domain_policy is:
> 
>     dp->plaform_info.cpuid_faulting = cpu_has_cpuid_faulting;
>     
> Looking at the code, calculate_pv_max_policy() will be simplified with
> the above change: pv_max_msr_domain_policy will become a copy of host
> policy.
> 
> This actually brings a question: what to do about per-pCPU MSRs in the
> context of MSR policy?

How does per-pCPU-ness of an MSR affect the policy? Are you
thinking of CPUs with different capabilities? We assume all CPUs
are identical in many other places.

Jan


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

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

* Re: [PATCH v1] x86/msr: add Raw and Host domain policies
  2018-02-16 11:06     ` Jan Beulich
@ 2018-02-16 11:31       ` Sergey Dyasli
  2018-02-16 11:37         ` Jan Beulich
  2018-02-16 11:38         ` Andrew Cooper
  0 siblings, 2 replies; 12+ messages in thread
From: Sergey Dyasli @ 2018-02-16 11:31 UTC (permalink / raw)
  To: JBeulich, Andrew Cooper; +Cc: Sergey Dyasli, xen-devel, Roger Pau Monne

On Fri, 2018-02-16 at 04:06 -0700, Jan Beulich wrote:
> > > > On 16.02.18 at 11:33, <sergey.dyasli@citrix.com> wrote:
> > 
> > On Thu, 2018-02-15 at 06:33 -0700, Jan Beulich wrote:
> > > > > > On 08.02.18 at 11:23, <sergey.dyasli@citrix.com> wrote:
> > > > 
> > > >  	uint64_t val;
> > > > +	int rc;
> > > >  
> > > > -	if (rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val) ||
> > > > +	if ((rc = rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val)) == 0)
> > > > +	{
> > > > +		dp->plaform_info.available = true;
> > > > +		if (val & MSR_PLATFORM_INFO_CPUID_FAULTING)
> > > > +			dp->plaform_info.cpuid_faulting = true;
> > > > +	}
> > > > +
> > > > +	if (rc ||
> > > >  	    !(val & MSR_PLATFORM_INFO_CPUID_FAULTING) ||
> > > >  	    rdmsr_safe(MSR_INTEL_MISC_FEATURES_ENABLES,
> > > >  		       this_cpu(msr_misc_features)))
> > > 
> > > Below here we have
> > > 
> > > 		setup_clear_cpu_cap(X86_FEATURE_CPUID_FAULTING);
> > > 
> > > Shouldn't this be reflected in the host policy?
> > 
> > I guess the correct thing to do for now for host_msr_domain_policy is:
> > 
> >     dp->plaform_info.cpuid_faulting = cpu_has_cpuid_faulting;
> >     
> > Looking at the code, calculate_pv_max_policy() will be simplified with
> > the above change: pv_max_msr_domain_policy will become a copy of host
> > policy.
> > 
> > This actually brings a question: what to do about per-pCPU MSRs in the
> > context of MSR policy?
> 
> How does per-pCPU-ness of an MSR affect the policy? Are you
> thinking of CPUs with different capabilities? We assume all CPUs
> are identical in many other places.

Yes, CPUs are assumed to be identical. But currently Xen checks
the presence of MISC_FEATURES_ENABLES (which is a per-pCPU msr)
on the boot CPU, and it affects X86_FEATURE_CPUID_FAULTING. Which
in it's turn affects the presence of MISC_FEATURES_ENABLES for PV vCPUs.

So the actual question is: where to store the availability of
MISC_FEATURES_ENABLES (and possibly other per-pCPU msrs in the future)
and is it even needed to do so?

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

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

* Re: [PATCH v1] x86/msr: add Raw and Host domain policies
  2018-02-16 11:31       ` Sergey Dyasli
@ 2018-02-16 11:37         ` Jan Beulich
  2018-02-16 11:38         ` Andrew Cooper
  1 sibling, 0 replies; 12+ messages in thread
From: Jan Beulich @ 2018-02-16 11:37 UTC (permalink / raw)
  To: Sergey Dyasli; +Cc: Andrew Cooper, xen-devel, Roger Pau Monne

>>> On 16.02.18 at 12:31, <sergey.dyasli@citrix.com> wrote:
> On Fri, 2018-02-16 at 04:06 -0700, Jan Beulich wrote:
>> > > > On 16.02.18 at 11:33, <sergey.dyasli@citrix.com> wrote:
>> > 
>> > On Thu, 2018-02-15 at 06:33 -0700, Jan Beulich wrote:
>> > > > > > On 08.02.18 at 11:23, <sergey.dyasli@citrix.com> wrote:
>> > > > 
>> > > >  	uint64_t val;
>> > > > +	int rc;
>> > > >  
>> > > > -	if (rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val) ||
>> > > > +	if ((rc = rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val)) == 0)
>> > > > +	{
>> > > > +		dp->plaform_info.available = true;
>> > > > +		if (val & MSR_PLATFORM_INFO_CPUID_FAULTING)
>> > > > +			dp->plaform_info.cpuid_faulting = true;
>> > > > +	}
>> > > > +
>> > > > +	if (rc ||
>> > > >  	    !(val & MSR_PLATFORM_INFO_CPUID_FAULTING) ||
>> > > >  	    rdmsr_safe(MSR_INTEL_MISC_FEATURES_ENABLES,
>> > > >  		       this_cpu(msr_misc_features)))
>> > > 
>> > > Below here we have
>> > > 
>> > > 		setup_clear_cpu_cap(X86_FEATURE_CPUID_FAULTING);
>> > > 
>> > > Shouldn't this be reflected in the host policy?
>> > 
>> > I guess the correct thing to do for now for host_msr_domain_policy is:
>> > 
>> >     dp->plaform_info.cpuid_faulting = cpu_has_cpuid_faulting;
>> >     
>> > Looking at the code, calculate_pv_max_policy() will be simplified with
>> > the above change: pv_max_msr_domain_policy will become a copy of host
>> > policy.
>> > 
>> > This actually brings a question: what to do about per-pCPU MSRs in the
>> > context of MSR policy?
>> 
>> How does per-pCPU-ness of an MSR affect the policy? Are you
>> thinking of CPUs with different capabilities? We assume all CPUs
>> are identical in many other places.
> 
> Yes, CPUs are assumed to be identical. But currently Xen checks
> the presence of MISC_FEATURES_ENABLES (which is a per-pCPU msr)
> on the boot CPU, and it affects X86_FEATURE_CPUID_FAULTING. Which
> in it's turn affects the presence of MISC_FEATURES_ENABLES for PV vCPUs.
> 
> So the actual question is: where to store the availability of
> MISC_FEATURES_ENABLES (and possibly other per-pCPU msrs in the future)
> and is it even needed to do so?

Well, just like the CPUID policy records which leaves are available,
the MSR policy ought to track which MSRs are available (alongside
the bits inside each MSRs that are valid to use).

Jan


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

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

* Re: [PATCH v1] x86/msr: add Raw and Host domain policies
  2018-02-16 11:31       ` Sergey Dyasli
  2018-02-16 11:37         ` Jan Beulich
@ 2018-02-16 11:38         ` Andrew Cooper
  2018-02-16 16:00           ` Sergey Dyasli
  1 sibling, 1 reply; 12+ messages in thread
From: Andrew Cooper @ 2018-02-16 11:38 UTC (permalink / raw)
  To: Sergey Dyasli, JBeulich; +Cc: xen-devel, Roger Pau Monne

On 16/02/18 11:31, Sergey Dyasli wrote:
> On Fri, 2018-02-16 at 04:06 -0700, Jan Beulich wrote:
>>>>> On 16.02.18 at 11:33, <sergey.dyasli@citrix.com> wrote:
>>> On Thu, 2018-02-15 at 06:33 -0700, Jan Beulich wrote:
>>>>>>> On 08.02.18 at 11:23, <sergey.dyasli@citrix.com> wrote:
>>>>>  	uint64_t val;
>>>>> +	int rc;
>>>>>  
>>>>> -	if (rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val) ||
>>>>> +	if ((rc = rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val)) == 0)
>>>>> +	{
>>>>> +		dp->plaform_info.available = true;
>>>>> +		if (val & MSR_PLATFORM_INFO_CPUID_FAULTING)
>>>>> +			dp->plaform_info.cpuid_faulting = true;
>>>>> +	}
>>>>> +
>>>>> +	if (rc ||
>>>>>  	    !(val & MSR_PLATFORM_INFO_CPUID_FAULTING) ||
>>>>>  	    rdmsr_safe(MSR_INTEL_MISC_FEATURES_ENABLES,
>>>>>  		       this_cpu(msr_misc_features)))
>>>> Below here we have
>>>>
>>>> 		setup_clear_cpu_cap(X86_FEATURE_CPUID_FAULTING);
>>>>
>>>> Shouldn't this be reflected in the host policy?
>>> I guess the correct thing to do for now for host_msr_domain_policy is:
>>>
>>>     dp->plaform_info.cpuid_faulting = cpu_has_cpuid_faulting;
>>>     
>>> Looking at the code, calculate_pv_max_policy() will be simplified with
>>> the above change: pv_max_msr_domain_policy will become a copy of host
>>> policy.
>>>
>>> This actually brings a question: what to do about per-pCPU MSRs in the
>>> context of MSR policy?
>> How does per-pCPU-ness of an MSR affect the policy? Are you
>> thinking of CPUs with different capabilities? We assume all CPUs
>> are identical in many other places.
> Yes, CPUs are assumed to be identical. But currently Xen checks
> the presence of MISC_FEATURES_ENABLES (which is a per-pCPU msr)
> on the boot CPU, and it affects X86_FEATURE_CPUID_FAULTING. Which
> in it's turn affects the presence of MISC_FEATURES_ENABLES for PV vCPUs.
>
> So the actual question is: where to store the availability of
> MISC_FEATURES_ENABLES (and possibly other per-pCPU msrs in the future)
> and is it even needed to do so?

Store it in one single host policy.

Part of my CPUID work will be cleaning up some of these warts in the
detection logic.

~Andrew

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

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

* Re: [PATCH v1] x86/msr: add Raw and Host domain policies
  2018-02-16 11:38         ` Andrew Cooper
@ 2018-02-16 16:00           ` Sergey Dyasli
  2018-02-16 16:02             ` Andrew Cooper
  0 siblings, 1 reply; 12+ messages in thread
From: Sergey Dyasli @ 2018-02-16 16:00 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Sergey Dyasli, xen-devel, JBeulich, Roger Pau Monne

On Fri, 2018-02-16 at 11:38 +0000, Andrew Cooper wrote:
> On 16/02/18 11:31, Sergey Dyasli wrote:
> > On Fri, 2018-02-16 at 04:06 -0700, Jan Beulich wrote:
> > > > > > On 16.02.18 at 11:33, <sergey.dyasli@citrix.com> wrote:
> > > > 
> > > > On Thu, 2018-02-15 at 06:33 -0700, Jan Beulich wrote:
> > > > > > > > On 08.02.18 at 11:23, <sergey.dyasli@citrix.com> wrote:
> > > > > > 
> > > > > >  	uint64_t val;
> > > > > > +	int rc;
> > > > > >  
> > > > > > -	if (rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val) ||
> > > > > > +	if ((rc = rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val)) == 0)
> > > > > > +	{
> > > > > > +		dp->plaform_info.available = true;
> > > > > > +		if (val & MSR_PLATFORM_INFO_CPUID_FAULTING)
> > > > > > +			dp->plaform_info.cpuid_faulting = true;
> > > > > > +	}
> > > > > > +
> > > > > > +	if (rc ||
> > > > > >  	    !(val & MSR_PLATFORM_INFO_CPUID_FAULTING) ||
> > > > > >  	    rdmsr_safe(MSR_INTEL_MISC_FEATURES_ENABLES,
> > > > > >  		       this_cpu(msr_misc_features)))
> > > > > 
> > > > > Below here we have
> > > > > 
> > > > > 		setup_clear_cpu_cap(X86_FEATURE_CPUID_FAULTING);
> > > > > 
> > > > > Shouldn't this be reflected in the host policy?
> > > > 
> > > > I guess the correct thing to do for now for host_msr_domain_policy is:
> > > > 
> > > >     dp->plaform_info.cpuid_faulting = cpu_has_cpuid_faulting;
> > > >     
> > > > Looking at the code, calculate_pv_max_policy() will be simplified with
> > > > the above change: pv_max_msr_domain_policy will become a copy of host
> > > > policy.
> > > > 
> > > > This actually brings a question: what to do about per-pCPU MSRs in the
> > > > context of MSR policy?
> > > 
> > > How does per-pCPU-ness of an MSR affect the policy? Are you
> > > thinking of CPUs with different capabilities? We assume all CPUs
> > > are identical in many other places.
> > 
> > Yes, CPUs are assumed to be identical. But currently Xen checks
> > the presence of MISC_FEATURES_ENABLES (which is a per-pCPU msr)
> > on the boot CPU, and it affects X86_FEATURE_CPUID_FAULTING. Which
> > in it's turn affects the presence of MISC_FEATURES_ENABLES for PV vCPUs.
> > 
> > So the actual question is: where to store the availability of
> > MISC_FEATURES_ENABLES (and possibly other per-pCPU msrs in the future)
> > and is it even needed to do so?
> 
> Store it in one single host policy.

And where do you propose to actually store it? Currently there are
two distinct structures: msr_domain_policy and msr_vcpu_policy.

> Part of my CPUID work will be cleaning up some of these warts in the
> detection logic.

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

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

* Re: [PATCH v1] x86/msr: add Raw and Host domain policies
  2018-02-16 16:00           ` Sergey Dyasli
@ 2018-02-16 16:02             ` Andrew Cooper
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Cooper @ 2018-02-16 16:02 UTC (permalink / raw)
  To: Sergey Dyasli; +Cc: xen-devel, JBeulich, Roger Pau Monne

On 16/02/18 16:00, Sergey Dyasli wrote:
> On Fri, 2018-02-16 at 11:38 +0000, Andrew Cooper wrote:
>> On 16/02/18 11:31, Sergey Dyasli wrote:
>>> On Fri, 2018-02-16 at 04:06 -0700, Jan Beulich wrote:
>>>>>>> On 16.02.18 at 11:33, <sergey.dyasli@citrix.com> wrote:
>>>>> On Thu, 2018-02-15 at 06:33 -0700, Jan Beulich wrote:
>>>>>>>>> On 08.02.18 at 11:23, <sergey.dyasli@citrix.com> wrote:
>>>>>>>  	uint64_t val;
>>>>>>> +	int rc;
>>>>>>>  
>>>>>>> -	if (rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val) ||
>>>>>>> +	if ((rc = rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val)) == 0)
>>>>>>> +	{
>>>>>>> +		dp->plaform_info.available = true;
>>>>>>> +		if (val & MSR_PLATFORM_INFO_CPUID_FAULTING)
>>>>>>> +			dp->plaform_info.cpuid_faulting = true;
>>>>>>> +	}
>>>>>>> +
>>>>>>> +	if (rc ||
>>>>>>>  	    !(val & MSR_PLATFORM_INFO_CPUID_FAULTING) ||
>>>>>>>  	    rdmsr_safe(MSR_INTEL_MISC_FEATURES_ENABLES,
>>>>>>>  		       this_cpu(msr_misc_features)))
>>>>>> Below here we have
>>>>>>
>>>>>> 		setup_clear_cpu_cap(X86_FEATURE_CPUID_FAULTING);
>>>>>>
>>>>>> Shouldn't this be reflected in the host policy?
>>>>> I guess the correct thing to do for now for host_msr_domain_policy is:
>>>>>
>>>>>     dp->plaform_info.cpuid_faulting = cpu_has_cpuid_faulting;
>>>>>     
>>>>> Looking at the code, calculate_pv_max_policy() will be simplified with
>>>>> the above change: pv_max_msr_domain_policy will become a copy of host
>>>>> policy.
>>>>>
>>>>> This actually brings a question: what to do about per-pCPU MSRs in the
>>>>> context of MSR policy?
>>>> How does per-pCPU-ness of an MSR affect the policy? Are you
>>>> thinking of CPUs with different capabilities? We assume all CPUs
>>>> are identical in many other places.
>>> Yes, CPUs are assumed to be identical. But currently Xen checks
>>> the presence of MISC_FEATURES_ENABLES (which is a per-pCPU msr)
>>> on the boot CPU, and it affects X86_FEATURE_CPUID_FAULTING. Which
>>> in it's turn affects the presence of MISC_FEATURES_ENABLES for PV vCPUs.
>>>
>>> So the actual question is: where to store the availability of
>>> MISC_FEATURES_ENABLES (and possibly other per-pCPU msrs in the future)
>>> and is it even needed to do so?
>> Store it in one single host policy.
> And where do you propose to actually store it? Currently there are
> two distinct structures: msr_domain_policy and msr_vcpu_policy.

msr_domain_policy, like this patch does.

By and large, I expect the "read only feature style" MSRs to all be in
the domain policy, and the "read/write make stuff happen" MSRs to all be
in the vcpu policy.

We can revisit this if/when we find a counterexample.

~Andrew

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

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

end of thread, other threads:[~2018-02-16 16:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-08 10:23 [PATCH v1] x86/msr: add Raw and Host domain policies Sergey Dyasli
2018-02-08 11:08 ` Andrew Cooper
2018-02-08 11:21 ` Roger Pau Monné
2018-02-08 11:29   ` Sergey Dyasli
2018-02-15 13:33 ` Jan Beulich
2018-02-16 10:33   ` Sergey Dyasli
2018-02-16 11:06     ` Jan Beulich
2018-02-16 11:31       ` Sergey Dyasli
2018-02-16 11:37         ` Jan Beulich
2018-02-16 11:38         ` Andrew Cooper
2018-02-16 16:00           ` Sergey Dyasli
2018-02-16 16:02             ` 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.