x86/headers: Clean up sigcontext types and headers
cover x86/headers: Clean up sigcontext types and headers
So Mikko Rapeli reported that sigcontext32.h does not build standalone, and while trying to fix it I came up with this series that cleans up all sorts of details and makes the sigcontext types (hopefully) much more maintainable.
Before this series we had a somewhat messy duplication that resulted in 3 type definitions (repeated for both sigcontext and for various FPU state structures):
- native 32-bit types (only available on 32-bit kernels) - native 64-bit types (only available on 64-bit kernels) - compat 32-bit types (only available on 64-bit kernels)
- wrappers defining _32 named variants of these types
... while in reality our compat 32-bit ABI structures are the same as the native 32-bit ABI structures.
So after the series there's a clear, bitness independent definition of all the relevant types:
struct sigcontext_32 (available on all kernels) struct sigcontext_64 (available on all kernels)
struct _fpstate_32 (available on all kernels)
struct _fpstate_64 (available on all kernels)
and the kernel bitness dependent 'struct sigcontext' and 'struct _fpstate' structures are then mapped to their respective types, depending on bitness.
Modern user-space can start using these cleaner types. (If they want to: all old names are kept as well).
I have also extended/harmonized all the disjunct (and often hard to read) comments in the various structure definitions. The patches add a lot of new comments, this is why the diffstat shows only a modest line count reduction:
13 files changed, 324 insertions(+), 338 deletions(-)
Another effect of the series is that sigcontext32.h is gone (only a wrapper to sigcontext.h is kept, in case existing user-space relies on the header), and the kernel side asm/sigcontext.h file is gone as well. This should solve the original build failure reported by Mikko Rapeli.
All legacy names are still kept to make sure we don't break user-space builds, and are collected at the end of the file, without confusing people who'd only like to read the file to understand the kernel side code.
The various _ia32 names are mostly gone as well from the kernel side, compatibility wrappers are kept for the user-space side.
There's one new type quirk in patch 11, which is the result of having unified C code operating on a 32-bit pointer field both from 64-bit kernel and from a native 32-bit kernel:
int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) {
+ unsigned long buf_val;
- get_user_ex(buf, &sc->fpstate); + get_user_ex(buf_val, &sc->fpstate); + buf = (void __user *)buf_val;
this is the cleanest I could structure it. If this is the only quirk then I think the advantages outweigh the ugliness - BYMMV.
So in general this is how I imagine our model should be to define ABIs going forward.
Comments, suggestions are welcome!
Ingo
============================>
Ingo Molnar (15):
x86/headers: Fix (old) header file dependency bug in uapi/asm/sigcontext32.h x86/headers: Clean up uapi/asm/sigcontext32.h
x86/headers: Clean up and better document uapi/asm/sigcontext.h x86/headers: Separate out legacy user-space structure definitions x86/headers: Use ABI types consistently in sigcontext*.h x86/headers: Unify register type definitions between 32-bit compat and i386 x86/headers: Unify 'struct _fpstate_ia32' and i386 struct _fpstate x86/headers: Convert uses of _fpstate_ia32 to _fpstate_32 x86/headers: Clean up the kernel's struct sigcontext types to be ABI-clean x86/headers: Move the 'struct sigcontext' definitions into the UAPI header x86/headers: Make sigcontext pointers bit independent x86/headers: Unify 'struct sigcontext_ia32' and 'struct sigcontext_32' x86/headers: Convert sigcontext_ia32 uses to sigcontext_32 x86/headers: Remove direct sigcontext32.h uses
x86/headers: Remove <asm/sigcontext.h>
arch/x86/ia32/ia32_signal.c | 8 +- arch/x86/include/asm/fpu/signal.h | 2 +- arch/x86/include/asm/ia32.h | 4 +- arch/x86/include/asm/processor.h | 2 +- arch/x86/include/asm/sigcontext.h | 79 ------ arch/x86/include/asm/sigframe.h | 8 +- arch/x86/include/asm/signal.h | 2 +- arch/x86/include/uapi/asm/sigcontext.h | 456 ++++++++++++++++++++----------- arch/x86/include/uapi/asm/sigcontext32.h | 73 +---- arch/x86/kernel/asm-offsets.c | 18 +- arch/x86/kernel/fpu/signal.c | 4 +- arch/x86/kernel/signal.c | 4 +- arch/x86/math-emu/fpu_emu.h | 2 +- 13 files changed, 324 insertions(+), 338 deletions(-) delete mode 100644 arch/x86/include/asm/sigcontext.h
Signature · 1 line
2.1.4
PATCH 1/15 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 <asm/sigcontext32.h>
Due to undefined 'struct __fpx_sw_bytes' which is defined in asm/sigcontext.h.
The following header order works:
#include <asm/sigcontext.h> #include <asm/sigcontext32.h>
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.
--- arch/x86/include/uapi/asm/sigcontext32.h | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/include/uapi/asm/sigcontext32.h +2 -0
@@ -3,6 +3,8 @@#include <linux/types.h> +#include <asm/sigcontext.h> +/* signal context for 32bit programs. */ #define X86_FXSR_MAGIC 0x0000
Signature · 1 line
2.1.4
PATCH 2/15 x86/headers: Clean up uapi/asm/sigcontext32.h
In reply to Ingo MolnarClean 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.
--- arch/x86/include/uapi/asm/sigcontext32.h | 110 ++++++++++++++++--------------- 1 file changed, 58 insertions(+), 52 deletions(-)
arch/x86/include/uapi/asm/sigcontext32.h +58 -52
@@ -1,79 +1,85 @@#ifndef _ASM_X86_SIGCONTEXT32_H#define _ASM_X86_SIGCONTEXT32_H +/* Signal context definitions for compat 32-bit programs: */ +#include <linux/types.h> #include <asm/sigcontext.h> -/* 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 */
Signature · 1 line
2.1.4
PATCH 10/15 x86/headers: Move the 'struct sigcontext' definitions into the UAPI header
In reply to Ingo MolnarOur 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'.
--- arch/x86/include/asm/sigcontext.h | 73 ------------------------------ arch/x86/include/uapi/asm/sigcontext.h | 83 ++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 73 deletions(-)
arch/x86/include/asm/sigcontext.h +0 -73
@@ -3,77 +3,4 @@#include <uapi/asm/sigcontext.h> -#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 */
arch/x86/include/uapi/asm/sigcontext.h +83 -0
89 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 9/15 x86/headers: Clean up the kernel's struct sigcontext types to be ABI-clean
In reply to Ingo MolnarUse 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.
--- arch/x86/include/asm/sigcontext.h | 104 +++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 52 deletions(-)
arch/x86/include/asm/sigcontext.h +52 -52
@@ -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 */
Signature · 1 line
2.1.4
PATCH 8/15 x86/headers: Convert uses of _fpstate_ia32 to _fpstate_32
In reply to Ingo MolnarRemove uses of _fpstate_ia32 from the kernel, and move the legacy _fpstate_ia32 definition to the user-space only portion of the header.
--- 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(-)
arch/x86/ia32/ia32_signal.c +1 -1
@@ -327,7 +327,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 ;
arch/x86/include/asm/sigframe.h +1 -1
@@ -31,7 +31,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 */
arch/x86/include/uapi/asm/sigcontext.h +3 -2
@@ -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;
arch/x86/include/uapi/asm/sigcontext32.h +1 -1
@@ -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; };
arch/x86/kernel/fpu/signal.c +2 -2
@@ -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. */
Signature · 1 line
2.1.4
PATCH 7/15 x86/headers: Unify 'struct _fpstate_ia32' and i386 struct _fpstate
In reply to Ingo Molnar'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.
--- 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(-)
arch/x86/include/asm/sigframe.h +0 -1
@@ -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 */
arch/x86/include/uapi/asm/sigcontext.h +17 -9
@@ -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_32struct _header {__u64 xfeatures;
arch/x86/include/uapi/asm/sigcontext32.h +0 -29
@@ -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;
Signature · 1 line
2.1.4
PATCH 6/15 x86/headers: Unify register type definitions between 32-bit compat and i386
In reply to Ingo MolnarThe 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.
--- arch/x86/include/uapi/asm/sigcontext.h | 3 ++- arch/x86/include/uapi/asm/sigcontext32.h | 22 ---------------------- 2 files changed, 2 insertions(+), 23 deletions(-)
arch/x86/include/uapi/asm/sigcontext.h +2 -1
@@ -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;
arch/x86/include/uapi/asm/sigcontext32.h +0 -22
@@ -3,30 +3,8 @@/* Signal context definitions for compat 32-bit programs: */ -#include <linux/types.h> -#include <asm/sigcontext.h> -/* 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: */
Signature · 1 line
2.1.4
PATCH 5/15 x86/headers: Use ABI types consistently in sigcontext*.h
In reply to Ingo MolnarUse 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.
--- arch/x86/include/uapi/asm/sigcontext.h | 82 ++++++++++++++++---------------- arch/x86/include/uapi/asm/sigcontext32.h | 58 +++++++++++----------- 2 files changed, 70 insertions(+), 70 deletions(-)
arch/x86/include/uapi/asm/sigcontext.h +41 -41
@@ -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 0x0000struct _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 {
arch/x86/include/uapi/asm/sigcontext32.h +29 -29
80 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 4/15 x86/headers: Separate out legacy user-space structure definitions
In reply to Ingo MolnarBetter separate the user-space struct sigcontext definitions from the kernel definitions, so that we can unify the kernel definitions with sigcontext32.h.
--- arch/x86/include/uapi/asm/sigcontext.h | 119 ++++++++++++++++----------------- 1 file changed, 59 insertions(+), 60 deletions(-)
arch/x86/include/uapi/asm/sigcontext.h +59 -60
@@ -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 */
Signature · 1 line
2.1.4
PATCH 3/15 x86/headers: Clean up and better document uapi/asm/sigcontext.h
In reply to Ingo MolnarClean 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.
--- arch/x86/include/uapi/asm/sigcontext.h | 330 ++++++++++++++++++--------------- 1 file changed, 182 insertions(+), 148 deletions(-)
arch/x86/include/uapi/asm/sigcontext.h +182 -148
@@ -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 <linux/compiler.h> #include <linux/types.h> -#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 <[email protected]>, 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 */
Signature · 1 line
2.1.4
PATCH 11/15 x86/headers: Make sigcontext pointers bit independent
In reply to Ingo MolnarBefore we can eliminate the duplication between 'struct sigcontext_32' and 'struct sigcontext_ia32', make the 'fpstate' pointer field in 'struct sigcontext_32' bit independent.
--- arch/x86/include/uapi/asm/sigcontext.h | 4 ++-- arch/x86/kernel/signal.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/include/uapi/asm/sigcontext.h +2 -2
@@ -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 ]; };
arch/x86/kernel/signal.c +3 -1
@@ -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 ));
Signature · 1 line
2.1.4
PATCH 15/15 x86/headers: Remove <asm/sigcontext.h>
In reply to Ingo MolnarNow that all type definitions are in the UAPI header, remove the <asm/sigcontext.h> wrapper.
--- 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 | 6 ------ arch/x86/include/asm/sigframe.h | 2 +- arch/x86/include/asm/signal.h | 2 +- arch/x86/include/uapi/asm/sigcontext32.h | 2 +- arch/x86/math-emu/fpu_emu.h | 2 +- 9 files changed, 8 insertions(+), 14 deletions(-)
arch/x86/ia32/ia32_signal.c +1 -1
@@ -26,7 +26,7 @@#include <asm/ptrace.h> #include <asm/ia32_unistd.h> #include <asm/user32.h> -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> #include <asm/proto.h> #include <asm/vdso.h> #include <asm/sigframe.h>
arch/x86/include/asm/fpu/signal.h +1 -1
@@ -5,7 +5,7 @@#define _ASM_X86_FPU_SIGNAL_H#ifdef CONFIG_X86_64 -# include <asm/sigcontext.h> +# include <uapi/asm/sigcontext.h> # include <asm/user32.h> struct ksignal ; int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
arch/x86/include/asm/ia32.h +1 -1
@@ -10,7 +10,7 @@* 32 bit structures for IA32 support. */ -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> /* signal.h */
arch/x86/include/asm/processor.h +1 -1
@@ -11,7 +11,7 @@ struct mm_struct;#include <asm/math_emu.h> #include <asm/segment.h> #include <asm/types.h> -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> #include <asm/current.h> #include <asm/cpufeature.h> #include <asm/page.h>
arch/x86/include/asm/sigcontext.h deleted +0 -6
@@ -1,6 +0,0 @@ -#ifndef _ASM_X86_SIGCONTEXT_H -#define _ASM_X86_SIGCONTEXT_H - -#include <uapi/asm/sigcontext.h> - -#endif /* _ASM_X86_SIGCONTEXT_H */
arch/x86/include/asm/sigframe.h +1 -1
@@ -1,7 +1,7 @@#ifndef _ASM_X86_SIGFRAME_H#define _ASM_X86_SIGFRAME_H -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> #include <asm/siginfo.h> #include <asm/ucontext.h>
arch/x86/include/asm/signal.h +1 -1
@@ -34,7 +34,7 @@ extern void do_notify_resume(struct pt_regs *, void *, __u32);#define __ARCH_HAS_SA_RESTORER -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> #ifdef __i386__
arch/x86/include/uapi/asm/sigcontext32.h +1 -1
@@ -3,6 +3,6 @@/* This is a legacy file - all the type definitions are in sigcontext.h: */ -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> #endif /* _ASM_X86_SIGCONTEXT32_H */
arch/x86/math-emu/fpu_emu.h +1 -1
@@ -71,7 +71,7 @@#include "fpu_system.h" -#include <asm/sigcontext.h> /* for struct _fpstate */ +#include <uapi/asm/sigcontext.h> /* for struct _fpstate */ #include <asm/math_emu.h> #include <linux/linkage.h>
Signature · 1 line
2.1.4
PATCH 14/15 x86/headers: Remove direct sigcontext32.h uses
In reply to Ingo MolnarNow 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.
--- 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(-)
arch/x86/ia32/ia32_signal.c +1 -1
@@ -26,7 +26,7 @@#include <asm/ptrace.h> #include <asm/ia32_unistd.h> #include <asm/user32.h> -#include <asm/sigcontext32.h> +#include <asm/sigcontext.h> #include <asm/proto.h> #include <asm/vdso.h> #include <asm/sigframe.h>
arch/x86/include/asm/fpu/signal.h +1 -1
@@ -5,7 +5,7 @@#define _ASM_X86_FPU_SIGNAL_H#ifdef CONFIG_X86_64 -# include <asm/sigcontext32.h> +# include <asm/sigcontext.h> # include <asm/user32.h> struct ksignal ; int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
arch/x86/include/asm/ia32.h +1 -1
@@ -10,7 +10,7 @@* 32 bit structures for IA32 support. */ -#include <asm/sigcontext32.h> +#include <asm/sigcontext.h> /* signal.h */
arch/x86/include/uapi/asm/sigcontext32.h +1 -1
@@ -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 <asm/sigcontext.h>
Signature · 1 line
2.1.4
PATCH 13/15 x86/headers: Convert sigcontext_ia32 uses to sigcontext_32
In reply to Ingo MolnarUse the new name in kernel code, and move the old name to the user-space-only legacy section of the UAPI header.
--- 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(-)
arch/x86/ia32/ia32_signal.c +2 -2
@@ -161,7 +161,7 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from) }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;
@@ -263,7 +263,7 @@ asmlinkage long sys32_rt_sigreturn(void)* 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) {
arch/x86/include/asm/ia32.h +1 -1
@@ -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 */ };
arch/x86/include/asm/sigframe.h +1 -1
@@ -21,7 +21,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
arch/x86/include/uapi/asm/sigcontext.h +9 -3
@@ -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 {
arch/x86/kernel/asm-offsets.c +9 -9
@@ -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);
Signature · 1 line
2.1.4
PATCH 12/15 x86/headers: Unify 'struct sigcontext_ia32' and 'struct sigcontext_32'
In reply to Ingo MolnarThe two structures are identical - merge them and keep the legacy name as a define.
--- 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(-)
arch/x86/include/asm/sigframe.h +0 -1
@@ -8,7 +8,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 */
arch/x86/include/uapi/asm/sigcontext.h +2 -0
@@ -223,6 +223,8 @@ struct sigcontext_32 {__u32 cr2; }; +#define sigcontext_ia32 sigcontext_32 +struct sigcontext_64 {__u64 r8;__u64 r9;
arch/x86/include/uapi/asm/sigcontext32.h +0 -26
@@ -5,30 +5,4 @@#include <asm/sigcontext.h> -/* 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 */
Signature · 1 line
2.1.4
Re: [PATCH 15/15] x86/headers: Remove <asm/sigcontext.h>
In reply to Ingo MolnarQuoted 120 lines · Ingo Molnar
Now that all type definitions are in the UAPI header, remove the <
asm/sigcontext.h> wrapper.Cc Andy Lutomirski <[email protected]>Cc Borislav Petkov <[email protected]>Cc Brian Gerst <[email protected]>Cc Denys Vlasenko <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Linus Torvalds <[email protected]>Cc Mikko Rapeli <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Thomas Gleixner <[email protected]>Signed-off-by Ingo Molnar <[email protected]>--- 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 | 6 ------ arch/x86/include/asm/sigframe.h | 2 +- arch/x86/include/asm/signal.h | 2 +- arch/x86/include/uapi/asm/sigcontext32.h | 2 +- arch/x86/math-emu/fpu_emu.h | 2 +- 9 files changed, 8 insertions(+), 14 deletions(-)arch/x86/ia32/ia32_signal.c +1
-1@@ -26,7 +26,7 @@#include <asm/ptrace.h> #include <asm/ia32_unistd.h> #include <asm/user32.h> -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> #include <asm/proto.h> #include <asm/vdso.h> #include <asm/sigframe.h> arch/x86/include/asm/fpu/signal.h +1
-1@@ -5,7 +5,7 @@#define _ASM_X86_FPU_SIGNAL_H#ifdef CONFIG_X86_64 -# include <asm/sigcontext.h> +# include <uapi/asm/sigcontext.h> # include <asm/user32.h> struct ksignal ; int ia32_setup_rt_frame(int sig, struct ksignal *ksig,arch/x86/include/asm/ia32.h +1
-1@@ -10,7 +10,7 @@* 32 bit structures for IA32 support. */ -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> /* signal.h */ arch/x86/include/asm/processor.h +1
-1@@ -11,7 +11,7 @@ struct mm_struct;#include <asm/math_emu.h> #include <asm/segment.h> #include <asm/types.h> -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> #include <asm/current.h> #include <asm/cpufeature.h> #include <asm/page.h> arch/x86/include/asm/sigcontext.h deleted +0
-6@@ -1,6 +0,0 @@ -#ifndef _ASM_X86_SIGCONTEXT_H -#define _ASM_X86_SIGCONTEXT_H - -#include <uapi/asm/sigcontext.h> - -#endif /* _ASM_X86_SIGCONTEXT_H */ arch/x86/include/asm/sigframe.h +1
-1@@ -1,7 +1,7 @@#ifndef _ASM_X86_SIGFRAME_H#define _ASM_X86_SIGFRAME_H -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> #include <asm/siginfo.h> #include <asm/ucontext.h> arch/x86/include/asm/signal.h +1
-1@@ -34,7 +34,7 @@ extern void do_notify_resume(struct pt_regs *, void *, __u32);#define __ARCH_HAS_SA_RESTORER -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> #ifdef __i386__arch/x86/include/uapi/asm/sigcontext32.h +0
-0
arch/x86/include/uapi/asm/sigcontext32.h line 6
Quoted 5 lines
arch/x86/include/uapi/asm/sigcontext32.h +1
-1@@ -3,6 +3,6 @@/* This is a legacy file - all the type definitions are in sigcontext.h: */ -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h>
This needs to be without uapi directory in path.
-Mikko
Quoted 17 lines
arch/x86/include/uapi/asm/sigcontext32.h +0
-0#endif /* _ASM_X86_SIGCONTEXT32_H */ arch/x86/math-emu/fpu_emu.h +1
-1@@ -71,7 +71,7 @@#include "fpu_system.h" -#include <asm/sigcontext.h> /* for struct _fpstate */ +#include <uapi/asm/sigcontext.h> /* for struct _fpstate */ #include <asm/math_emu.h> #include <linux/linkage.h> Signature · 1 line
2.1.4
Re: [PATCH 15/15] x86/headers: Remove <asm/sigcontext.h>
Quoted 6 lines · Mikko Rapeli
Quoted 6 lines
arch/x86/include/uapi/asm/sigcontext32.h +0
-0@@ -3,6 +3,6 @@
Quoted 6 lines
arch/x86/include/uapi/asm/sigcontext32.h line 6
Quoted 4 lines
arch/x86/include/uapi/asm/sigcontext32.h +1
-1/* This is a legacy file - all the type definitions are in sigcontext.h: */ -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> This needs to be without uapi directory in path.
What do you mean?
Thanks,
Ingo
Re: [PATCH 15/15] x86/headers: Remove <asm/sigcontext.h>
Quoted 9 lines · Ingo Molnar
Quoted 6 lines · Mikko Rapeli
Quoted 6 lines
arch/x86/include/uapi/asm/sigcontext32.h +0
-0@@ -3,6 +3,6 @@
Quoted 8 lines
Quoted 6 lines
arch/x86/include/uapi/asm/sigcontext32.h line 6
Quoted 4 lines
arch/x86/include/uapi/asm/sigcontext32.h +1
-1/* This is a legacy file - all the type definitions are in sigcontext.h: */ -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> This needs to be without uapi directory in path.
What do you mean?
There is not uapi in path in userspace so it fails to compile:
cc -Wall -c -nostdinc -I /usr/lib/gcc/i586-linux-gnu/5/include -I /usr/lib/gcc/i 586-linux-gnu/5/include-fixed -I . -I ../headers_compile_test_include -I ../head ers_compile_test_include/i586-linux-gnu ./asm/sigcontext32.c
In file included from ./asm/sigcontext32.c:1:0:./asm/sigcontext32.h:6:33: fatal error: uapi/asm/sigcontext.h: No such file or d irectory
compilation terminated.
FAILED: ./asm/sigcontext32.h
This is the fix:
arch/x86/include/uapi/asm/sigcontext32.h +1 -1
@@ -3,6 +3,6 @@/* This is a legacy file - all the type definitions are in sigcontext.h: */ -#include <uapi/asm/sigcontext.h> +#include <asm/sigcontext.h> #endif /* _ASM_X86_SIGCONTEXT32_H */
-Mikko
Re: [PATCH 15/15] x86/headers: Remove <asm/sigcontext.h>
Quoted 12 lines · Mikko Rapeli
Quoted 11 lines · Ingo Molnar
Quoted 8 lines · Mikko Rapeli
Quoted 8 lines
arch/x86/include/uapi/asm/sigcontext32.h +0
-0@@ -3,6 +3,6 @@/* This is a legacy file - all the type definitions are in sigcontext.h: */
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
arch/x86/include/uapi/asm/sigcontext32.h line 6
Quoted 2 lines
arch/x86/include/uapi/asm/sigcontext32.h +1
-1-#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> This needs to be without uapi directory in path.
What do you mean?
There is not uapi in path in userspace so it fails to compile:
Ok, I see. So it's not common, but I don't think there's an outright prohibition for uapi headers to refer to each other:
arch/hexagon/include/uapi/asm/signal.h:#include <uapi/asm/registers.h> arch/mips/include/uapi/asm/siginfo.h:#include <uapi/asm-generic/siginfo.h> arch/x86/include/uapi/asm/sigcontext32.h:#include <uapi/asm/sigcontext.h>
There are a couple of solutions:
- copy the uapi/ directory if you take the kernel headers as-is
- adapt the headers to the old user-space layout when you import them.
(i.e. do a sed -i 's/<uapi/</' on them).
- create a symbolic link from asm/uapi to asm/ in user-space.
The kernel side solutions are uglier:
- We could create a symbolic link from asm/uapi/sigcontext32.h to asm/uapi/sigcontext.h, although I'm not sure what the policy for that is in the kernel repository - I think it's generally frowned upon.
- We could keep asm/sigcontext.h that includes asm/uapi/sigcontext.h - a poor man's symbolic link.
OTOH the last option isn't all that ugly.
arch/x86/include/uapi/asm/sigcontext32.h line 6
Quoted 10 lines
This is the fix:
arch/x86/include/uapi/asm/sigcontext32.h +1
-1@@ -3,6 +3,6 @@/* This is a legacy file - all the type definitions are in sigcontext.h: */ -#include <uapi/asm/sigcontext.h> +#include <asm/sigcontext.h>
There's no asm/sigcontext.h file anymore if you apply my patches - but we could reintroduce it to make the copy of UAPI headers to user-space work as-is.
Thanks,
Ingo
Re: [PATCH 15/15] x86/headers: Remove <asm/sigcontext.h>
Quoted 42 lines · Ingo Molnar
Quoted 12 lines · Mikko Rapeli
Quoted 11 lines · Ingo Molnar
Quoted 8 lines · Mikko Rapeli
Quoted 8 lines
arch/x86/include/uapi/asm/sigcontext32.h +0
-0@@ -3,6 +3,6 @@/* This is a legacy file - all the type definitions are in sigcontext.h: */ Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
arch/x86/include/uapi/asm/sigcontext32.h line 6
Quoted 2 lines
arch/x86/include/uapi/asm/sigcontext32.h +1
-1-#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> This needs to be without uapi directory in path.
What do you mean?
There is not uapi in path in userspace so it fails to compile:
Ok, I see. So it's not common, but I don't think there's an outright prohibition for uapi headers to refer to each other:
arch/hexagon/include/uapi/asm/signal.h:#include <
uapi/asm/registers.h> arch/mips/include/uapi/asm/siginfo.h:#include <uapi/asm-generic/siginfo.h> arch/x86/include/uapi/asm/sigcontext32.h:#include <uapi/asm/sigcontext.h>There are a couple of solutions:
- copy the uapi/ directory if you take the kernel headers as-is
- adapt the headers to the old user-space layout when you import them.
(i.e. do a sed -i 's/<uapi/</' on them).- create a symbolic link from asm/uapi to asm/ in user-space.
The kernel side solutions are uglier:
Quoted 8 lines
- We could create a symbolic link from
asm/uapi/sigcontext32.htoasm/uapi/sigcontext.h, although I'm not sure what the policy for that is in the kernel repository - I think it's generally frowned upon.- We could keep
asm/sigcontext.hthat includesasm/uapi/sigcontext.h- a poor man's symbolic link.OTOH the last option isn't all that ugly.
Yes, AFAIK it's a common patterns in kernel.
Quoted 6 lines
Quoted 6 lines
This is the fix:
arch/x86/include/uapi/asm/sigcontext32.h +0
-0@@ -3,6 +3,6 @@
Quoted 7 lines
arch/x86/include/uapi/asm/sigcontext32.h line 6
Quoted 4 lines
arch/x86/include/uapi/asm/sigcontext32.h +1
-1/* This is a legacy file - all the type definitions are in sigcontext.h: */ -#include <uapi/asm/sigcontext.h> +#include <asm/sigcontext.h> There's no
asm/sigcontext.hfile anymore if you apply my patches - but we could reintroduce it to make the copy of UAPI headers to user-space work as-is.
Actually there is, in user space :)
$ git show -s --pretty=one HEAD bea04c5252803fa53dcc5366ae32357a0ab07b44 x86/headers: Remove <asm/sigcontext.h> $ make headers_install ... $ ls usr/include/asm/sigcontext.h usr/include/asm/sigcontext.h $ diff -up arch/x86/include/uapi/asm/sigcontext.h usr/include/asm/sigcontext.h --- arch/x86/include/uapi/asm/sigcontext.h 2015-09-06 22:10:54.918303649 +0200 +++ usr/include/asm/sigcontext.h 2015-09-06 22:11:18.214835356 +0200 @@ -1,5 +1,5 @@ -#ifndef _UAPI_ASM_X86_SIGCONTEXT_H -#define _UAPI_ASM_X86_SIGCONTEXT_H +#ifndef _ASM_X86_SIGCONTEXT_H +#define _ASM_X86_SIGCONTEXT_H
/*
* Linux signal context definitions. The sigcontext includes a complex hierarchy of CPU
@@ -14,7 +14,7 @@
* to grow new quirks for quite some time. Promise!
*/
-#include <linux/compiler.h>
+
#include <linux/types.h>
#define FP_XSTATE_MAGIC1 0x46505853U
@@ -271,20 +271,12 @@ struct sigcontext_64 {
/*
* 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
* field names but otherwise the same layout.
*/
-#ifndef __KERNEL__
#define _fpstate_ia32 _fpstate_32
#define sigcontext_ia32 sigcontext_32
@@ -311,7 +303,7 @@ struct sigcontext {
__u32 eflags;
__u32 esp_at_signal;
__u16 ss, __ssh;
- struct _fpstate __user *fpstate;
+ struct _fpstate *fpstate;
__u32 oldmask;
__u32 cr2;
};
@@ -343,13 +335,12 @@ struct sigcontext {
__u64 trapno;
__u64 oldmask;
__u64 cr2;
- struct _fpstate __user *fpstate; /* Zero when no FPU context */
+ struct _fpstate *fpstate; /* Zero when no FPU context */
# ifdef __ILP32__
__u32 __fpstate_pad;
# endif
__u64 reserved1[8];
};
# endif /* __x86_64__ */ -#endif /* !__KERNEL__ */
-#endif /* _UAPI_ASM_X86_SIGCONTEXT_H */
+#endif /* _ASM_X86_SIGCONTEXT_H */
So that's what changes when the file is exported for userspace together with the path from which uapi is removed. So if, like you said kernel side has problems with
arch/x86/include/uapi/asm/sigcontext32.h +1 -1
@@ -3,6 +3,6 @@/* This is a legacy file - all the type definitions are in sigcontext.h: */ -#include <uapi/asm/sigcontext.h> +#include <asm/sigcontext.h> #endif /* _ASM_X86_SIGCONTEXT32_H */
Then a nice solution would be for the kernel side wrapper to do like you said (on top of your changes on master):
arch/x86/include/asm/sigcontext.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef _ASM_X86_SIGCONTEXT_H +#define _ASM_X86_SIGCONTEXT_H + +#include <uapi/asm/sigcontext.h> + +#endif /* _ASM_X86_SIGCONTEXT_H */
And I guess logically this belongs to commit "x86/headers: Remove <asm/sigcontext.h>".
-Mikko
Re: [PATCH 15/15] x86/headers: Remove <asm/sigcontext.h>
Quoted 5 lines · Mikko Rapeli
Quoted 5 lines
Quoted 5 lines
+++
b/arch/x86/include/uapi/asm/sigcontext32.harch/x86/include/uapi/asm/sigcontext32.h +0
-0@@ -3,6 +3,6 @@/* This is a legacy file - all the type definitions are in sigcontext.h: */
Quoted 7 lines
Quoted 5 lines
arch/x86/include/uapi/asm/sigcontext32.h line 5
Quoted 2 lines
arch/x86/include/uapi/asm/sigcontext32.h +1
-1-#include <uapi/asm/sigcontext.h> +#include <asm/sigcontext.h> There's no
asm/sigcontext.hfile anymore if you apply my patches - but we could reintroduce it to make the copy of UAPI headers to user-space work as-is.Actually there is, in user space :)
I mean in the kernel arch/x86/include/asm/sigcontext.h is gone (at least in that series), we use the UAPI header directly.
Quoted 13 lines
Then a nice solution would be for the kernel side wrapper to do like you said (on top of your changes on master):
arch/x86/include/asm/sigcontext.h new file +6
-0@@ -0,0 +1,6 @@ +#ifndef _ASM_X86_SIGCONTEXT_H +#define _ASM_X86_SIGCONTEXT_H + +#include <uapi/asm/sigcontext.h> + +#endif /* _ASM_X86_SIGCONTEXT_H */
Quoted 2 lines
And I guess logically this belongs to commit "x86/headers: Remove <
asm/sigcontext.h>".
Yeah, will do this, plus some comments explaining that this is really just so that we can keep the UAPI side compatible with a 'straight user-space copying of the header files'.
This won't affect the kernel as we won't include asm/sigcontext.h directly. (And even if we do, there's no harm done.)
Agreed?
Thanks,
Ingo
Re: [PATCH 15/15] x86/headers: Remove <asm/sigcontext.h>
Quoted 39 lines · Ingo Molnar
Quoted 5 lines · Mikko Rapeli
Quoted 5 lines
Quoted 5 lines
+++
b/arch/x86/include/uapi/asm/sigcontext32.harch/x86/include/uapi/asm/sigcontext32.h +0
-0@@ -3,6 +3,6 @@/* This is a legacy file - all the type definitions are in sigcontext.h: */ Quoted 7 lines
Quoted 5 lines
arch/x86/include/uapi/asm/sigcontext32.h line 5
Quoted 2 lines
arch/x86/include/uapi/asm/sigcontext32.h +1
-1-#include <uapi/asm/sigcontext.h> +#include <asm/sigcontext.h> There's no
asm/sigcontext.hfile anymore if you apply my patches - but we could reintroduce it to make the copy of UAPI headers to user-space work as-is.Actually there is, in user space :)
I mean in the kernel
arch/x86/include/asm/sigcontext.his gone (at least in that series), we use the UAPI header directly.Quoted 13 lines
Then a nice solution would be for the kernel side wrapper to do like you said (on top of your changes on master):
arch/x86/include/asm/sigcontext.h new file +6
-0@@ -0,0 +1,6 @@ +#ifndef _ASM_X86_SIGCONTEXT_H +#define _ASM_X86_SIGCONTEXT_H + +#include <uapi/asm/sigcontext.h> + +#endif /* _ASM_X86_SIGCONTEXT_H */ Quoted 2 lines
And I guess logically this belongs to commit "x86/headers: Remove <
asm/sigcontext.h>".Yeah, will do this, plus some comments explaining that this is really just so that we can keep the UAPI side compatible with a 'straight user-space copying of the header files'.
Quoted 4 lines
This won't affect the kernel as we won't include
asm/sigcontext.hdirectly. (And even if we do, there's no harm done.)Agreed?
Perfect. Thanks for takling this issue!
-Mikko
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Fix (old) header file dependency bug in uapi/asm/sigcontext32.h
In reply to Ingo Molnarx86/headers: Fix (old) header file dependency bug in uapi/asm/sigcontext32.h
Commit-ID: b76cb6c869b966b4c991251136b45b3e1babc4e8 Gitweb: http://git.kernel.org/tip/b76cb6c869b966b4c991251136b45b3e1babc4e8 Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:29 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:55 +0200
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 <asm/sigcontext32.h>
Due to undefined 'struct __fpx_sw_bytes' which is defined in asm/sigcontext.h.
The following header order works:
#include <asm/sigcontext.h> #include <asm/sigcontext32.h>
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.
--- arch/x86/include/uapi/asm/sigcontext32.h | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/include/uapi/asm/sigcontext32.h +2 -0
@@ -3,6 +3,8 @@#include <linux/types.h> +#include <asm/sigcontext.h> +/* signal context for 32bit programs. */ #define X86_FXSR_MAGIC 0x0000
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Clean up uapi/asm/sigcontext32.h
In reply to Ingo Molnarx86/headers: Clean up uapi/asm/sigcontext32.h
Commit-ID: c3f4986fb0774bb13feb4bade1276bed2ba8a3db Gitweb: http://git.kernel.org/tip/c3f4986fb0774bb13feb4bade1276bed2ba8a3db Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:30 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:55 +0200
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.
--- arch/x86/include/uapi/asm/sigcontext32.h | 110 ++++++++++++++++--------------- 1 file changed, 58 insertions(+), 52 deletions(-)
arch/x86/include/uapi/asm/sigcontext32.h +58 -52
@@ -1,79 +1,85 @@#ifndef _ASM_X86_SIGCONTEXT32_H#define _ASM_X86_SIGCONTEXT32_H +/* Signal context definitions for compat 32-bit programs: */ +#include <linux/types.h> #include <asm/sigcontext.h> -/* 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 */
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Clean up and better document uapi/ asm/sigcontext.h
In reply to Ingo Molnarx86/headers: Clean up and better document uapi/asm/sigcontext.h
Commit-ID: cbf5f4fbf435e871e59d49653d555266b8796efc Gitweb: http://git.kernel.org/tip/cbf5f4fbf435e871e59d49653d555266b8796efc Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:31 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:55 +0200
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.
--- arch/x86/include/uapi/asm/sigcontext.h | 330 ++++++++++++++++++--------------- 1 file changed, 182 insertions(+), 148 deletions(-)
arch/x86/include/uapi/asm/sigcontext.h +182 -148
@@ -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 <linux/compiler.h> #include <linux/types.h> -#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 <[email protected]>, 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 */
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Separate out legacy user-space structure definitions
In reply to Ingo Molnarx86/headers: Separate out legacy user-space structure definitions
Commit-ID: 128f8257a17a47b9a40f550cc2f36458cd8c07b0 Gitweb: http://git.kernel.org/tip/128f8257a17a47b9a40f550cc2f36458cd8c07b0 Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:32 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:56 +0200
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.
--- arch/x86/include/uapi/asm/sigcontext.h | 119 ++++++++++++++++----------------- 1 file changed, 59 insertions(+), 60 deletions(-)
arch/x86/include/uapi/asm/sigcontext.h +59 -60
@@ -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 */
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Use ABI types consistently in sigcontext*.h
In reply to Ingo Molnarx86/headers: Use ABI types consistently in sigcontext*.h
Commit-ID: 3f623a5b27c150451387e358774131780dbd2407 Gitweb: http://git.kernel.org/tip/3f623a5b27c150451387e358774131780dbd2407 Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:33 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:56 +0200
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.
--- arch/x86/include/uapi/asm/sigcontext.h | 82 ++++++++++++++++---------------- arch/x86/include/uapi/asm/sigcontext32.h | 58 +++++++++++----------- 2 files changed, 70 insertions(+), 70 deletions(-)
arch/x86/include/uapi/asm/sigcontext.h +41 -41
@@ -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 0x0000struct _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 {
arch/x86/include/uapi/asm/sigcontext32.h +29 -29
80 lines not on this page · raw message
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Unify register type definitions between 32-bit compat and i386
In reply to Ingo Molnarx86/headers: Unify register type definitions between 32-bit compat and i386
Commit-ID: 337a167d1a5b2704414679d1a993220a4613ec13 Gitweb: http://git.kernel.org/tip/337a167d1a5b2704414679d1a993220a4613ec13 Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:34 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:56 +0200
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.
--- arch/x86/include/uapi/asm/sigcontext.h | 3 ++- arch/x86/include/uapi/asm/sigcontext32.h | 22 ---------------------- 2 files changed, 2 insertions(+), 23 deletions(-)
arch/x86/include/uapi/asm/sigcontext.h +2 -1
@@ -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;
arch/x86/include/uapi/asm/sigcontext32.h +0 -22
@@ -3,30 +3,8 @@/* Signal context definitions for compat 32-bit programs: */ -#include <linux/types.h> -#include <asm/sigcontext.h> -/* 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: */
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Convert uses of _fpstate_ia32 to _fpstate_32
In reply to Ingo Molnarx86/headers: Convert uses of _fpstate_ia32 to _fpstate_32
Commit-ID: 86e9fc3a0ecdd3c21a938e325daf462ca1724f68 Gitweb: http://git.kernel.org/tip/86e9fc3a0ecdd3c21a938e325daf462ca1724f68 Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:36 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:57 +0200
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.
--- 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(-)
arch/x86/ia32/ia32_signal.c +1 -1
@@ -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 ;
arch/x86/include/asm/sigframe.h +1 -1
@@ -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 */
arch/x86/include/uapi/asm/sigcontext.h +3 -2
@@ -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;
arch/x86/include/uapi/asm/sigcontext32.h +1 -1
@@ -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; };
arch/x86/kernel/fpu/signal.c +2 -2
@@ -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. */
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Clean up the kernel' s struct sigcontext types to be ABI-clean
In reply to Ingo Molnarx86/headers: Clean up the kernel's struct sigcontext types to be ABI-clean
Commit-ID: 2d057c69e743bfb88f1259ddbf1b1160bdd850e5 Gitweb: http://git.kernel.org/tip/2d057c69e743bfb88f1259ddbf1b1160bdd850e5 Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:37 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:57 +0200
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.
--- arch/x86/include/asm/sigcontext.h | 104 +++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 52 deletions(-)
arch/x86/include/asm/sigcontext.h +52 -52
@@ -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 */
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Move the 'struct sigcontext' definitions into the UAPI header
In reply to Ingo Molnarx86/headers: Move the 'struct sigcontext' definitions into the UAPI header
Commit-ID: f2c609bca0b6526810fa22330ce4d173cc023ef8 Gitweb: http://git.kernel.org/tip/f2c609bca0b6526810fa22330ce4d173cc023ef8 Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:38 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:58 +0200
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'.
--- arch/x86/include/asm/sigcontext.h | 73 ------------------------------ arch/x86/include/uapi/asm/sigcontext.h | 83 ++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 73 deletions(-)
arch/x86/include/asm/sigcontext.h +0 -73
@@ -3,77 +3,4 @@#include <uapi/asm/sigcontext.h> -#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 */
arch/x86/include/uapi/asm/sigcontext.h +83 -0
89 lines not on this page · raw message
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Make sigcontext pointers bit independent
In reply to Ingo Molnarx86/headers: Make sigcontext pointers bit independent
Commit-ID: 530e5c827182a7a5322c55276b0617fd06874c24 Gitweb: http://git.kernel.org/tip/530e5c827182a7a5322c55276b0617fd06874c24 Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:39 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:58 +0200
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.
--- arch/x86/include/uapi/asm/sigcontext.h | 4 ++-- arch/x86/kernel/signal.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/include/uapi/asm/sigcontext.h +2 -2
@@ -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 ]; };
arch/x86/kernel/signal.c +3 -1
@@ -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 ));
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Unify 'struct sigcontext_ia32' and 'struct sigcontext_32'
In reply to Ingo Molnarx86/headers: Unify 'struct sigcontext_ia32' and 'struct sigcontext_32'
Commit-ID: db1e031401c6abab983919e882916d028f3b385e Gitweb: http://git.kernel.org/tip/db1e031401c6abab983919e882916d028f3b385e Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:40 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:58 +0200
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.
--- 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(-)
arch/x86/include/asm/sigframe.h +0 -1
@@ -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 */
arch/x86/include/uapi/asm/sigcontext.h +2 -0
@@ -223,6 +223,8 @@ struct sigcontext_32 {__u32 cr2; }; +#define sigcontext_ia32 sigcontext_32 +struct sigcontext_64 {__u64 r8;__u64 r9;
arch/x86/include/uapi/asm/sigcontext32.h +0 -26
@@ -5,30 +5,4 @@#include <asm/sigcontext.h> -/* 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 */
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Remove direct sigcontext32.h uses
In reply to Ingo Molnarx86/headers: Remove direct sigcontext32.h uses
Commit-ID: 711531f4f3cb881f4598cddfcc36663101dee411 Gitweb: http://git.kernel.org/tip/711531f4f3cb881f4598cddfcc36663101dee411 Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:42 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:59 +0200
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.
--- 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(-)
arch/x86/ia32/ia32_signal.c +1 -1
@@ -26,7 +26,7 @@#include <asm/ptrace.h> #include <asm/ia32_unistd.h> #include <asm/user32.h> -#include <asm/sigcontext32.h> +#include <asm/sigcontext.h> #include <asm/proto.h> #include <asm/vdso.h> #include <asm/sigframe.h>
arch/x86/include/asm/fpu/signal.h +1 -1
@@ -5,7 +5,7 @@#define _ASM_X86_FPU_SIGNAL_H#ifdef CONFIG_X86_64 -# include <asm/sigcontext32.h> +# include <asm/sigcontext.h> # include <asm/user32.h> struct ksignal ; int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
arch/x86/include/asm/ia32.h +1 -1
@@ -10,7 +10,7 @@* 32 bit structures for IA32 support. */ -#include <asm/sigcontext32.h> +#include <asm/sigcontext.h> /* signal.h */
arch/x86/include/uapi/asm/sigcontext32.h +1 -1
@@ -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 <asm/sigcontext.h>
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Remove <asm/sigcontext.h> references on the kernel side
In reply to Ingo Molnarx86/headers: Remove <asm/sigcontext.h> references on the kernel side
Commit-ID: decb4c41159e1511197f2964da758fa7f2eeb741 Gitweb: http://git.kernel.org/tip/decb4c41159e1511197f2964da758fa7f2eeb741 Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:43 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:06:05 +0200
x86/headers: Remove <asm/sigcontext.h> references on the kernel side
Now that all type definitions are in the UAPI header, include it directly, instead of through <asm/sigcontext.h>.
[ We still keep asm/sigcontext.h, so that uapi/asm/sigcontext32.h
can include <asm/sigcontext.h>. ]
--- 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(-)
arch/x86/ia32/ia32_signal.c +1 -1
@@ -26,7 +26,7 @@#include <asm/ptrace.h> #include <asm/ia32_unistd.h> #include <asm/user32.h> -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> #include <asm/proto.h> #include <asm/vdso.h> #include <asm/sigframe.h>
arch/x86/include/asm/fpu/signal.h +1 -1
@@ -5,7 +5,7 @@#define _ASM_X86_FPU_SIGNAL_H#ifdef CONFIG_X86_64 -# include <asm/sigcontext.h> +# include <uapi/asm/sigcontext.h> # include <asm/user32.h> struct ksignal ; int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
arch/x86/include/asm/ia32.h +1 -1
@@ -10,7 +10,7 @@* 32 bit structures for IA32 support. */ -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> /* signal.h */
arch/x86/include/asm/processor.h +1 -1
@@ -11,7 +11,7 @@ struct vm86;#include <asm/math_emu.h> #include <asm/segment.h> #include <asm/types.h> -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> #include <asm/current.h> #include <asm/cpufeature.h> #include <asm/page.h>
arch/x86/include/asm/sigcontext.h +2 -0
@@ -1,6 +1,8 @@#ifndef _ASM_X86_SIGCONTEXT_H#define _ASM_X86_SIGCONTEXT_H +/* This is a legacy header - all kernel code includes <uapi/asm/sigcontext.h> directly. */ +#include <uapi/asm/sigcontext.h> #endif /* _ASM_X86_SIGCONTEXT_H */
arch/x86/include/asm/sigframe.h +1 -1
@@ -1,7 +1,7 @@#ifndef _ASM_X86_SIGFRAME_H#define _ASM_X86_SIGFRAME_H -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> #include <asm/siginfo.h> #include <asm/ucontext.h> #include <linux/compat.h>
arch/x86/include/asm/signal.h +1 -1
@@ -34,7 +34,7 @@ extern void do_signal(struct pt_regs *regs);#define __ARCH_HAS_SA_RESTORER -#include <asm/sigcontext.h> +#include <uapi/asm/sigcontext.h> #ifdef __i386__
arch/x86/math-emu/fpu_emu.h +1 -1
@@ -71,7 +71,7 @@#include "fpu_system.h" -#include <asm/sigcontext.h> /* for struct _fpstate */ +#include <uapi/asm/sigcontext.h> /* for struct _fpstate */ #include <asm/math_emu.h> #include <linux/linkage.h>
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Convert sigcontext_ia32 uses to sigcontext_32
In reply to Ingo Molnarx86/headers: Convert sigcontext_ia32 uses to sigcontext_32
Commit-ID: 8fcb346b910e860d2525457742ae984c4ddc64b5 Gitweb: http://git.kernel.org/tip/8fcb346b910e860d2525457742ae984c4ddc64b5 Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:41 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:59 +0200
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.
--- 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(-)
arch/x86/ia32/ia32_signal.c +2 -2
@@ -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) {
arch/x86/include/asm/ia32.h +1 -1
@@ -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 */ };
arch/x86/include/asm/sigframe.h +1 -1
@@ -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
arch/x86/include/uapi/asm/sigcontext.h +9 -3
@@ -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 {
arch/x86/kernel/asm-offsets.c +9 -9
@@ -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);
tip-bot for Ingo Molnar
merge bot[tip:x86/headers] x86/headers: Unify 'struct _fpstate_ia32' and i386 struct _fpstate
In reply to Ingo Molnarx86/headers: Unify 'struct _fpstate_ia32' and i386 struct _fpstate
Commit-ID: 7bb0dc2222779b4cbf1ec9ad651e500e62fa5b11 Gitweb: http://git.kernel.org/tip/7bb0dc2222779b4cbf1ec9ad651e500e62fa5b11 Author: Ingo Molnar <[email protected]> AuthorDate: Sat, 5 Sep 2015 09:32:35 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 8 Sep 2015 10:03:57 +0200
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.
--- 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(-)
arch/x86/include/asm/sigframe.h +0 -1
@@ -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 */
arch/x86/include/uapi/asm/sigcontext.h +17 -9
@@ -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_32struct _header {__u64 xfeatures;
arch/x86/include/uapi/asm/sigcontext32.h +0 -29
@@ -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;
Mikko Rapeli
Tested-byRe: [tip:x86/headers] x86/headers: Remove <asm/sigcontext.h> references on the kernel side
In reply to tip-bot for Ingo MolnarHi,
Tested these changes on top of my uapi headers fix branch and they compile without problems in userspace and thus fix the original issue.
Also abi-compliance-checker reports that these changes don't break anything in i386 ABI (details at [2]):
"Test Info
Library Name kernel
Version #1 headers_test_v04
Version #2 headers_test_v04+test_ingo_x86_cleanup
CPU Type x86
GCC Version 5.2.1
Subject Binary Compatibility
Test Results
Total Header Files 767
Total Shared Libraries 0 (not analyzed)
Total Symbols / Types 62 / 67
Verdict Compatible"
or API:
"Test Info
Library Name kernel
Version #1 headers_test_v04
Version #2 headers_test_v04+test_ingo_x86_cleanup
CPU Type x86
GCC Version 5.2.1
Subject Source Compatibility
Test Results
Total Header Files 767
Total Shared Libraries 0 (not analyzed)
Total Symbols / Types 96 / 101
Verdict Compatible"
While abi-compliance-checker is still quite broken with kernel header files[3] addition of new constants was correctly detected:
"Other Changes in Constants (3)sigcontext.h
[−] _fpstate
Change Effect
1 The constant _fpstate with value _fpstate_32 has been added. No effect.
[−] _fpstate_ia32
Change Effect
1 The constant _fpstate_ia32 with value _fpstate_32 has been added. No effect.
[−] sigcontext_ia32
Change Effect
1 The constant sigcontext_ia32 with value sigcontext_32 has been added. No effect."
So for 32 bit userspace side
-Mikko
[1] http://lvc.github.io/abi-compliance-checker/
[2] API/ABI check results
https://mcfrisk.kapsi.fi/temp/headers_test_v04_to_headers_test_v04+test_ingo_x86_cleanup/
[3] abi checker still has some issues with kernel headers:
https://mcfrisk.kapsi.fi/temp/headers_test_v04+test_ingo_x86_cleanup/log.txt
Re: [tip:x86/headers] x86/headers: Clean up and better document uapi/ asm/sigcontext.h
In reply to tip-bot for Ingo MolnarQuoted 7 lines · tip-bot for Ingo Molnar
+++
b/arch/x86/include/uapi/asm/sigcontext.h(quoted diff) +2
-0@@ -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
Review line 15
Quoted 10 lines
(quoted diff) +10
-0+ * 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! + */
I don't mind the occasional long line, but this seems gratuitous.
--- arch/x86/include/uapi/asm/sigcontext.h | 57 ++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 26 deletions(-)
arch/x86/include/uapi/asm/sigcontext.h +31 -26
@@ -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 <linux/compiler.h>
@@ -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;
tip-bot for Peter Zijlstra
merge bot[tip:x86/headers] x86/headers: Clean up too long lines
x86/headers: Clean up too long lines
Commit-ID: 0e2815de552a638295cfdaf0865e575573bf263e Gitweb: http://git.kernel.org/tip/0e2815de552a638295cfdaf0865e575573bf263e Author: Peter Zijlstra <[email protected]> AuthorDate: Wed, 9 Sep 2015 09:12:44 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 14 Sep 2015 11:09:33 +0200
x86/headers: Clean up too long lines
--- arch/x86/include/uapi/asm/sigcontext.h | 57 ++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 26 deletions(-)
arch/x86/include/uapi/asm/sigcontext.h +31 -26
@@ -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 <linux/compiler.h>
@@ -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;