• Ard Biesheuvel's avatar
    x86/sev: Fix position dependent variable references in startup code · 1c811d40
    Ard Biesheuvel authored
    The early startup code executes from a 1:1 mapping of memory, which
    differs from the mapping that the code was linked and/or relocated to
    run at. The latter mapping is not active yet at this point, and so
    symbol references that rely on it will fault.
    
    Given that the core kernel is built without -fPIC, symbol references are
    typically emitted as absolute, and so any such references occuring in
    the early startup code will therefore crash the kernel.
    
    While an attempt was made to work around this for the early SEV/SME
    startup code, by forcing RIP-relative addressing for certain global
    SEV/SME variables via inline assembly (see snp_cpuid_get_table() for
    example), RIP-relative addressing must be pervasively enforced for
    SEV/SME global variables when accessed prior to page table fixups.
    
    __startup_64() already handles this issue for select non-SEV/SME global
    variables using fixup_pointer(), which adjusts the pointer relative to a
    `physaddr` argu...
    1c811d40
sev-shared.c 31.5 KB