Re: [RFC][PATCH 6/6] objtool,x86: Rewrite retpoline thunk calls
From: Borislav Petkov
Date: Sat Feb 20 2021 - 12:46:44 EST
On Sat, Feb 20, 2021 at 05:48:46PM +0100, Peter Zijlstra wrote:
> - straight line execution is always better than a round-trip to
> somewhere else, no matter how trivial.
Sure, but not at that price. Especially not if it is waaay down in perf
profiles.
> - supposely EIBRS (yeah, I know, there's a paper out there) should
> result in no longer using retpolines.
Yap, supposedly both vendors have stuff like that in the works. When
that happens, we can finally use ALTERNATIVE_3 in the ratpolines. :-)
> - I really, as in _REALLY_ don't want to do a CET enabled retpoline
WTF is that? Can we deal with one atrocity at a time pls...
> - IOW, retpolines should be on their way out (knock on wood)
Yap, my hope too.
> - doing this was fun :-)
I know.
> - this stuff was mostly trivial make work stuff I could do with a head
> full of snot and a headache.
I don't want to imagine what you'd come up with when you're all healthy
and rested. :-P
> - if we had negative alternatives objtool doesn't need to actually
> rewrite code in this case. It could simply emit alternative entries
> and call it a day.
I don't mind the negative alt per se - I mind the implementation I saw.
I'm sure we can come up with something nicer, like, for example, struct
alt_instr.flags to denote that this feature is a NOT feature. IOW, I'd
like for the fact that a feature is a NOT feature or patching needs to
happen in the NOT case, to be explicitly stated with a flag. I.e.,
if (!boot_cpu_has(a->cpuid) && !(a->flags & PATCH_WHEN_X86_FEATURE_FLAG_NOT_SET))
continue;
Something like that.
> - objtool already rewrites code
Sure, as long as one can reconstruct from looking at the asm, what
objdool has changed. I fear that'll get out of control if not done with
restraint and proper documentation.
> - I have more cases for objtool to rewrite code (I'll see if I can
> rebase and post that this weekend -- no promises).
Oh noes.
> - also https://lkml.kernel.org/r/20200625200235.GQ4781@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Oh well, I guess you can simply make objtool compile the kernel and be
done with it.
:)
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette