Messages in this thread | | | Date | Thu, 10 Dec 2020 18:58:46 +0100 | From | Borislav Petkov <> | Subject | Re: [PATCH v2 07/12] x86: add new features for paravirt patching |
| |
On Wed, Dec 09, 2020 at 01:22:24PM +0100, Jürgen Groß wrote: > Lets take the spin_unlock() case. With patch 11 of the series this is > > PVOP_ALT_VCALLEE1(lock.queued_spin_unlock, lock, > "movb $0, (%%" _ASM_ARG1 ");", > X86_FEATURE_NO_PVUNLOCK); > > which boils down to ALTERNATIVE "call *lock.queued_spin_unlock" > "movb $0,(%rdi)" X86_FEATURE_NO_PVUNLOCK > > The initial (paravirt) code is an indirect call in order to allow > spin_unlock() before paravirt/alternative patching takes place. > > Paravirt patching will then replace the indirect call with a direct call > to the correct unlock function. Then alternative patching might replace > the direct call to the bare metal unlock with a plain "movb $0,(%rdi)" > in case pvlocks are not enabled.
Aha, that zeros the locking var on unlock, I see.
> In case alternative patching would occur first, the indirect call might > be replaced with the "movb ...", and then paravirt patching would > clobber that with the direct call, resulting in the bare metal > optimization being removed again.
Yeah, that explains the whole situation much better - thanks - and considering how complex the whole patching is, I wouldn't mind the gist of it as text in alternative_instructions() or in a comment above it so that we don't have to swap everything back in, months and years from now, when we optimize it yet again. :-}
Thx.
-- Regards/Gruss, Boris.
https://people.kernel.org/tglx/notes-about-netiquette
| |