linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/fpu: Warn only when CPU-provided sizes less than struct declaration
@ 2019-12-03  9:01 Suravee Suthikulpanit
  2019-12-03 10:34 ` Sebastian Andrzej Siewior
  2019-12-03 17:27 ` Dave Hansen
  0 siblings, 2 replies; 13+ messages in thread
From: Suravee Suthikulpanit @ 2019-12-03  9:01 UTC (permalink / raw)
  To: linux-kernel, x86
  Cc: tglx, mingo, bp, hpa, jon.grimm, Suravee Suthikulpanit,
	Sebastian Andrzej Siewior, Dave Hansen, Thomas Lendacky

The current XCHECK_SZ macro warns if the XFEATURE size reported
by CPUID does not match the size of kernel structure. However, depending
on the hardware implementation, CPUID can report the XSAVE state size
larger than the size of C structures defined for each of the XSAVE state
due to padding. Such case should be safe and should not need to generate
warning message.

Therefore, change the logic to warn only when the CPUID reported size is
less than then size of C structure.

Fixes: ef78f2a4bf84 ("x86/fpu: Check CPU-provided sizes against struct declarations")
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Thomas Lendacky <Thomas.Lendacky@amd.com> 
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
 arch/x86/kernel/fpu/xstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index e5cb67d..f002115 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -523,7 +523,7 @@ static void __xstate_dump_leaves(void)
 
 #define XCHECK_SZ(sz, nr, nr_macro, __struct) do {			\
 	if ((nr == nr_macro) &&						\
-	    WARN_ONCE(sz != sizeof(__struct),				\
+	    WARN_ONCE(sz < sizeof(__struct),				\
 		"%s: struct is %zu bytes, cpu state %d bytes\n",	\
 		__stringify(nr_macro), sizeof(__struct), sz)) {		\
 		__xstate_dump_leaves();					\
-- 
1.8.3.1


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

end of thread, other threads:[~2020-05-01 23:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03  9:01 [PATCH] x86/fpu: Warn only when CPU-provided sizes less than struct declaration Suravee Suthikulpanit
2019-12-03 10:34 ` Sebastian Andrzej Siewior
2019-12-06  8:14   ` Suravee Suthikulpanit
2019-12-03 17:27 ` Dave Hansen
2019-12-06  8:14   ` Suravee Suthikulpanit
2019-12-06 15:28     ` Dave Hansen
2019-12-11  5:24       ` Suravee Suthikulpanit
2019-12-11 14:13         ` Dave Hansen
2019-12-12  6:52           ` Suravee Suthikulpanit
2020-01-13  9:54             ` Suravee Suthikulpanit
2020-01-15 16:54               ` Dave Hansen
2020-04-29 19:18       ` AMD / Memory Protection Keys Dave Hansen
2020-05-01 23:50         ` Suravee Suthikulpanit

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).