Commit 4302d506 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'x86-headers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 sigcontext header cleanups from Ingo Molnar:
 "This series reorganizes and cleans up various aspects of the main
  sigcontext UAPI headers, such as unifying the data structures and
  updating/adding lots of comments to explain all the ABI details and
  quirks.  The headers can now also be built in user-space standalone"

* 'x86-headers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/headers: Clean up too long lines
  x86/headers: Remove <asm/sigcontext.h> references on the kernel side
  x86/headers: Remove direct sigcontext32.h uses
  x86/headers: Convert sigcontext_ia32 uses to sigcontext_32
  x86/headers: Unify 'struct sigcontext_ia32' and 'struct sigcontext_32'
  x86/headers: Make sigcontext pointers bit independent
  x86/headers: Move the 'struct sigcontext' definitions into the UAPI header
  x86/headers: Clean up the kernel's struct sigcontext types to be ABI-clean
  x86/headers: Convert uses of _fpstate_ia32 to _fpstate_32
  x86/headers: Unify 'struct _fpstate_ia32' and i386 struct _fpstate
  x86/headers: Unify register type definitions between 32-bit compat and i386
  x86/headers: Use ABI types consistently in sigcontext*.h
  x86/headers: Separate out legacy user-space structure definitions
  x86/headers: Clean up and better document uapi/asm/sigcontext.h
  x86/headers: Clean up uapi/asm/sigcontext32.h
  x86/headers: Fix (old) header file dependency bug in uapi/asm/sigcontext32.h
parents ce4d72fa 0e2815de
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <asm/ia32_unistd.h> #include <asm/ia32_unistd.h>
#include <asm/user32.h> #include <asm/user32.h>
#include <asm/sigcontext32.h> #include <uapi/asm/sigcontext.h>
#include <asm/proto.h> #include <asm/proto.h>
#include <asm/vdso.h> #include <asm/vdso.h>
#include <asm/sigframe.h> #include <asm/sigframe.h>
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
} }
static int ia32_restore_sigcontext(struct pt_regs *regs, static int ia32_restore_sigcontext(struct pt_regs *regs,
struct sigcontext_ia32 __user *sc) struct sigcontext_32 __user *sc)
{ {
unsigned int tmpflags, err = 0; unsigned int tmpflags, err = 0;
void __user *buf; void __user *buf;
...@@ -170,7 +170,7 @@ asmlinkage long sys32_rt_sigreturn(void) ...@@ -170,7 +170,7 @@ asmlinkage long sys32_rt_sigreturn(void)
* Set up a signal frame. * 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, void __user *fpstate,
struct pt_regs *regs, unsigned int mask) struct pt_regs *regs, unsigned int mask)
{ {
...@@ -234,7 +234,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, ...@@ -234,7 +234,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
unsigned long fx_aligned, math_size; unsigned long fx_aligned, math_size;
sp = fpu__alloc_mathframe(sp, 1, &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, if (copy_fpstate_to_sigframe(*fpstate, (void __user *)fx_aligned,
math_size) < 0) math_size) < 0)
return (void __user *) -1L; return (void __user *) -1L;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define _ASM_X86_FPU_SIGNAL_H #define _ASM_X86_FPU_SIGNAL_H
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
# include <asm/sigcontext32.h> # include <uapi/asm/sigcontext.h>
# include <asm/user32.h> # include <asm/user32.h>
struct ksignal; struct ksignal;
int ia32_setup_rt_frame(int sig, struct ksignal *ksig, int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* 32 bit structures for IA32 support. * 32 bit structures for IA32 support.
*/ */
#include <asm/sigcontext32.h> #include <uapi/asm/sigcontext.h>
/* signal.h */ /* signal.h */
...@@ -18,7 +18,7 @@ struct ucontext_ia32 { ...@@ -18,7 +18,7 @@ struct ucontext_ia32 {
unsigned int uc_flags; unsigned int uc_flags;
unsigned int uc_link; unsigned int uc_link;
compat_stack_t uc_stack; compat_stack_t uc_stack;
struct sigcontext_ia32 uc_mcontext; struct sigcontext_32 uc_mcontext;
compat_sigset_t uc_sigmask; /* mask last for extensibility */ compat_sigset_t uc_sigmask; /* mask last for extensibility */
}; };
......
...@@ -11,7 +11,7 @@ struct vm86; ...@@ -11,7 +11,7 @@ struct vm86;
#include <asm/math_emu.h> #include <asm/math_emu.h>
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/types.h> #include <asm/types.h>
#include <asm/sigcontext.h> #include <uapi/asm/sigcontext.h>
#include <asm/current.h> #include <asm/current.h>
#include <asm/cpufeature.h> #include <asm/cpufeature.h>
#include <asm/page.h> #include <asm/page.h>
......
#ifndef _ASM_X86_SIGCONTEXT_H #ifndef _ASM_X86_SIGCONTEXT_H
#define _ASM_X86_SIGCONTEXT_H #define _ASM_X86_SIGCONTEXT_H
#include <uapi/asm/sigcontext.h> /* This is a legacy header - all kernel code includes <uapi/asm/sigcontext.h> directly. */
#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;
/* #include <uapi/asm/sigcontext.h>
* 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 */
unsigned long oldmask;
unsigned long cr2;
};
#else /* __i386__ */
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;
/*
* 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 */
unsigned long reserved1[8];
};
#endif /* !__i386__ */
#endif /* _ASM_X86_SIGCONTEXT_H */ #endif /* _ASM_X86_SIGCONTEXT_H */
#ifndef _ASM_X86_SIGFRAME_H #ifndef _ASM_X86_SIGFRAME_H
#define _ASM_X86_SIGFRAME_H #define _ASM_X86_SIGFRAME_H
#include <asm/sigcontext.h> #include <uapi/asm/sigcontext.h>
#include <asm/siginfo.h> #include <asm/siginfo.h>
#include <asm/ucontext.h> #include <asm/ucontext.h>
#include <linux/compat.h> #include <linux/compat.h>
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
#define sigframe_ia32 sigframe #define sigframe_ia32 sigframe
#define rt_sigframe_ia32 rt_sigframe #define rt_sigframe_ia32 rt_sigframe
#define sigcontext_ia32 sigcontext
#define _fpstate_ia32 _fpstate
#define ucontext_ia32 ucontext #define ucontext_ia32 ucontext
#else /* !CONFIG_X86_32 */ #else /* !CONFIG_X86_32 */
...@@ -24,7 +22,7 @@ ...@@ -24,7 +22,7 @@
struct sigframe_ia32 { struct sigframe_ia32 {
u32 pretcode; u32 pretcode;
int sig; int sig;
struct sigcontext_ia32 sc; struct sigcontext_32 sc;
/* /*
* fpstate is unused. fpstate is moved/allocated after * fpstate is unused. fpstate is moved/allocated after
* retcode[] below. This movement allows to have the FP state and the * retcode[] below. This movement allows to have the FP state and the
...@@ -33,7 +31,7 @@ struct sigframe_ia32 { ...@@ -33,7 +31,7 @@ struct sigframe_ia32 {
* the offset of extramask[] in the sigframe and thus prevent any * the offset of extramask[] in the sigframe and thus prevent any
* legacy application accessing/modifying it. * legacy application accessing/modifying it.
*/ */
struct _fpstate_ia32 fpstate_unused; struct _fpstate_32 fpstate_unused;
#ifdef CONFIG_IA32_EMULATION #ifdef CONFIG_IA32_EMULATION
unsigned int extramask[_COMPAT_NSIG_WORDS-1]; unsigned int extramask[_COMPAT_NSIG_WORDS-1];
#else /* !CONFIG_IA32_EMULATION */ #else /* !CONFIG_IA32_EMULATION */
......
...@@ -34,7 +34,7 @@ extern void do_signal(struct pt_regs *regs); ...@@ -34,7 +34,7 @@ extern void do_signal(struct pt_regs *regs);
#define __ARCH_HAS_SA_RESTORER #define __ARCH_HAS_SA_RESTORER
#include <asm/sigcontext.h> #include <uapi/asm/sigcontext.h>
#ifdef __i386__ #ifdef __i386__
......
#ifndef _UAPI_ASM_X86_SIGCONTEXT_H #ifndef _UAPI_ASM_X86_SIGCONTEXT_H
#define _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/compiler.h>
#include <linux/types.h> #include <linux/types.h>
#define FP_XSTATE_MAGIC1 0x46505853U #define FP_XSTATE_MAGIC1 0x46505853U
#define FP_XSTATE_MAGIC2 0x46505845U #define FP_XSTATE_MAGIC2 0x46505845U
#define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2) #define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2)
/* /*
* bytes 464..511 in the current 512byte layout of fxsave/fxrstor frame * Bytes 464..511 in the current 512-byte layout of the FXSAVE/FXRSTOR frame
* are reserved for SW usage. On cpu's supporting xsave/xrstor, these bytes * are reserved for SW usage. On CPUs supporting XSAVE/XRSTOR, these bytes are
* are used to extended the fpstate pointer in the sigcontext, which now * used to extend the fpstate pointer in the sigcontext, which now includes the
* includes the extended state information along with fpstate information. * 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
* FP_XSTATE_MAGIC2 so that you can sanity check your size calculations.)
* *
* Presence of FP_XSTATE_MAGIC1 at the beginning of this SW reserved * This extended area typically grows with newer CPUs that have larger and
* area and FP_XSTATE_MAGIC2 at the end of memory layout * larger XSAVE areas.
* (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.
*/ */
struct _fpx_sw_bytes { struct _fpx_sw_bytes {
__u32 magic1; /* FP_XSTATE_MAGIC1 */ /*
__u32 extended_size; /* total size of the layout referred by * If set to FP_XSTATE_MAGIC1 then this is an xstate context.
* fpstate pointer in the sigcontext. * 0 if a legacy frame.
*/ */
__u64 xfeatures; __u32 magic1;
/* feature bit mask (including fp/sse/extended
* state) that is present in the memory /*
* layout. * Total size of the fpstate area:
*/ *
__u32 xstate_size; /* actual xsave state size, based on the * - if magic1 == 0 then it's sizeof(struct _fpstate)
* features saved in the layout. * - if magic1 == FP_XSTATE_MAGIC1 then it's sizeof(struct _xstate)
* 'extended_size' will be greater than * plus extensions (if any)
* 'xstate_size'. */
*/ __u32 extended_size;
__u32 padding[7]; /* for future use. */
/*
* 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 * The first part of "struct _fpstate" is just the normal i387 hardware setup,
* Gareth Hughes <gareth@valinux.com>, May 2000 * 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 * The FPU state data structure has had to grow to accommodate the extended FPU
* extended FPU state required by the Streaming SIMD Extensions. * state required by the Streaming SIMD Extensions. There is no documented
* There is no documented standard to accomplish this at the moment. * standard to accomplish this at the moment.
*/ */
/* 10-byte legacy floating point register: */
struct _fpreg { struct _fpreg {
unsigned short significand[4]; __u16 significand[4];
unsigned short exponent; __u16 exponent;
}; };
/* 16-byte floating point register: */
struct _fpxreg { struct _fpxreg {
unsigned short significand[4]; __u16 significand[4];
unsigned short exponent; __u16 exponent;
unsigned short padding[3]; __u16 padding[3];
}; };
/* 16-byte XMM register: */
struct _xmmreg { struct _xmmreg {
unsigned long element[4]; __u32 element[4];
}; };
struct _fpstate { #define X86_FXSR_MAGIC 0x0000
/* Regular FPU environment */
unsigned long cw; /*
unsigned long sw; * The 32-bit FPU frame:
unsigned long tag; */
unsigned long ipoff; struct _fpstate_32 {
unsigned long cssel; /* Legacy FPU environment: */
unsigned long dataoff; __u32 cw;
unsigned long datasel; __u32 sw;
struct _fpreg _st[8]; __u32 tag;
unsigned short status; __u32 ipoff;
unsigned short magic; /* 0xffff = regular FPU data only */ __u32 cssel;
__u32 dataoff;
__u32 datasel;
struct _fpreg _st[8];
__u16 status;
__u16 magic; /* 0xffff: regular FPU data only */
/* 0x0000: FXSR FPU data */
/* FXSR FPU environment */ /* FXSR FPU environment */
unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */ __u32 _fxsr_env[6]; /* FXSR FPU env is ignored */
unsigned long mxcsr; __u32 mxcsr;
unsigned long reserved; __u32 reserved;
struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */ struct _fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */
struct _xmmreg _xmm[8]; struct _xmmreg _xmm[8]; /* First 8 XMM registers */
unsigned long padding1[44]; union {
__u32 padding1[44]; /* Second 8 XMM registers plus padding */
__u32 padding[44]; /* Alias name for old user-space */
};
union { union {
unsigned long padding2[12]; __u32 padding2[12];
struct _fpx_sw_bytes sw_reserved; /* represents the extended struct _fpx_sw_bytes sw_reserved; /* Potential extended state is encoded here */
* state info */
}; };
}; };
#define X86_FXSR_MAGIC 0x0000
#ifndef __KERNEL__
/* /*
* User-space might still rely on the old definition: * 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
* '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 sigcontext { struct _fpstate_64 {
unsigned short gs, __gsh; __u16 cwd;
unsigned short fs, __fsh; __u16 swd;
unsigned short es, __esh; /* Note this is not the same as the 32-bit/x87/FSAVE twd: */
unsigned short ds, __dsh; __u16 twd;
unsigned long edi; __u16 fop;
unsigned long esi; __u64 rip;
unsigned long ebp; __u64 rdp;
unsigned long esp; __u32 mxcsr;
unsigned long ebx; __u32 mxcsr_mask;
unsigned long edx; __u32 st_space[32]; /* 8x FP registers, 16 bytes each */
unsigned long ecx; __u32 xmm_space[64]; /* 16x XMM registers, 16 bytes each */
unsigned long eax; __u32 reserved2[12];
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 /* __i386__ */
/* FXSAVE frame */
/* Note: reserved1/2 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];
union { union {
__u32 reserved3[12]; __u32 reserved3[12];
struct _fpx_sw_bytes sw_reserved; /* represents the extended struct _fpx_sw_bytes sw_reserved; /* Potential extended state is encoded here */
* state information */
}; };
}; };
#ifndef __KERNEL__ #ifdef __i386__
/* # define _fpstate _fpstate_32
* User-space might still rely on the old definition: #else
*/ # define _fpstate _fpstate_64
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 #endif
__u64 reserved1[8];
};
#endif /* !__KERNEL__ */
#endif /* !__i386__ */
struct _header { struct _header {
__u64 xfeatures; __u64 xfeatures;
__u64 reserved1[2]; __u64 reserved1[2];
__u64 reserved2[5]; __u64 reserved2[5];
}; };
struct _ymmh_state { struct _ymmh_state {
/* 16 * 16 bytes for each YMMH-reg */ /* 16x YMM registers, 16 bytes each: */
__u32 ymmh_space[64]; __u32 ymmh_space[64];
}; };
/* /*
* Extended state pointed by the fpstate pointer in the sigcontext. * Extended state pointed to by sigcontext::fpstate.
* In addition to the fpstate, information encoded in the xstate_hdr *
* indicates the presence of other extended state information * In addition to the fpstate, information encoded in _xstate::xstate_hdr
* supported by the processor and OS. * indicates the presence of other extended state information supported
* by the CPU and kernel:
*/ */
struct _xstate { struct _xstate {
struct _fpstate fpstate; struct _fpstate fpstate;
struct _header xstate_hdr; struct _header xstate_hdr;
struct _ymmh_state ymmh; struct _ymmh_state ymmh;
/* new processor state extensions go here */ /* New processor state extensions go here: */
};
/*
* The 32-bit signal frame:
*/
struct sigcontext_32 {
__u16 gs, __gsh;
__u16 fs, __fsh;
__u16 es, __esh;
__u16 ds, __dsh;
__u32 di;
__u32 si;
__u32 bp;
__u32 sp;
__u32 bx;
__u32 dx;
__u32 cx;
__u32 ax;
__u32 trapno;
__u32 err;
__u32 ip;
__u16 cs, __csh;
__u32 flags;
__u32 sp_at_signal;
__u16 ss, __ssh;
/*
* fpstate is really (struct _fpstate *) or (struct _xstate *)
* depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved
* bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end
* of extended memory layout. See comments at the definition of
* (struct _fpx_sw_bytes)
*/
__u32 fpstate; /* Zero when no FPU/extended context */
__u32 oldmask;
__u32 cr2;
};
/*
* The 64-bit signal frame:
*/
struct sigcontext_64 {
__u64 r8;
__u64 r9;
__u64 r10;
__u64 r11;
__u64 r12;
__u64 r13;
__u64 r14;
__u64 r15;
__u64 di;
__u64 si;
__u64 bp;
__u64 bx;
__u64 dx;
__u64 ax;
__u64 cx;
__u64 sp;
__u64 ip;
__u64 flags;
__u16 cs;
__u16 gs;
__u16 fs;
__u16 __pad0;
__u64 err;
__u64 trapno;
__u64 oldmask;
__u64 cr2;
/*
* fpstate is really (struct _fpstate *) or (struct _xstate *)
* depending on the FP_XSTATE_MAGIC1 encoded in the SW reserved
* bytes of (struct _fpstate) and FP_XSTATE_MAGIC2 present at the end
* of extended memory layout. See comments at the definition of
* (struct _fpx_sw_bytes)
*/
__u64 fpstate; /* Zero when no FPU/extended context */
__u64 reserved1[8];
};
/*
* Create the real 'struct sigcontext' type:
*/
#ifdef __KERNEL__
# ifdef __i386__
# define sigcontext sigcontext_32
# else
# define sigcontext sigcontext_64
# endif
#endif
/*
* The old user-space sigcontext definition, just in case user-space still
* relies on it. The kernel definition (in asm/sigcontext.h) has unified
* field names but otherwise the same layout.
*/
#ifndef __KERNEL__
#define _fpstate_ia32 _fpstate_32
#define sigcontext_ia32 sigcontext_32
# ifdef __i386__
struct sigcontext {
__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;
__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 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 /* __x86_64__ */
#endif /* !__KERNEL__ */
#endif /* _UAPI_ASM_X86_SIGCONTEXT_H */ #endif /* _UAPI_ASM_X86_SIGCONTEXT_H */
#ifndef _ASM_X86_SIGCONTEXT32_H #ifndef _ASM_X86_SIGCONTEXT32_H
#define _ASM_X86_SIGCONTEXT32_H #define _ASM_X86_SIGCONTEXT32_H
#include <linux/types.h> /* This is a legacy file - all the type definitions are in sigcontext.h: */
/* signal context for 32bit programs. */ #include <asm/sigcontext.h>
#define X86_FXSR_MAGIC 0x0000
struct _fpreg {
unsigned short significand[4];
unsigned short exponent;
};
struct _fpxreg {
unsigned short significand[4];
unsigned short exponent;
unsigned short padding[3];
};
struct _xmmreg {
__u32 element[4];
};
/* 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 */
/* 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];
union {
__u32 padding2[12];
struct _fpx_sw_bytes sw_reserved;
};
};
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;
};
#endif /* _ASM_X86_SIGCONTEXT32_H */ #endif /* _ASM_X86_SIGCONTEXT32_H */
...@@ -43,15 +43,15 @@ void common(void) { ...@@ -43,15 +43,15 @@ void common(void) {
#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
BLANK(); BLANK();
OFFSET(IA32_SIGCONTEXT_ax, sigcontext_ia32, ax); OFFSET(IA32_SIGCONTEXT_ax, sigcontext_32, ax);
OFFSET(IA32_SIGCONTEXT_bx, sigcontext_ia32, bx); OFFSET(IA32_SIGCONTEXT_bx, sigcontext_32, bx);
OFFSET(IA32_SIGCONTEXT_cx, sigcontext_ia32, cx); OFFSET(IA32_SIGCONTEXT_cx, sigcontext_32, cx);
OFFSET(IA32_SIGCONTEXT_dx, sigcontext_ia32, dx); OFFSET(IA32_SIGCONTEXT_dx, sigcontext_32, dx);
OFFSET(IA32_SIGCONTEXT_si, sigcontext_ia32, si); OFFSET(IA32_SIGCONTEXT_si, sigcontext_32, si);
OFFSET(IA32_SIGCONTEXT_di, sigcontext_ia32, di); OFFSET(IA32_SIGCONTEXT_di, sigcontext_32, di);
OFFSET(IA32_SIGCONTEXT_bp, sigcontext_ia32, bp); OFFSET(IA32_SIGCONTEXT_bp, sigcontext_32, bp);
OFFSET(IA32_SIGCONTEXT_sp, sigcontext_ia32, sp); OFFSET(IA32_SIGCONTEXT_sp, sigcontext_32, sp);
OFFSET(IA32_SIGCONTEXT_ip, sigcontext_ia32, ip); OFFSET(IA32_SIGCONTEXT_ip, sigcontext_32, ip);
BLANK(); BLANK();
OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext); OFFSET(IA32_RT_SIGFRAME_sigcontext, rt_sigframe_ia32, uc.uc_mcontext);
......
...@@ -56,7 +56,7 @@ static inline int save_fsave_header(struct task_struct *tsk, void __user *buf) ...@@ -56,7 +56,7 @@ static inline int save_fsave_header(struct task_struct *tsk, void __user *buf)
if (use_fxsr()) { if (use_fxsr()) {
struct xregs_state *xsave = &tsk->thread.fpu.state.xsave; struct xregs_state *xsave = &tsk->thread.fpu.state.xsave;
struct user_i387_ia32_struct env; struct user_i387_ia32_struct env;
struct _fpstate_ia32 __user *fp = buf; struct _fpstate_32 __user *fp = buf;
convert_from_fxsr(&env, tsk); convert_from_fxsr(&env, tsk);
...@@ -165,7 +165,7 @@ int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size) ...@@ -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)) if (!static_cpu_has(X86_FEATURE_FPU))
return fpregs_soft_get(current, NULL, 0, return fpregs_soft_get(current, NULL, 0,
sizeof(struct user_i387_ia32_struct), NULL, sizeof(struct user_i387_ia32_struct), NULL,
(struct _fpstate_ia32 __user *) buf) ? -1 : 1; (struct _fpstate_32 __user *) buf) ? -1 : 1;
if (fpregs_active()) { if (fpregs_active()) {
/* Save the live register state to the user directly. */ /* Save the live register state to the user directly. */
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
{ {
unsigned long buf_val;
void __user *buf; void __user *buf;
unsigned int tmpflags; unsigned int tmpflags;
unsigned int err = 0; unsigned int err = 0;
...@@ -107,7 +108,8 @@ int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) ...@@ -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->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
regs->orig_ax = -1; /* disable syscall checks */ 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); } get_user_catch(err);
err |= fpu__restore_sig(buf, config_enabled(CONFIG_X86_32)); err |= fpu__restore_sig(buf, config_enabled(CONFIG_X86_32));
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
#include "fpu_system.h" #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 <asm/math_emu.h>
#include <linux/linkage.h> #include <linux/linkage.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment