From b76cb6c869b966b4c991251136b45b3e1babc4e8 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:29 +0200 Subject: x86/headers: Fix (old) header file dependency bug in uapi/asm/sigcontext32.h Mikko Rapeli reported that the following standalone user-space header does not compile: #include Due to undefined 'struct __fpx_sw_bytes' which is defined in asm/sigcontext.h. The following header order works: #include #include and that's probably how everyone's been using these headers for the past decade or so, but it's a legit header file dependency bug, so include asm/sigcontext.h in sigcontext32.h to allow it to be built standlone. Reported-by: Mikko Rapeli Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-2-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/uapi/asm/sigcontext32.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/x86') diff --git a/arch/x86/include/uapi/asm/sigcontext32.h b/arch/x86/include/uapi/asm/sigcontext32.h index ad1478c4ae12..ff7826c41a1c 100644 --- a/arch/x86/include/uapi/asm/sigcontext32.h +++ b/arch/x86/include/uapi/asm/sigcontext32.h @@ -3,6 +3,8 @@ #include +#include + /* signal context for 32bit programs. */ #define X86_FXSR_MAGIC 0x0000 -- cgit v1.2.3 From c3f4986fb0774bb13feb4bade1276bed2ba8a3db Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:30 +0200 Subject: x86/headers: Clean up uapi/asm/sigcontext32.h Clean up sigcontext32.h a bit: - use consistent and readable vertical spacing - fix, harmonize and extend comments No field name has been changed, user-space might be relying on them. Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-3-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/uapi/asm/sigcontext32.h | 110 ++++++++++++++++--------------- 1 file changed, 58 insertions(+), 52 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/include/uapi/asm/sigcontext32.h b/arch/x86/include/uapi/asm/sigcontext32.h index ff7826c41a1c..6ff4fbab650e 100644 --- a/arch/x86/include/uapi/asm/sigcontext32.h +++ b/arch/x86/include/uapi/asm/sigcontext32.h @@ -1,79 +1,85 @@ #ifndef _ASM_X86_SIGCONTEXT32_H #define _ASM_X86_SIGCONTEXT32_H +/* Signal context definitions for compat 32-bit programs: */ + #include #include -/* signal context for 32bit programs. */ - -#define X86_FXSR_MAGIC 0x0000 - +/* 10-byte legacy floating point register: */ struct _fpreg { - unsigned short significand[4]; - unsigned short exponent; + unsigned short significand[4]; + unsigned short exponent; }; +/* 16-byte floating point register: */ struct _fpxreg { - unsigned short significand[4]; - unsigned short exponent; - unsigned short padding[3]; + unsigned short significand[4]; + unsigned short exponent; + unsigned short padding[3]; }; +/* 16-byte XMM vector register: */ struct _xmmreg { __u32 element[4]; }; -/* FSAVE frame with extensions */ +#define X86_FXSR_MAGIC 0x0000 + +/* FXSAVE frame: FSAVE frame with extensions */ struct _fpstate_ia32 { - /* Regular FPU environment */ - __u32 cw; - __u32 sw; - __u32 tag; /* not compatible to 64bit twd */ - __u32 ipoff; - __u32 cssel; - __u32 dataoff; - __u32 datasel; - struct _fpreg _st[8]; - unsigned short status; - unsigned short magic; /* 0xffff = regular FPU data only */ + /* 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]; + unsigned short status; + unsigned short magic; /* 0xffff: regular FPU data only */ + /* 0x0000: FXSR data */ - /* FXSR FPU environment */ - __u32 _fxsr_env[6]; - __u32 mxcsr; - __u32 reserved; - struct _fpxreg _fxsr_st[8]; - struct _xmmreg _xmm[8]; /* It's actually 16 */ - __u32 padding[44]; + /* 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]; - struct _fpx_sw_bytes sw_reserved; + __u32 padding2[12]; + /* Might encode xstate extensions, see asm/sigcontext.h: */ + struct _fpx_sw_bytes sw_reserved; }; }; +/* 32-bit compat sigcontext: */ struct sigcontext_ia32 { - unsigned short gs, __gsh; - unsigned short fs, __fsh; - unsigned short es, __esh; - unsigned short ds, __dsh; - unsigned int di; - unsigned int si; - unsigned int bp; - unsigned int sp; - unsigned int bx; - unsigned int dx; - unsigned int cx; - unsigned int ax; - unsigned int trapno; - unsigned int err; - unsigned int ip; - unsigned short cs, __csh; - unsigned int flags; - unsigned int sp_at_signal; - unsigned short ss, __ssh; - unsigned int fpstate; /* really (struct _fpstate_ia32 *) */ - unsigned int oldmask; - unsigned int cr2; + unsigned short gs, __gsh; + unsigned short fs, __fsh; + unsigned short es, __esh; + unsigned short ds, __dsh; + unsigned int di; + unsigned int si; + unsigned int bp; + unsigned int sp; + unsigned int bx; + unsigned int dx; + unsigned int cx; + unsigned int ax; + unsigned int trapno; + unsigned int err; + unsigned int ip; + unsigned short cs, __csh; + unsigned int flags; + unsigned int sp_at_signal; + unsigned short ss, __ssh; + unsigned int fpstate; /* Pointer to 'struct _fpstate_ia32' */ + unsigned int oldmask; + unsigned int cr2; }; #endif /* _ASM_X86_SIGCONTEXT32_H */ -- cgit v1.2.3 From cbf5f4fbf435e871e59d49653d555266b8796efc Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:31 +0200 Subject: x86/headers: Clean up and better document uapi/asm/sigcontext.h Clean up sigcontext.h: - the explanations were full of typos and were hard to read in general - use consistent and readable vertical spacing - fix, harmonize and extend comments No field name has been changed, user-space might be relying on them. Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-4-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/uapi/asm/sigcontext.h | 330 ++++++++++++++++++--------------- 1 file changed, 182 insertions(+), 148 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/include/uapi/asm/sigcontext.h b/arch/x86/include/uapi/asm/sigcontext.h index 40836a9a7250..f89b2f1abe7c 100644 --- a/arch/x86/include/uapi/asm/sigcontext.h +++ b/arch/x86/include/uapi/asm/sigcontext.h @@ -1,221 +1,255 @@ #ifndef _UAPI_ASM_X86_SIGCONTEXT_H #define _UAPI_ASM_X86_SIGCONTEXT_H +/* + * Linux signal context definitions. The sigcontext includes a complex hierarchy of CPU + * and FPU state, available to user-space (on the stack) when a signal handler is + * executed. + * + * As over the years this ABI grew from its very simple roots towards supporting more and + * more CPU state organically, some of the details (which were rather clever hacks back + * in the days) became a bit quirky by today. + * + * The current ABI includes flexible provisions for future extensions, so we won't have + * to grow new quirks for quite some time. Promise! + */ + #include #include -#define FP_XSTATE_MAGIC1 0x46505853U -#define FP_XSTATE_MAGIC2 0x46505845U -#define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2) +#define FP_XSTATE_MAGIC1 0x46505853U +#define FP_XSTATE_MAGIC2 0x46505845U +#define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2) /* - * bytes 464..511 in the current 512byte layout of fxsave/fxrstor frame - * are reserved for SW usage. On cpu's supporting xsave/xrstor, these bytes - * are used to extended the fpstate pointer in the sigcontext, which now + * Bytes 464..511 in the current 512-byte layout of the FXSAVE/FXRSTOR frame + * are reserved for SW usage. On CPUs supporting XSAVE/XRSTOR, these bytes + * are used to extend the fpstate pointer in the sigcontext, which now * includes the extended state information along with fpstate information. * - * Presence of FP_XSTATE_MAGIC1 at the beginning of this SW reserved - * area and FP_XSTATE_MAGIC2 at the end of memory layout - * (extended_size - FP_XSTATE_MAGIC2_SIZE) indicates the presence of the - * extended state information in the memory layout pointed by the fpstate - * pointer in sigcontext. + * If sw_reserved.magic1 == FP_XSTATE_MAGIC1 then there's a sw_reserved.extended_size + * bytes large extended context area present. (The last 32-bit word of this extended + * area (at the fpstate+extended_size-FP_XSTATE_MAGIC2_SIZE address) is set to + * FP_XSTATE_MAGIC2 so that you can sanity check your size calculations.) + * + * This extended area typically grows with newer CPUs that have larger and larger + * XSAVE areas. */ struct _fpx_sw_bytes { - __u32 magic1; /* FP_XSTATE_MAGIC1 */ - __u32 extended_size; /* total size of the layout referred by - * fpstate pointer in the sigcontext. - */ - __u64 xfeatures; - /* feature bit mask (including fp/sse/extended - * state) that is present in the memory - * layout. - */ - __u32 xstate_size; /* actual xsave state size, based on the - * features saved in the layout. - * 'extended_size' will be greater than - * 'xstate_size'. - */ - __u32 padding[7]; /* for future use. */ + /* If set to FP_XSTATE_MAGIC1 then this is an xstate context. 0 if a legacy frame. */ + __u32 magic1; + + /* + * Total size of the fpstate area: + * + * - if magic1 == 0 then it's sizeof(struct _fpstate) + * - if magic1 == FP_XSTATE_MAGIC1 then it's sizeof(struct _xstate) plus extensions (if any) + */ + __u32 extended_size; + + /* + * Feature bit mask (including FP/SSE/extended state) that is present + * in the memory layout: + */ + __u64 xfeatures; + + /* + * Actual XSAVE state size, based on the xfeatures saved in the layout. + * 'extended_size' is greater than 'xstate_size': + */ + __u32 xstate_size; + + /* For future use: */ + __u32 padding[7]; }; #ifdef __i386__ /* - * As documented in the iBCS2 standard.. + * As documented in the iBCS2 standard: * * The first part of "struct _fpstate" is just the normal i387 * hardware setup, the extra "status" word is used to save the * coprocessor status word before entering the handler. * - * Pentium III FXSR, SSE support - * Gareth Hughes , May 2000 - * * The FPU state data structure has had to grow to accommodate the * extended FPU state required by the Streaming SIMD Extensions. * There is no documented standard to accomplish this at the moment. */ + +/* 10-byte legacy floating point register: */ struct _fpreg { - unsigned short significand[4]; - unsigned short exponent; + unsigned short significand[4]; + unsigned short exponent; }; +/* 16-byte floating point register: */ struct _fpxreg { - unsigned short significand[4]; - unsigned short exponent; - unsigned short padding[3]; + unsigned short significand[4]; + unsigned short exponent; + unsigned short padding[3]; }; +/* 16-byte XMM register: */ struct _xmmreg { - unsigned long element[4]; + unsigned long element[4]; }; +#define X86_FXSR_MAGIC 0x0000 + struct _fpstate { - /* Regular FPU environment */ - unsigned long cw; - unsigned long sw; - unsigned long tag; - unsigned long ipoff; - unsigned long cssel; - unsigned long dataoff; - unsigned long datasel; - struct _fpreg _st[8]; - unsigned short status; - unsigned short magic; /* 0xffff = regular FPU data only */ + /* Legacy FPU environment: */ + unsigned long cw; + unsigned long sw; + unsigned long tag; + unsigned long ipoff; + unsigned long cssel; + unsigned long dataoff; + unsigned long datasel; + struct _fpreg _st[8]; + unsigned short status; + unsigned short magic; /* 0xffff: regular FPU data only */ + /* 0x0000: FXSR FPU data */ /* FXSR FPU environment */ - unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */ - unsigned long mxcsr; - unsigned long reserved; - struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ - struct _xmmreg _xmm[8]; - unsigned long padding1[44]; + unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */ + unsigned long mxcsr; + unsigned long reserved; + struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ + struct _xmmreg _xmm[8]; /* First 8 XMM registers */ + unsigned long padding1[44]; /* Second 8 XMM registers plus padding */ union { - unsigned long padding2[12]; - struct _fpx_sw_bytes sw_reserved; /* represents the extended - * state info */ + unsigned long padding2[12]; + struct _fpx_sw_bytes sw_reserved; /* Potential extended state is encoded here */ }; }; -#define X86_FXSR_MAGIC 0x0000 - -#ifndef __KERNEL__ +# ifndef __KERNEL__ /* * User-space might still rely on the old definition: */ struct sigcontext { - unsigned short gs, __gsh; - unsigned short fs, __fsh; - unsigned short es, __esh; - unsigned short ds, __dsh; - unsigned long edi; - unsigned long esi; - unsigned long ebp; - unsigned long esp; - unsigned long ebx; - unsigned long edx; - unsigned long ecx; - unsigned long eax; - unsigned long trapno; - unsigned long err; - unsigned long eip; - unsigned short cs, __csh; - unsigned long eflags; - unsigned long esp_at_signal; - unsigned short ss, __ssh; - struct _fpstate __user *fpstate; - unsigned long oldmask; - unsigned long cr2; + unsigned short gs, __gsh; + unsigned short fs, __fsh; + unsigned short es, __esh; + unsigned short ds, __dsh; + unsigned long edi; + unsigned long esi; + unsigned long ebp; + unsigned long esp; + unsigned long ebx; + unsigned long edx; + unsigned long ecx; + unsigned long eax; + unsigned long trapno; + unsigned long err; + unsigned long eip; + unsigned short cs, __csh; + unsigned long eflags; + unsigned long esp_at_signal; + unsigned short ss, __ssh; + struct _fpstate __user *fpstate; + unsigned long oldmask; + unsigned long cr2; }; -#endif /* !__KERNEL__ */ +# endif /* !__KERNEL__ */ -#else /* __i386__ */ +#else /* __x86_64__: */ -/* FXSAVE frame */ -/* Note: reserved1/2 may someday contain valuable data. Always save/restore - them when you change signal frames. */ +/* + * The FXSAVE frame. + * + * Note1: If sw_reserved.magic1 == FP_XSTATE_MAGIC1 then the structure is + * larger: 'struct _xstate'. Note that 'struct _xstate' embedds + * 'struct _fpstate' so that you can always assume the _fpstate portion + * exists so that you can check the magic value. + * + * Note2: Reserved fields may someday contain valuable data. Always save/restore + * them when you change signal frames. + */ struct _fpstate { - __u16 cwd; - __u16 swd; - __u16 twd; /* Note this is not the same as the - 32bit/x87/FSAVE twd */ - __u16 fop; - __u64 rip; - __u64 rdp; - __u32 mxcsr; - __u32 mxcsr_mask; - __u32 st_space[32]; /* 8*16 bytes for each FP-reg */ - __u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg */ - __u32 reserved2[12]; + __u16 cwd; + __u16 swd; + /* Note this is not the same as the 32-bit/x87/FSAVE twd: */ + __u16 twd; + __u16 fop; + __u64 rip; + __u64 rdp; + __u32 mxcsr; + __u32 mxcsr_mask; + __u32 st_space[32]; /* 8x FP registers, 16 bytes each */ + __u32 xmm_space[64]; /* 16x XMM registers, 16 bytes each */ + __u32 reserved2[12]; union { - __u32 reserved3[12]; - struct _fpx_sw_bytes sw_reserved; /* represents the extended - * state information */ + __u32 reserved3[12]; + struct _fpx_sw_bytes sw_reserved; /* Potential extended state is encoded here */ }; }; -#ifndef __KERNEL__ +# ifndef __KERNEL__ /* * User-space might still rely on the old definition: */ struct sigcontext { - __u64 r8; - __u64 r9; - __u64 r10; - __u64 r11; - __u64 r12; - __u64 r13; - __u64 r14; - __u64 r15; - __u64 rdi; - __u64 rsi; - __u64 rbp; - __u64 rbx; - __u64 rdx; - __u64 rax; - __u64 rcx; - __u64 rsp; - __u64 rip; - __u64 eflags; /* RFLAGS */ - __u16 cs; - __u16 gs; - __u16 fs; - __u16 __pad0; - __u64 err; - __u64 trapno; - __u64 oldmask; - __u64 cr2; - struct _fpstate __user *fpstate; /* zero when no FPU context */ -#ifdef __ILP32__ - __u32 __fpstate_pad; -#endif - __u64 reserved1[8]; + __u64 r8; + __u64 r9; + __u64 r10; + __u64 r11; + __u64 r12; + __u64 r13; + __u64 r14; + __u64 r15; + __u64 rdi; + __u64 rsi; + __u64 rbp; + __u64 rbx; + __u64 rdx; + __u64 rax; + __u64 rcx; + __u64 rsp; + __u64 rip; + __u64 eflags; /* RFLAGS */ + __u16 cs; + __u16 gs; + __u16 fs; + __u16 __pad0; + __u64 err; + __u64 trapno; + __u64 oldmask; + __u64 cr2; + struct _fpstate __user *fpstate; /* Zero when no FPU context */ +# ifdef __ILP32__ + __u32 __fpstate_pad; +# endif + __u64 reserved1[8]; }; -#endif /* !__KERNEL__ */ +# endif /* !__KERNEL__ */ -#endif /* !__i386__ */ +#endif /* __x86_64__ */ struct _header { - __u64 xfeatures; - __u64 reserved1[2]; - __u64 reserved2[5]; + __u64 xfeatures; + __u64 reserved1[2]; + __u64 reserved2[5]; }; struct _ymmh_state { - /* 16 * 16 bytes for each YMMH-reg */ - __u32 ymmh_space[64]; + /* 16x YMM registers, 16 bytes each: */ + __u32 ymmh_space[64]; }; /* - * Extended state pointed by the fpstate pointer in the sigcontext. - * In addition to the fpstate, information encoded in the xstate_hdr - * indicates the presence of other extended state information - * supported by the processor and OS. + * Extended state pointed to by sigcontext::fpstate. + * + * In addition to the fpstate, information encoded in _xstate::xstate_hdr + * indicates the presence of other extended state information supported + * by the CPU and kernel: */ struct _xstate { - struct _fpstate fpstate; - struct _header xstate_hdr; - struct _ymmh_state ymmh; - /* new processor state extensions go here */ + struct _fpstate fpstate; + struct _header xstate_hdr; + struct _ymmh_state ymmh; + /* New processor state extensions go here: */ }; #endif /* _UAPI_ASM_X86_SIGCONTEXT_H */ -- cgit v1.2.3 From 128f8257a17a47b9a40f550cc2f36458cd8c07b0 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:32 +0200 Subject: x86/headers: Separate out legacy user-space structure definitions Better separate the user-space struct sigcontext definitions from the kernel definitions, so that we can unify the kernel definitions with sigcontext32.h. Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-5-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/uapi/asm/sigcontext.h | 119 ++++++++++++++++----------------- 1 file changed, 59 insertions(+), 60 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/include/uapi/asm/sigcontext.h b/arch/x86/include/uapi/asm/sigcontext.h index f89b2f1abe7c..40d6cbac08c6 100644 --- a/arch/x86/include/uapi/asm/sigcontext.h +++ b/arch/x86/include/uapi/asm/sigcontext.h @@ -124,36 +124,6 @@ struct _fpstate { }; }; -# ifndef __KERNEL__ -/* - * User-space might still rely on the old definition: - */ -struct sigcontext { - unsigned short gs, __gsh; - unsigned short fs, __fsh; - unsigned short es, __esh; - unsigned short ds, __dsh; - unsigned long edi; - unsigned long esi; - unsigned long ebp; - unsigned long esp; - unsigned long ebx; - unsigned long edx; - unsigned long ecx; - unsigned long eax; - unsigned long trapno; - unsigned long err; - unsigned long eip; - unsigned short cs, __csh; - unsigned long eflags; - unsigned long esp_at_signal; - unsigned short ss, __ssh; - struct _fpstate __user *fpstate; - unsigned long oldmask; - unsigned long cr2; -}; -# endif /* !__KERNEL__ */ - #else /* __x86_64__: */ /* @@ -186,10 +156,65 @@ struct _fpstate { }; }; -# ifndef __KERNEL__ +#endif /* __x86_64__ */ + +struct _header { + __u64 xfeatures; + __u64 reserved1[2]; + __u64 reserved2[5]; +}; + +struct _ymmh_state { + /* 16x YMM registers, 16 bytes each: */ + __u32 ymmh_space[64]; +}; + /* - * User-space might still rely on the old definition: + * Extended state pointed to by sigcontext::fpstate. + * + * In addition to the fpstate, information encoded in _xstate::xstate_hdr + * indicates the presence of other extended state information supported + * by the CPU and kernel: */ +struct _xstate { + struct _fpstate fpstate; + struct _header xstate_hdr; + struct _ymmh_state ymmh; + /* New processor state extensions go here: */ +}; + +/* + * The old user-space sigcontext definition, just in case user-space still + * relies on it. The kernel definition (in asm/sigcontext.h) has unified + * field names but otherwise the same layout. + */ +#ifndef __KERNEL__ +# ifdef __i386__ +struct sigcontext { + unsigned short gs, __gsh; + unsigned short fs, __fsh; + unsigned short es, __esh; + unsigned short ds, __dsh; + unsigned long edi; + unsigned long esi; + unsigned long ebp; + unsigned long esp; + unsigned long ebx; + unsigned long edx; + unsigned long ecx; + unsigned long eax; + unsigned long trapno; + unsigned long err; + unsigned long eip; + unsigned short cs, __csh; + unsigned long eflags; + unsigned long esp_at_signal; + unsigned short ss, __ssh; + struct _fpstate __user *fpstate; + unsigned long oldmask; + unsigned long cr2; +}; +# else /* __x86_64__: */ struct sigcontext { __u64 r8; __u64 r9; @@ -223,33 +248,7 @@ struct sigcontext { # endif __u64 reserved1[8]; }; -# endif /* !__KERNEL__ */ - -#endif /* __x86_64__ */ - -struct _header { - __u64 xfeatures; - __u64 reserved1[2]; - __u64 reserved2[5]; -}; - -struct _ymmh_state { - /* 16x YMM registers, 16 bytes each: */ - __u32 ymmh_space[64]; -}; - -/* - * Extended state pointed to by sigcontext::fpstate. - * - * In addition to the fpstate, information encoded in _xstate::xstate_hdr - * indicates the presence of other extended state information supported - * by the CPU and kernel: - */ -struct _xstate { - struct _fpstate fpstate; - struct _header xstate_hdr; - struct _ymmh_state ymmh; - /* New processor state extensions go here: */ -}; +# endif /* __x86_64__ */ +#endif /* !__KERNEL__ */ #endif /* _UAPI_ASM_X86_SIGCONTEXT_H */ -- cgit v1.2.3 From 3f623a5b27c150451387e358774131780dbd2407 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:33 +0200 Subject: x86/headers: Use ABI types consistently in sigcontext*.h Use the __u16/32/64 types we standardized on in ABI definitions - and which most of this header was already using. This will allow us to more obviously unify the compat header into the main header. No change in functionality. Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-6-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/uapi/asm/sigcontext.h | 82 ++++++++++++++++---------------- arch/x86/include/uapi/asm/sigcontext32.h | 58 +++++++++++----------- 2 files changed, 70 insertions(+), 70 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/include/uapi/asm/sigcontext.h b/arch/x86/include/uapi/asm/sigcontext.h index 40d6cbac08c6..07b0e32a1d23 100644 --- a/arch/x86/include/uapi/asm/sigcontext.h +++ b/arch/x86/include/uapi/asm/sigcontext.h @@ -78,48 +78,48 @@ struct _fpx_sw_bytes { /* 10-byte legacy floating point register: */ struct _fpreg { - unsigned short significand[4]; - unsigned short exponent; + __u16 significand[4]; + __u16 exponent; }; /* 16-byte floating point register: */ struct _fpxreg { - unsigned short significand[4]; - unsigned short exponent; - unsigned short padding[3]; + __u16 significand[4]; + __u16 exponent; + __u16 padding[3]; }; /* 16-byte XMM register: */ struct _xmmreg { - unsigned long element[4]; + __u32 element[4]; }; #define X86_FXSR_MAGIC 0x0000 struct _fpstate { /* Legacy FPU environment: */ - unsigned long cw; - unsigned long sw; - unsigned long tag; - unsigned long ipoff; - unsigned long cssel; - unsigned long dataoff; - unsigned long datasel; + __u32 cw; + __u32 sw; + __u32 tag; + __u32 ipoff; + __u32 cssel; + __u32 dataoff; + __u32 datasel; struct _fpreg _st[8]; - unsigned short status; - unsigned short magic; /* 0xffff: regular FPU data only */ + __u16 status; + __u16 magic; /* 0xffff: regular FPU data only */ /* 0x0000: FXSR FPU data */ /* FXSR FPU environment */ - unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */ - unsigned long mxcsr; - unsigned long reserved; + __u32 _fxsr_env[6]; /* FXSR FPU env is ignored */ + __u32 mxcsr; + __u32 reserved; struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ struct _xmmreg _xmm[8]; /* First 8 XMM registers */ - unsigned long padding1[44]; /* Second 8 XMM registers plus padding */ + __u32 padding1[44]; /* Second 8 XMM registers plus padding */ union { - unsigned long padding2[12]; + __u32 padding2[12]; struct _fpx_sw_bytes sw_reserved; /* Potential extended state is encoded here */ }; }; @@ -191,28 +191,28 @@ struct _xstate { #ifndef __KERNEL__ # ifdef __i386__ struct sigcontext { - unsigned short gs, __gsh; - unsigned short fs, __fsh; - unsigned short es, __esh; - unsigned short ds, __dsh; - unsigned long edi; - unsigned long esi; - unsigned long ebp; - unsigned long esp; - unsigned long ebx; - unsigned long edx; - unsigned long ecx; - unsigned long eax; - unsigned long trapno; - unsigned long err; - unsigned long eip; - unsigned short cs, __csh; - unsigned long eflags; - unsigned long esp_at_signal; - unsigned short ss, __ssh; + __u16 gs, __gsh; + __u16 fs, __fsh; + __u16 es, __esh; + __u16 ds, __dsh; + __u32 edi; + __u32 esi; + __u32 ebp; + __u32 esp; + __u32 ebx; + __u32 edx; + __u32 ecx; + __u32 eax; + __u32 trapno; + __u32 err; + __u32 eip; + __u16 cs, __csh; + __u32 eflags; + __u32 esp_at_signal; + __u16 ss, __ssh; struct _fpstate __user *fpstate; - unsigned long oldmask; - unsigned long cr2; + __u32 oldmask; + __u32 cr2; }; # else /* __x86_64__: */ struct sigcontext { diff --git a/arch/x86/include/uapi/asm/sigcontext32.h b/arch/x86/include/uapi/asm/sigcontext32.h index 6ff4fbab650e..939a84885673 100644 --- a/arch/x86/include/uapi/asm/sigcontext32.h +++ b/arch/x86/include/uapi/asm/sigcontext32.h @@ -9,15 +9,15 @@ /* 10-byte legacy floating point register: */ struct _fpreg { - unsigned short significand[4]; - unsigned short exponent; + __u16 significand[4]; + __u16 exponent; }; /* 16-byte floating point register: */ struct _fpxreg { - unsigned short significand[4]; - unsigned short exponent; - unsigned short padding[3]; + __u16 significand[4]; + __u16 exponent; + __u16 padding[3]; }; /* 16-byte XMM vector register: */ @@ -38,8 +38,8 @@ struct _fpstate_ia32 { __u32 dataoff; __u32 datasel; struct _fpreg _st[8]; - unsigned short status; - unsigned short magic; /* 0xffff: regular FPU data only */ + __u16 status; + __u16 magic; /* 0xffff: regular FPU data only */ /* 0x0000: FXSR data */ /* Extended FXSR FPU environment: */ @@ -58,28 +58,28 @@ struct _fpstate_ia32 { /* 32-bit compat sigcontext: */ struct sigcontext_ia32 { - unsigned short gs, __gsh; - unsigned short fs, __fsh; - unsigned short es, __esh; - unsigned short ds, __dsh; - unsigned int di; - unsigned int si; - unsigned int bp; - unsigned int sp; - unsigned int bx; - unsigned int dx; - unsigned int cx; - unsigned int ax; - unsigned int trapno; - unsigned int err; - unsigned int ip; - unsigned short cs, __csh; - unsigned int flags; - unsigned int sp_at_signal; - unsigned short ss, __ssh; - unsigned int fpstate; /* Pointer to 'struct _fpstate_ia32' */ - unsigned int oldmask; - unsigned int cr2; + __u16 gs, __gsh; + __u16 fs, __fsh; + __u16 es, __esh; + __u16 ds, __dsh; + __u32 di; + __u32 si; + __u32 bp; + __u32 sp; + __u32 bx; + __u32 dx; + __u32 cx; + __u32 ax; + __u32 trapno; + __u32 err; + __u32 ip; + __u16 cs, __csh; + __u32 flags; + __u32 sp_at_signal; + __u16 ss, __ssh; + __u32 fpstate; /* Pointer to 'struct _fpstate_ia32' */ + __u32 oldmask; + __u32 cr2; }; #endif /* _ASM_X86_SIGCONTEXT32_H */ -- cgit v1.2.3 From 337a167d1a5b2704414679d1a993220a4613ec13 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:34 +0200 Subject: x86/headers: Unify register type definitions between 32-bit compat and i386 The following sigcontext related types were duplicated across native 32-bit and compat 32-bit headers: struct _fpreg; struct _fpxreg; struct _xmmreg; X86_FXSR_MAGIC Unify them. Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-7-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/uapi/asm/sigcontext.h | 3 ++- arch/x86/include/uapi/asm/sigcontext32.h | 22 ---------------------- 2 files changed, 2 insertions(+), 23 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/include/uapi/asm/sigcontext.h b/arch/x86/include/uapi/asm/sigcontext.h index 07b0e32a1d23..9df4df3e40ef 100644 --- a/arch/x86/include/uapi/asm/sigcontext.h +++ b/arch/x86/include/uapi/asm/sigcontext.h @@ -63,7 +63,6 @@ struct _fpx_sw_bytes { __u32 padding[7]; }; -#ifdef __i386__ /* * As documented in the iBCS2 standard: * @@ -96,6 +95,8 @@ struct _xmmreg { #define X86_FXSR_MAGIC 0x0000 +#ifdef __i386__ + struct _fpstate { /* Legacy FPU environment: */ __u32 cw; diff --git a/arch/x86/include/uapi/asm/sigcontext32.h b/arch/x86/include/uapi/asm/sigcontext32.h index 939a84885673..356caab997e7 100644 --- a/arch/x86/include/uapi/asm/sigcontext32.h +++ b/arch/x86/include/uapi/asm/sigcontext32.h @@ -3,30 +3,8 @@ /* Signal context definitions for compat 32-bit programs: */ -#include - #include -/* 10-byte legacy floating point register: */ -struct _fpreg { - __u16 significand[4]; - __u16 exponent; -}; - -/* 16-byte floating point register: */ -struct _fpxreg { - __u16 significand[4]; - __u16 exponent; - __u16 padding[3]; -}; - -/* 16-byte XMM vector register: */ -struct _xmmreg { - __u32 element[4]; -}; - -#define X86_FXSR_MAGIC 0x0000 - /* FXSAVE frame: FSAVE frame with extensions */ struct _fpstate_ia32 { /* Regular FPU environment: */ -- cgit v1.2.3 From 7bb0dc2222779b4cbf1ec9ad651e500e62fa5b11 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:35 +0200 Subject: x86/headers: Unify 'struct _fpstate_ia32' and i386 struct _fpstate '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. Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-8-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- 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(-) (limited to 'arch/x86') diff --git a/arch/x86/include/asm/sigframe.h b/arch/x86/include/asm/sigframe.h index 1f3175bb994e..a27c73d6863a 100644 --- a/arch/x86/include/asm/sigframe.h +++ b/arch/x86/include/asm/sigframe.h @@ -10,7 +10,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 -/* 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; -- cgit v1.2.3 From 86e9fc3a0ecdd3c21a938e325daf462ca1724f68 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:36 +0200 Subject: x86/headers: Convert uses of _fpstate_ia32 to _fpstate_32 Remove uses of _fpstate_ia32 from the kernel, and move the legacy _fpstate_ia32 definition to the user-space only portion of the header. Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-9-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/ia32/ia32_signal.c | 2 +- arch/x86/include/asm/sigframe.h | 2 +- arch/x86/include/uapi/asm/sigcontext.h | 5 +++-- arch/x86/include/uapi/asm/sigcontext32.h | 2 +- arch/x86/kernel/fpu/signal.c | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c index a0a19b7ba22d..b22015e847dd 100644 --- a/arch/x86/ia32/ia32_signal.c +++ b/arch/x86/ia32/ia32_signal.c @@ -234,7 +234,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, unsigned long fx_aligned, math_size; sp = fpu__alloc_mathframe(sp, 1, &fx_aligned, &math_size); - *fpstate = (struct _fpstate_ia32 __user *) sp; + *fpstate = (struct _fpstate_32 __user *) sp; if (copy_fpstate_to_sigframe(*fpstate, (void __user *)fx_aligned, math_size) < 0) return (void __user *) -1L; diff --git a/arch/x86/include/asm/sigframe.h b/arch/x86/include/asm/sigframe.h index a27c73d6863a..5ff020a65e1b 100644 --- a/arch/x86/include/asm/sigframe.h +++ b/arch/x86/include/asm/sigframe.h @@ -32,7 +32,7 @@ struct sigframe_ia32 { * the offset of extramask[] in the sigframe and thus prevent any * legacy application accessing/modifying it. */ - struct _fpstate_ia32 fpstate_unused; + struct _fpstate_32 fpstate_unused; #ifdef CONFIG_IA32_EMULATION unsigned int extramask[_COMPAT_NSIG_WORDS-1]; #else /* !CONFIG_IA32_EMULATION */ diff --git a/arch/x86/include/uapi/asm/sigcontext.h b/arch/x86/include/uapi/asm/sigcontext.h index 85811167821f..ca542e37c783 100644 --- a/arch/x86/include/uapi/asm/sigcontext.h +++ b/arch/x86/include/uapi/asm/sigcontext.h @@ -165,8 +165,6 @@ struct _fpstate_64 { # define _fpstate _fpstate_64 #endif -#define _fpstate_ia32 _fpstate_32 - struct _header { __u64 xfeatures; __u64 reserved1[2]; @@ -198,6 +196,9 @@ struct _xstate { * field names but otherwise the same layout. */ #ifndef __KERNEL__ + +#define _fpstate_ia32 _fpstate_32 + # ifdef __i386__ struct sigcontext { __u16 gs, __gsh; diff --git a/arch/x86/include/uapi/asm/sigcontext32.h b/arch/x86/include/uapi/asm/sigcontext32.h index 19a89165ea1d..06c749b40263 100644 --- a/arch/x86/include/uapi/asm/sigcontext32.h +++ b/arch/x86/include/uapi/asm/sigcontext32.h @@ -26,7 +26,7 @@ struct sigcontext_ia32 { __u32 flags; __u32 sp_at_signal; __u16 ss, __ssh; - __u32 fpstate; /* Pointer to 'struct _fpstate_ia32' */ + __u32 fpstate; /* Pointer to 'struct _fpstate_32' */ __u32 oldmask; __u32 cr2; }; diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c index 50ec9af1bd51..24aac16603a2 100644 --- a/arch/x86/kernel/fpu/signal.c +++ b/arch/x86/kernel/fpu/signal.c @@ -56,7 +56,7 @@ static inline int save_fsave_header(struct task_struct *tsk, void __user *buf) if (use_fxsr()) { struct xregs_state *xsave = &tsk->thread.fpu.state.xsave; struct user_i387_ia32_struct env; - struct _fpstate_ia32 __user *fp = buf; + struct _fpstate_32 __user *fp = buf; convert_from_fxsr(&env, tsk); @@ -165,7 +165,7 @@ int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size) if (!static_cpu_has(X86_FEATURE_FPU)) return fpregs_soft_get(current, NULL, 0, sizeof(struct user_i387_ia32_struct), NULL, - (struct _fpstate_ia32 __user *) buf) ? -1 : 1; + (struct _fpstate_32 __user *) buf) ? -1 : 1; if (fpregs_active()) { /* Save the live register state to the user directly. */ -- cgit v1.2.3 From 2d057c69e743bfb88f1259ddbf1b1160bdd850e5 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:37 +0200 Subject: x86/headers: Clean up the kernel's struct sigcontext types to be ABI-clean Use the __u16/32/64 types we standardized on in ABI definitions and which other sigcontext related types are already using. This will help unify struct sigcontext types between native 32-bit, compat and 64-bit kernels. Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-10-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/asm/sigcontext.h | 104 +++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 52 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/include/asm/sigcontext.h b/arch/x86/include/asm/sigcontext.h index 9dfce4e0417d..b9c2bd6402df 100644 --- a/arch/x86/include/asm/sigcontext.h +++ b/arch/x86/include/asm/sigcontext.h @@ -5,25 +5,25 @@ #ifdef __i386__ struct sigcontext { - unsigned short gs, __gsh; - unsigned short fs, __fsh; - unsigned short es, __esh; - unsigned short ds, __dsh; - unsigned long di; - unsigned long si; - unsigned long bp; - unsigned long sp; - unsigned long bx; - unsigned long dx; - unsigned long cx; - unsigned long ax; - unsigned long trapno; - unsigned long err; - unsigned long ip; - unsigned short cs, __csh; - unsigned long flags; - unsigned long sp_at_signal; - unsigned short ss, __ssh; + __u16 gs, __gsh; + __u16 fs, __fsh; + __u16 es, __esh; + __u16 ds, __dsh; + __u32 di; + __u32 si; + __u32 bp; + __u32 sp; + __u32 bx; + __u32 dx; + __u32 cx; + __u32 ax; + __u32 trapno; + __u32 err; + __u32 ip; + __u16 cs, __csh; + __u32 flags; + __u32 sp_at_signal; + __u16 ss, __ssh; /* * fpstate is really (struct _fpstate *) or (struct _xstate *) @@ -32,38 +32,38 @@ struct sigcontext { * of extended memory layout. See comments at the definition of * (struct _fpx_sw_bytes) */ - void __user *fpstate; /* zero when no FPU/extended context */ - unsigned long oldmask; - unsigned long cr2; + void __user *fpstate; /* Zero when no FPU/extended context */ + __u32 oldmask; + __u32 cr2; }; -#else /* __i386__ */ +#else /* __x86_64__: */ struct sigcontext { - unsigned long r8; - unsigned long r9; - unsigned long r10; - unsigned long r11; - unsigned long r12; - unsigned long r13; - unsigned long r14; - unsigned long r15; - unsigned long di; - unsigned long si; - unsigned long bp; - unsigned long bx; - unsigned long dx; - unsigned long ax; - unsigned long cx; - unsigned long sp; - unsigned long ip; - unsigned long flags; - unsigned short cs; - unsigned short gs; - unsigned short fs; - unsigned short __pad0; - unsigned long err; - unsigned long trapno; - unsigned long oldmask; - unsigned long cr2; + __u64 r8; + __u64 r9; + __u64 r10; + __u64 r11; + __u64 r12; + __u64 r13; + __u64 r14; + __u64 r15; + __u64 di; + __u64 si; + __u64 bp; + __u64 bx; + __u64 dx; + __u64 ax; + __u64 cx; + __u64 sp; + __u64 ip; + __u64 flags; + __u16 cs; + __u16 gs; + __u16 fs; + __u16 __pad0; + __u64 err; + __u64 trapno; + __u64 oldmask; + __u64 cr2; /* * fpstate is really (struct _fpstate *) or (struct _xstate *) @@ -72,8 +72,8 @@ struct sigcontext { * of extended memory layout. See comments at the definition of * (struct _fpx_sw_bytes) */ - void __user *fpstate; /* zero when no FPU/extended context */ - unsigned long reserved1[8]; + void __user *fpstate; /* Zero when no FPU/extended context */ + __u64 reserved1[8]; }; -#endif /* !__i386__ */ +#endif /* !__x86_64__ */ #endif /* _ASM_X86_SIGCONTEXT_H */ -- cgit v1.2.3 From f2c609bca0b6526810fa22330ce4d173cc023ef8 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:38 +0200 Subject: x86/headers: Move the 'struct sigcontext' definitions into the UAPI header Our goal is to eliminate the duplicate struct sigcontext_ia32 definition, so move the kernel's primary sigcontext type into the UAPI header, defining these two variants: struct sigcontext_32 struct sigcontext_64 ... and map them to 'struct sigcontext'. Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-11-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/asm/sigcontext.h | 73 ------------------------------ arch/x86/include/uapi/asm/sigcontext.h | 83 ++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 73 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/include/asm/sigcontext.h b/arch/x86/include/asm/sigcontext.h index b9c2bd6402df..25815f00b4ff 100644 --- a/arch/x86/include/asm/sigcontext.h +++ b/arch/x86/include/asm/sigcontext.h @@ -3,77 +3,4 @@ #include -#ifdef __i386__ -struct sigcontext { - __u16 gs, __gsh; - __u16 fs, __fsh; - __u16 es, __esh; - __u16 ds, __dsh; - __u32 di; - __u32 si; - __u32 bp; - __u32 sp; - __u32 bx; - __u32 dx; - __u32 cx; - __u32 ax; - __u32 trapno; - __u32 err; - __u32 ip; - __u16 cs, __csh; - __u32 flags; - __u32 sp_at_signal; - __u16 ss, __ssh; - - /* - * fpstate is really (struct _fpstate *) or (struct _xstate *) - * depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved - * bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end - * of extended memory layout. See comments at the definition of - * (struct _fpx_sw_bytes) - */ - void __user *fpstate; /* Zero when no FPU/extended context */ - __u32 oldmask; - __u32 cr2; -}; -#else /* __x86_64__: */ -struct sigcontext { - __u64 r8; - __u64 r9; - __u64 r10; - __u64 r11; - __u64 r12; - __u64 r13; - __u64 r14; - __u64 r15; - __u64 di; - __u64 si; - __u64 bp; - __u64 bx; - __u64 dx; - __u64 ax; - __u64 cx; - __u64 sp; - __u64 ip; - __u64 flags; - __u16 cs; - __u16 gs; - __u16 fs; - __u16 __pad0; - __u64 err; - __u64 trapno; - __u64 oldmask; - __u64 cr2; - - /* - * fpstate is really (struct _fpstate *) or (struct _xstate *) - * depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved - * bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end - * of extended memory layout. See comments at the definition of - * (struct _fpx_sw_bytes) - */ - void __user *fpstate; /* Zero when no FPU/extended context */ - __u64 reserved1[8]; -}; -#endif /* !__x86_64__ */ #endif /* _ASM_X86_SIGCONTEXT_H */ diff --git a/arch/x86/include/uapi/asm/sigcontext.h b/arch/x86/include/uapi/asm/sigcontext.h index ca542e37c783..3591cef6d7d2 100644 --- a/arch/x86/include/uapi/asm/sigcontext.h +++ b/arch/x86/include/uapi/asm/sigcontext.h @@ -190,6 +190,89 @@ struct _xstate { /* New processor state extensions go here: */ }; +struct sigcontext_32 { + __u16 gs, __gsh; + __u16 fs, __fsh; + __u16 es, __esh; + __u16 ds, __dsh; + __u32 di; + __u32 si; + __u32 bp; + __u32 sp; + __u32 bx; + __u32 dx; + __u32 cx; + __u32 ax; + __u32 trapno; + __u32 err; + __u32 ip; + __u16 cs, __csh; + __u32 flags; + __u32 sp_at_signal; + __u16 ss, __ssh; + + /* + * fpstate is really (struct _fpstate *) or (struct _xstate *) + * depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved + * bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end + * of extended memory layout. See comments at the definition of + * (struct _fpx_sw_bytes) + */ + void __user *fpstate; /* Zero when no FPU/extended context */ + __u32 oldmask; + __u32 cr2; +}; + +struct sigcontext_64 { + __u64 r8; + __u64 r9; + __u64 r10; + __u64 r11; + __u64 r12; + __u64 r13; + __u64 r14; + __u64 r15; + __u64 di; + __u64 si; + __u64 bp; + __u64 bx; + __u64 dx; + __u64 ax; + __u64 cx; + __u64 sp; + __u64 ip; + __u64 flags; + __u16 cs; + __u16 gs; + __u16 fs; + __u16 __pad0; + __u64 err; + __u64 trapno; + __u64 oldmask; + __u64 cr2; + + /* + * fpstate is really (struct _fpstate *) or (struct _xstate *) + * depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved + * bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end + * of extended memory layout. See comments at the definition of + * (struct _fpx_sw_bytes) + */ + void __user *fpstate; /* Zero when no FPU/extended context */ + __u64 reserved1[8]; +}; + +/* + * Create the real 'struct sigcontext' type: + */ +#ifdef __KERNEL__ +# ifdef __i386__ +# define sigcontext sigcontext_32 +# else +# define sigcontext sigcontext_64 +# endif +#endif + /* * The old user-space sigcontext definition, just in case user-space still * relies on it. The kernel definition (in asm/sigcontext.h) has unified -- cgit v1.2.3 From 530e5c827182a7a5322c55276b0617fd06874c24 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:39 +0200 Subject: x86/headers: Make sigcontext pointers bit independent Before we can eliminate the duplication between 'struct sigcontext_32' and 'struct sigcontext_ia32', make the 'fpstate' pointer field in 'struct sigcontext_32' bit independent. Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-12-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/uapi/asm/sigcontext.h | 4 ++-- arch/x86/kernel/signal.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/include/uapi/asm/sigcontext.h b/arch/x86/include/uapi/asm/sigcontext.h index 3591cef6d7d2..d0def259d545 100644 --- a/arch/x86/include/uapi/asm/sigcontext.h +++ b/arch/x86/include/uapi/asm/sigcontext.h @@ -218,7 +218,7 @@ struct sigcontext_32 { * of extended memory layout. See comments at the definition of * (struct _fpx_sw_bytes) */ - void __user *fpstate; /* Zero when no FPU/extended context */ + __u32 fpstate; /* Zero when no FPU/extended context */ __u32 oldmask; __u32 cr2; }; @@ -258,7 +258,7 @@ struct sigcontext_64 { * of extended memory layout. See comments at the definition of * (struct _fpx_sw_bytes) */ - void __user *fpstate; /* Zero when no FPU/extended context */ + __u64 fpstate; /* Zero when no FPU/extended context */ __u64 reserved1[8]; }; diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c index da52e6bb5c7f..3724ff38033e 100644 --- a/arch/x86/kernel/signal.c +++ b/arch/x86/kernel/signal.c @@ -63,6 +63,7 @@ int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) { + unsigned long buf_val; void __user *buf; unsigned int tmpflags; unsigned int err = 0; @@ -107,7 +108,8 @@ int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS); regs->orig_ax = -1; /* disable syscall checks */ - get_user_ex(buf, &sc->fpstate); + get_user_ex(buf_val, &sc->fpstate); + buf = (void __user *)buf_val; } get_user_catch(err); err |= fpu__restore_sig(buf, config_enabled(CONFIG_X86_32)); -- cgit v1.2.3 From db1e031401c6abab983919e882916d028f3b385e Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:40 +0200 Subject: x86/headers: Unify 'struct sigcontext_ia32' and 'struct sigcontext_32' The two structures are identical - merge them and keep the legacy name as a define. Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-13-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/asm/sigframe.h | 1 - arch/x86/include/uapi/asm/sigcontext.h | 2 ++ arch/x86/include/uapi/asm/sigcontext32.h | 26 -------------------------- 3 files changed, 2 insertions(+), 27 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/include/asm/sigframe.h b/arch/x86/include/asm/sigframe.h index 5ff020a65e1b..98f04018663a 100644 --- a/arch/x86/include/asm/sigframe.h +++ b/arch/x86/include/asm/sigframe.h @@ -9,7 +9,6 @@ #ifdef CONFIG_X86_32 #define sigframe_ia32 sigframe #define rt_sigframe_ia32 rt_sigframe -#define sigcontext_ia32 sigcontext #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 d0def259d545..592bfafd5cb2 100644 --- a/arch/x86/include/uapi/asm/sigcontext.h +++ b/arch/x86/include/uapi/asm/sigcontext.h @@ -223,6 +223,8 @@ struct sigcontext_32 { __u32 cr2; }; +#define sigcontext_ia32 sigcontext_32 + struct sigcontext_64 { __u64 r8; __u64 r9; diff --git a/arch/x86/include/uapi/asm/sigcontext32.h b/arch/x86/include/uapi/asm/sigcontext32.h index 06c749b40263..257fbb3baaa7 100644 --- a/arch/x86/include/uapi/asm/sigcontext32.h +++ b/arch/x86/include/uapi/asm/sigcontext32.h @@ -5,30 +5,4 @@ #include -/* 32-bit compat sigcontext: */ -struct sigcontext_ia32 { - __u16 gs, __gsh; - __u16 fs, __fsh; - __u16 es, __esh; - __u16 ds, __dsh; - __u32 di; - __u32 si; - __u32 bp; - __u32 sp; - __u32 bx; - __u32 dx; - __u32 cx; - __u32 ax; - __u32 trapno; - __u32 err; - __u32 ip; - __u16 cs, __csh; - __u32 flags; - __u32 sp_at_signal; - __u16 ss, __ssh; - __u32 fpstate; /* Pointer to 'struct _fpstate_32' */ - __u32 oldmask; - __u32 cr2; -}; - #endif /* _ASM_X86_SIGCONTEXT32_H */ -- cgit v1.2.3 From 8fcb346b910e860d2525457742ae984c4ddc64b5 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:41 +0200 Subject: x86/headers: Convert sigcontext_ia32 uses to sigcontext_32 Use the new name in kernel code, and move the old name to the user-space-only legacy section of the UAPI header. Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-14-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/ia32/ia32_signal.c | 4 ++-- arch/x86/include/asm/ia32.h | 2 +- arch/x86/include/asm/sigframe.h | 2 +- arch/x86/include/uapi/asm/sigcontext.h | 12 +++++++++--- arch/x86/kernel/asm-offsets.c | 18 +++++++++--------- 5 files changed, 22 insertions(+), 16 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c index b22015e847dd..b42103086a78 100644 --- a/arch/x86/ia32/ia32_signal.c +++ b/arch/x86/ia32/ia32_signal.c @@ -68,7 +68,7 @@ } static int ia32_restore_sigcontext(struct pt_regs *regs, - struct sigcontext_ia32 __user *sc) + struct sigcontext_32 __user *sc) { unsigned int tmpflags, err = 0; void __user *buf; @@ -170,7 +170,7 @@ badframe: * Set up a signal frame. */ -static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc, +static int ia32_setup_sigcontext(struct sigcontext_32 __user *sc, void __user *fpstate, struct pt_regs *regs, unsigned int mask) { diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h index 28019765442e..3173b48c3c56 100644 --- a/arch/x86/include/asm/ia32.h +++ b/arch/x86/include/asm/ia32.h @@ -18,7 +18,7 @@ struct ucontext_ia32 { unsigned int uc_flags; unsigned int uc_link; compat_stack_t uc_stack; - struct sigcontext_ia32 uc_mcontext; + struct sigcontext_32 uc_mcontext; compat_sigset_t uc_sigmask; /* mask last for extensibility */ }; diff --git a/arch/x86/include/asm/sigframe.h b/arch/x86/include/asm/sigframe.h index 98f04018663a..867a7577fbeb 100644 --- a/arch/x86/include/asm/sigframe.h +++ b/arch/x86/include/asm/sigframe.h @@ -22,7 +22,7 @@ struct sigframe_ia32 { u32 pretcode; int sig; - struct sigcontext_ia32 sc; + struct sigcontext_32 sc; /* * fpstate is unused. fpstate is moved/allocated after * retcode[] below. This movement allows to have the FP state and the diff --git a/arch/x86/include/uapi/asm/sigcontext.h b/arch/x86/include/uapi/asm/sigcontext.h index 592bfafd5cb2..4411e6a8f8e7 100644 --- a/arch/x86/include/uapi/asm/sigcontext.h +++ b/arch/x86/include/uapi/asm/sigcontext.h @@ -190,6 +190,9 @@ struct _xstate { /* New processor state extensions go here: */ }; +/* + * The 32-bit signal frame: + */ struct sigcontext_32 { __u16 gs, __gsh; __u16 fs, __fsh; @@ -223,8 +226,9 @@ struct sigcontext_32 { __u32 cr2; }; -#define sigcontext_ia32 sigcontext_32 - +/* + * The 64-bit signal frame: + */ struct sigcontext_64 { __u64 r8; __u64 r9; @@ -282,7 +286,9 @@ struct sigcontext_64 { */ #ifndef __KERNEL__ -#define _fpstate_ia32 _fpstate_32 +#define _fpstate_ia32 _fpstate_32 +#define sigcontext_ia32 sigcontext_32 + # ifdef __i386__ struct sigcontext { diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c index 8e3d22a1af94..bc9f4afa889a 100644 --- a/arch/x86/kernel/asm-offsets.c +++ b/arch/x86/kernel/asm-offsets.c @@ -43,15 +43,15 @@ void common(void) { #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) BLANK(); - OFFSET(IA32_SIGCONTEXT_ax, sigcontext_ia32, ax); - OFFSET(IA32_SIGCONTEXT_bx, sigcontext_ia32, bx); - OFFSET(IA32_SIGCONTEXT_cx, sigcontext_ia32, cx); - OFFSET(IA32_SIGCONTEXT_dx, sigcontext_ia32, dx); - OFFSET(IA32_SIGCONTEXT_si, sigcontext_ia32, si); - OFFSET(IA32_SIGCONTEXT_di, sigcontext_ia32, di); - OFFSET(IA32_SIGCONTEXT_bp, sigcontext_ia32, bp); - OFFSET(IA32_SIGCONTEXT_sp, sigcontext_ia32, sp); - OFFSET(IA32_SIGCONTEXT_ip, sigcontext_ia32, ip); + OFFSET(IA32_SIGCONTEXT_ax, sigcontext_32, ax); + OFFSET(IA32_SIGCONTEXT_bx, sigcontext_32, bx); + OFFSET(IA32_SIGCONTEXT_cx, sigcontext_32, cx); + OFFSET(IA32_SIGCONTEXT_dx, sigcontext_32, dx); + OFFSET(IA32_SIGCONTEXT_si, sigcontext_32, si); + OFFSET(IA32_SIGCONTEXT_di, sigcontext_32, di); + OFFSET(IA32_SIGCONTEXT_bp, sigcontext_32, bp); + OFFSET(IA32_SIGCONTEXT_sp, sigcontext_32, sp); + OFFSET(IA32_SIGCONTEXT_ip, sigcontext_32, ip); BLANK(); OFFSET(TI_sysenter_return, thread_info, sysenter_return); -- cgit v1.2.3 From 711531f4f3cb881f4598cddfcc36663101dee411 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:42 +0200 Subject: x86/headers: Remove direct sigcontext32.h uses Now that all sigcontext types are defined in asm/sigcontext.h, remove the various sigcontext32.h uses in the kernel. We still keep the header itself, which includes sigcontext.h, in case user-space relies on it. Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-15-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/ia32/ia32_signal.c | 2 +- arch/x86/include/asm/fpu/signal.h | 2 +- arch/x86/include/asm/ia32.h | 2 +- arch/x86/include/uapi/asm/sigcontext32.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c index b42103086a78..955ca03910ee 100644 --- a/arch/x86/ia32/ia32_signal.c +++ b/arch/x86/ia32/ia32_signal.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/x86/include/asm/fpu/signal.h b/arch/x86/include/asm/fpu/signal.h index 7358e9d61f1e..856f4b3cf1e3 100644 --- a/arch/x86/include/asm/fpu/signal.h +++ b/arch/x86/include/asm/fpu/signal.h @@ -5,7 +5,7 @@ #define _ASM_X86_FPU_SIGNAL_H #ifdef CONFIG_X86_64 -# include +# include # include struct ksignal; int ia32_setup_rt_frame(int sig, struct ksignal *ksig, diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h index 3173b48c3c56..16edda2816be 100644 --- a/arch/x86/include/asm/ia32.h +++ b/arch/x86/include/asm/ia32.h @@ -10,7 +10,7 @@ * 32 bit structures for IA32 support. */ -#include +#include /* signal.h */ diff --git a/arch/x86/include/uapi/asm/sigcontext32.h b/arch/x86/include/uapi/asm/sigcontext32.h index 257fbb3baaa7..a92b0f0dc09e 100644 --- a/arch/x86/include/uapi/asm/sigcontext32.h +++ b/arch/x86/include/uapi/asm/sigcontext32.h @@ -1,7 +1,7 @@ #ifndef _ASM_X86_SIGCONTEXT32_H #define _ASM_X86_SIGCONTEXT32_H -/* Signal context definitions for compat 32-bit programs: */ +/* This is a legacy file - all the type definitions are in sigcontext.h: */ #include -- cgit v1.2.3 From decb4c41159e1511197f2964da758fa7f2eeb741 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sat, 5 Sep 2015 09:32:43 +0200 Subject: x86/headers: Remove references on the kernel side Now that all type definitions are in the UAPI header, include it directly, instead of through . [ We still keep asm/sigcontext.h, so that uapi/asm/sigcontext32.h can include . ] Acked-by: Mikko Rapeli Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Link: http://lkml.kernel.org/r/1441438363-9999-16-git-send-email-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/ia32/ia32_signal.c | 2 +- arch/x86/include/asm/fpu/signal.h | 2 +- arch/x86/include/asm/ia32.h | 2 +- arch/x86/include/asm/processor.h | 2 +- arch/x86/include/asm/sigcontext.h | 2 ++ arch/x86/include/asm/sigframe.h | 2 +- arch/x86/include/asm/signal.h | 2 +- arch/x86/math-emu/fpu_emu.h | 2 +- 8 files changed, 9 insertions(+), 7 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c index 955ca03910ee..5959042fae8d 100644 --- a/arch/x86/ia32/ia32_signal.c +++ b/arch/x86/ia32/ia32_signal.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/x86/include/asm/fpu/signal.h b/arch/x86/include/asm/fpu/signal.h index 856f4b3cf1e3..0e970d00dfcd 100644 --- a/arch/x86/include/asm/fpu/signal.h +++ b/arch/x86/include/asm/fpu/signal.h @@ -5,7 +5,7 @@ #define _ASM_X86_FPU_SIGNAL_H #ifdef CONFIG_X86_64 -# include +# include # include struct ksignal; int ia32_setup_rt_frame(int sig, struct ksignal *ksig, diff --git a/arch/x86/include/asm/ia32.h b/arch/x86/include/asm/ia32.h index 16edda2816be..a9bdf5569ab3 100644 --- a/arch/x86/include/asm/ia32.h +++ b/arch/x86/include/asm/ia32.h @@ -10,7 +10,7 @@ * 32 bit structures for IA32 support. */ -#include +#include /* signal.h */ diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 19577dd325fa..bb911e718330 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -11,7 +11,7 @@ struct vm86; #include #include #include -#include +#include #include #include #include diff --git a/arch/x86/include/asm/sigcontext.h b/arch/x86/include/asm/sigcontext.h index 25815f00b4ff..e6cd2c489dbb 100644 --- a/arch/x86/include/asm/sigcontext.h +++ b/arch/x86/include/asm/sigcontext.h @@ -1,6 +1,8 @@ #ifndef _ASM_X86_SIGCONTEXT_H #define _ASM_X86_SIGCONTEXT_H +/* This is a legacy header - all kernel code includes directly. */ + #include #endif /* _ASM_X86_SIGCONTEXT_H */ diff --git a/arch/x86/include/asm/sigframe.h b/arch/x86/include/asm/sigframe.h index 867a7577fbeb..34edd1650bae 100644 --- a/arch/x86/include/asm/sigframe.h +++ b/arch/x86/include/asm/sigframe.h @@ -1,7 +1,7 @@ #ifndef _ASM_X86_SIGFRAME_H #define _ASM_X86_SIGFRAME_H -#include +#include #include #include #include diff --git a/arch/x86/include/asm/signal.h b/arch/x86/include/asm/signal.h index c481be78fcf1..2138c9ae19ee 100644 --- a/arch/x86/include/asm/signal.h +++ b/arch/x86/include/asm/signal.h @@ -34,7 +34,7 @@ extern void do_signal(struct pt_regs *regs); #define __ARCH_HAS_SA_RESTORER -#include +#include #ifdef __i386__ diff --git a/arch/x86/math-emu/fpu_emu.h b/arch/x86/math-emu/fpu_emu.h index 4dae511c85ad..afbc4d805d66 100644 --- a/arch/x86/math-emu/fpu_emu.h +++ b/arch/x86/math-emu/fpu_emu.h @@ -71,7 +71,7 @@ #include "fpu_system.h" -#include /* for struct _fpstate */ +#include /* for struct _fpstate */ #include #include -- cgit v1.2.3 From 0e2815de552a638295cfdaf0865e575573bf263e Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Wed, 9 Sep 2015 09:12:44 +0200 Subject: x86/headers: Clean up too long lines Signed-off-by: Peter Zijlstra Cc: Linus Torvalds Cc: Thomas Gleixner Cc: bp@alien8.de Cc: brgerst@gmail.com Cc: dvlasenk@redhat.com Cc: luto@amacapital.net Cc: mikko.rapeli@iki.fi Cc: oleg@redhat.com Link: http://lkml.kernel.org/r/20150909071244.GM3644@twins.programming.kicks-ass.net Signed-off-by: Ingo Molnar --- arch/x86/include/uapi/asm/sigcontext.h | 57 ++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 26 deletions(-) (limited to 'arch/x86') diff --git a/arch/x86/include/uapi/asm/sigcontext.h b/arch/x86/include/uapi/asm/sigcontext.h index 4411e6a8f8e7..d485232f1e9f 100644 --- a/arch/x86/include/uapi/asm/sigcontext.h +++ b/arch/x86/include/uapi/asm/sigcontext.h @@ -2,16 +2,16 @@ #define _UAPI_ASM_X86_SIGCONTEXT_H /* - * Linux signal context definitions. The sigcontext includes a complex hierarchy of CPU - * and FPU state, available to user-space (on the stack) when a signal handler is - * executed. + * Linux signal context definitions. The sigcontext includes a complex + * hierarchy of CPU and FPU state, available to user-space (on the stack) when + * a signal handler is executed. * - * As over the years this ABI grew from its very simple roots towards supporting more and - * more CPU state organically, some of the details (which were rather clever hacks back - * in the days) became a bit quirky by today. + * As over the years this ABI grew from its very simple roots towards + * supporting more and more CPU state organically, some of the details (which + * were rather clever hacks back in the days) became a bit quirky by today. * - * The current ABI includes flexible provisions for future extensions, so we won't have - * to grow new quirks for quite some time. Promise! + * The current ABI includes flexible provisions for future extensions, so we + * won't have to grow new quirks for quite some time. Promise! */ #include @@ -23,27 +23,32 @@ /* * Bytes 464..511 in the current 512-byte layout of the FXSAVE/FXRSTOR frame - * are reserved for SW usage. On CPUs supporting XSAVE/XRSTOR, these bytes - * are used to extend the fpstate pointer in the sigcontext, which now - * includes the extended state information along with fpstate information. + * are reserved for SW usage. On CPUs supporting XSAVE/XRSTOR, these bytes are + * used to extend the fpstate pointer in the sigcontext, which now includes the + * extended state information along with fpstate information. * - * If sw_reserved.magic1 == FP_XSTATE_MAGIC1 then there's a sw_reserved.extended_size - * bytes large extended context area present. (The last 32-bit word of this extended - * area (at the fpstate+extended_size-FP_XSTATE_MAGIC2_SIZE address) is set to + * If sw_reserved.magic1 == FP_XSTATE_MAGIC1 then there's a + * sw_reserved.extended_size bytes large extended context area present. (The + * last 32-bit word of this extended area (at the + * fpstate+extended_size-FP_XSTATE_MAGIC2_SIZE address) is set to * FP_XSTATE_MAGIC2 so that you can sanity check your size calculations.) * - * This extended area typically grows with newer CPUs that have larger and larger - * XSAVE areas. + * This extended area typically grows with newer CPUs that have larger and + * larger XSAVE areas. */ struct _fpx_sw_bytes { - /* If set to FP_XSTATE_MAGIC1 then this is an xstate context. 0 if a legacy frame. */ + /* + * If set to FP_XSTATE_MAGIC1 then this is an xstate context. + * 0 if a legacy frame. + */ __u32 magic1; /* * Total size of the fpstate area: * * - if magic1 == 0 then it's sizeof(struct _fpstate) - * - if magic1 == FP_XSTATE_MAGIC1 then it's sizeof(struct _xstate) plus extensions (if any) + * - if magic1 == FP_XSTATE_MAGIC1 then it's sizeof(struct _xstate) + * plus extensions (if any) */ __u32 extended_size; @@ -66,13 +71,13 @@ struct _fpx_sw_bytes { /* * As documented in the iBCS2 standard: * - * The first part of "struct _fpstate" is just the normal i387 - * hardware setup, the extra "status" word is used to save the - * coprocessor status word before entering the handler. + * The first part of "struct _fpstate" is just the normal i387 hardware setup, + * the extra "status" word is used to save the coprocessor status word before + * entering the handler. * - * The FPU state data structure has had to grow to accommodate the - * extended FPU state required by the Streaming SIMD Extensions. - * There is no documented standard to accomplish this at the moment. + * The FPU state data structure has had to grow to accommodate the extended FPU + * state required by the Streaming SIMD Extensions. There is no documented + * standard to accomplish this at the moment. */ /* 10-byte legacy floating point register: */ @@ -137,8 +142,8 @@ struct _fpstate_32 { * 'struct _fpstate' so that you can always assume the _fpstate portion * exists so that you can check the magic value. * - * Note2: Reserved fields may someday contain valuable data. Always save/restore - * them when you change signal frames. + * Note2: Reserved fields may someday contain valuable data. Always + * save/restore them when you change signal frames. */ struct _fpstate_64 { __u16 cwd; -- cgit v1.2.3