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

From: Sean Christopherson
Date: Wed Jan 15 2020 - 17:57:27 EST


On Wed, Jan 15, 2020 at 02:27:54PM -0800, Luck, Tony wrote:
> 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:

Sounds like you're also writing code, in which case you should give
yourself credit with your own Co-developed-by: tag.

> > > +#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?

Not at all. I picked a semi-arbitrary name that was similar to existing
TIF names, I'll defer to anyone with an opinion.

> > > +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.

It's mostly paranoia, e.g. if sld_state==sld_off but the MSR bit was
misconfigured. No objection if you want to omit the check.

> > > @@ -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.

There's a random newline removal in do_trap(). It's a good change in the
sense that it eliminates an extra newline, bad in the sense that it's
unrelated to the rest of the patch.