Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1660464 > unrolled thread
| Started by | Andi Kleen <andi@firstfloor.org> |
|---|---|
| First post | 2017-06-08 01:40 +0200 |
| Last post | 2017-06-13 02:20 +0200 |
| Articles | 4 — 1 participant |
Back to article view | Back to linux.kernel
Support generic disabling of all XSAVE features Andi Kleen <andi@firstfloor.org> - 2017-06-08 01:40 +0200
[PATCH v2 5/5] x86/xsave: Using generic CPUID clearing when disabling XSAVE Andi Kleen <andi@firstfloor.org> - 2017-06-08 01:40 +0200
[PATCH v2 4/5] x86/xsave: Make XSAVE check the base CPUID features before enabling Andi Kleen <andi@firstfloor.org> - 2017-06-08 01:40 +0200
Re: Support generic disabling of all XSAVE features Andi Kleen <andi@firstfloor.org> - 2017-06-13 02:20 +0200
| From | Andi Kleen <andi@firstfloor.org> |
|---|---|
| Date | 2017-06-08 01:40 +0200 |
| Subject | Support generic disabling of all XSAVE features |
| Message-ID | <tPSIq-4Pr-11@gated-at.bofh.it> |
For performance testing and debugging it can be useful to disable XSAVE features individually. This patchkit hooks up XSAVE with the generic clearcpuid=... option, so that disabling a CPUID feature automatically disables the respective XSAVE feature. It also cleans up CPUID dependency management. Currently it's possible to generate configurations with cleacpuid that crash. It replaces an earlier patchkit that did this with special case options. v1: Initial post v2: Work around broken lguest by exporting set_cpu_cap Repost with cover letter
[toc] | [next] | [standalone]
| From | Andi Kleen <andi@firstfloor.org> |
|---|---|
| Date | 2017-06-08 01:40 +0200 |
| Subject | [PATCH v2 5/5] x86/xsave: Using generic CPUID clearing when disabling XSAVE |
| Message-ID | <tPSIs-4Pr-51@gated-at.bofh.it> |
| In reply to | #1660464 |
From: Andi Kleen <ak@linux.intel.com>
Now that the generic CPUID clearing understands dependencies,
it's enough to clear the XSAVE CPUID bit to clear all depending
features when XSAVE gets disabled.
So we don't need this hard to maintain explicit list
of features depending on XSAVE anymore. Just call the generic
clear_cpu_cap() function for XSAVE.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
arch/x86/kernel/fpu/xstate.c | 20 --------------------
1 file changed, 20 deletions(-)
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 8f0b96320cc9..73c4fda76d32 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -73,26 +73,6 @@ unsigned int fpu_user_xstate_size;
void fpu__xstate_clear_all_cpu_caps(void)
{
setup_clear_cpu_cap(X86_FEATURE_XSAVE);
- setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
- setup_clear_cpu_cap(X86_FEATURE_XSAVEC);
- setup_clear_cpu_cap(X86_FEATURE_XSAVES);
- setup_clear_cpu_cap(X86_FEATURE_AVX);
- setup_clear_cpu_cap(X86_FEATURE_AVX2);
- setup_clear_cpu_cap(X86_FEATURE_AVX512F);
- setup_clear_cpu_cap(X86_FEATURE_AVX512IFMA);
- setup_clear_cpu_cap(X86_FEATURE_AVX512PF);
- setup_clear_cpu_cap(X86_FEATURE_AVX512ER);
- setup_clear_cpu_cap(X86_FEATURE_AVX512CD);
- setup_clear_cpu_cap(X86_FEATURE_AVX512DQ);
- setup_clear_cpu_cap(X86_FEATURE_AVX512BW);
- setup_clear_cpu_cap(X86_FEATURE_AVX512VL);
- setup_clear_cpu_cap(X86_FEATURE_MPX);
- setup_clear_cpu_cap(X86_FEATURE_XGETBV1);
- setup_clear_cpu_cap(X86_FEATURE_AVX512VBMI);
- setup_clear_cpu_cap(X86_FEATURE_PKU);
- setup_clear_cpu_cap(X86_FEATURE_AVX512_4VNNIW);
- setup_clear_cpu_cap(X86_FEATURE_AVX512_4FMAPS);
- setup_clear_cpu_cap(X86_FEATURE_AVX512_VPOPCNTDQ);
}
/*
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Andi Kleen <andi@firstfloor.org> |
|---|---|
| Date | 2017-06-08 01:40 +0200 |
| Subject | [PATCH v2 4/5] x86/xsave: Make XSAVE check the base CPUID features before enabling |
| Message-ID | <tPSIs-4Pr-57@gated-at.bofh.it> |
| In reply to | #1660464 |
From: Andi Kleen <ak@linux.intel.com>
Before enabling XSAVE, not only check the XSAVE specific CPUID bits,
but also the base CPUID features of the respective XSAVE feature.
This allows to disable individual XSAVE states using the existing
clearcpuid= option, which can be useful for performance testing
and debugging, and also in general avoids inconsistencies.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
arch/x86/kernel/fpu/xstate.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index c24ac1efb12d..8f0b96320cc9 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -15,6 +15,7 @@
#include <asm/fpu/xstate.h>
#include <asm/tlbflush.h>
+#include <asm/cpufeature.h>
/*
* Although we spell it out in here, the Processor Trace
@@ -36,6 +37,19 @@ static const char *xfeature_names[] =
"unknown xstate feature" ,
};
+static short xsave_cpuid_features[] = {
+ X86_FEATURE_FPU,
+ X86_FEATURE_XMM,
+ X86_FEATURE_AVX,
+ X86_FEATURE_MPX,
+ X86_FEATURE_MPX,
+ X86_FEATURE_AVX512F,
+ X86_FEATURE_AVX512F,
+ X86_FEATURE_AVX512F,
+ X86_FEATURE_INTEL_PT,
+ X86_FEATURE_PKU,
+};
+
/*
* Mask of xstate features supported by the CPU and the kernel:
*/
@@ -702,6 +716,7 @@ void __init fpu__init_system_xstate(void)
unsigned int eax, ebx, ecx, edx;
static int on_boot_cpu __initdata = 1;
int err;
+ int i;
WARN_ON_FPU(!on_boot_cpu);
on_boot_cpu = 0;
@@ -735,6 +750,13 @@ void __init fpu__init_system_xstate(void)
goto out_disable;
}
+ /*
+ * Clear XSAVE features that are disabled in the normal CPUID.
+ */
+ for (i = 0; i < ARRAY_SIZE(xsave_cpuid_features); i++)
+ if (!boot_cpu_has(xsave_cpuid_features[i]))
+ xfeatures_mask &= ~BIT(i);
+
xfeatures_mask &= fpu__get_supported_xfeatures_mask();
/* Enable xstate instructions to be able to continue with initialization: */
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Andi Kleen <andi@firstfloor.org> |
|---|---|
| Date | 2017-06-13 02:20 +0200 |
| Message-ID | <tRHIR-LU-1@gated-at.bofh.it> |
| In reply to | #1660464 |
Andi Kleen <andi@firstfloor.org> writes: Any comments on this patchkit? If there are no objections please merge. -Andi > For performance testing and debugging it can be useful to disable XSAVE > features individually. This patchkit hooks up XSAVE with the > generic clearcpuid=... option, so that disabling a CPUID feature > automatically disables the respective XSAVE feature. > > It also cleans up CPUID dependency management. Currently it's > possible to generate configurations with cleacpuid that crash. > > It replaces an earlier patchkit that did this with special > case options. > > v1: > Initial post > v2: > Work around broken lguest by exporting set_cpu_cap > Repost with cover letter
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web