Re: [PATCH 3/3] x86/mm, tracing: Fix CR2 corruption

From: Peter Zijlstra
Date: Thu Jul 04 2019 - 05:14:32 EST


On Thu, Jul 04, 2019 at 12:00:57AM +0200, Peter Zijlstra wrote:
> On Wed, Jul 03, 2019 at 01:27:09PM -0700, Andy Lutomirski wrote:
> > On Wed, Jul 3, 2019 at 3:28 AM root <peterz@xxxxxxxxxxxxx> wrote:
>
> > > @@ -1338,18 +1347,9 @@ ENTRY(error_entry)
> > > movq %rax, %rsp /* switch stack */
> > > ENCODE_FRAME_POINTER
> > > pushq %r12
> > > -
> > > - /*
> > > - * We need to tell lockdep that IRQs are off. We can't do this until
> > > - * we fix gsbase, and we should do it before enter_from_user_mode
> > > - * (which can take locks).
> > > - */
> > > - TRACE_IRQS_OFF
> >
> > This hunk looks wrong. Am I missing some other place that handles the
> > case where we enter from kernel mode and IRQs were on?
>
> > > - CALL_enter_from_user_mode
> > > ret
> > >
> > > .Lerror_entry_done:
> > > - TRACE_IRQS_OFF
> > > ret
> > >
> > > /*
>
> Did you perchance mean to complain about the .Lerror_entry_done one?
>
> Because I'm not seeing how the one before CALL_enter_from_user_mode can
> ever be from-kernel.
>
> But yes, that .Lerror_entry_done one looks fishy.

That works because idtentry will now do an unconditional TRACE_IRQS_OFF,
note how the patch removes the .if \paranoid around that.