Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RfC] OvmfPkg/AmdSev: add support for systemd-boot and secure boot #6537

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion OvmfPkg/AmdSev/AmdSevX64.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
BUILD_TARGETS = NOOPT|DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
FLASH_DEFINITION = OvmfPkg/AmdSev/AmdSevX64.fdf
PREBUILD = sh OvmfPkg/AmdSev/Grub/grub.sh

#
# Defines for default states. These can be changed on the command line.
# -D FLAG=VALUE
#
DEFINE SECURE_BOOT_ENABLE = TRUE
DEFINE SOURCE_DEBUG_ENABLE = FALSE

!include OvmfPkg/Include/Dsc/OvmfTpmDefines.dsc.inc
Expand All @@ -39,6 +39,7 @@
# Shell can be useful for debugging but should not be enabled for production
#
DEFINE BUILD_SHELL = FALSE
DEFINE SD_BOOT_ENABLE = FALSE

#
# Device drivers
Expand Down Expand Up @@ -189,7 +190,15 @@
OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf

!if $(SECURE_BOOT_ENABLE) == TRUE
PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
PlatformPKProtectionLib|SecurityPkg/Library/PlatformPKProtectionLibVarPolicy/PlatformPKProtectionLibVarPolicy.inf
SecureBootVariableProvisionLib|SecurityPkg/Library/SecureBootVariableProvisionLib/SecureBootVariableProvisionLib.inf
!else
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
!endif
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
Expand Down Expand Up @@ -385,6 +394,10 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
!if $(SECURE_BOOT_ENABLE) == TRUE
gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
!endif

[PcdsFixedAtBuild]
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize|1
Expand Down Expand Up @@ -606,6 +619,9 @@

MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
<LibraryClasses>
!if $(SECURE_BOOT_ENABLE) == TRUE
NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
!endif
!include OvmfPkg/Include/Dsc/OvmfTpmSecurityStub.dsc.inc
}

Expand Down Expand Up @@ -728,11 +744,19 @@
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf

OvmfPkg/AmdSev/SecretDxe/SecretDxe.inf
!if $(SD_BOOT_ENABLE) == TRUE
OvmfPkg/SdBootDxe/SdBoot.inf
!else
OvmfPkg/AmdSev/Grub/Grub.inf
!endif

!include OvmfPkg/Include/Dsc/ShellComponents.dsc.inc
!include OvmfPkg/Include/Dsc/OvmfRngComponents.dsc.inc

!if $(SECURE_BOOT_ENABLE) == TRUE
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
!endif

OvmfPkg/PlatformDxe/Platform.inf
OvmfPkg/AmdSevDxe/AmdSevDxe.inf {
<LibraryClasses>
Expand Down
10 changes: 9 additions & 1 deletion OvmfPkg/AmdSev/AmdSevX64.fdf
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ INF OvmfPkg/MptScsiDxe/MptScsiDxe.inf
INF OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf
!endif

!if $(SECURE_BOOT_ENABLE) == TRUE
INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
!endif

INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
Expand Down Expand Up @@ -282,8 +286,12 @@ INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResour
INF FatPkg/EnhancedFatDxe/Fat.inf
INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf

INF OvmfPkg/AmdSev/SecretDxe/SecretDxe.inf
INF OvmfPkg/AmdSev/SecretDxe/SecretDxe.inf
!if $(SD_BOOT_ENABLE) == TRUE
INF OvmfPkg/SdBootDxe/SdBoot.inf
!else
INF OvmfPkg/AmdSev/Grub/Grub.inf
!endif

INF MdeModulePkg/Logo/LogoDxe.inf

Expand Down
15 changes: 14 additions & 1 deletion OvmfPkg/AmdSev/BlobVerifierLibSevHashes/BlobVerifierSevHashes.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,23 @@ BlobVerifierLibSevHashesConstructor (
Ptr = (void *)(UINTN)FixedPcdGet64 (PcdQemuHashTableBase);
Size = FixedPcdGet32 (PcdQemuHashTableSize);

DEBUG ((
DEBUG_INFO,
"%a: hash table: 0x%p +0x%x\n",
__func__,
Ptr,
Size
));

if ((Ptr == NULL) || (Size < sizeof *Ptr) ||
!CompareGuid (&Ptr->Guid, &SEV_HASH_TABLE_GUID) ||
(Ptr->Len < sizeof *Ptr) || (Ptr->Len > Size))
{
DEBUG ((
DEBUG_INFO,
"%a: hash table: 404\n",
__func__
));
return RETURN_SUCCESS;
}

Expand All @@ -251,7 +264,7 @@ BlobVerifierLibSevHashesConstructor (
mHashesTableSize = Ptr->Len - sizeof Ptr->Guid - sizeof Ptr->Len;

DEBUG ((
DEBUG_VERBOSE,
DEBUG_INFO,
"%a: mHashesTable=0x%p, Size=%u\n",
__func__,
mHashesTable,
Expand Down
9 changes: 9 additions & 0 deletions OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,15 @@ PlatformBootManagerAfterConsole (
LOAD_OPTION_ACTIVE
);

//
// Register systemd-boot
//
PlatformRegisterFvBootOption (
&gSdBootFileGuid,
L"systemd boot",
LOAD_OPTION_ACTIVE
);

RemoveStaleFvFileOptions ();
SetBootOrderFromQemu ();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@
gRootBridgesConnectedEventGroupGuid
gUefiShellFileGuid
gGrubFileGuid
gSdBootFileGuid
1 change: 1 addition & 0 deletions OvmfPkg/OvmfPkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
gOvmfVariableGuid = {0x50bea1e5, 0xa2c5, 0x46e9, {0x9b, 0x3a, 0x59, 0x59, 0x65, 0x16, 0xb0, 0x0a}}
gQemuFirmwareResourceHobGuid = {0x3cc47b04, 0x0d3e, 0xaa64, {0x06, 0xa6, 0x4b, 0xdc, 0x9a, 0x2c, 0x61, 0x19}}
gRtcRegisterBaseAddressHobGuid = {0x40435d97, 0xeb37, 0x4a4b, {0x7f, 0xad, 0xb7, 0xed, 0x72, 0xa1, 0x43, 0xc5}}
gSdBootFileGuid = {0x2b86cc73, 0x1c22, 0x4179, {0x87, 0xaa, 0x8e, 0x31, 0xfa, 0x8c, 0x86, 0x7b}}

[Ppis]
# PPI whose presence in the PPI database signals that the TPM base address
Expand Down
23 changes: 23 additions & 0 deletions OvmfPkg/SdBootDxe/SdBoot.inf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## @file
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##

[Defines]
INF_VERSION = 0x00010006
BASE_NAME = SdBoot
FILE_GUID = 2b86cc73-1c22-4179-87aa-8e31fa8c867b # gSdBootFileGuid
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = UefiMain

[Packages]
OvmfPkg/OvmfPkg.dec

[Binaries.X64]
PE32|/usr/lib/systemd/boot/efi/systemd-bootx64.efi|*

[Binaries.AA64]
PE32|/usr/lib/systemd/boot/efi/systemd-bootaa64.efi|*

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kraxel Can you also add support for Binaries.LOONGARCH64 (systemd-bootloongarch64.efi)? I will be able to do platform testing for you, Tks !

Loading