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__
......
This diff is collapsed.
#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