summaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/fpu
diff options
context:
space:
mode:
authorYu-cheng Yu <yu-cheng.yu@intel.com>2020-01-09 13:14:52 -0800
committerBorislav Petkov <bp@suse.de>2020-02-12 15:43:34 +0100
commite70b100806d63fb79775858ea92e1a716da46186 (patch)
treeab9fcc22a0c0f9c48f0138b6efe1296b08cfb69b /arch/x86/kernel/fpu
parent49a91d61aed1db01097b51a24c77137eb348a0bf (diff)
downloadlinux-e70b100806d63fb79775858ea92e1a716da46186.tar.gz
linux-e70b100806d63fb79775858ea92e1a716da46186.tar.bz2
linux-e70b100806d63fb79775858ea92e1a716da46186.zip
x86/fpu/xstate: Warn when checking alignment of disabled xfeatures
An XSAVES component's alignment/offset is meaningful only when the feature is enabled. Return zero and WARN_ONCE on checking alignment of disabled features. Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com> Link: https://lkml.kernel.org/r/20200109211452.27369-4-yu-cheng.yu@intel.com
Diffstat (limited to 'arch/x86/kernel/fpu')
-rw-r--r--arch/x86/kernel/fpu/xstate.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index edcaacd583d8..73fe5979629c 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -325,6 +325,13 @@ static int xfeature_is_aligned(int xfeature_nr)
u32 eax, ebx, ecx, edx;
CHECK_XFEATURE(xfeature_nr);
+
+ if (!xfeature_enabled(xfeature_nr)) {
+ WARN_ONCE(1, "Checking alignment of disabled xfeature %d\n",
+ xfeature_nr);
+ return 0;
+ }
+
cpuid_count(XSTATE_CPUID, xfeature_nr, &eax, &ebx, &ecx, &edx);
/*
* The value returned by ECX[1] indicates the alignment