xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] x86/xen: cpuid() cleanup
@ 2017-02-17  7:36 Juergen Gross
  2017-02-17  7:36 ` [PATCH 1/2] x86/xen: don't indicate DCA support in pv domains Juergen Gross
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Juergen Gross @ 2017-02-17  7:36 UTC (permalink / raw)
  To: linux-kernel, xen-devel, x86
  Cc: Juergen Gross, boris.ostrovsky, mingo, tglx, hpa

Reduce special casing of xen_cpuid() and disable DCA feature for pv
domains as it isn't supported under Xen.

Juergen Gross (2):
  x86/xen: don't indicate DCA support in pv domains
  x86/xen: use capabilities instead of fake cpuid values

 arch/x86/xen/enlighten.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

-- 
2.10.2


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

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

* [PATCH 1/2] x86/xen: don't indicate DCA support in pv domains
  2017-02-17  7:36 [PATCH 0/2] x86/xen: cpuid() cleanup Juergen Gross
@ 2017-02-17  7:36 ` Juergen Gross
  2017-02-17  7:36 ` [PATCH 2/2] x86/xen: use capabilities instead of fake cpuid values Juergen Gross
       [not found] ` <20170217073625.13418-3-jgross@suse.com>
  2 siblings, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2017-02-17  7:36 UTC (permalink / raw)
  To: linux-kernel, xen-devel, x86
  Cc: Juergen Gross, boris.ostrovsky, mingo, tglx, hpa

Xen doesn't support DCA (direct cache access) for pv domains. Clear
the corresponding capability indicator.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/xen/enlighten.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 51ef952..83399ce 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -461,6 +461,9 @@ static void __init xen_init_cpuid_mask(void)
 		cpuid_leaf1_ecx_mask &= ~xsave_mask; /* disable XSAVE & OSXSAVE */
 	if (xen_check_mwait())
 		cpuid_leaf1_ecx_set_mask = (1 << (X86_FEATURE_MWAIT % 32));
+
+	/* Disable DCA feature. */
+	setup_clear_cpu_cap(X86_FEATURE_DCA);
 }
 
 static void xen_set_debugreg(int reg, unsigned long val)
-- 
2.10.2


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

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

* [PATCH 2/2] x86/xen: use capabilities instead of fake cpuid values
  2017-02-17  7:36 [PATCH 0/2] x86/xen: cpuid() cleanup Juergen Gross
  2017-02-17  7:36 ` [PATCH 1/2] x86/xen: don't indicate DCA support in pv domains Juergen Gross
@ 2017-02-17  7:36 ` Juergen Gross
       [not found] ` <20170217073625.13418-3-jgross@suse.com>
  2 siblings, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2017-02-17  7:36 UTC (permalink / raw)
  To: linux-kernel, xen-devel, x86
  Cc: Juergen Gross, boris.ostrovsky, mingo, tglx, hpa

When running as pv domain xen_cpuid() is being used instead of
native_cpuid(). In xen_cpuid() the aperf/mperf feature is indicated
as not being present by special casing the related cpuid leaf.

Instead of delivering fake cpuid values clear the cpu capability bit
for aperf/mperf instead.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/xen/enlighten.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 83399ce..0eebb75 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -301,9 +301,6 @@ xen_running_on_version_or_later(unsigned int major, unsigned int minor)
 	return false;
 }
 
-#define CPUID_THERM_POWER_LEAF 6
-#define APERFMPERF_PRESENT 0
-
 static __read_mostly unsigned int cpuid_leaf1_edx_mask = ~0;
 static __read_mostly unsigned int cpuid_leaf1_ecx_mask = ~0;
 
@@ -337,11 +334,6 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
 		*dx = cpuid_leaf5_edx_val;
 		return;
 
-	case CPUID_THERM_POWER_LEAF:
-		/* Disabling APERFMPERF for kernel usage */
-		maskecx = ~(1 << APERFMPERF_PRESENT);
-		break;
-
 	case 0xb:
 		/* Suppress extended topology stuff */
 		maskebx = 0;
@@ -462,6 +454,9 @@ static void __init xen_init_cpuid_mask(void)
 	if (xen_check_mwait())
 		cpuid_leaf1_ecx_set_mask = (1 << (X86_FEATURE_MWAIT % 32));
 
+	/* Disable APERFMPERF feature. */
+	setup_clear_cpu_cap(X86_FEATURE_APERFMPERF);
+
 	/* Disable DCA feature. */
 	setup_clear_cpu_cap(X86_FEATURE_DCA);
 }
-- 
2.10.2


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

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

* Re: [PATCH 2/2] x86/xen: use capabilities instead of fake cpuid values
       [not found] ` <20170217073625.13418-3-jgross@suse.com>
@ 2017-02-17 14:05   ` Boris Ostrovsky
       [not found]   ` <f960f590-d6a2-d505-a044-127fe2c9e4d7@oracle.com>
  1 sibling, 0 replies; 7+ messages in thread
From: Boris Ostrovsky @ 2017-02-17 14:05 UTC (permalink / raw)
  To: Juergen Gross, linux-kernel, xen-devel, x86; +Cc: tglx, mingo, hpa



On 02/17/2017 02:36 AM, Juergen Gross wrote:
> When running as pv domain xen_cpuid() is being used instead of
> native_cpuid(). In xen_cpuid() the aperf/mperf feature is indicated
> as not being present by special casing the related cpuid leaf.
>
> Instead of delivering fake cpuid values clear the cpu capability bit
> for aperf/mperf instead.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
>  arch/x86/xen/enlighten.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> index 83399ce..0eebb75 100644
> --- a/arch/x86/xen/enlighten.c
> +++ b/arch/x86/xen/enlighten.c
> @@ -301,9 +301,6 @@ xen_running_on_version_or_later(unsigned int major, unsigned int minor)
>  	return false;
>  }
>
> -#define CPUID_THERM_POWER_LEAF 6
> -#define APERFMPERF_PRESENT 0
> -
>  static __read_mostly unsigned int cpuid_leaf1_edx_mask = ~0;
>  static __read_mostly unsigned int cpuid_leaf1_ecx_mask = ~0;
>
> @@ -337,11 +334,6 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
>  		*dx = cpuid_leaf5_edx_val;
>  		return;
>
> -	case CPUID_THERM_POWER_LEAF:
> -		/* Disabling APERFMPERF for kernel usage */
> -		maskecx = ~(1 << APERFMPERF_PRESENT);
> -		break;
> -


But now APERF/MPERF will be reported as supported by CPUID, won't it?


>  	case 0xb:
>  		/* Suppress extended topology stuff */
>  		maskebx = 0;
> @@ -462,6 +454,9 @@ static void __init xen_init_cpuid_mask(void)
>  	if (xen_check_mwait())
>  		cpuid_leaf1_ecx_set_mask = (1 << (X86_FEATURE_MWAIT % 32));
>
> +	/* Disable APERFMPERF feature. */
> +	setup_clear_cpu_cap(X86_FEATURE_APERFMPERF);
> +
>  	/* Disable DCA feature. */
>  	setup_clear_cpu_cap(X86_FEATURE_DCA);


I think both of those can go to xen_set_cpu_features().

-boris

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

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

* Re: [PATCH 2/2] x86/xen: use capabilities instead of fake cpuid values
       [not found]   ` <f960f590-d6a2-d505-a044-127fe2c9e4d7@oracle.com>
@ 2017-02-17 14:19     ` Juergen Gross
       [not found]     ` <1f923425-47f5-5e6d-5bca-e4c98d54ced5@suse.com>
  1 sibling, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2017-02-17 14:19 UTC (permalink / raw)
  To: Boris Ostrovsky, linux-kernel, xen-devel, x86; +Cc: tglx, mingo, hpa

On 17/02/17 15:05, Boris Ostrovsky wrote:
> 
> 
> On 02/17/2017 02:36 AM, Juergen Gross wrote:
>> When running as pv domain xen_cpuid() is being used instead of
>> native_cpuid(). In xen_cpuid() the aperf/mperf feature is indicated
>> as not being present by special casing the related cpuid leaf.
>>
>> Instead of delivering fake cpuid values clear the cpu capability bit
>> for aperf/mperf instead.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>>  arch/x86/xen/enlighten.c | 11 +++--------
>>  1 file changed, 3 insertions(+), 8 deletions(-)
>>
>> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
>> index 83399ce..0eebb75 100644
>> --- a/arch/x86/xen/enlighten.c
>> +++ b/arch/x86/xen/enlighten.c
>> @@ -301,9 +301,6 @@ xen_running_on_version_or_later(unsigned int
>> major, unsigned int minor)
>>      return false;
>>  }
>>
>> -#define CPUID_THERM_POWER_LEAF 6
>> -#define APERFMPERF_PRESENT 0
>> -
>>  static __read_mostly unsigned int cpuid_leaf1_edx_mask = ~0;
>>  static __read_mostly unsigned int cpuid_leaf1_ecx_mask = ~0;
>>
>> @@ -337,11 +334,6 @@ static void xen_cpuid(unsigned int *ax, unsigned
>> int *bx,
>>          *dx = cpuid_leaf5_edx_val;
>>          return;
>>
>> -    case CPUID_THERM_POWER_LEAF:
>> -        /* Disabling APERFMPERF for kernel usage */
>> -        maskecx = ~(1 << APERFMPERF_PRESENT);
>> -        break;
>> -
> 
> 
> But now APERF/MPERF will be reported as supported by CPUID, won't it?

Yes. But this shouldn't be a problem as the kernel is always testing
X86_FEATURE_APERFMPERF for testing the support.

>>      case 0xb:
>>          /* Suppress extended topology stuff */
>>          maskebx = 0;
>> @@ -462,6 +454,9 @@ static void __init xen_init_cpuid_mask(void)
>>      if (xen_check_mwait())
>>          cpuid_leaf1_ecx_set_mask = (1 << (X86_FEATURE_MWAIT % 32));
>>
>> +    /* Disable APERFMPERF feature. */
>> +    setup_clear_cpu_cap(X86_FEATURE_APERFMPERF);
>> +
>>      /* Disable DCA feature. */
>>      setup_clear_cpu_cap(X86_FEATURE_DCA);
> 
> 
> I think both of those can go to xen_set_cpu_features().

Okay. I'll move them.

I think we can convert some of the remaining cpuid bit modifications to
cpu capabilities as well.


Juergen

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

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

* Re: [PATCH 2/2] x86/xen: use capabilities instead of fake cpuid values
       [not found]     ` <1f923425-47f5-5e6d-5bca-e4c98d54ced5@suse.com>
@ 2017-02-17 14:30       ` Boris Ostrovsky
  2017-02-17 14:43         ` Juergen Gross
  0 siblings, 1 reply; 7+ messages in thread
From: Boris Ostrovsky @ 2017-02-17 14:30 UTC (permalink / raw)
  To: Juergen Gross, linux-kernel, xen-devel, x86; +Cc: tglx, mingo, hpa



On 02/17/2017 09:19 AM, Juergen Gross wrote:
> On 17/02/17 15:05, Boris Ostrovsky wrote:
>>
>>
>> On 02/17/2017 02:36 AM, Juergen Gross wrote:
>>> When running as pv domain xen_cpuid() is being used instead of
>>> native_cpuid(). In xen_cpuid() the aperf/mperf feature is indicated
>>> as not being present by special casing the related cpuid leaf.
>>>
>>> Instead of delivering fake cpuid values clear the cpu capability bit
>>> for aperf/mperf instead.
>>>
>>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>> ---
>>>  arch/x86/xen/enlighten.c | 11 +++--------
>>>  1 file changed, 3 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
>>> index 83399ce..0eebb75 100644
>>> --- a/arch/x86/xen/enlighten.c
>>> +++ b/arch/x86/xen/enlighten.c
>>> @@ -301,9 +301,6 @@ xen_running_on_version_or_later(unsigned int
>>> major, unsigned int minor)
>>>      return false;
>>>  }
>>>
>>> -#define CPUID_THERM_POWER_LEAF 6
>>> -#define APERFMPERF_PRESENT 0
>>> -
>>>  static __read_mostly unsigned int cpuid_leaf1_edx_mask = ~0;
>>>  static __read_mostly unsigned int cpuid_leaf1_ecx_mask = ~0;
>>>
>>> @@ -337,11 +334,6 @@ static void xen_cpuid(unsigned int *ax, unsigned
>>> int *bx,
>>>          *dx = cpuid_leaf5_edx_val;
>>>          return;
>>>
>>> -    case CPUID_THERM_POWER_LEAF:
>>> -        /* Disabling APERFMPERF for kernel usage */
>>> -        maskecx = ~(1 << APERFMPERF_PRESENT);
>>> -        break;
>>> -
>>
>>
>> But now APERF/MPERF will be reported as supported by CPUID, won't it?
>
> Yes. But this shouldn't be a problem as the kernel is always testing
> X86_FEATURE_APERFMPERF for testing the support.


But X86_FEATURE_APERFMPERF cap is set based on CPUID query.

-boris

>
>>>      case 0xb:
>>>          /* Suppress extended topology stuff */
>>>          maskebx = 0;
>>> @@ -462,6 +454,9 @@ static void __init xen_init_cpuid_mask(void)
>>>      if (xen_check_mwait())
>>>          cpuid_leaf1_ecx_set_mask = (1 << (X86_FEATURE_MWAIT % 32));
>>>
>>> +    /* Disable APERFMPERF feature. */
>>> +    setup_clear_cpu_cap(X86_FEATURE_APERFMPERF);
>>> +
>>>      /* Disable DCA feature. */
>>>      setup_clear_cpu_cap(X86_FEATURE_DCA);
>>
>>
>> I think both of those can go to xen_set_cpu_features().
>
> Okay. I'll move them.
>
> I think we can convert some of the remaining cpuid bit modifications to
> cpu capabilities as well.
>
>
> Juergen
>

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

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

* Re: [PATCH 2/2] x86/xen: use capabilities instead of fake cpuid values
  2017-02-17 14:30       ` Boris Ostrovsky
@ 2017-02-17 14:43         ` Juergen Gross
  0 siblings, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2017-02-17 14:43 UTC (permalink / raw)
  To: Boris Ostrovsky, linux-kernel, xen-devel, x86; +Cc: tglx, mingo, hpa

On 17/02/17 15:30, Boris Ostrovsky wrote:
> 
> 
> On 02/17/2017 09:19 AM, Juergen Gross wrote:
>> On 17/02/17 15:05, Boris Ostrovsky wrote:
>>>
>>>
>>> On 02/17/2017 02:36 AM, Juergen Gross wrote:
>>>> When running as pv domain xen_cpuid() is being used instead of
>>>> native_cpuid(). In xen_cpuid() the aperf/mperf feature is indicated
>>>> as not being present by special casing the related cpuid leaf.
>>>>
>>>> Instead of delivering fake cpuid values clear the cpu capability bit
>>>> for aperf/mperf instead.
>>>>
>>>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>>> ---
>>>>  arch/x86/xen/enlighten.c | 11 +++--------
>>>>  1 file changed, 3 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
>>>> index 83399ce..0eebb75 100644
>>>> --- a/arch/x86/xen/enlighten.c
>>>> +++ b/arch/x86/xen/enlighten.c
>>>> @@ -301,9 +301,6 @@ xen_running_on_version_or_later(unsigned int
>>>> major, unsigned int minor)
>>>>      return false;
>>>>  }
>>>>
>>>> -#define CPUID_THERM_POWER_LEAF 6
>>>> -#define APERFMPERF_PRESENT 0
>>>> -
>>>>  static __read_mostly unsigned int cpuid_leaf1_edx_mask = ~0;
>>>>  static __read_mostly unsigned int cpuid_leaf1_ecx_mask = ~0;
>>>>
>>>> @@ -337,11 +334,6 @@ static void xen_cpuid(unsigned int *ax, unsigned
>>>> int *bx,
>>>>          *dx = cpuid_leaf5_edx_val;
>>>>          return;
>>>>
>>>> -    case CPUID_THERM_POWER_LEAF:
>>>> -        /* Disabling APERFMPERF for kernel usage */
>>>> -        maskecx = ~(1 << APERFMPERF_PRESENT);
>>>> -        break;
>>>> -
>>>
>>>
>>> But now APERF/MPERF will be reported as supported by CPUID, won't it?
>>
>> Yes. But this shouldn't be a problem as the kernel is always testing
>> X86_FEATURE_APERFMPERF for testing the support.
> 
> 
> But X86_FEATURE_APERFMPERF cap is set based on CPUID query.

Right. And setup_clear_cpu_cap() will result in removing the feature
from the capabilities (removes it from boot cpu capabilities at once
and is setting it in the mask which is negated and anded into the
capabilities after issuing the cpuid queries).


Juergen

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

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

end of thread, other threads:[~2017-02-17 14:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-17  7:36 [PATCH 0/2] x86/xen: cpuid() cleanup Juergen Gross
2017-02-17  7:36 ` [PATCH 1/2] x86/xen: don't indicate DCA support in pv domains Juergen Gross
2017-02-17  7:36 ` [PATCH 2/2] x86/xen: use capabilities instead of fake cpuid values Juergen Gross
     [not found] ` <20170217073625.13418-3-jgross@suse.com>
2017-02-17 14:05   ` Boris Ostrovsky
     [not found]   ` <f960f590-d6a2-d505-a044-127fe2c9e4d7@oracle.com>
2017-02-17 14:19     ` Juergen Gross
     [not found]     ` <1f923425-47f5-5e6d-5bca-e4c98d54ced5@suse.com>
2017-02-17 14:30       ` Boris Ostrovsky
2017-02-17 14:43         ` Juergen Gross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).