Re: [PATCHv4 09/14] x86/mm: Handle boot-time paging mode switching at early boot

From: Ingo Molnar
Date: Thu Aug 17 2017 - 05:05:15 EST



* Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> wrote:

> /* Prepare to add new identity pagetables on demand. */
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index daf8936d0628..077e8b45784c 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -273,8 +273,20 @@ return_from_SYSCALL_64:
> * Change top bits to match most significant bit (47th or 56th bit
> * depending on paging mode) in the address.
> */
> +#ifdef CONFIG_X86_5LEVEL
> + testl $1, p4d_folded(%rip)
> + jnz 1f
> + shl $(64 - 57), %rcx
> + sar $(64 - 57), %rcx
> + jmp 2f
> +1:
> + shl $(64 - 48), %rcx
> + sar $(64 - 48), %rcx
> +2:
> +#else
> shl $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx
> sar $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx
> +#endif

So I really, really hate this change, as it slows down everything, not just LA57
hardware, and slows down a critical system call hot path. (I expect enterprise
distros to enable CONFIG_X86_5LEVEL.)

Could this use alternatives patching instead?

Thanks,

Ingo