• Ard Biesheuvel's avatar
    x86/startup_64: Simplify virtual switch on primary boot · 82826395
    Ard Biesheuvel authored
    The secondary startup code is used on the primary boot path as well, but
    in this case, the initial part runs from a 1:1 mapping, until an
    explicit cross-jump is made to the kernel virtual mapping of the same
    code.
    
    On the secondary boot path, this jump is pointless as the code already
    executes from the mapping targeted by the jump. So combine this
    cross-jump with the jump from startup_64() into the common boot path.
    This simplifies the execution flow, and clearly separates code that runs
    from a 1:1 mapping from code that runs from the kernel virtual mapping.
    
    Note that this requires a page table switch, so hoist the CR3 assignment
    into startup_64() as well. And since absolute symbol references will no
    longer be permitted in .head.text once we enable the associated build
    time checks, a RIP-relative memory operand is used in the JMP
    instruction, referring to an absolute constant in the .init.rodata
    section.
    
    Given that the secondary startup code does not require a special
    placement inside the executable, move it to the .text section.
    Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
    Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
    Tested-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
    Link: https://lore.kernel.org/r/20240227151907.387873-15-ardb+git@google.com
    82826395
head_64.S 19.3 KB