On Tue, Nov 28, 2017 at 05:39:08PM +0100, Peter Zijlstra wrote: > @@ -220,7 +221,21 @@ For 32-bit we have the following conventions - kernel is > built with > .macro SWITCH_TO_USER_CR3 scratch_reg:req > STATIC_JUMP_IF_FALSE .Lend_\@, kaiser_enabled_key, def=1 > mov %cr3, \scratch_reg > - ADJUST_USER_CR3 \scratch_reg > + push \scratch_reg > + andq $(0x7FF), \scratch_reg > + bt \scratch_reg, PER_CPU_VAR(__asid_flush) > + jnc .Lnoflush_\@ > + > + btr \scratch_reg, PER_CPU_VAR(__asid_flush) > + pop \scratch_reg > + jmp .Ldo_\@ > + > +.Lnoflush_\@: > + pop \scratch_reg > + ALTERNATIVE "", "bts $63, \scratch_reg", X86_FEATURE_PCID > + > +.Ldo_\@: > + orq $(KAISER_SWITCH_MASK), \scratch_reg > mov \scratch_reg, %cr3 > .Lend_\@: > .endm
Ah, I suppose I should also deal with RESTORE_CR3...