[PATCH 07/15] x86/headers: Unify 'struct _fpstate_ia32' and i386 struct _fpstate

From: Ingo Molnar
Date: Sat Sep 05 2015 - 03:34:28 EST


'struct _fpstate_ia32' and 'struct _fpstate' on i386 are identical in all fields,
except 'padding1' being named 'padding'.

We unify the two structures and add a union that is both named 'padding1' and
'padding', in the (unlikely) case there's user-space code that relies on the
padding field name.

We rename the two main types to be:

struct _fpstate_32
struct _fpstate_64

for the 32-bit and 64-bit frame, and map them to the main and compat structure
names (_fpstate) depending on whether we are on 32-bit or on 64-bit kernels.

We also keep the old _fpstate_ia32 name as a legacy name.

Cc: Andy Lutomirski <luto@xxxxxxxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxxxx>
Cc: Brian Gerst <brgerst@xxxxxxxxx>
Cc: Denys Vlasenko <dvlasenk@xxxxxxxxxx>
Cc: H. Peter Anvin <hpa@xxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Mikko Rapeli <mikko.rapeli@xxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
arch/x86/include/asm/sigframe.h | 1 -
arch/x86/include/uapi/asm/sigcontext.h | 26 +++++++++++++++++---------
arch/x86/include/uapi/asm/sigcontext32.h | 29 -----------------------------
3 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/arch/x86/include/asm/sigframe.h b/arch/x86/include/asm/sigframe.h
index 7c7c27c97daa..67d3027520ee 100644
--- a/arch/x86/include/asm/sigframe.h
+++ b/arch/x86/include/asm/sigframe.h
@@ -9,7 +9,6 @@
#define sigframe_ia32 sigframe
#define rt_sigframe_ia32 rt_sigframe
#define sigcontext_ia32 sigcontext
-#define _fpstate_ia32 _fpstate
#define ucontext_ia32 ucontext
#else /* !CONFIG_X86_32 */

diff --git a/arch/x86/include/uapi/asm/sigcontext.h b/arch/x86/include/uapi/asm/sigcontext.h
index 9df4df3e40ef..85811167821f 100644
--- a/arch/x86/include/uapi/asm/sigcontext.h
+++ b/arch/x86/include/uapi/asm/sigcontext.h
@@ -95,9 +95,10 @@ struct _xmmreg {

#define X86_FXSR_MAGIC 0x0000

-#ifdef __i386__
-
-struct _fpstate {
+/*
+ * The 32-bit FPU frame:
+ */
+struct _fpstate_32 {
/* Legacy FPU environment: */
__u32 cw;
__u32 sw;
@@ -117,7 +118,10 @@ struct _fpstate {
__u32 reserved;
struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */
struct _xmmreg _xmm[8]; /* First 8 XMM registers */
- __u32 padding1[44]; /* Second 8 XMM registers plus padding */
+ union {
+ __u32 padding1[44]; /* Second 8 XMM registers plus padding */
+ __u32 padding[44]; /* Alias name for old user-space */
+ };

union {
__u32 padding2[12];
@@ -125,10 +129,8 @@ struct _fpstate {
};
};

-#else /* __x86_64__: */
-
/*
- * The FXSAVE frame.
+ * The 64-bit FPU frame. (FXSAVE format and later)
*
* Note1: If sw_reserved.magic1 == FP_XSTATE_MAGIC1 then the structure is
* larger: 'struct _xstate'. Note that 'struct _xstate' embedds
@@ -138,7 +140,7 @@ struct _fpstate {
* Note2: Reserved fields may someday contain valuable data. Always save/restore
* them when you change signal frames.
*/
-struct _fpstate {
+struct _fpstate_64 {
__u16 cwd;
__u16 swd;
/* Note this is not the same as the 32-bit/x87/FSAVE twd: */
@@ -157,7 +159,13 @@ struct _fpstate {
};
};

-#endif /* __x86_64__ */
+#ifdef __i386__
+# define _fpstate _fpstate_32
+#else
+# define _fpstate _fpstate_64
+#endif
+
+#define _fpstate_ia32 _fpstate_32

struct _header {
__u64 xfeatures;
diff --git a/arch/x86/include/uapi/asm/sigcontext32.h b/arch/x86/include/uapi/asm/sigcontext32.h
index 356caab997e7..19a89165ea1d 100644
--- a/arch/x86/include/uapi/asm/sigcontext32.h
+++ b/arch/x86/include/uapi/asm/sigcontext32.h
@@ -5,35 +5,6 @@

#include <asm/sigcontext.h>

-/* FXSAVE frame: FSAVE frame with extensions */
-struct _fpstate_ia32 {
- /* Regular FPU environment: */
- __u32 cw;
- __u32 sw;
- __u32 tag; /* Not compatible with the 64-bit frame */
- __u32 ipoff;
- __u32 cssel;
- __u32 dataoff;
- __u32 datasel;
- struct _fpreg _st[8];
- __u16 status;
- __u16 magic; /* 0xffff: regular FPU data only */
- /* 0x0000: FXSR data */
-
- /* Extended FXSR FPU environment: */
- __u32 _fxsr_env[6];
- __u32 mxcsr;
- __u32 reserved;
- struct _fpxreg _fxsr_st[8];
- struct _xmmreg _xmm[8]; /* The first 8 XMM registers */
- __u32 padding[44]; /* The second 8 XMM registers plus padding */
- union {
- __u32 padding2[12];
- /* Might encode xstate extensions, see asm/sigcontext.h: */
- struct _fpx_sw_bytes sw_reserved;
- };
-};
-
/* 32-bit compat sigcontext: */
struct sigcontext_ia32 {
__u16 gs, __gsh;
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/