Re: [PATCH v11] x86/split_lock: Enable split lock detection by kernel

From: Luck, Tony
Date: Wed Jan 15 2020 - 17:27:59 EST


On Mon, Jan 13, 2020 at 09:55:21PM -0800, Sean Christopherson wrote:
> On Fri, Jan 10, 2020 at 11:24:09AM -0800, Luck, Tony wrote:

All comments accepted and code changed ... except for these three:

> > +#define TIF_SLD 18 /* split_lock_detect */
>
> A more informative name comment would be helpful since the flag is set when
> SLD is disabled by the previous task. Something like?
>
> #define TIF_NEED_SLD_RESTORE 18 /* Restore split lock detection on context switch */

That name is more informative ... but it is also really, really long. Are
you sure?

> > +bool handle_user_split_lock(struct pt_regs *regs, long error_code)
> > +{
> > + if ((regs->flags & X86_EFLAGS_AC) || sld_state == sld_fatal)
> > + return false;
>
> Maybe add "|| WARN_ON_ONCE(sld_state != sld_off)" to try to prevent the
> kernel from going fully into the weeds if a spurious #AC occurs.

Can a spurious #AC occur? I don't see how.

> > @@ -242,7 +243,6 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
> > {
> > struct task_struct *tsk = current;
> >
> > -
>
> Whitespace.
>
> > if (!do_trap_no_signal(tsk, trapnr, str, regs, error_code))
> > return;

I'm staring at the post patch code, and I can't see what whitespace
issue you see.

-Tony