Thread (96 messages) 96 messages, 7 authors, 2021-11-11

Re: [PATCH v6 14/42] x86/sev: Register GHCB memory when SEV-SNP is active

From: Brijesh Singh <hidden>
Date: 2021-11-04 15:27:15
Also in: kvm, linux-efi, linux-mm, lkml, platform-driver-x86


On 11/4/21 8:58 AM, Borislav Petkov wrote:
On Wed, Nov 03, 2021 at 03:10:16PM -0500, Brijesh Singh wrote:
quoted
Looking at the secondary CPU bring up path it seems that we will not be
getting #VC until the early_setup_idt() is called. I am thinking to add
function to register the GHCB from the early_setup_idt()

early_setup_idt()
{
   ...
   if (IS_ENABLED(CONFIG_MEM_ENCRYPT))
     sev_snp_register_ghcb()
   ...
}

The above will cover the APs
That will cover the APs during early boot as that is being called from
asm.
quoted
and for BSP case I can call the same function just after the final IDT
is loaded
Why after and not before?
I just looked at load_current_idt() and we should not get #VC before 
loading the new idt, so, its safe to do is before.

quoted
cpu_init_exception_handling()
{
    ...
    ...
    /* Finally load the IDT */
    load_current_idt();

    if (IS_ENABLED(CONFIG_MEM_ENCRYPT))
      sev_snp_register_ghcb()

}
That is also called on the APs - not only the BSP. trap_init() calls it
from start_kernel() which is the BSP and cpu_init_secondary() calls it
too, which is ofc the APs.

I guess that should be ok since you're calling the same function from
both but WTH do I know...
For AP case, we will be registering the same GHCB GPA twice, that should 
not be an issue. The GHCB spec does not restrict us on registering the 
GPA twice.

Of course, the current patch does not suffer with it. Let me know your 
preference.

thanks
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help