x86/startup_64: Simplify calculation of initial page table address
authorArd Biesheuvel <ardb@kernel.org>
Tue, 27 Feb 2024 15:19:11 +0000 (16:19 +0100)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 4 Mar 2024 17:12:16 +0000 (18:12 +0100)
commitd6a41f184dcea0814260af2780e147022c11dca8
tree9e031b5b8a82e03dc1a071cf138a3e8ba5e14c3c
parent63bed96604205fa0b23c91d268df5f1f1b26faf6
x86/startup_64: Simplify calculation of initial page table address

Determining the address of the initial page table to program into CR3
involves:
- taking the physical address
- adding the SME encryption mask

On the primary entry path, the code is mapped using a 1:1 virtual to
physical translation, so the physical address can be taken directly
using a RIP-relative LEA instruction.

On the secondary entry path, the address can be obtained by taking the
offset from the virtual kernel base (__START_kernel_map) and adding the
physical kernel base.

This is implemented in a slightly confusing way, so clean this up.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20240227151907.387873-14-ardb+git@google.com
arch/x86/kernel/head_64.S