mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	hpa@zytor.com, jon.grimm@amd.com,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Dave Hansen <dave.hansen@intel.com>,
	Thomas Lendacky <Thomas.Lendacky@amd.com>
Subject: [PATCH] x86/fpu: Warn only when CPU-provided sizes less than struct declaration
Date: Tue,  3 Dec 2019 04:01:28 -0500	[thread overview]
Message-ID: <1575363688-36727-1-git-send-email-suravee.suthikulpanit@amd.com> (raw)

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


             reply	other threads:[~2019-12-03  9:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-03  9:01 Suravee Suthikulpanit [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1575363688-36727-1-git-send-email-suravee.suthikulpanit@amd.com \
    --to=suravee.suthikulpanit@amd.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=bigeasy@linutronix.de \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=hpa@zytor.com \
    --cc=jon.grimm@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®