Skip to content

Commit e70b100

Browse files
yyu-intel-comsuryasaimadhu
authored andcommitted
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 <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Dave Hansen <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 49a91d6 commit e70b100

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/x86/kernel/fpu/xstate.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,13 @@ static int xfeature_is_aligned(int xfeature_nr)
325325
u32 eax, ebx, ecx, edx;
326326

327327
CHECK_XFEATURE(xfeature_nr);
328+
329+
if (!xfeature_enabled(xfeature_nr)) {
330+
WARN_ONCE(1, "Checking alignment of disabled xfeature %d\n",
331+
xfeature_nr);
332+
return 0;
333+
}
334+
328335
cpuid_count(XSTATE_CPUID, xfeature_nr, &eax, &ebx, &ecx, &edx);
329336
/*
330337
* The value returned by ECX[1] indicates the alignment

0 commit comments

Comments
 (0)