x86/cpu: Remove segment load from switch_to_new_gdt()
authorThomas Gleixner <tglx@linutronix.de>
Thu, 15 Sep 2022 11:10:41 +0000 (13:10 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 17 Oct 2022 14:40:56 +0000 (16:40 +0200)
commitb5636d45aae42aa345b4c7918bdef245ed63da68
tree4e8fd6a035991d8409d32dfeb1a37258ae389a81
parent9abf2313adc1ca1b6180c508c25f22f9395cc780
x86/cpu: Remove segment load from switch_to_new_gdt()

On 32bit FS and on 64bit GS segments are already set up correctly, but
load_percpu_segment() still sets [FG]S after switching from the early GDT
to the direct GDT.

For 32bit the segment load has no side effects, but on 64bit it causes
GSBASE to become 0, which means that any per CPU access before GSBASE is
set to the new value is going to fault. That's the reason why the whole
file containing this code has stackprotector removed.

But that's a pointless exercise for both 32 and 64 bit as the relevant
segment selector is already correct. Loading the new GDT does not change
that.

Remove the segment loads and add comments.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220915111143.097052006@infradead.org
arch/x86/include/asm/processor.h
arch/x86/kernel/cpu/common.c