Re: [PATCH 07/11] x86/fault: Split the OOPS code out from no_context()

From: Andy Lutomirski
Date: Tue Feb 09 2021 - 19:10:37 EST


On Wed, Feb 3, 2021 at 10:56 AM Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> On Sun, Jan 31, 2021 at 09:24:38AM -0800, Andy Lutomirski wrote:
> > Not all callers of no_context() want to run exception fixups.
> > Separate the OOPS code out from the fixup code in no_context().
> >
> > Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> > Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> > Signed-off-by: Andy Lutomirski <luto@xxxxxxxxxx>
> > ---
> > arch/x86/mm/fault.c | 116 +++++++++++++++++++++++---------------------
> > 1 file changed, 62 insertions(+), 54 deletions(-)
> >
> > diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> > index 1939e546beae..6f43d080e1e8 100644
> > --- a/arch/x86/mm/fault.c
> > +++ b/arch/x86/mm/fault.c
> > @@ -618,53 +618,20 @@ static void set_signal_archinfo(unsigned long address,
> > }
> >
> > static noinline void
> > -no_context(struct pt_regs *regs, unsigned long error_code,
> > - unsigned long address, int signal, int si_code)
> > +page_fault_oops(struct pt_regs *regs, unsigned long error_code,
>
> Not sure about this name - it still tries to recover:
> efi_recover_from_page_fault().
>
> Judging by where it is called, maybe no_context_tail() or
> no_context_oops() or no_context_finish_me_already()...
>
> Yah, I haz no better idea. :-\
>
> ...
>
> > @@ -739,6 +692,61 @@ no_context(struct pt_regs *regs, unsigned long error_code,
> > oops_end(flags, regs, sig);
> > }
> >
> > +static noinline void
> > +no_context(struct pt_regs *regs, unsigned long error_code,
> > + unsigned long address, int signal, int si_code)
> > +{
> > + if (user_mode(regs)) {
> > + /*
> > + * This is an implicit supervisor-mode access from user
> > + * mode. Bypass all the kernel-mode recovery code and just
> > + * OOPS.
> > + */
> > + goto oops;
>
> Just do
>
> return page_fault_oops(...);
>
> here and get rid of the label.

I'm going to skip this one, because that code is deleted later in the
series, and fixing it here just adds more churn.