Re: [PATCH v4 01/11] x86/startup_64: Simplify global variable accesses in GDT/IDT programming

From: Ard Biesheuvel
Date: Tue Feb 13 2024 - 16:54:16 EST


On Tue, 13 Feb 2024 at 21:06, Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> On Tue, Feb 13, 2024 at 01:41:45PM +0100, Ard Biesheuvel wrote:
> > @@ -632,5 +616,5 @@ void __head startup_64_setup_env(unsigned long physbase)
> > "movl %%eax, %%ss\n"
> > "movl %%eax, %%es\n" : : "a"(__KERNEL_DS) : "memory");
> >
> > - startup_64_load_idt(physbase);
> > + startup_64_load_idt(&RIP_REL_REF(vc_no_ghcb));
>
> It took me a while to figure out that even if we pass in one of the two
> GHCB handler pointers, we only set it if CONFIG_AMD_MEM_ENCRYPT.
>
> I think this ontop of yours is a bit more readable as it makes it
> perfectly clear *when* the pointer is valid.
>

Looks fine to me.

> Yeah, if handler is set, we set it for the X86_TRAP_VC vector
> unconditionally but that can be changed later, if really needed.
>

We might call the parameter 'vc_handler' to make this clearer.