x86/gsseg: Use the LKGS instruction if available for load_gs_index()
authorH. Peter Anvin (Intel) <hpa@zytor.com>
Thu, 12 Jan 2023 07:20:32 +0000 (23:20 -0800)
committerIngo Molnar <mingo@kernel.org>
Fri, 13 Jan 2023 09:07:27 +0000 (10:07 +0100)
commit92cbbadf73f45c5d8bb26ed8668ff59671ff21e6
treeaf1ce62216d2f0aa7051471fa8704f14a4288b06
parentae53fa18703000f507107df43efd1168a0365361
x86/gsseg: Use the LKGS instruction if available for load_gs_index()

The LKGS instruction atomically loads a segment descriptor into the
%gs descriptor registers, *except* that %gs.base is unchanged, and the
base is instead loaded into MSR_IA32_KERNEL_GS_BASE, which is exactly
what we want this function to do.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Signed-off-by: Xin Li <xin3.li@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230112072032.35626-6-xin3.li@intel.com
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
arch/x86/include/asm/gsseg.h
arch/x86/kernel/cpu/common.c
arch/x86/xen/enlighten_pv.c