x86: signal: move ia32 func declarations into arch/x86/kernel/signal.c
PATCH 1/6 x86: signal: move ia32 func declarations into arch/x86/kernel/signal.c
From: Hiroshi Shimamoto <[email protected]>
Impact: cleanup
Move declarations of ia32_setup_rt_frame() and ia32_setup_frame() into arch/x86/kernel/signal.c.
---
This is for future use of sigframe.h.
arch/x86/kernel/sigframe.h | 5 ----- arch/x86/kernel/signal.c | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-)
arch/x86/kernel/sigframe.h +0 -5
@@ -34,9 +34,4 @@ struct rt_sigframe {struct siginfo info; /* fp state follows here */ }; - -int ia32_setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info, -sigset_t *set,struct pt_regs *regs); -int ia32_setup_frame (int sig,struct k_sigaction *ka, -sigset_t *set,struct pt_regs *regs);#endif
arch/x86/kernel/signal.c +5 -0
@@ -671,6 +671,11 @@ static int signr_convert(int sig)#define is_ia32 0#endif /* CONFIG_IA32_EMULATION */ +int ia32_setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info, +sigset_t *set,struct pt_regs *regs); +int ia32_setup_frame (int sig,struct k_sigaction *ka, +sigset_t *set,struct pt_regs *regs); +#endif /* CONFIG_X86_32 */ static int
Signature · 1 line
1.6.0.4
PATCH 2/6 x86: signal: rename sigframe and rt_sigframe on 32-bit
From: Hiroshi Shimamoto <[email protected]>
Impact: prepare to move sigframe.h
On 32-bit, rename struct sigrame to struct sigframe_ia32, struct rt_sigframe to struct rt_sigframe_ia32 and several structures.
And add helper macros to access the above data in arch/x86/kernel/signal.c.
--- arch/x86/kernel/sigframe.h | 28 +++++++++++++++++----------- 1 files changed, 17 insertions(+), 11 deletions(-)
arch/x86/kernel/sigframe.h +17 -11
@@ -1,8 +1,14 @@ #ifdef CONFIG_X86_32 -struct sigframe { - char __user *pretcode; +#define sigframe_ia32 sigframe +#define rt_sigframe_ia32 rt_sigframe +#define sigcontext_ia32 sigcontext +#define _fpstate_ia32 _fpstate +#define ucontext_ia32 ucontext + +struct sigframe_ia32 { + u32 pretcode; int sig; - struct sigcontext sc; + struct sigcontext_ia32 sc; /* * fpstate is unused. fpstate is moved/allocated after * retcode[] below. This movement allows to have the FP state and the
@@ -11,27 +17,27 @@ struct sigframe {* the offset of extramask[] in the sigframe and thus prevent any * legacy application accessing/modifying it. */ -struct _fpstate fpstate_unused; +struct _fpstate_ia32 fpstate_unused;unsigned long extramask[_NSIG_WORDS-1 ];char retcode[8 ]; /* fp state follows here */ }; -struct rt_sigframe { -char __user *pretcode; +struct rt_sigframe_ia32 { +u32 pretcode;int sig; -struct siginfo __user *pinfo; -void __user *puc; +u32 pinfo; +u32 puc;struct siginfo info; -struct ucontext uc; +struct ucontext_ia32 uc;char retcode[8 ];/* fp state follows here */ }; -#else +#else /* !CONFIG_X86_32 */ struct rt_sigframe {char __user *pretcode;struct ucontext uc;struct siginfo info;/* fp state follows here */ }; -#endif +#endif /* CONFIG_X86_32 */
Signature · 1 line
1.6.0.4
PATCH 3/6 x86: signal: move sigframe.h to arch/x86/include/asm
In reply to Hiroshi ShimamotoFrom: Hiroshi Shimamoto <[email protected]>
Impact: move header file
Move arch/x86/kernel/sigframe.h to arch/x86/include/asm/sigframe.h. It will be used in arch/x86/ia32/ia32_signal.c.
--- arch/x86/include/asm/sigframe.h | 43 ++++++++++++++++++++++++++++++++++++++ arch/x86/kernel/asm-offsets_32.c | 2 +- arch/x86/kernel/sigframe.h | 43 -------------------------------------- arch/x86/kernel/signal.c | 2 +- 4 files changed, 45 insertions(+), 45 deletions(-) create mode 100644 arch/x86/include/asm/sigframe.h delete mode 100644 arch/x86/kernel/sigframe.h
arch/x86/include/asm/sigframe.h new file +43 -0
@@ -0,0 +1,43 @@ +#ifdef CONFIG_X86_32 +#define sigframe_ia32 sigframe +#define rt_sigframe_ia32 rt_sigframe +#define sigcontext_ia32 sigcontext +#define _fpstate_ia32 _fpstate +#define ucontext_ia32 ucontext + +struct sigframe_ia32 { +u32 pretcode; +int sig; +struct sigcontext_ia32 sc; +/* +* fpstate is unused. fpstate is moved/allocated after +* retcode[] below. This movement allows to have the FP state and the +* future state extensions (xsave) stay together. +* And at the same time retaining the unused fpstate, prevents changing +* the offset of extramask[] in the sigframe and thus prevent any +* legacy application accessing/modifying it. +*/ +struct _fpstate_ia32 fpstate_unused; +unsigned long extramask[_NSIG_WORDS-1 ]; +char retcode[8 ]; +/* fp state follows here */ +}; + +struct rt_sigframe_ia32 { +u32 pretcode; +int sig; +u32 pinfo; +u32 puc; +struct siginfo info; +struct ucontext_ia32 uc; +char retcode[8 ]; +/* fp state follows here */ +}; +#else /* !CONFIG_X86_32 */ +struct rt_sigframe { +char __user *pretcode; +struct ucontext uc; +struct siginfo info; +/* fp state follows here */ +}; +#endif /* CONFIG_X86_32 */
arch/x86/kernel/asm-offsets_32.c +1 -1
@@ -11,7 +11,7 @@#include <linux/suspend.h> #include <linux/kbuild.h> #include <asm/ucontext.h> -#include "sigframe.h" +#include <asm/sigframe.h> #include <asm/pgtable.h> #include <asm/fixmap.h> #include <asm/processor.h>
arch/x86/kernel/sigframe.h deleted +0 -43
43 lines not on this page · raw message
arch/x86/kernel/signal.c +1 -1
@@ -35,7 +35,7 @@#include <asm/syscall.h> #include <asm/syscalls.h> -#include "sigframe.h" +#include <asm/sigframe.h> #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
Signature · 1 line
1.6.0.4
PATCH 4/6 x86: signal: prepare to include from ia32_signal.c
In reply to Hiroshi ShimamotoFrom: Hiroshi Shimamoto <[email protected]>
Impact: prepare to use from ia32_signal.c
Make struct sigframe_ia32 and rt_sigframe_ia32 visible to ia32_signal.c.
--- arch/x86/include/asm/sigframe.h | 22 ++++++++++++++++++++-- 1 files changed, 20 insertions(+), 2 deletions(-)
arch/x86/include/asm/sigframe.h +20 -2
@@ -4,7 +4,15 @@#define sigcontext_ia32 sigcontext#define _fpstate_ia32 _fpstate#define ucontext_ia32 ucontext +#else /* !CONFIG_X86_32 */ + +#ifdef CONFIG_IA32_EMULATION +#include <asm/ia32.h> +#endif /* CONFIG_IA32_EMULATION */ + +#endif /* CONFIG_X86_32 */ +#if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) struct sigframe_ia32 { u32 pretcode; int sig;
@@ -18,7 +26,11 @@ struct sigframe_ia32 {* legacy application accessing/modifying it. */ struct _fpstate_ia32 fpstate_unused; +#ifdef CONFIG_IA32_EMULATION +unsigned int extramask[_COMPAT_NSIG_WORDS-1 ]; +#else /* !CONFIG_IA32_EMULATION */ unsigned long extramask[_NSIG_WORDS-1 ]; +#endif /* CONFIG_IA32_EMULATION */ char retcode[8 ];/* fp state follows here */ };
@@ -28,16 +40,22 @@ struct rt_sigframe_ia32 {int sig;u32 pinfo;u32 puc; +#ifdef CONFIG_IA32_EMULATION +compat_siginfo_t info; +#else /* !CONFIG_IA32_EMULATION */ struct siginfo info; +#endif /* CONFIG_IA32_EMULATION */ struct ucontext_ia32 uc;char retcode[8 ]; /* fp state follows here */ }; -#else /* !CONFIG_X86_32 */ +#endif /* defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) */ + +#ifdef CONFIG_X86_64 struct rt_sigframe {char __user *pretcode;struct ucontext uc;struct siginfo info;/* fp state follows here */ }; -#endif /* CONFIG_X86_32 */ +#endif /* CONFIG_X86_64 */
Signature · 1 line
1.6.0.4
PATCH 5/6 x86: ia32_signal: rename struct sigframe and rt_sigframe
In reply to Hiroshi ShimamotoFrom: Hiroshi Shimamoto <[email protected]>
Impact: prepare to include sigframe.h
Rename struct sigframe to struct sigframe_ia32 and struct rt_sigframe to struct rt_sigframe_ia32.
--- arch/x86/ia32/ia32_signal.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
arch/x86/ia32/ia32_signal.c +7 -7
@@ -174,7 +174,7 @@ asmlinkage long sys32_sigaltstack(const stack_ia32_t __user *uss_ptr,* Do a signal return; undo the signal stack. */ -struct sigframe +struct sigframe_ia32 {u32 pretcode;int sig;
@@ -185,7 +185,7 @@ struct sigframe/* fp state follows here */ }; -struct rt_sigframe +struct rt_sigframe_ia32 {u32 pretcode;int sig;
@@ -271,7 +271,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,asmlinkage long sys32_sigreturn (struct pt_regs *regs) { -struct sigframe __user *frame = (struct sigframe __user *)(regs->sp-8 ); +struct sigframe_ia32 __user *frame = (struct sigframe_ia32 __user *)(regs->sp-8 );sigset_t set;unsigned int ax;
@@ -301,12 +301,12 @@ badframe:asmlinkage long sys32_rt_sigreturn (struct pt_regs *regs) { -struct rt_sigframe __user *frame; +struct rt_sigframe_ia32 __user *frame;sigset_t set;unsigned int ax;struct pt_regs tregs; - frame = (struct rt_sigframe __user *)(regs->sp -4 ); + frame = (struct rt_sigframe_ia32 __user *)(regs->sp -4 );if (!access_ok (VERIFY_READ , frame,sizeof (*frame))) goto badframe;
@@ -418,7 +418,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,int ia32_setup_frame (int sig,struct k_sigaction *ka,compat_sigset_t *set,struct pt_regs *regs) { -struct sigframe __user *frame; +struct sigframe_ia32 __user *frame;void __user *restorer;int err =0 ;void __user *fpstate =NULL ;
@@ -497,7 +497,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,int ia32_setup_rt_frame (int sig,struct k_sigaction *ka,siginfo_t *info,compat_sigset_t *set,struct pt_regs *regs) { -struct rt_sigframe __user *frame; +struct rt_sigframe_ia32 __user *frame;void __user *restorer;int err =0 ;void __user *fpstate =NULL ;
Signature · 1 line
1.6.0.4
PATCH 6/6 x86: ia32_signal: use sigframe.h
In reply to Hiroshi ShimamotoFrom: Hiroshi Shimamoto <[email protected]>
Impact: cleanup
Use arch/x86/include/asm/sigframe.h instead of making redundant structure.
--- arch/x86/ia32/ia32_signal.c | 26 ++------------------------ 1 files changed, 2 insertions(+), 24 deletions(-)
arch/x86/ia32/ia32_signal.c +2 -24
@@ -32,6 +32,8 @@#include <asm/proto.h> #include <asm/vdso.h> +#include <asm/sigframe.h> +#define DEBUG_SIG 0#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
@@ -173,30 +175,6 @@ asmlinkage long sys32_sigaltstack(const stack_ia32_t __user *uss_ptr,/* * Do a signal return; undo the signal stack. */ - -struct sigframe_ia32 -{ -u32 pretcode; -int sig; -struct sigcontext_ia32 sc; -struct _fpstate_ia32 fpstate_unused;/* look at kernel/sigframe.h */ -unsigned int extramask[_COMPAT_NSIG_WORDS-1 ]; -char retcode[8 ]; -/* fp state follows here */ -}; - -struct rt_sigframe_ia32 -{ -u32 pretcode; -int sig; -u32 pinfo; -u32 puc; -compat_siginfo_t info; -struct ucontext_ia32 uc; -char retcode[8 ]; -/* fp state follows here */ -}; -#define COPY (x) { \ err |= __get_user(regs->x, &sc->x); \ }
Signature · 1 line
1.6.0.4
Ingo Molnar
AppliedI have applied your patches to tip/x86/signal:
d98f9d8: x86: ia32_signal: use sigframe.h
3b0d29e: x86: ia32_signal: rename struct sigframe and rt_sigframe
c85c2ff: x86: signal: prepare to include from ia32_signal.c 41af86f: x86: signal: move sigframe.h to arch/x86/include/asm
a5c56eb: x86: signal: rename sigframe and rt_sigframe on 32-bit
f522376: x86: signal: move ia32 func declarations into arch/x86/kernel/signal.c
they are nice cleanups! Thanks,
Ingo
PATCH 1/1 x86: sigframe.h: add guard macro
From: Hiroshi Shimamoto <[email protected]>
Impact: cleanup
Add missing guard macro _ASM_X86_SIGFRAME_H.
---
I forgot include guard:)
arch/x86/include/asm/sigframe.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
arch/x86/include/asm/sigframe.h +5 -0
@@ -1,3 +1,6 @@ +#ifndef _ASM_X86_SIGFRAME_H +#define _ASM_X86_SIGFRAME_H +#ifdef CONFIG_X86_32 #define sigframe_ia32 sigframe#define rt_sigframe_ia32 rt_sigframe
@@ -59,3 +62,5 @@ struct rt_sigframe {/* fp state follows here */ };#endif /* CONFIG_X86_64 */ + +#endif /* _ASM_X86_SIGFRAME_H */
Signature · 1 line
1.6.0.4
Ingo Molnar
AppliedRe: [PATCH] x86: sigframe.h: add guard macro
Quoted 4 lines · Hiroshi Shimamoto
From: Hiroshi Shimamoto <[email protected]>
Impact: cleanup
Quoted 8 lines
Add missing guard macro
_ASM_X86_SIGFRAME_H.Signed-off-by Hiroshi Shimamoto <[email protected]>---
I forgot include guard:)arch/x86/include/asm/sigframe.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
applied, thanks!
It didnt matter in practice yet, because all uses of sigframe.h were single-instance and were done in flat .c files, not in .h files:
./arch/x86/kernel/asm-offsets_32.c:#include "sigframe.h" ./arch/x86/kernel/signal_32.c:#include "sigframe.h" ./arch/x86/kernel/signal_64.c:#include "sigframe.h"
./arch/x86/ia32/ia32_signal.c: struct _fpstate_ia32 fpstate_unused; /* look at kernel/sigframe.h */
but indeed it's better to have this fixed - just in case we put sigframe.h into an include file.
Ingo