2008-12-18 02:47:28

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [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.

Signed-off-by: Hiroshi Shimamoto <[email protected]>
---
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(-)

diff --git a/arch/x86/kernel/sigframe.h b/arch/x86/kernel/sigframe.h
index cc673aa..6dd7e2b 100644
--- a/arch/x86/kernel/sigframe.h
+++ b/arch/x86/kernel/sigframe.h
@@ -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
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 605592a..78202a1 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -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
--
1.6.0.4


2008-12-18 02:50:10

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [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.

Signed-off-by: Hiroshi Shimamoto <[email protected]>
---
arch/x86/kernel/sigframe.h | 28 +++++++++++++++++-----------
1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kernel/sigframe.h b/arch/x86/kernel/sigframe.h
index 6dd7e2b..6718ed0 100644
--- a/arch/x86/kernel/sigframe.h
+++ b/arch/x86/kernel/sigframe.h
@@ -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 */
--
1.6.0.4

2008-12-18 02:51:23

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH 4/6] x86: signal: prepare to include from ia32_signal.c

From: 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.

Signed-off-by: Hiroshi Shimamoto <[email protected]>
---
arch/x86/include/asm/sigframe.h | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/sigframe.h b/arch/x86/include/asm/sigframe.h
index 6718ed0..491a087 100644
--- a/arch/x86/include/asm/sigframe.h
+++ b/arch/x86/include/asm/sigframe.h
@@ -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 */
--
1.6.0.4

2008-12-18 02:50:52

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH 3/6] x86: signal: move sigframe.h to arch/x86/include/asm

From: 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.

Signed-off-by: Hiroshi Shimamoto <[email protected]>
---
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

diff --git a/arch/x86/include/asm/sigframe.h b/arch/x86/include/asm/sigframe.h
new file mode 100644
index 0000000..6718ed0
--- /dev/null
+++ b/arch/x86/include/asm/sigframe.h
@@ -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 */
diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c
index 6649d09..ee4df08 100644
--- a/arch/x86/kernel/asm-offsets_32.c
+++ b/arch/x86/kernel/asm-offsets_32.c
@@ -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>
diff --git a/arch/x86/kernel/sigframe.h b/arch/x86/kernel/sigframe.h
deleted file mode 100644
index 6718ed0..0000000
--- a/arch/x86/kernel/sigframe.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#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 */
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 78202a1..4fa5243 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -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)))

--
1.6.0.4

2008-12-18 02:52:56

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH 6/6] x86: ia32_signal: use sigframe.h

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Use arch/x86/include/asm/sigframe.h instead of making redundant structure.

Signed-off-by: Hiroshi Shimamoto <[email protected]>
---
arch/x86/ia32/ia32_signal.c | 26 ++------------------------
1 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index 54e4d93..32c549f 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -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); \
}
--
1.6.0.4

2008-12-18 02:52:00

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH 5/6] x86: ia32_signal: rename struct sigframe and rt_sigframe

From: 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.

Signed-off-by: Hiroshi Shimamoto <[email protected]>
---
arch/x86/ia32/ia32_signal.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index ee1ad4a..54e4d93 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -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;
--
1.6.0.4

2008-12-18 10:30:00

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 1/6] x86: signal: move ia32 func declarations into arch/x86/kernel/signal.c


I 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

2008-12-18 17:18:50

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH] x86: sigframe.h: add guard macro

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

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(-)

diff --git a/arch/x86/include/asm/sigframe.h b/arch/x86/include/asm/sigframe.h
index 491a087..3bd0f42 100644
--- a/arch/x86/include/asm/sigframe.h
+++ b/arch/x86/include/asm/sigframe.h
@@ -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 */
--
1.6.0.4

2008-12-18 21:06:48

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH] x86: sigframe.h: add guard macro


* Hiroshi Shimamoto <[email protected]> wrote:

> From: Hiroshi Shimamoto <[email protected]>
>
> Impact: cleanup
>
> 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