]> git.ipfire.org Git - thirdparty/linux.git/commit
x86/boot/64: Simplify global variable accesses in GDT/IDT programming
authorArd Biesheuvel <ardb@kernel.org>
Wed, 21 Feb 2024 11:35:08 +0000 (12:35 +0100)
committerIngo Molnar <mingo@kernel.org>
Mon, 26 Feb 2024 11:58:11 +0000 (12:58 +0100)
commit5da793671957e8e99fa74423fab2737bf8c772a8
tree75945bf9778275cdd8ed4feafce47411a959ca69
parent2e5fc4786b7ad311393a70894c773aa106c6dbb3
x86/boot/64: Simplify global variable accesses in GDT/IDT programming

There are two code paths in the startup code to program an IDT: one that
runs from the 1:1 mapping and one that runs from the virtual kernel
mapping. Currently, these are strictly separate because fixup_pointer()
is used on the 1:1 path, which will produce the wrong value when used
while executing from the virtual kernel mapping.

Switch to RIP_REL_REF() so that the two code paths can be merged. Also,
move the GDT and IDT descriptors to the stack so that they can be
referenced directly, rather than via RIP_REL_REF().

Rename startup_64_setup_env() to startup_64_setup_gdt_idt() while at it,
to make the call from assembler self-documenting.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20240221113506.2565718-19-ardb+git@google.com
arch/x86/include/asm/setup.h
arch/x86/kernel/head64.c
arch/x86/kernel/head_64.S