Skip to contentSkip to conversation

x86: ia32_signal: cleanup macro COPY

PATCH Superseded Hiroshi Shimamoto 4 participants 22 messages Nov 15, 2008 – Nov 18, 2008 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 x86: ia32_signal: cleanup macro COPY

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

No need to use temporary variable in this case.

---
 arch/x86/ia32/ia32_signal.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/ia32/ia32_signal.c +2 -4
index e886907..a28790a 100644
@@ -197,10 +197,8 @@ struct rt_sigframe
 	/* fp state follows here */
 };
 
-#define COPY(x)		{ 		\
-	unsigned int reg;		\
-	err |= __get_user(reg, &sc->x);	\
-	regs->x = reg;			\
+#define COPY(x)			{		\
+	err |= __get_user(regs->x, &sc->x);	\
 }
 
 #define RELOAD_SEG(seg,mask)						\
Signature · 1 line
1.5.6
#1 lore raw

PATCH 2/5 x86: ia32_signal: introduce COPY_SEG_STRICT

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Introduce COPY_SEG_STRICT for ia32_restore_sigcontext().

---
 arch/x86/ia32/ia32_signal.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
arch/x86/ia32/ia32_signal.c +8 -4
index a28790a..f74178e 100644
@@ -201,6 +201,12 @@ struct rt_sigframe
 	err |= __get_user(regs->x, &sc->x);	\
 }
 
+#define COPY_SEG_STRICT(seg)	{			\
+		unsigned short tmp;			\
+		err |= __get_user(tmp, &sc->seg);	\
+		regs->seg = tmp | 3;			\
+}
+
 #define RELOAD_SEG(seg,mask)						\
 	{ unsigned int cur;						\
 	  unsigned short pre;						\
@@ -246,10 +252,8 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
 	COPY(dx); COPY(cx); COPY(ip);
 	/* Don't touch extended registers */
 
-	err |= __get_user(regs->cs, &sc->cs);
-	regs->cs |= 3;
-	err |= __get_user(regs->ss, &sc->ss);
-	regs->ss |= 3;
+	COPY_SEG_STRICT(cs);
+	COPY_SEG_STRICT(ss);
 
 	err |= __get_user(tmpflags, &sc->flags);
 	regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
Signature · 1 line
1.5.6
#2 lore raw

Re: [PATCH 2/5] x86: ia32_signal: introduce COPY_SEG_STRICT

Quoted 16 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Introduce COPY_SEG_STRICT for ia32_restore_sigcontext().

---
 arch/x86/ia32/ia32_signal.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
arch/x86/ia32/ia32_signal.c +0 -0
index a28790a..f74178e 100644

arch/x86/ia32/ia32_signal.c struct rt_sigframe · line 209

Quoted 9 lines
arch/x86/ia32/ia32_signal.c +6 -0
@@ -201,6 +201,12 @@ struct rt_sigframe
       err |= __get_user(regs->x, &sc->x);     \
 }
 
+#define COPY_SEG_STRICT(seg)   {                       \
+               unsigned short tmp;                     \
+               err |= __get_user(tmp, &sc->seg);       \
+               regs->seg = tmp | 3;                    \
+}
+

Since your first patch is to kill the temporary variables, then why do you introduce a temporary variable here? It can be avoided like it was.

Can you explain the reason? :)

#3 lore raw

Re: [PATCH 2/5] x86: ia32_signal: introduce COPY_SEG_STRICT

Quoted 31 lines · Américo Wang
Quoted 16 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Introduce COPY_SEG_STRICT for ia32_restore_sigcontext().

---
 arch/x86/ia32/ia32_signal.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
arch/x86/ia32/ia32_signal.c +0 -0
index a28790a..f74178e 100644

arch/x86/ia32/ia32_signal.c struct rt_sigframe · line 209

Quoted 9 lines
arch/x86/ia32/ia32_signal.c +6 -0
@@ -201,6 +201,12 @@ struct rt_sigframe
       err |= __get_user(regs->x, &sc->x);     \
 }
 
+#define COPY_SEG_STRICT(seg)   {                       \
+               unsigned short tmp;                     \
+               err |= __get_user(tmp, &sc->seg);       \
+               regs->seg = tmp | 3;                    \
+}
+

Since your first patch is to kill the temporary variables, then why do you introduce a temporary variable here? It can be avoided like it was.

Quoted 1 line

Can you explain the reason? :)

The first reason is to make this macro same as arch/x86/kernel/signal_{32|64}.c. And second, I guess gcc may generate little better code.

thanks,
Hiroshi Shimamoto

#4 lore raw

PATCH 3/5 x86: ia32_signal: cleanup macro RELOAD_SEG

In reply to Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Remove mask parameter because it's always 3.

---
 arch/x86/ia32/ia32_signal.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)
arch/x86/ia32/ia32_signal.c +11 -10
index f74178e..0b7fcf6 100644
@@ -207,13 +207,14 @@ struct rt_sigframe
 		regs->seg = tmp | 3;			\
 }
 
-#define RELOAD_SEG(seg,mask)						\
-	{ unsigned int cur;						\
-	  unsigned short pre;						\
-	  err |= __get_user(pre, &sc->seg);				\
-	  savesegment(seg, cur);					\
-	  pre |= mask;							\
-	  if (pre != cur) loadsegment(seg, pre); }
+#define RELOAD_SEG(seg)		{		\
+	unsigned int cur, pre;			\
+	err |= __get_user(pre, &sc->seg);	\
+	savesegment(seg, cur);			\
+	pre |= 3;				\
+	if (pre != cur)				\
+		loadsegment(seg, pre);		\
+}
 
 static int ia32_restore_sigcontext(struct pt_regs *regs,
 				   struct sigcontext_ia32 __user *sc,
@@ -244,9 +245,9 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
 	if (gs != oldgs)
 		load_gs_index(gs);
 
-	RELOAD_SEG(fs, 3);
-	RELOAD_SEG(ds, 3);
-	RELOAD_SEG(es, 3);
+	RELOAD_SEG(fs);
+	RELOAD_SEG(ds);
+	RELOAD_SEG(es);
 
 	COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
 	COPY(dx); COPY(cx); COPY(ip);
Signature · 1 line
1.5.6
#6 lore raw

PATCH 4/5 x86: ia32_signal: remove using temporary variable

In reply to Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

No need to use temporary variable.
Also rename the variable same as kernel/signal_32.c.

---
 arch/x86/ia32/ia32_signal.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/ia32/ia32_signal.c +2 -4
index 0b7fcf6..2883f41 100644
@@ -218,7 +218,7 @@ struct rt_sigframe
 
 static int ia32_restore_sigcontext(struct pt_regs *regs,
 				   struct sigcontext_ia32 __user *sc,
-				   unsigned int *peax)
+				   unsigned int *pax)
 {
 	unsigned int tmpflags, gs, oldgs, err = 0;
 	void __user *buf;
@@ -265,9 +265,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
 	buf = compat_ptr(tmp);
 	err |= restore_i387_xstate_ia32(buf);
 
-	err |= __get_user(tmp, &sc->ax);
-	*peax = tmp;
-
+	err |= __get_user(*pax, &sc->ax);
 	return err;
 }
 
Signature · 1 line
1.5.6
#8 lore raw

Re: [PATCH 4/5] x86: ia32_signal: remove using temporary variable

Quoted 11 lines · Américo Wang
Quoted 6 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

No need to use temporary variable.
Also rename the variable same as kernel/signal_32.c.

I think you mean arch/x86/kernel/signal_32.c, of course. :-)

Yep, it should be. I didn't keep correctness, sorry.

thanks,
Hiroshi Shimamoto

Quoted 10 lines
Quoted 2 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#9 lore raw

PATCH 5/5 x86: ia32_signal: change order of storing in setup_sigcontext()

In reply to Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Change order of storing to match the sigcontext_ia32.

---
 arch/x86/ia32/ia32_signal.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/ia32/ia32_signal.c +2 -2
index 2883f41..909181a 100644
@@ -360,13 +360,13 @@ static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc,
 	err |= __put_user(regs->dx, &sc->dx);
 	err |= __put_user(regs->cx, &sc->cx);
 	err |= __put_user(regs->ax, &sc->ax);
-	err |= __put_user(regs->cs, &sc->cs);
-	err |= __put_user(regs->ss, &sc->ss);
 	err |= __put_user(current->thread.trap_no, &sc->trapno);
 	err |= __put_user(current->thread.error_code, &sc->err);
 	err |= __put_user(regs->ip, &sc->ip);
+	err |= __put_user(regs->cs, (unsigned int __user *)&sc->cs);
 	err |= __put_user(regs->flags, &sc->flags);
 	err |= __put_user(regs->sp, &sc->sp_at_signal);
+	err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss);
 
 	err |= __put_user(ptr_to_compat(fpstate), &sc->fpstate);
 
Signature · 1 line
1.5.6
#10 lore raw

Re: [PATCH 5/5] x86: ia32_signal: change order of storing in setup_sigcontext()

Quoted 5 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Change order of storing to match the sigcontext_ia32.

Well, more than reordering... Please see below.

Quoted 13 lines
---
 arch/x86/ia32/ia32_signal.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/ia32/ia32_signal.c +0 -0
index 2883f41..909181a 100644
@@ -360,13 +360,13 @@ static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc,
       err |= __put_user(regs->dx, &sc->dx);
       err |= __put_user(regs->cx, &sc->cx);

arch/x86/ia32/ia32_signal.c static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc, · line 369

Quoted 10 lines
arch/x86/ia32/ia32_signal.c +2 -2
       err |= __put_user(regs->ax, &sc->ax);
-       err |= __put_user(regs->cs, &sc->cs);
-       err |= __put_user(regs->ss, &sc->ss);
       err |= __put_user(current->thread.trap_no, &sc->trapno);
       err |= __put_user(current->thread.error_code, &sc->err);
       err |= __put_user(regs->ip, &sc->ip);
+       err |= __put_user(regs->cs, (unsigned int __user *)&sc->cs);
       err |= __put_user(regs->flags, &sc->flags);
       err |= __put_user(regs->sp, &sc->sp_at_signal);
+       err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss);

Why do you add two casts? If these two are necessary, I am afraid the rest ones also need. :)

#11 lore raw

Re: [PATCH 5/5] x86: ia32_signal: change order of storing in setup_sigcontext()

Quoted 29 lines · Américo Wang
Quoted 5 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Change order of storing to match the sigcontext_ia32.

Well, more than reordering... Please see below.

Quoted 18 lines
---
 arch/x86/ia32/ia32_signal.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/ia32/ia32_signal.c +0 -2
index 2883f41..909181a 100644
@@ -360,13 +360,13 @@ static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc,
       err |= __put_user(regs->dx, &sc->dx);
       err |= __put_user(regs->cx, &sc->cx);
       err |= __put_user(regs->ax, &sc->ax);
-       err |= __put_user(regs->cs, &sc->cs);
-       err |= __put_user(regs->ss, &sc->ss);
       err |= __put_user(current->thread.trap_no, &sc->trapno);
       err |= __put_user(current->thread.error_code, &sc->err);
       err |= __put_user(regs->ip, &sc->ip);
Quoted 8 lines

arch/x86/ia32/ia32_signal.c static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc, · line 369

Quoted 4 lines
arch/x86/ia32/ia32_signal.c +2 -0
+       err |= __put_user(regs->cs, (unsigned int __user *)&sc->cs);
       err |= __put_user(regs->flags, &sc->flags);
       err |= __put_user(regs->sp, &sc->sp_at_signal);
+       err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss);

Why do you add two casts? If these two are necessary, I am afraid the rest ones also need. :)

Thanks, I forgot to mention it.
This cast is to make this code same as arch/x86/kernel/signal_32.c. No one cares upper part, but it makes improvement by avoiding operand size prefix.

thanks,
Hiroshi Shimamoto

#12 lore raw
In reply to Hiroshi Shimamoto
Quoted 16 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

No need to use temporary variable in this case.

---
 arch/x86/ia32/ia32_signal.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/ia32/ia32_signal.c +0 -0
index e886907..a28790a 100644

arch/x86/ia32/ia32_signal.c struct rt_sigframe · line 202

Quoted 10 lines
arch/x86/ia32/ia32_signal.c +2 -4
@@ -197,10 +197,8 @@ struct rt_sigframe
       /* fp state follows here */
 };
 
-#define COPY(x)                {               \
-       unsigned int reg;               \
-       err |= __get_user(reg, &sc->x); \
-       regs->x = reg;                  \
+#define COPY(x)                        {               \
+       err |= __get_user(regs->x, &sc->x);     \
 }

Then you can also kill the braces now. :)

What's more, if I saw it correctly, the belowing two __get_user() calls can also be replaced by COPY().

#13 lore raw
Quoted 21 lines · Américo Wang
Quoted 19 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

No need to use temporary variable in this case.

---
 arch/x86/ia32/ia32_signal.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/ia32/ia32_signal.c +0 -0
index e886907..a28790a 100644
@@ -197,10 +197,8 @@ struct rt_sigframe
       /* fp state follows here */
 };
 
Quoted 7 lines

arch/x86/ia32/ia32_signal.c struct rt_sigframe · line 202

Quoted 7 lines
arch/x86/ia32/ia32_signal.c +2 -4
-#define COPY(x)                {               \
-       unsigned int reg;               \
-       err |= __get_user(reg, &sc->x); \
-       regs->x = reg;                  \
+#define COPY(x)                        {               \
+       err |= __get_user(regs->x, &sc->x);     \
 }

Thanks for reviewing this!

Quoted 2 lines

Then you can also kill the braces now. :)

I guess, checkpatch will complain. Personally I don't care.

Quoted 3 lines

What's more, if I saw it correctly, the belowing two __get_user() calls can also be replaced by COPY().

I'm sorry, I cannot catch about this. Which __get_user()?

thanks,
Hiroshi Shimamoto

#14 lore raw

PATCH v2 1/5 x86: ia32_signal: cleanup macro COPY

In reply to Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

No need to use temporary variable in this case.

---
 arch/x86/ia32/ia32_signal.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/ia32/ia32_signal.c +2 -4
index e886907..a28790a 100644
@@ -197,10 +197,8 @@ struct rt_sigframe
 	/* fp state follows here */
 };
 
-#define COPY(x)		{ 		\
-	unsigned int reg;		\
-	err |= __get_user(reg, &sc->x);	\
-	regs->x = reg;			\
+#define COPY(x)			{		\
+	err |= __get_user(regs->x, &sc->x);	\
 }
 
 #define RELOAD_SEG(seg,mask)						\
Signature · 1 line
1.5.6
#15 lore raw

PATCH v2 2/5 x86: ia32_signal: introduce COPY_SEG_STRICT

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Introduce COPY_SEG_STRICT for ia32_restore_sigcontext().

---
 arch/x86/ia32/ia32_signal.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
arch/x86/ia32/ia32_signal.c +8 -4
index a28790a..f74178e 100644
@@ -201,6 +201,12 @@ struct rt_sigframe
 	err |= __get_user(regs->x, &sc->x);	\
 }
 
+#define COPY_SEG_STRICT(seg)	{			\
+		unsigned short tmp;			\
+		err |= __get_user(tmp, &sc->seg);	\
+		regs->seg = tmp | 3;			\
+}
+
 #define RELOAD_SEG(seg,mask)						\
 	{ unsigned int cur;						\
 	  unsigned short pre;						\
@@ -246,10 +252,8 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
 	COPY(dx); COPY(cx); COPY(ip);
 	/* Don't touch extended registers */
 
-	err |= __get_user(regs->cs, &sc->cs);
-	regs->cs |= 3;
-	err |= __get_user(regs->ss, &sc->ss);
-	regs->ss |= 3;
+	COPY_SEG_STRICT(cs);
+	COPY_SEG_STRICT(ss);
 
 	err |= __get_user(tmpflags, &sc->flags);
 	regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
Signature · 1 line
1.5.6
#16 lore raw

Re: [PATCH v2 2/5] x86: ia32_signal: introduce COPY_SEG_STRICT

Quoted 6 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Introduce COPY_SEG_STRICT for ia32_restore_sigcontext().

I don't like the name _STRICT() for this; if anything it seems to have quite the opposite meaning. I would suggest COPY_SEG_USER() or even COPY_SEG_CPL3().

-hpa

#17 lore raw

Re: [PATCH v2 2/5] x86: ia32_signal: introduce COPY_SEG_STRICT

Quoted 11 lines · H. Peter Anvin
Quoted 6 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Introduce COPY_SEG_STRICT for ia32_restore_sigcontext().

I don't like the name _STRICT() for this; if anything it seems to have quite the opposite meaning. I would suggest COPY_SEG_USER() or even COPY_SEG_CPL3().

Sounds nice.
I haven't thought about the name. I could not catch wrong meaning from _STRICT. My English skill isn't good.

thanks,
Hiroshi Shimamoto

#18 lore raw

Re: [PATCH v2 2/5] x86: ia32_signal: introduce COPY_SEG_STRICT

Quoted 9 lines · Hiroshi Shimamoto
Quoted 8 lines · H. Peter Anvin
Quoted 6 lines · Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Introduce COPY_SEG_STRICT for ia32_restore_sigcontext().

Quoted 7 lines
Quoted 3 lines

I don't like the name _STRICT() for this; if anything it seems to have quite the opposite meaning. I would suggest COPY_SEG_USER() or even COPY_SEG_CPL3().

Sounds nice.
I haven't thought about the name. I could not catch wrong meaning from _STRICT. My English skill isn't good.

i have changed it to COPY_SEG_CPL3() - no need to resend. Here are the patches i've picked up into tip/x86/signal:

6497760: x86: ia32_signal: change order of storing in setup_sigcontext() 047ce93: x86: ia32_signal: remove using temporary variable 8c6e5ce: x86: ia32_signal: cleanup macro RELOAD_SEG
d71a68d: x86: ia32_signal: introduce COPY_SEG_CPL3
b78a5b5: x86: ia32_signal: cleanup macro COPY

thanks!

Ingo

#19 lore raw

PATCH v2 3/5 x86: ia32_signal: cleanup macro RELOAD_SEG

In reply to Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Remove mask parameter because it's always 3.
Cleanup coding styles.

---
 arch/x86/ia32/ia32_signal.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)
arch/x86/ia32/ia32_signal.c +11 -10
index f74178e..0b7fcf6 100644
@@ -207,13 +207,14 @@ struct rt_sigframe
 		regs->seg = tmp | 3;			\
 }
 
-#define RELOAD_SEG(seg,mask)						\
-	{ unsigned int cur;						\
-	  unsigned short pre;						\
-	  err |= __get_user(pre, &sc->seg);				\
-	  savesegment(seg, cur);					\
-	  pre |= mask;							\
-	  if (pre != cur) loadsegment(seg, pre); }
+#define RELOAD_SEG(seg)		{		\
+	unsigned int cur, pre;			\
+	err |= __get_user(pre, &sc->seg);	\
+	savesegment(seg, cur);			\
+	pre |= 3;				\
+	if (pre != cur)				\
+		loadsegment(seg, pre);		\
+}
 
 static int ia32_restore_sigcontext(struct pt_regs *regs,
 				   struct sigcontext_ia32 __user *sc,
@@ -244,9 +245,9 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
 	if (gs != oldgs)
 		load_gs_index(gs);
 
-	RELOAD_SEG(fs, 3);
-	RELOAD_SEG(ds, 3);
-	RELOAD_SEG(es, 3);
+	RELOAD_SEG(fs);
+	RELOAD_SEG(ds);
+	RELOAD_SEG(es);
 
 	COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
 	COPY(dx); COPY(cx); COPY(ip);
Signature · 1 line
1.5.6
#20 lore raw

PATCH v2 4/5 x86: ia32_signal: remove using temporary variable

In reply to Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

No need to use temporary variable.
Also rename the variable same as arch/x86/kernel/signal_32.c.

---
 arch/x86/ia32/ia32_signal.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
arch/x86/ia32/ia32_signal.c +2 -4
index 0b7fcf6..2883f41 100644
@@ -218,7 +218,7 @@ struct rt_sigframe
 
 static int ia32_restore_sigcontext(struct pt_regs *regs,
 				   struct sigcontext_ia32 __user *sc,
-				   unsigned int *peax)
+				   unsigned int *pax)
 {
 	unsigned int tmpflags, gs, oldgs, err = 0;
 	void __user *buf;
@@ -265,9 +265,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
 	buf = compat_ptr(tmp);
 	err |= restore_i387_xstate_ia32(buf);
 
-	err |= __get_user(tmp, &sc->ax);
-	*peax = tmp;
-
+	err |= __get_user(*pax, &sc->ax);
 	return err;
 }
 
Signature · 1 line
1.5.6
#21 lore raw

PATCH v2 5/5 x86: ia32_signal: change order of storing in setup_sigcontext()

In reply to Hiroshi Shimamoto

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Change order of storing to match the sigcontext_ia32.
And add casting to make this code same as arch/x86/kernel/signal_32.c.

---
 arch/x86/ia32/ia32_signal.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/ia32/ia32_signal.c +2 -2
index 2883f41..909181a 100644
@@ -360,13 +360,13 @@ static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc,
 	err |= __put_user(regs->dx, &sc->dx);
 	err |= __put_user(regs->cx, &sc->cx);
 	err |= __put_user(regs->ax, &sc->ax);
-	err |= __put_user(regs->cs, &sc->cs);
-	err |= __put_user(regs->ss, &sc->ss);
 	err |= __put_user(current->thread.trap_no, &sc->trapno);
 	err |= __put_user(current->thread.error_code, &sc->err);
 	err |= __put_user(regs->ip, &sc->ip);
+	err |= __put_user(regs->cs, (unsigned int __user *)&sc->cs);
 	err |= __put_user(regs->flags, &sc->flags);
 	err |= __put_user(regs->sp, &sc->sp_at_signal);
+	err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss);
 
 	err |= __put_user(ptr_to_compat(fpstate), &sc->fpstate);
 
Signature · 1 line
1.5.6