From: Dave Hansen <dave@sr71.net>
To: dave@sr71.net
Cc: torvalds@linux-foundation.org, mingo@kernel.org,
linux-kernel@vger.kernel.org, luto@amacapital.net, bp@alien8.de,
fenghua.yu@intel.com, hpa@zytor.com, oleg@redhat.com,
tglx@linutronix.de, ross.zwisler@linux.intel.com
Subject: [RFC][PATCH 2/2] x86, fpu: enlarge xregs_state
Date: Thu, 16 Jul 2015 01:13:32 -0700 [thread overview]
Message-ID: <20150716081332.641D2B2F@viggo.jf.intel.com> (raw)
In-Reply-To: <20150716081332.9413DD5B@viggo.jf.intel.com>
This takes a stab at sizing the xsave buffer so that it will work for
AVX-512 systems. The logic is explained in the comment.
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: leg Nesterov <oleg@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
---
b/arch/x86/include/asm/fpu/types.h | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff -puN arch/x86/include/asm/fpu/types.h~enlarge-init-fpu-buf arch/x86/include/asm/fpu/types.h
--- a/arch/x86/include/asm/fpu/types.h~enlarge-init-fpu-buf 2015-07-16 01:11:03.301028886 -0700
+++ b/arch/x86/include/asm/fpu/types.h 2015-07-16 01:11:03.304029021 -0700
@@ -159,10 +159,19 @@ struct xstate_header {
u64 reserved[6];
} __attribute__((packed));
-/* New processor state extensions should be added here: */
-#define XSTATE_RESERVE (sizeof(struct ymmh_struct) + \
- sizeof(struct lwp_struct) + \
- sizeof(struct mpx_struct) )
+/*
+ * The largest xsave buffer known today is 2752 bytes on a system
+ * implementing AVX-512. This includes the 512-byte i387 state
+ * and 64-byte header. We add a small amount of padding in case
+ * an implementation adds some padding or wastes some space.
+ *
+ * Note, if we overflow this, we will disable XSAVE completely.
+ *
+ * Also, note that the real size we need is enumerated by
+ * cpuid leaves and can not be known at compile time.
+ */
+#define XSTATE_MAX_SIZE (2752 + 256)
+
/*
* This is our most modern FPU state format, as saved by the XSAVE
* and restored by the XRSTOR instructions.
@@ -172,9 +181,13 @@ struct xstate_header {
* Not all CPUs support all the extensions.
*/
struct xregs_state {
- struct fxregs_state i387;
- struct xstate_header header;
- u8 __reserved[XSTATE_RESERVE];
+ union {
+ struct {
+ struct fxregs_state i387;
+ struct xstate_header header;
+ };
+ u8 __reserved[XSTATE_MAX_SIZE];
+ };
} __attribute__ ((packed, aligned (64)));
/*
_
next prev parent reply other threads:[~2015-07-16 8:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-16 8:13 [RFC][PATCH 1/2] x86, fpu: disable XSAVE if init buf too small Dave Hansen
2015-07-16 8:13 ` Dave Hansen [this message]
2015-07-16 9:10 ` [RFC][PATCH 2/2] x86, fpu: enlarge xregs_state Dave Hansen
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=20150716081332.641D2B2F@viggo.jf.intel.com \
--to=dave@sr71.net \
--cc=bp@alien8.de \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=ross.zwisler@linux.intel.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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
Powered by JetHome