[PATCH] x86: signal: cosmetic unification of setup_sigcontext() - Kernel

This is a discussion on [PATCH] x86: signal: cosmetic unification of setup_sigcontext() - Kernel ; From: Hiroshi Shimamoto Impact: cleanup Make setup_sigcontext() same. Signed-off-by: Hiroshi Shimamoto --- arch/x86/kernel/signal_32.c | 32 ++++++++++++++++++++++++++++---- arch/x86/kernel/signal_64.c | 33 ++++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c index 6a05c74..27a5c81 100644 --- a/arch/x86/kernel/signal_32.c +++ b/arch/x86/kernel/signal_32.c @@ -279,14 ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: [PATCH] x86: signal: cosmetic unification of setup_sigcontext()

  1. [PATCH] x86: signal: cosmetic unification of setup_sigcontext()

    From: Hiroshi Shimamoto

    Impact: cleanup

    Make setup_sigcontext() same.

    Signed-off-by: Hiroshi Shimamoto
    ---
    arch/x86/kernel/signal_32.c | 32 ++++++++++++++++++++++++++++----
    arch/x86/kernel/signal_64.c | 33 ++++++++++++++++++++++++++++-----
    2 files changed, 56 insertions(+), 9 deletions(-)

    diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
    index 6a05c74..27a5c81 100644
    --- a/arch/x86/kernel/signal_32.c
    +++ b/arch/x86/kernel/signal_32.c
    @@ -279,14 +279,20 @@ static int
    setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
    struct pt_regs *regs, unsigned long mask)
    {
    - int tmp, err = 0;
    + int err = 0;

    - err |= __put_user(regs->fs, (unsigned int __user *)&sc->fs);
    - savesegment(gs, tmp);
    - err |= __put_user(tmp, (unsigned int __user *)&sc->gs);
    +#ifdef CONFIG_X86_32
    + {
    + unsigned int tmp;

    + savesegment(gs, tmp);
    + err |= __put_user(tmp, (unsigned int __user *)&sc->gs);
    + }
    + err |= __put_user(regs->fs, (unsigned int __user *)&sc->fs);
    err |= __put_user(regs->es, (unsigned int __user *)&sc->es);
    err |= __put_user(regs->ds, (unsigned int __user *)&sc->ds);
    +#endif /* CONFIG_X86_32 */
    +
    err |= __put_user(regs->di, &sc->di);
    err |= __put_user(regs->si, &sc->si);
    err |= __put_user(regs->bp, &sc->bp);
    @@ -295,13 +301,31 @@ setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
    err |= __put_user(regs->dx, &sc->dx);
    err |= __put_user(regs->cx, &sc->cx);
    err |= __put_user(regs->ax, &sc->ax);
    +#ifdef CONFIG_X86_64
    + err |= __put_user(regs->r8, &sc->r8);
    + err |= __put_user(regs->r9, &sc->r9);
    + err |= __put_user(regs->r10, &sc->r10);
    + err |= __put_user(regs->r11, &sc->r11);
    + err |= __put_user(regs->r12, &sc->r12);
    + err |= __put_user(regs->r13, &sc->r13);
    + err |= __put_user(regs->r14, &sc->r14);
    + err |= __put_user(regs->r15, &sc->r15);
    +#endif /* CONFIG_X86_64 */
    +
    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);
    +#ifdef CONFIG_X86_32
    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);
    +#else /* !CONFIG_X86_32 */
    + err |= __put_user(regs->flags, &sc->flags);
    + err |= __put_user(regs->cs, &sc->cs);
    + err |= __put_user(0, &sc->gs);
    + err |= __put_user(0, &sc->fs);
    +#endif /* CONFIG_X86_32 */

    err |= __put_user(fpstate, &sc->fpstate);

    diff --git a/arch/x86/kernel/signal_64.c b/arch/x86/kernel/signal_64.c
    index 3868c2a..d2307e4 100644
    --- a/arch/x86/kernel/signal_64.c
    +++ b/arch/x86/kernel/signal_64.c
    @@ -157,16 +157,23 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
    /*
    * Set up a signal frame.
    */
    -
    -static inline int
    +static int
    setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
    struct pt_regs *regs, unsigned long mask)
    {
    int err = 0;

    - err |= __put_user(regs->cs, &sc->cs);
    - err |= __put_user(0, &sc->gs);
    - err |= __put_user(0, &sc->fs);
    +#ifdef CONFIG_X86_32
    + {
    + unsigned int tmp;
    +
    + savesegment(gs, tmp);
    + err |= __put_user(tmp, (unsigned int __user *)&sc->gs);
    + }
    + err |= __put_user(regs->fs, (unsigned int __user *)&sc->fs);
    + err |= __put_user(regs->es, (unsigned int __user *)&sc->es);
    + err |= __put_user(regs->ds, (unsigned int __user *)&sc->ds);
    +#endif /* CONFIG_X86_32 */

    err |= __put_user(regs->di, &sc->di);
    err |= __put_user(regs->si, &sc->si);
    @@ -176,6 +183,7 @@ setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
    err |= __put_user(regs->dx, &sc->dx);
    err |= __put_user(regs->cx, &sc->cx);
    err |= __put_user(regs->ax, &sc->ax);
    +#ifdef CONFIG_X86_64
    err |= __put_user(regs->r8, &sc->r8);
    err |= __put_user(regs->r9, &sc->r9);
    err |= __put_user(regs->r10, &sc->r10);
    @@ -184,11 +192,26 @@ setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
    err |= __put_user(regs->r13, &sc->r13);
    err |= __put_user(regs->r14, &sc->r14);
    err |= __put_user(regs->r15, &sc->r15);
    +#endif /* CONFIG_X86_64 */
    +
    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);
    +#ifdef CONFIG_X86_32
    + 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);
    +#else /* !CONFIG_X86_32 */
    + err |= __put_user(regs->flags, &sc->flags);
    + err |= __put_user(regs->cs, &sc->cs);
    + err |= __put_user(0, &sc->gs);
    + err |= __put_user(0, &sc->fs);
    +#endif /* CONFIG_X86_32 */
    +
    err |= __put_user(fpstate, &sc->fpstate);
    +
    + /* non-iBCS2 extensions.. */
    err |= __put_user(mask, &sc->oldmask);
    err |= __put_user(current->thread.cr2, &sc->cr2);

    --
    1.5.6

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

  2. Re: [PATCH] x86: signal: cosmetic unification of setup_sigcontext()


    * Hiroshi Shimamoto wrote:

    > From: Hiroshi Shimamoto
    >
    > Impact: cleanup
    >
    > Make setup_sigcontext() same.
    >
    > Signed-off-by: Hiroshi Shimamoto
    > ---
    > arch/x86/kernel/signal_32.c | 32 ++++++++++++++++++++++++++++----
    > arch/x86/kernel/signal_64.c | 33 ++++++++++++++++++++++++++++-----
    > 2 files changed, 56 insertions(+), 9 deletions(-)


    applied to tip/x86/signal, thanks!

    (the 10 patches of yours that are already in tip/x86/signal are
    working perfectly)

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

+ Reply to Thread