2008-11-15 03:24:59

by Hiroshi Shimamoto

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

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

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index e886907..a28790a 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -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) \
--
1.5.6


2008-11-15 03:26:48

by Hiroshi Shimamoto

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

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

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index a28790a..f74178e 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -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);
--
1.5.6

2008-11-15 03:27:29

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH 3/5] x86: ia32_signal: cleanup macro RELOAD_SEG

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Remove mask parameter because it's always 3.

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

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index f74178e..0b7fcf6 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -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);
--
1.5.6

2008-11-15 03:28:18

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH 4/5] x86: ia32_signal: remove using temporary variable

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

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

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

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index 0b7fcf6..2883f41 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -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;
}

--
1.5.6

2008-11-15 03:29:03

by Hiroshi Shimamoto

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

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

Change order of storing to match the sigcontext_ia32.

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

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index 2883f41..909181a 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -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);

--
1.5.6

2008-11-15 17:07:04

by Cong Wang

[permalink] [raw]
Subject: Re: [PATCH 1/5] x86: ia32_signal: cleanup macro COPY

On Sat, Nov 15, 2008 at 3:24 AM, Hiroshi Shimamoto
<[email protected]> wrote:
> From: Hiroshi Shimamoto <[email protected]>
>
> Impact: cleanup
>
> No need to use temporary variable in this case.
>
> Signed-off-by: Hiroshi Shimamoto <[email protected]>
> ---
> arch/x86/ia32/ia32_signal.c | 6 ++----
> 1 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
> index e886907..a28790a 100644
> --- a/arch/x86/ia32/ia32_signal.c
> +++ b/arch/x86/ia32/ia32_signal.c
> @@ -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().

2008-11-15 17:12:01

by Cong Wang

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

On Sat, Nov 15, 2008 at 3:26 AM, Hiroshi Shimamoto
<[email protected]> wrote:
> From: Hiroshi Shimamoto <[email protected]>
>
> Impact: cleanup
>
> Introduce COPY_SEG_STRICT for ia32_restore_sigcontext().
>
> Signed-off-by: Hiroshi Shimamoto <[email protected]>
> ---
> arch/x86/ia32/ia32_signal.c | 12 ++++++++----
> 1 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
> index a28790a..f74178e 100644
> --- a/arch/x86/ia32/ia32_signal.c
> +++ b/arch/x86/ia32/ia32_signal.c
> @@ -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? :)

2008-11-15 17:15:25

by Cong Wang

[permalink] [raw]
Subject: Re: [PATCH 3/5] x86: ia32_signal: cleanup macro RELOAD_SEG

On Sat, Nov 15, 2008 at 3:27 AM, Hiroshi Shimamoto
<[email protected]> wrote:
> From: Hiroshi Shimamoto <[email protected]>
>
> Impact: cleanup
>
> Remove mask parameter because it's always 3.


It also contains some style cleanups. :)

>
> Signed-off-by: Hiroshi Shimamoto <[email protected]>

If you need, you can add:

Reviewed-by: WANG Cong <[email protected]>

2008-11-15 17:22:53

by Cong Wang

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

On Sat, Nov 15, 2008 at 3:28 AM, Hiroshi Shimamoto
<[email protected]> wrote:
> 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. :-)

>
> Signed-off-by: Hiroshi Shimamoto <[email protected]>

Reviewed-by: WANG Cong <[email protected]>

2008-11-15 17:25:59

by Cong Wang

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

On Sat, Nov 15, 2008 at 3:28 AM, Hiroshi Shimamoto
<[email protected]> wrote:
> From: Hiroshi Shimamoto <[email protected]>
>
> Impact: cleanup
>
> Change order of storing to match the sigcontext_ia32.


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

>
> Signed-off-by: Hiroshi Shimamoto <[email protected]>
> ---
> arch/x86/ia32/ia32_signal.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
> index 2883f41..909181a 100644
> --- a/arch/x86/ia32/ia32_signal.c
> +++ b/arch/x86/ia32/ia32_signal.c
> @@ -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);


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

2008-11-17 17:57:34

by Hiroshi Shimamoto

[permalink] [raw]
Subject: Re: [PATCH 1/5] x86: ia32_signal: cleanup macro COPY

Américo Wang wrote:
> On Sat, Nov 15, 2008 at 3:24 AM, Hiroshi Shimamoto
> <[email protected]> wrote:
>> From: Hiroshi Shimamoto <[email protected]>
>>
>> Impact: cleanup
>>
>> No need to use temporary variable in this case.
>>
>> Signed-off-by: Hiroshi Shimamoto <[email protected]>
>> ---
>> arch/x86/ia32/ia32_signal.c | 6 ++----
>> 1 files changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
>> index e886907..a28790a 100644
>> --- a/arch/x86/ia32/ia32_signal.c
>> +++ b/arch/x86/ia32/ia32_signal.c
>> @@ -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); \
>> }

Thanks for reviewing this!

>
> Then you can also kill the braces now. :)

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

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

2008-11-17 18:03:18

by Hiroshi Shimamoto

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

Américo Wang wrote:
> On Sat, Nov 15, 2008 at 3:26 AM, Hiroshi Shimamoto
> <[email protected]> wrote:
>> From: Hiroshi Shimamoto <[email protected]>
>>
>> Impact: cleanup
>>
>> Introduce COPY_SEG_STRICT for ia32_restore_sigcontext().
>>
>> Signed-off-by: Hiroshi Shimamoto <[email protected]>
>> ---
>> arch/x86/ia32/ia32_signal.c | 12 ++++++++----
>> 1 files changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
>> index a28790a..f74178e 100644
>> --- a/arch/x86/ia32/ia32_signal.c
>> +++ b/arch/x86/ia32/ia32_signal.c
>> @@ -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? :)

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

2008-11-17 18:09:57

by Hiroshi Shimamoto

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

Américo Wang wrote:
> On Sat, Nov 15, 2008 at 3:28 AM, Hiroshi Shimamoto
> <[email protected]> wrote:
>> 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

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

2008-11-17 18:20:42

by Hiroshi Shimamoto

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

Américo Wang wrote:
> On Sat, Nov 15, 2008 at 3:28 AM, Hiroshi Shimamoto
> <[email protected]> wrote:
>> From: Hiroshi Shimamoto <[email protected]>
>>
>> Impact: cleanup
>>
>> Change order of storing to match the sigcontext_ia32.
>
>
> Well, more than reordering... Please see below.
>
>> Signed-off-by: Hiroshi Shimamoto <[email protected]>
>> ---
>> arch/x86/ia32/ia32_signal.c | 4 ++--
>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
>> index 2883f41..909181a 100644
>> --- a/arch/x86/ia32/ia32_signal.c
>> +++ b/arch/x86/ia32/ia32_signal.c
>> @@ -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);
>
>
> 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

2008-11-17 23:45:18

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH v2 1/5] x86: ia32_signal: cleanup macro COPY

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

No need to use temporary variable in this case.

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

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index e886907..a28790a 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -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) \
--
1.5.6

2008-11-17 23:47:18

by Hiroshi Shimamoto

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

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

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index a28790a..f74178e 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -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);
--
1.5.6

2008-11-17 23:47:59

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH v2 3/5] x86: ia32_signal: cleanup macro RELOAD_SEG

From: Hiroshi Shimamoto <[email protected]>

Impact: cleanup

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

Signed-off-by: Hiroshi Shimamoto <[email protected]>
Reviewed-by: WANG Cong <[email protected]>
---
arch/x86/ia32/ia32_signal.c | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index f74178e..0b7fcf6 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -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);
--
1.5.6

2008-11-17 23:48:41

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH v2 4/5] x86: ia32_signal: remove using temporary variable

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.

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

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index 0b7fcf6..2883f41 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -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;
}

--
1.5.6

2008-11-17 23:49:40

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH v2 5/5] x86: ia32_signal: change order of storing in setup_sigcontext()

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.

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

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index 2883f41..909181a 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -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);

--
1.5.6

2008-11-17 23:52:52

by H. Peter Anvin

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

Hiroshi Shimamoto wrote:
> 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

2008-11-18 00:09:44

by Hiroshi Shimamoto

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

H. Peter Anvin wrote:
> Hiroshi Shimamoto wrote:
>> 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

2008-11-18 15:56:42

by Ingo Molnar

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


* Hiroshi Shimamoto <[email protected]> wrote:

> H. Peter Anvin wrote:
> > Hiroshi Shimamoto wrote:
> >> 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.

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