Re: [RFC 1/2] x86/entry/64: Use the TSS sp2 slot for rsp_scratch

From: Ingo Molnar
Date: Sun Jul 22 2018 - 16:19:54 EST



* Andy Lutomirski <luto@xxxxxxxxxx> wrote:

> In the non-trampoline SYSCALL64 path, we use a percpu variable to
> temporarily store the user RSP value. Instead of a separate
> variable, use the otherwise unused sp2 slot in the TSS. This will
> improve cache locality, as the sp1 slot is already used in the same
> code to find the kernel stack. It will also simplify a future
> change to make the non-trampoline path work in PTI mode.
>
> Signed-off-by: Andy Lutomirski <luto@xxxxxxxxxx>
> ---
> arch/x86/include/asm/processor.h | 5 +++++
> arch/x86/include/asm/thread_info.h | 1 +
> arch/x86/kernel/asm-offsets_64.c | 1 +
> arch/x86/kernel/process_64.c | 2 --
> 4 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
> index cfd29ee8c3da..2ef4c39ded45 100644
> --- a/arch/x86/include/asm/processor.h
> +++ b/arch/x86/include/asm/processor.h
> @@ -308,7 +308,12 @@ struct x86_hw_tss {
> */
> u64 sp1;
>
> + /*
> + * sp2 is scratch space used by the SYSCALL64 handler. Linux does
> + * not use rung 2, so sp2 is not otherwise needed.
> + */
> u64 sp2;

s/rung/ring

Thanks,

Ingo