Re: [PATCH v7 3/9] x86/startup_64: Simplify calculation of initial page table address

From: Borislav Petkov
Date: Wed Feb 28 2024 - 16:28:46 EST


On Tue, Feb 27, 2024 at 04:19:11PM +0100, Ard Biesheuvel wrote:
> From: Ard Biesheuvel <ardb@xxxxxxxxxx>
>
> 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@xxxxxxxxxx>
> ---
> arch/x86/kernel/head_64.S | 25 ++++++--------------
> 1 file changed, 7 insertions(+), 18 deletions(-)

Reviewed-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette