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

From: Peter Zijlstra
Date: Sat Jan 25 2020 - 15:12:50 EST


On Sat, Jan 25, 2020 at 11:55:13AM -0800, Luck, Tony wrote:
> > > +static inline bool match_option(const char *arg, int arglen, const char *opt)
> > > +{
> > > + int len = strlen(opt);
> > > +
> > > + return len == arglen && !strncmp(arg, opt, len);
> > > +}
> >
> > There's the same function in arch/x86/kernel/cpu/bugs.c. Why are you
> > duplicating it here?
> >
> > Yeah, this whole chunk looks like it has been "influenced" by the sec
> > mitigations in bugs.c :-)
>
> Blame PeterZ for that. For now I'd like to add the duplicate inline function
> and then clean up by putting it into some header file (and maybe hunting down
> other places where it could be used).

Yeah, I copy/paste cobbled that together. I figured it was easier to
'borrow' something that worked and adapt it than try and write
something new in a hurry.

> > > + /*
> > > + * If this is anything other than the boot-cpu, you've done
> > > + * funny things and you get to keep whatever pieces.
> > > + */
> > > + pr_warn("MSR fail -- disabled\n");
> >
> > What's that for? Guests?
>
> Also some PeterZ code. As the comment implies we really shouldn't be able
> to get here. This whole function should only be called on CPU models that
> support the MSR ... but PeterZ is defending against the situation that sometimes
> there are special SKUs with the same model number (since we may be here because
> of an x86_match_cpu() hit, rather than the architectural enumeration check).

My thinking was Virt, virt likes to mess up all msr expectations.