Re: [RFC PATCH v2 6/6] x86/entry/pti: don't switch PGD on when pti_disable is set

From: Peter Zijlstra
Date: Wed Jan 10 2018 - 03:29:24 EST


On Tue, Jan 09, 2018 at 01:56:20PM +0100, Willy Tarreau wrote:
> - use pti_disable instead of task flag
> ---
> arch/x86/entry/calling.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h
> index 2c0d3b5..5361a10 100644
> --- a/arch/x86/entry/calling.h
> +++ b/arch/x86/entry/calling.h
> @@ -229,6 +229,11 @@
>
> .macro SWITCH_TO_USER_CR3_NOSTACK scratch_reg:req scratch_reg2:req
> ALTERNATIVE "jmp .Lend_\@", "", X86_FEATURE_PTI
> +
> + /* The "pti_disable" mm attribute is mirrored into this per-cpu var */
> + cmpb $0, PER_CPU_VAR(pti_disable)
> + jne .Lend_\@
> +
> mov %cr3, \scratch_reg

So could you switch back to a task flag for this? That word is already
cache-hot on the exit path while your new variable is not.