lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20150716081332.641D2B2F@viggo.jf.intel.com>
Date:	Thu, 16 Jul 2015 01:13:32 -0700
From:	Dave Hansen <dave@...1.net>
To:	dave@...1.net
Cc:	torvalds@...ux-foundation.org, mingo@...nel.org,
	linux-kernel@...r.kernel.org, luto@...capital.net, bp@...en8.de,
	fenghua.yu@...el.com, hpa@...or.com, oleg@...hat.com,
	tglx@...utronix.de, ross.zwisler@...ux.intel.com
Subject: [RFC][PATCH 2/2] x86, fpu: enlarge xregs_state


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@...ux-foundation.org>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Cc: Andy Lutomirski <luto@...capital.net>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Fenghua Yu <fenghua.yu@...el.com>
Cc: "H. Peter Anvin" <hpa@...or.com>
Cc: leg Nesterov <oleg@...hat.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ross Zwisler <ross.zwisler@...ux.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)));
 
 /*
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ