public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Tejun Heo <tj@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>,
	linux-kernel@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH 1/3] x86: Use pt_regs pointer in do_device_not_available()
Date: Wed, 11 Feb 2009 11:13:59 +0100	[thread overview]
Message-ID: <20090211101359.GG20518@elte.hu> (raw)
In-Reply-To: <499281B5.2070502@kernel.org>


* Tejun Heo <tj@kernel.org> wrote:

> Hello, Brian.
> 
> Brian Gerst wrote:
> > The generic exception handler (error_code) passes in the pt_regs
> > pointer and the error code (unused in this case).  The commit
> > "x86: fix math_emu register frame access" changed this to pass by
> > value, which doesn't work correctly with stack protector enabled.
> > Change it back to use the pt_regs pointer.
> > 
> > Signed-off-by: Brian Gerst <brgerst@gmail.com>
> > ---
> >  arch/x86/include/asm/traps.h |    2 +-
> >  arch/x86/kernel/traps.c      |    9 +++++----
> >  2 files changed, 6 insertions(+), 5 deletions(-)
> > 
> > diff --git a/arch/x86/include/asm/traps.h b/arch/x86/include/asm/traps.h
> > index cf3bb05..0d53425 100644
> > --- a/arch/x86/include/asm/traps.h
> > +++ b/arch/x86/include/asm/traps.h
> > @@ -41,7 +41,7 @@ dotraplinkage void do_int3(struct pt_regs *, long);
> >  dotraplinkage void do_overflow(struct pt_regs *, long);
> >  dotraplinkage void do_bounds(struct pt_regs *, long);
> >  dotraplinkage void do_invalid_op(struct pt_regs *, long);
> > -dotraplinkage void do_device_not_available(struct pt_regs);
> > +dotraplinkage void do_device_not_available(struct pt_regs *, long);
> >  dotraplinkage void do_coprocessor_segment_overrun(struct pt_regs *, long);
> >  dotraplinkage void do_invalid_TSS(struct pt_regs *, long);
> >  dotraplinkage void do_segment_not_present(struct pt_regs *, long);
> > diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
> > index 3b7b2e1..71a8f87 100644
> > --- a/arch/x86/kernel/traps.c
> > +++ b/arch/x86/kernel/traps.c
> > @@ -905,19 +905,20 @@ void math_emulate(struct math_emu_info *info)
> >  }
> >  #endif /* CONFIG_MATH_EMULATION */
> >  
> > -dotraplinkage void __kprobes do_device_not_available(struct pt_regs regs)
> > +dotraplinkage void __kprobes
> > +do_device_not_available(struct pt_regs *regs, long error_code)
> 
> What do you think about just taking pt_regs and accessing
> regs->orig_eax instead of having separate call convention for pt_regs
> ones and trap ones?  Too much work without enough benefit?

Looks worthwile to me. [ Cleanups rarely have clear benefits of their own,
it's the sheer mass of them that makes a difference in the end. Like the
many snowflakes that can bend a tree ;-) ]

There's one small namespace complication here: it's pt_regs->orig_eax on
32-bit and pt_regs->orig_rax on 64-bit.

So i'd suggest the introduction of an anonymous union "error_code" field
which overlays orig_eax and that can be used just fine from unified code too.
That would also be more readable.

Or we could rename orig_eax/orig_rax to error_code. (it might be a bit
confusing in the syscall entry context though.)

	Ingo

  reply	other threads:[~2009-02-11 10:14 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-10 14:51 [PATCH 0/3] x86: Fix pt_regs passed by value Brian Gerst
2009-02-10 14:51 ` [PATCH 1/3] x86: Use pt_regs pointer in do_device_not_available() Brian Gerst
2009-02-11  7:43   ` Tejun Heo
2009-02-11 10:13     ` Ingo Molnar [this message]
2009-02-11 14:34     ` Brian Gerst
2009-02-11 14:42       ` Tejun Heo
2009-02-11 14:46         ` Brian Gerst
2009-02-11 14:53           ` Tejun Heo
2009-02-10 14:51 ` [PATCH 2/3] x86: Pass in pt_regs pointer for syscalls that need it Brian Gerst
2009-02-11  7:41   ` Tejun Heo
2009-02-11 10:18     ` Ingo Molnar
2009-02-11 14:14       ` Tejun Heo
2009-02-11 14:31     ` Brian Gerst
2009-02-11 14:41       ` Tejun Heo
2009-02-11 14:43         ` Tejun Heo
2009-02-11 14:48         ` Tejun Heo
2009-02-11 14:58           ` Ingo Molnar
2009-02-11 14:59           ` Brian Gerst
2009-02-11 15:05             ` Tejun Heo
2009-02-11 15:10               ` Brian Gerst
2009-02-11 15:14                 ` Tejun Heo
2009-02-11 15:59                   ` Ingo Molnar
2009-02-12  1:12                     ` Tejun Heo
2009-02-11 15:01       ` Ingo Molnar
2009-02-11 17:52   ` H. Peter Anvin
2009-02-11 18:27     ` Brian Gerst
2009-02-11 19:50       ` H. Peter Anvin
2009-02-11 19:57         ` Brian Gerst
2009-02-11 20:00           ` H. Peter Anvin
2009-02-11 21:43   ` [PATCH] x86: pass in pt_regs pointer for syscalls that need it (take 2) Brian Gerst
2009-02-11 21:50     ` H. Peter Anvin
2009-02-11 22:06     ` H. Peter Anvin
2009-02-12 11:02       ` Ingo Molnar
2009-02-10 14:51 ` [PATCH 3/3] x86: Drop -fno-stack-protector after pt_regs fixes Brian Gerst
2009-02-11 11:42 ` [PATCH 0/3] x86: Fix pt_regs passed by value Ingo Molnar
2009-02-11 14:15   ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090211101359.GG20518@elte.hu \
    --to=mingo@elte.hu \
    --cc=brgerst@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox