• Brijesh Singh's avatar
    crypto: ccp: Add support to initialize the AMD-SP for SEV-SNP · 1ca5614b
    Brijesh Singh authored
    Before SNP VMs can be launched, the platform must be appropriately
    configured and initialized via the SNP_INIT command.
    
    During the execution of SNP_INIT command, the firmware configures
    and enables SNP security policy enforcement in many system components.
    Some system components write to regions of memory reserved by early
    x86 firmware (e.g. UEFI). Other system components write to regions
    provided by the operation system, hypervisor, or x86 firmware.
    Such system components can only write to HV-fixed pages or Default
    pages. They will error when attempting to write to pages in other page
    states after SNP_INIT enables their SNP enforcement.
    
    Starting in SNP firmware v1.52, the SNP_INIT_EX command takes a list of
    system physical address ranges to convert into the HV-fixed page states
    during the RMP initialization. If INIT_RMP is 1, hypervisors should
    provide all system physical address ranges that the hypervisor will
    never assign to a guest until the next RMP re-initialization.
    
    For instance, the memory that UEFI reserves should be included in the
    range list. This allows system components that occasionally write to
    memory (e.g. logging to UEFI reserved regions) to not fail due to
    RMP initialization and SNP enablement.
    
    Note that SNP_INIT(_EX) must not be executed while non-SEV guests are
    executing, otherwise it is possible that the system could reset or hang.
    The psp_init_on_probe module parameter was added for SEV/SEV-ES support
    and the init_ex_path module parameter to allow for time for the
    necessary file system to be mounted/available.
    
    SNP_INIT(_EX) does not use the file associated with init_ex_path. So, to
    avoid running into issues where SNP_INIT(_EX) is called while there are
    other running guests, issue it during module probe regardless of the
    psp_init_on_probe setting, but maintain the previous deferrable handling
    for SEV/SEV-ES initialization.
    
      [ mdr: Squash in psp_init_on_probe changes from Tom, reduce
        proliferation of 'probe' function parameter where possible.
        bp: Fix 32-bit allmodconfig build. ]
    Signed-off-by: default avatarBrijesh Singh <brijesh.singh@amd.com>
    Co-developed-by: default avatarAshish Kalra <ashish.kalra@amd.com>
    Signed-off-by: default avatarAshish Kalra <ashish.kalra@amd.com>
    Co-developed-by: default avatarJarkko Sakkinen <jarkko@profian.com>
    Signed-off-by: default avatarJarkko Sakkinen <jarkko@profian.com>
    Signed-off-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
    Signed-off-by: default avatarMichael Roth <michael.roth@amd.com>
    Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
    Link: https://lore.kernel.org/r/20240126041126.1927228-14-michael.roth@amd.com
    1ca5614b
sev-dev.c 40.8 KB