Skip to contentSkip to conversation

x86_64: ia32_signal.c: use macro instead of immediate

PATCH In review Hiroshi Shimamoto 3 participants 7 messages Jul 14, 2008 – Jul 18, 2008 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86_64: ia32_signal.c: use macro instead of immediate

From: Hiroshi Shimamoto <[email protected]>

Make and use macro FIX_EFLAGS, instead of immediate value 0x40DD5 in ia32_restore_sigcontext().

---
 arch/x86/ia32/ia32_signal.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
arch/x86/ia32/ia32_signal.c +12 -1
index cb3856a..7cf50cb 100644
@@ -36,6 +36,17 @@
 
 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
 
+#define __FIX_EFLAGS	(X86_EFLAGS_AC | X86_EFLAGS_OF | \
+			 X86_EFLAGS_DF | X86_EFLAGS_TF | X86_EFLAGS_SF | \
+			 X86_EFLAGS_ZF | X86_EFLAGS_AF | X86_EFLAGS_PF | \
+			 X86_EFLAGS_CF)
+
+#ifdef CONFIG_X86_32
+# define FIX_EFLAGS	(__FIX_EFLAGS | X86_EFLAGS_RF)
+#else
+# define FIX_EFLAGS	__FIX_EFLAGS
+#endif
+
 asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset);
 void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
 
@@ -248,7 +259,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
 	regs->ss |= 3;
 
 	err |= __get_user(tmpflags, &sc->flags);
-	regs->flags = (regs->flags & ~0x40DD5) | (tmpflags & 0x40DD5);
+	regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
 	/* disable syscall checks */
 	regs->orig_ax = -1;
 
Signature · 1 line
1.5.4.1
#1 lore raw

arch/x86/ia32/ia32_signal.c line 49

Quoted 12 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Make and use macro FIX_EFLAGS, instead of immediate value 0x40DD5 in ia32_restore_sigcontext().

arch/x86/ia32/ia32_signal.c +7 -0
+
+#ifdef CONFIG_X86_32
+# define FIX_EFLAGS	(__FIX_EFLAGS | X86_EFLAGS_RF)
+#else
+# define FIX_EFLAGS	__FIX_EFLAGS
+#endif
+

Where did this come from? First of all, this is in a 64-bit-only file, so CONFIG_X86_32 will never be set; second of all, it seems a bit fishy that these should be different.

-hpa

#2 lore raw
Quoted 6 lines · H. Peter Anvin
Quoted 5 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Make and use macro FIX_EFLAGS, instead of immediate value 0x40DD5 in ia32_restore_sigcontext().

Quoted 11 lines

arch/x86/ia32/ia32_signal.c line 49

Quoted 7 lines
arch/x86/ia32/ia32_signal.c +7 -0
+
+#ifdef CONFIG_X86_32
+# define FIX_EFLAGS	(__FIX_EFLAGS | X86_EFLAGS_RF)
+#else
+# define FIX_EFLAGS	__FIX_EFLAGS
+#endif
+

Where did this come from? First of all, this is in a 64-bit-only file, so CONFIG_X86_32 will never be set; second of all, it seems a bit fishy that these should be different.

It came from arch/x86/kernel/signal_64.c. (And signal_32.c has the same one.) And yes, CONFIG_X86_32 is not set, I compiled and compare the results, the macro was replaced by 0x40dd5, no RF.
I guess, someone made it same on signal_32.c and signal_64.c.

Thanks,
Hiroshi Shimamoto

#3 lore raw
Quoted 16 lines · Hiroshi Shimamoto
Quoted 6 lines · H. Peter Anvin
Quoted 5 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Make and use macro FIX_EFLAGS, instead of immediate value 0x40DD5 in ia32_restore_sigcontext().

Quoted 8 lines

arch/x86/ia32/ia32_signal.c line 49

Quoted 7 lines
arch/x86/ia32/ia32_signal.c +7 -0
+
+#ifdef CONFIG_X86_32
+# define FIX_EFLAGS	(__FIX_EFLAGS | X86_EFLAGS_RF)
+#else
+# define FIX_EFLAGS	__FIX_EFLAGS
+#endif
+

Where did this come from? First of all, this is in a 64-bit-only file, so CONFIG_X86_32 will never be set; second of all, it seems a bit fishy that these should be different.

Quoted 5 lines

It came from arch/x86/kernel/signal_64.c. (And signal_32.c has the same one.) And yes, CONFIG_X86_32 is not set, I compiled and compare the results, the macro was replaced by 0x40dd5, no RF.
I guess, someone made it same on signal_32.c and signal_64.c.

Yes, it's working toward unification (and ia32signal.c is obviously also a candidate for unification.) However, please make that a separate patch.

-hpa

#4 lore raw
Quoted 18 lines · H. Peter Anvin
Quoted 17 lines · Hiroshi Shimamoto
Quoted 16 lines · H. Peter Anvin

arch/x86/ia32/ia32_signal.c line 49

Quoted 12 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Make and use macro FIX_EFLAGS, instead of immediate value 0x40DD5 in ia32_restore_sigcontext().

arch/x86/ia32/ia32_signal.c +7 -0
+
+#ifdef CONFIG_X86_32
+# define FIX_EFLAGS	(__FIX_EFLAGS | X86_EFLAGS_RF)
+#else
+# define FIX_EFLAGS	__FIX_EFLAGS
+#endif
+

Where did this come from? First of all, this is in a 64-bit-only file, so CONFIG_X86_32 will never be set; second of all, it seems a bit fishy that these should be different.

Quoted 8 lines
Quoted 5 lines

It came from arch/x86/kernel/signal_64.c. (And signal_32.c has the same one.) And yes, CONFIG_X86_32 is not set, I compiled and compare the results, the macro was replaced by 0x40dd5, no RF.
I guess, someone made it same on signal_32.c and signal_64.c.

Yes, it's working toward unification (and ia32signal.c is obviously also a candidate for unification.) However, please make that a separate patch.

OK. Will do.

Thanks,
Hiroshi Shimamoto

#5 lore raw

PATCH 1/1 x86_64: ia32_signal.c: use macro instead of immediate

In reply to H. Peter Anvin

From: Hiroshi Shimamoto <[email protected]>

Make and use macro FIX_EFLAGS, instead of immediate value 0x40DD5 in ia32_restore_sigcontext().

---
 arch/x86/ia32/ia32_signal.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
arch/x86/ia32/ia32_signal.c +6 -1
index cb3856a..dc9b9b9 100644
@@ -36,6 +36,11 @@
 
 #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
 
+#define FIX_EFLAGS	(X86_EFLAGS_AC | X86_EFLAGS_OF | \
+			 X86_EFLAGS_DF | X86_EFLAGS_TF | X86_EFLAGS_SF | \
+			 X86_EFLAGS_ZF | X86_EFLAGS_AF | X86_EFLAGS_PF | \
+			 X86_EFLAGS_CF)
+
 asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset);
 void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
 
@@ -248,7 +253,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
 	regs->ss |= 3;
 
 	err |= __get_user(tmpflags, &sc->flags);
-	regs->flags = (regs->flags & ~0x40DD5) | (tmpflags & 0x40DD5);
+	regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
 	/* disable syscall checks */
 	regs->orig_ax = -1;
 
Signature · 1 line
1.5.4.1
Applied
#6 lore raw
Quoted 4 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Make and use macro FIX_EFLAGS, instead of immediate value 0x40DD5 in ia32_restore_sigcontext().

applied to tip/x86/cleanups - thanks!

Ingo