• Dionna Glaze's avatar
    x86/efi: Safely enable unaccepted memory in UEFI · c0461bd1
    Dionna Glaze authored
    The UEFI v2.9 specification includes a new memory type to be used in
    environments where the OS must accept memory that is provided from its
    host. Before the introduction of this memory type, all memory was
    accepted eagerly in the firmware. In order for the firmware to safely
    stop accepting memory on the OS's behalf, the OS must affirmatively
    indicate support to the firmware. This is only a problem for AMD
    SEV-SNP, since Linux has had support for it since 5.19. The other
    technology that can make use of unaccepted memory, Intel TDX, does not
    yet have Linux support, so it can strictly require unaccepted memory
    support as a dependency of CONFIG_TDX and not require communication with
    the firmware.
    
    Enabling unaccepted memory requires calling a 0-argument enablement
    protocol before ExitBootServices. This call is only made if the kernel
    is compiled with UNACCEPTED_MEMORY=y
    
    This protocol will be removed after the end of life of the first LTS
    that includes it, in order to give firmware implementations an
    expiration date for it. When the protocol is removed, firmware will
    strictly infer that a SEV-SNP VM is running an OS that supports the
    unaccepted memory type. At the earliest convenience, when unaccepted
    memory support is added to Linux, SEV-SNP may take strict dependence in
    it. After the firmware removes support for the protocol, this should be
    reverted.
    
      [tl: address some checkscript warnings]
    Signed-off-by: default avatarDionna Glaze <dionnaglaze@google.com>
    Signed-off-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
    Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
    Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
    Link: https://lore.kernel.org/r/0d5f3d9a20b5cf361945b7ab1263c36586a78a42.1686063086.git.thomas.lendacky@amd.com
    c0461bd1
x86-stub.c 25.5 KB