Re: [PATCH] m68k, exec: remove redundant set_fs(USER_DS)

From: Geert Uytterhoeven
Date: Wed Jun 15 2011 - 10:40:35 EST


On Fri, Jun 10, 2011 at 15:09, Mathias Krause <minipli@xxxxxxxxxxxxxx> wrote:
> The address limit is already set in flush_old_exec() so those calls to
> set_fs(USER_DS) are redundant.
>
> Signed-off-by: Mathias Krause <minipli@xxxxxxxxxxxxxx>
> Cc: Greg Ungerer <gerg@xxxxxxxxxxx>
> ---
>
> Note: I'm not sure about the assignment to current->thread.fs in
> flush_thread() -- shouldn't this be done in set_fs() itself?

set_fs() is used to temporary set the address space to be used from the
kernel.
current->thread.fs is the address space that will be used when the
thread returns
to userspace.
So I think it's correct.

For nommu, thread.fs is set, but not really used.

> Âarch/m68k/include/asm/processor.h | Â Â4 ----
> Âarch/m68k/kernel/process_mm.c   |  Â2 +-
> Âarch/m68k/kernel/process_no.c   |  Â2 +-
> Â3 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/arch/m68k/include/asm/processor.h b/arch/m68k/include/asm/processor.h
> index f111b02..d8ef53a 100644
> --- a/arch/m68k/include/asm/processor.h
> +++ b/arch/m68k/include/asm/processor.h
> @@ -105,9 +105,6 @@ struct thread_struct {
> Âstatic inline void start_thread(struct pt_regs * regs, unsigned long pc,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âunsigned long usp)
> Â{
> - Â Â Â /* reads from user space */
> - Â Â Â set_fs(USER_DS);
> -
> Â Â Â Âregs->pc = pc;
> Â Â Â Âregs->sr &= ~0x2000;
> Â Â Â Âwrusp(usp);
> @@ -129,7 +126,6 @@ extern int handle_kernel_fault(struct pt_regs *regs);
>
> Â#define start_thread(_regs, _pc, _usp) Â Â Â Â Â Â Â Â Â\
> Âdo { Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â\
> - Â Â Â set_fs(USER_DS); /* reads from user space */ Â Â\
> Â Â Â Â(_regs)->pc = (_pc); Â Â Â Â Â Â Â Â Â Â Â Â Â Â\
> Â Â Â Â((struct switch_stack *)(_regs))[-1].a6 = 0; Â Â\
> Â Â Â Âreformat(_regs); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â\
> diff --git a/arch/m68k/kernel/process_mm.c b/arch/m68k/kernel/process_mm.c
> index c2a1fc2..1bc223a 100644
> --- a/arch/m68k/kernel/process_mm.c
> +++ b/arch/m68k/kernel/process_mm.c
> @@ -185,7 +185,7 @@ EXPORT_SYMBOL(kernel_thread);
> Âvoid flush_thread(void)
> Â{
> Â Â Â Âunsigned long zero = 0;
> - Â Â Â set_fs(USER_DS);
> +
> Â Â Â Âcurrent->thread.fs = __USER_DS;
> Â Â Â Âif (!FPU_IS_EMU)
> Â Â Â Â Â Â Â Âasm volatile (".chip 68k/68881\n\t"
> diff --git a/arch/m68k/kernel/process_no.c b/arch/m68k/kernel/process_no.c
> index 9b86ad1..69c1803 100644
> --- a/arch/m68k/kernel/process_no.c
> +++ b/arch/m68k/kernel/process_no.c
> @@ -158,7 +158,7 @@ void flush_thread(void)
> Â#ifdef CONFIG_FPU
> Â Â Â Âunsigned long zero = 0;
> Â#endif
> - Â Â Â set_fs(USER_DS);
> +
> Â Â Â Âcurrent->thread.fs = __USER_DS;
> Â#ifdef CONFIG_FPU
> Â Â Â Âif (!FPU_IS_EMU)

Gr{oetje,eeting}s,

            Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
             Â Â -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/