* [PATCH v2 1/1] OvmfPkg: replace SECURE_BOOT_FEATURE_ENABLED with PcdSecureBootSupported
@ 2023-04-21 6:55 Gerd Hoffmann
2023-05-04 10:09 ` Gerd Hoffmann
2023-05-06 7:14 ` Yao, Jiewen
0 siblings, 2 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2023-04-21 6:55 UTC (permalink / raw)
To: devel
Cc: Sebastien Boeuf, Pawel Polawski, Ard Biesheuvel, Jiewen Yao,
Jordan Justen, Gerd Hoffmann, Oliver Steffen
Drop the '-D SECURE_BOOT_FEATURE_ENABLED' compile time option,
use a new FeaturePcd instead.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
OvmfPkg/OvmfPkg.dec | 3 +++
OvmfPkg/CloudHv/CloudHvX64.dsc | 10 +---------
OvmfPkg/IntelTdx/IntelTdxX64.dsc | 10 +---------
OvmfPkg/Microvm/MicrovmX64.dsc | 10 +---------
OvmfPkg/OvmfPkgIa32.dsc | 10 +---------
OvmfPkg/OvmfPkgIa32X64.dsc | 10 +---------
OvmfPkg/OvmfPkgX64.dsc | 10 +---------
OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf | 2 ++
OvmfPkg/PlatformPei/PlatformPei.inf | 1 +
OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c | 11 ++++-------
OvmfPkg/PlatformPei/Platform.c | 7 ++++---
11 files changed, 20 insertions(+), 64 deletions(-)
diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index 749fbd3b6bf4..03ae29e7b034 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -488,6 +488,9 @@ [PcdsFeatureFlag]
# used by OVMF, the varstore pflash chip, LockBox etc).
gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|FALSE|BOOLEAN|0x1e
+ ## This feature flag indicates the firmware build supports secure boot.
+ gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|FALSE|BOOLEAN|0x6d
+
## Informs modules (including pre-DXE-phase modules) whether the platform
# firmware contains a CSM (Compatibility Support Module).
#
diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index cc2dd925bc94..2a1139daaa19 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -93,15 +93,6 @@ [BuildOptions]
INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
- #
- # SECURE_BOOT_FEATURE_ENABLED
- #
-!if $(SECURE_BOOT_ENABLE) == TRUE
- MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
- INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
- GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
-!endif
-
!include NetworkPkg/NetworkBuildOptions.dsc.inc
[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
@@ -477,6 +468,7 @@ [PcdsFeatureFlag]
gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
!endif
!if $(SECURE_BOOT_ENABLE) == TRUE
+ gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
!endif
diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
index f73440905540..d4403f11a7c6 100644
--- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
+++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
@@ -90,15 +90,6 @@ [BuildOptions]
INTEL:*_*_*_CC_FLAGS = /D TDX_PEI_LESS_BOOT
GCC:*_*_*_CC_FLAGS = -D TDX_PEI_LESS_BOOT
- #
- # SECURE_BOOT_FEATURE_ENABLED
- #
-!if $(SECURE_BOOT_ENABLE) == TRUE
- MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
- INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
- GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
-!endif
-
[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
XCODE:*_*_*_DLINK_FLAGS = -seg1addr 0x1000 -segalign 0x1000
@@ -387,6 +378,7 @@ [PcdsFeatureFlag]
gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|TRUE
!endif
!if $(SECURE_BOOT_ENABLE) == TRUE
+ gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
!endif
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index e9aab515592f..6fc11cc4d192 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -91,15 +91,6 @@ [BuildOptions]
INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
- #
- # SECURE_BOOT_FEATURE_ENABLED
- #
-!if $(SECURE_BOOT_ENABLE) == TRUE
- MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
- INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
- GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
-!endif
-
!include NetworkPkg/NetworkBuildOptions.dsc.inc
[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
@@ -473,6 +464,7 @@ [PcdsFeatureFlag]
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
!if $(SECURE_BOOT_ENABLE) == TRUE
+ gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
!endif
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 86177bb94899..16916ec58247 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -94,15 +94,6 @@ [BuildOptions]
INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
- #
- # SECURE_BOOT_FEATURE_ENABLED
- #
-!if $(SECURE_BOOT_ENABLE) == TRUE
- MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
- INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
- GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
-!endif
-
!include NetworkPkg/NetworkBuildOptions.dsc.inc
[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
@@ -484,6 +475,7 @@ [PcdsFeatureFlag]
gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
!endif
!if $(SECURE_BOOT_ENABLE) == TRUE
+ gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
!endif
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 065b54450647..936d763269c1 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -98,15 +98,6 @@ [BuildOptions]
INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
- #
- # SECURE_BOOT_FEATURE_ENABLED
- #
-!if $(SECURE_BOOT_ENABLE) == TRUE
- MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
- INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
- GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
-!endif
-
!include NetworkPkg/NetworkBuildOptions.dsc.inc
[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
@@ -490,6 +481,7 @@ [PcdsFeatureFlag]
gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
!endif
!if $(SECURE_BOOT_ENABLE) == TRUE
+ gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
!endif
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 3d405cd4ade0..1c763b27def1 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -112,15 +112,6 @@ [BuildOptions]
INTEL:*_*_*_CC_FLAGS = /D TDX_GUEST_SUPPORTED
GCC:*_*_*_CC_FLAGS = -D TDX_GUEST_SUPPORTED
- #
- # SECURE_BOOT_FEATURE_ENABLED
- #
-!if $(SECURE_BOOT_ENABLE) == TRUE
- MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
- INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
- GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
-!endif
-
!include NetworkPkg/NetworkBuildOptions.dsc.inc
[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
@@ -511,6 +502,7 @@ [PcdsFeatureFlag]
gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
!endif
!if $(SECURE_BOOT_ENABLE) == TRUE
+ gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
!endif
diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
index 8cda78d0d0b4..f152c5504661 100644
--- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
+++ b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
@@ -47,6 +47,8 @@ [LibraryClasses]
[Protocols]
gEfiSimpleFileSystemProtocolGuid ## CONSUMES
+[Pcd]
+ gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported
[Guids]
gEfiFileInfoGuid
diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
index 1fadadeb5565..3934aeed9514 100644
--- a/OvmfPkg/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/PlatformPei/PlatformPei.inf
@@ -94,6 +94,7 @@ [Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase
gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtr
gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtrSize
+ gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported
gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
index 72289da35819..d4139b911528 100644
--- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
+++ b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
@@ -28,14 +28,12 @@ ConnectNvVarsToFileSystem (
IN EFI_HANDLE FsHandle
)
{
- #ifdef SECURE_BOOT_FEATURE_ENABLED
-
- return EFI_UNSUPPORTED;
-
- #else
-
EFI_STATUS Status;
+ if (FeaturePcdGet (PcdSecureBootSupported)) {
+ return EFI_UNSUPPORTED;
+ }
+
//
// We might fail to load the variable, since the file system initially
// will not have the NvVars file.
@@ -52,7 +50,6 @@ ConnectNvVarsToFileSystem (
}
return Status;
- #endif
}
/**
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index cc9384ba5c4e..c56247e294f2 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -222,9 +222,10 @@ ReserveEmuVariableNvStore (
VariableStore = (EFI_PHYSICAL_ADDRESS)(UINTN)PlatformReserveEmuVariableNvStore ();
PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
- #ifdef SECURE_BOOT_FEATURE_ENABLED
- PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
- #endif
+ if (FeaturePcdGet (PcdSecureBootSupported)) {
+ // restore emulated VarStore from pristine ROM copy
+ PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
+ }
ASSERT_RETURN_ERROR (PcdStatus);
}
--
2.40.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] OvmfPkg: replace SECURE_BOOT_FEATURE_ENABLED with PcdSecureBootSupported
2023-04-21 6:55 [PATCH v2 1/1] OvmfPkg: replace SECURE_BOOT_FEATURE_ENABLED with PcdSecureBootSupported Gerd Hoffmann
@ 2023-05-04 10:09 ` Gerd Hoffmann
2023-05-04 13:57 ` [edk2-devel] " Ard Biesheuvel
2023-05-06 7:14 ` Yao, Jiewen
1 sibling, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2023-05-04 10:09 UTC (permalink / raw)
To: devel
Cc: Sebastien Boeuf, Pawel Polawski, Ard Biesheuvel, Jiewen Yao,
Jordan Justen, Oliver Steffen
Ping.
On Fri, Apr 21, 2023 at 08:55:44AM +0200, Gerd Hoffmann wrote:
> Drop the '-D SECURE_BOOT_FEATURE_ENABLED' compile time option,
> use a new FeaturePcd instead.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> OvmfPkg/OvmfPkg.dec | 3 +++
> OvmfPkg/CloudHv/CloudHvX64.dsc | 10 +---------
> OvmfPkg/IntelTdx/IntelTdxX64.dsc | 10 +---------
> OvmfPkg/Microvm/MicrovmX64.dsc | 10 +---------
> OvmfPkg/OvmfPkgIa32.dsc | 10 +---------
> OvmfPkg/OvmfPkgIa32X64.dsc | 10 +---------
> OvmfPkg/OvmfPkgX64.dsc | 10 +---------
> OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf | 2 ++
> OvmfPkg/PlatformPei/PlatformPei.inf | 1 +
> OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c | 11 ++++-------
> OvmfPkg/PlatformPei/Platform.c | 7 ++++---
> 11 files changed, 20 insertions(+), 64 deletions(-)
>
> diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
> index 749fbd3b6bf4..03ae29e7b034 100644
> --- a/OvmfPkg/OvmfPkg.dec
> +++ b/OvmfPkg/OvmfPkg.dec
> @@ -488,6 +488,9 @@ [PcdsFeatureFlag]
> # used by OVMF, the varstore pflash chip, LockBox etc).
> gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|FALSE|BOOLEAN|0x1e
>
> + ## This feature flag indicates the firmware build supports secure boot.
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|FALSE|BOOLEAN|0x6d
> +
> ## Informs modules (including pre-DXE-phase modules) whether the platform
> # firmware contains a CSM (Compatibility Support Module).
> #
> diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
> index cc2dd925bc94..2a1139daaa19 100644
> --- a/OvmfPkg/CloudHv/CloudHvX64.dsc
> +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
> @@ -93,15 +93,6 @@ [BuildOptions]
> INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
> GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
>
> - #
> - # SECURE_BOOT_FEATURE_ENABLED
> - #
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> -!endif
> -
> !include NetworkPkg/NetworkBuildOptions.dsc.inc
>
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> @@ -477,6 +468,7 @@ [PcdsFeatureFlag]
> gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
> !endif
> !if $(SECURE_BOOT_ENABLE) == TRUE
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> !endif
>
> diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> index f73440905540..d4403f11a7c6 100644
> --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> @@ -90,15 +90,6 @@ [BuildOptions]
> INTEL:*_*_*_CC_FLAGS = /D TDX_PEI_LESS_BOOT
> GCC:*_*_*_CC_FLAGS = -D TDX_PEI_LESS_BOOT
>
> - #
> - # SECURE_BOOT_FEATURE_ENABLED
> - #
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> -!endif
> -
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> XCODE:*_*_*_DLINK_FLAGS = -seg1addr 0x1000 -segalign 0x1000
> @@ -387,6 +378,7 @@ [PcdsFeatureFlag]
> gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|TRUE
> !endif
> !if $(SECURE_BOOT_ENABLE) == TRUE
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> !endif
>
> diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
> index e9aab515592f..6fc11cc4d192 100644
> --- a/OvmfPkg/Microvm/MicrovmX64.dsc
> +++ b/OvmfPkg/Microvm/MicrovmX64.dsc
> @@ -91,15 +91,6 @@ [BuildOptions]
> INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
> GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
>
> - #
> - # SECURE_BOOT_FEATURE_ENABLED
> - #
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> -!endif
> -
> !include NetworkPkg/NetworkBuildOptions.dsc.inc
>
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> @@ -473,6 +464,7 @@ [PcdsFeatureFlag]
> gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
> gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
> !if $(SECURE_BOOT_ENABLE) == TRUE
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> !endif
>
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 86177bb94899..16916ec58247 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -94,15 +94,6 @@ [BuildOptions]
> INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
> GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
>
> - #
> - # SECURE_BOOT_FEATURE_ENABLED
> - #
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> -!endif
> -
> !include NetworkPkg/NetworkBuildOptions.dsc.inc
>
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> @@ -484,6 +475,7 @@ [PcdsFeatureFlag]
> gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
> !endif
> !if $(SECURE_BOOT_ENABLE) == TRUE
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> !endif
>
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 065b54450647..936d763269c1 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -98,15 +98,6 @@ [BuildOptions]
> INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
> GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
>
> - #
> - # SECURE_BOOT_FEATURE_ENABLED
> - #
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> -!endif
> -
> !include NetworkPkg/NetworkBuildOptions.dsc.inc
>
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> @@ -490,6 +481,7 @@ [PcdsFeatureFlag]
> gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
> !endif
> !if $(SECURE_BOOT_ENABLE) == TRUE
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> !endif
>
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index 3d405cd4ade0..1c763b27def1 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -112,15 +112,6 @@ [BuildOptions]
> INTEL:*_*_*_CC_FLAGS = /D TDX_GUEST_SUPPORTED
> GCC:*_*_*_CC_FLAGS = -D TDX_GUEST_SUPPORTED
>
> - #
> - # SECURE_BOOT_FEATURE_ENABLED
> - #
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> -!endif
> -
> !include NetworkPkg/NetworkBuildOptions.dsc.inc
>
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> @@ -511,6 +502,7 @@ [PcdsFeatureFlag]
> gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
> !endif
> !if $(SECURE_BOOT_ENABLE) == TRUE
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> !endif
>
> diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
> index 8cda78d0d0b4..f152c5504661 100644
> --- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
> +++ b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
> @@ -47,6 +47,8 @@ [LibraryClasses]
> [Protocols]
> gEfiSimpleFileSystemProtocolGuid ## CONSUMES
>
> +[Pcd]
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported
>
> [Guids]
> gEfiFileInfoGuid
> diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
> index 1fadadeb5565..3934aeed9514 100644
> --- a/OvmfPkg/PlatformPei/PlatformPei.inf
> +++ b/OvmfPkg/PlatformPei/PlatformPei.inf
> @@ -94,6 +94,7 @@ [Pcd]
> gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase
> gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtr
> gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtrSize
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported
> gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
> gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
> diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
> index 72289da35819..d4139b911528 100644
> --- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
> +++ b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
> @@ -28,14 +28,12 @@ ConnectNvVarsToFileSystem (
> IN EFI_HANDLE FsHandle
> )
> {
> - #ifdef SECURE_BOOT_FEATURE_ENABLED
> -
> - return EFI_UNSUPPORTED;
> -
> - #else
> -
> EFI_STATUS Status;
>
> + if (FeaturePcdGet (PcdSecureBootSupported)) {
> + return EFI_UNSUPPORTED;
> + }
> +
> //
> // We might fail to load the variable, since the file system initially
> // will not have the NvVars file.
> @@ -52,7 +50,6 @@ ConnectNvVarsToFileSystem (
> }
>
> return Status;
> - #endif
> }
>
> /**
> diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
> index cc9384ba5c4e..c56247e294f2 100644
> --- a/OvmfPkg/PlatformPei/Platform.c
> +++ b/OvmfPkg/PlatformPei/Platform.c
> @@ -222,9 +222,10 @@ ReserveEmuVariableNvStore (
> VariableStore = (EFI_PHYSICAL_ADDRESS)(UINTN)PlatformReserveEmuVariableNvStore ();
> PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
>
> - #ifdef SECURE_BOOT_FEATURE_ENABLED
> - PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
> - #endif
> + if (FeaturePcdGet (PcdSecureBootSupported)) {
> + // restore emulated VarStore from pristine ROM copy
> + PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
> + }
>
> ASSERT_RETURN_ERROR (PcdStatus);
> }
> --
> 2.40.0
>
--
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [PATCH v2 1/1] OvmfPkg: replace SECURE_BOOT_FEATURE_ENABLED with PcdSecureBootSupported
2023-05-04 10:09 ` Gerd Hoffmann
@ 2023-05-04 13:57 ` Ard Biesheuvel
0 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2023-05-04 13:57 UTC (permalink / raw)
To: devel, kraxel
Cc: Sebastien Boeuf, Pawel Polawski, Ard Biesheuvel, Jiewen Yao,
Jordan Justen, Oliver Steffen
On Thu, 4 May 2023 at 12:09, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> Ping.
>
Queued up now - thanks.
> On Fri, Apr 21, 2023 at 08:55:44AM +0200, Gerd Hoffmann wrote:
> > Drop the '-D SECURE_BOOT_FEATURE_ENABLED' compile time option,
> > use a new FeaturePcd instead.
> >
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> > ---
> > OvmfPkg/OvmfPkg.dec | 3 +++
> > OvmfPkg/CloudHv/CloudHvX64.dsc | 10 +---------
> > OvmfPkg/IntelTdx/IntelTdxX64.dsc | 10 +---------
> > OvmfPkg/Microvm/MicrovmX64.dsc | 10 +---------
> > OvmfPkg/OvmfPkgIa32.dsc | 10 +---------
> > OvmfPkg/OvmfPkgIa32X64.dsc | 10 +---------
> > OvmfPkg/OvmfPkgX64.dsc | 10 +---------
> > OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf | 2 ++
> > OvmfPkg/PlatformPei/PlatformPei.inf | 1 +
> > OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c | 11 ++++-------
> > OvmfPkg/PlatformPei/Platform.c | 7 ++++---
> > 11 files changed, 20 insertions(+), 64 deletions(-)
> >
> > diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
> > index 749fbd3b6bf4..03ae29e7b034 100644
> > --- a/OvmfPkg/OvmfPkg.dec
> > +++ b/OvmfPkg/OvmfPkg.dec
> > @@ -488,6 +488,9 @@ [PcdsFeatureFlag]
> > # used by OVMF, the varstore pflash chip, LockBox etc).
> > gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|FALSE|BOOLEAN|0x1e
> >
> > + ## This feature flag indicates the firmware build supports secure boot.
> > + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|FALSE|BOOLEAN|0x6d
> > +
> > ## Informs modules (including pre-DXE-phase modules) whether the platform
> > # firmware contains a CSM (Compatibility Support Module).
> > #
> > diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
> > index cc2dd925bc94..2a1139daaa19 100644
> > --- a/OvmfPkg/CloudHv/CloudHvX64.dsc
> > +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
> > @@ -93,15 +93,6 @@ [BuildOptions]
> > INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
> > GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> >
> > - #
> > - # SECURE_BOOT_FEATURE_ENABLED
> > - #
> > -!if $(SECURE_BOOT_ENABLE) == TRUE
> > - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> > - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> > - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> > -!endif
> > -
> > !include NetworkPkg/NetworkBuildOptions.dsc.inc
> >
> > [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> > @@ -477,6 +468,7 @@ [PcdsFeatureFlag]
> > gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
> > !endif
> > !if $(SECURE_BOOT_ENABLE) == TRUE
> > + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> > gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> > !endif
> >
> > diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> > index f73440905540..d4403f11a7c6 100644
> > --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> > +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> > @@ -90,15 +90,6 @@ [BuildOptions]
> > INTEL:*_*_*_CC_FLAGS = /D TDX_PEI_LESS_BOOT
> > GCC:*_*_*_CC_FLAGS = -D TDX_PEI_LESS_BOOT
> >
> > - #
> > - # SECURE_BOOT_FEATURE_ENABLED
> > - #
> > -!if $(SECURE_BOOT_ENABLE) == TRUE
> > - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> > - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> > - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> > -!endif
> > -
> > [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> > GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> > XCODE:*_*_*_DLINK_FLAGS = -seg1addr 0x1000 -segalign 0x1000
> > @@ -387,6 +378,7 @@ [PcdsFeatureFlag]
> > gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|TRUE
> > !endif
> > !if $(SECURE_BOOT_ENABLE) == TRUE
> > + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> > gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> > !endif
> >
> > diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
> > index e9aab515592f..6fc11cc4d192 100644
> > --- a/OvmfPkg/Microvm/MicrovmX64.dsc
> > +++ b/OvmfPkg/Microvm/MicrovmX64.dsc
> > @@ -91,15 +91,6 @@ [BuildOptions]
> > INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
> > GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> >
> > - #
> > - # SECURE_BOOT_FEATURE_ENABLED
> > - #
> > -!if $(SECURE_BOOT_ENABLE) == TRUE
> > - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> > - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> > - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> > -!endif
> > -
> > !include NetworkPkg/NetworkBuildOptions.dsc.inc
> >
> > [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> > @@ -473,6 +464,7 @@ [PcdsFeatureFlag]
> > gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
> > gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
> > !if $(SECURE_BOOT_ENABLE) == TRUE
> > + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> > gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> > !endif
> >
> > diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> > index 86177bb94899..16916ec58247 100644
> > --- a/OvmfPkg/OvmfPkgIa32.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32.dsc
> > @@ -94,15 +94,6 @@ [BuildOptions]
> > INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
> > GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> >
> > - #
> > - # SECURE_BOOT_FEATURE_ENABLED
> > - #
> > -!if $(SECURE_BOOT_ENABLE) == TRUE
> > - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> > - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> > - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> > -!endif
> > -
> > !include NetworkPkg/NetworkBuildOptions.dsc.inc
> >
> > [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> > @@ -484,6 +475,7 @@ [PcdsFeatureFlag]
> > gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
> > !endif
> > !if $(SECURE_BOOT_ENABLE) == TRUE
> > + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> > gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> > !endif
> >
> > diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> > index 065b54450647..936d763269c1 100644
> > --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> > @@ -98,15 +98,6 @@ [BuildOptions]
> > INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
> > GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> >
> > - #
> > - # SECURE_BOOT_FEATURE_ENABLED
> > - #
> > -!if $(SECURE_BOOT_ENABLE) == TRUE
> > - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> > - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> > - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> > -!endif
> > -
> > !include NetworkPkg/NetworkBuildOptions.dsc.inc
> >
> > [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> > @@ -490,6 +481,7 @@ [PcdsFeatureFlag]
> > gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
> > !endif
> > !if $(SECURE_BOOT_ENABLE) == TRUE
> > + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> > gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> > !endif
> >
> > diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> > index 3d405cd4ade0..1c763b27def1 100644
> > --- a/OvmfPkg/OvmfPkgX64.dsc
> > +++ b/OvmfPkg/OvmfPkgX64.dsc
> > @@ -112,15 +112,6 @@ [BuildOptions]
> > INTEL:*_*_*_CC_FLAGS = /D TDX_GUEST_SUPPORTED
> > GCC:*_*_*_CC_FLAGS = -D TDX_GUEST_SUPPORTED
> >
> > - #
> > - # SECURE_BOOT_FEATURE_ENABLED
> > - #
> > -!if $(SECURE_BOOT_ENABLE) == TRUE
> > - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> > - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> > - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> > -!endif
> > -
> > !include NetworkPkg/NetworkBuildOptions.dsc.inc
> >
> > [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> > @@ -511,6 +502,7 @@ [PcdsFeatureFlag]
> > gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
> > !endif
> > !if $(SECURE_BOOT_ENABLE) == TRUE
> > + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> > gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> > !endif
> >
> > diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
> > index 8cda78d0d0b4..f152c5504661 100644
> > --- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
> > +++ b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
> > @@ -47,6 +47,8 @@ [LibraryClasses]
> > [Protocols]
> > gEfiSimpleFileSystemProtocolGuid ## CONSUMES
> >
> > +[Pcd]
> > + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported
> >
> > [Guids]
> > gEfiFileInfoGuid
> > diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
> > index 1fadadeb5565..3934aeed9514 100644
> > --- a/OvmfPkg/PlatformPei/PlatformPei.inf
> > +++ b/OvmfPkg/PlatformPei/PlatformPei.inf
> > @@ -94,6 +94,7 @@ [Pcd]
> > gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase
> > gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtr
> > gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtrSize
> > + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported
> > gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
> > gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
> > gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
> > diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
> > index 72289da35819..d4139b911528 100644
> > --- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
> > +++ b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
> > @@ -28,14 +28,12 @@ ConnectNvVarsToFileSystem (
> > IN EFI_HANDLE FsHandle
> > )
> > {
> > - #ifdef SECURE_BOOT_FEATURE_ENABLED
> > -
> > - return EFI_UNSUPPORTED;
> > -
> > - #else
> > -
> > EFI_STATUS Status;
> >
> > + if (FeaturePcdGet (PcdSecureBootSupported)) {
> > + return EFI_UNSUPPORTED;
> > + }
> > +
> > //
> > // We might fail to load the variable, since the file system initially
> > // will not have the NvVars file.
> > @@ -52,7 +50,6 @@ ConnectNvVarsToFileSystem (
> > }
> >
> > return Status;
> > - #endif
> > }
> >
> > /**
> > diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
> > index cc9384ba5c4e..c56247e294f2 100644
> > --- a/OvmfPkg/PlatformPei/Platform.c
> > +++ b/OvmfPkg/PlatformPei/Platform.c
> > @@ -222,9 +222,10 @@ ReserveEmuVariableNvStore (
> > VariableStore = (EFI_PHYSICAL_ADDRESS)(UINTN)PlatformReserveEmuVariableNvStore ();
> > PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
> >
> > - #ifdef SECURE_BOOT_FEATURE_ENABLED
> > - PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
> > - #endif
> > + if (FeaturePcdGet (PcdSecureBootSupported)) {
> > + // restore emulated VarStore from pristine ROM copy
> > + PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
> > + }
> >
> > ASSERT_RETURN_ERROR (PcdStatus);
> > }
> > --
> > 2.40.0
> >
>
> --
>
>
>
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/1] OvmfPkg: replace SECURE_BOOT_FEATURE_ENABLED with PcdSecureBootSupported
2023-04-21 6:55 [PATCH v2 1/1] OvmfPkg: replace SECURE_BOOT_FEATURE_ENABLED with PcdSecureBootSupported Gerd Hoffmann
2023-05-04 10:09 ` Gerd Hoffmann
@ 2023-05-06 7:14 ` Yao, Jiewen
1 sibling, 0 replies; 4+ messages in thread
From: Yao, Jiewen @ 2023-05-06 7:14 UTC (permalink / raw)
To: Gerd Hoffmann, devel@edk2.groups.io
Cc: Boeuf, Sebastien, Pawel Polawski, Ard Biesheuvel,
Justen, Jordan L, Oliver Steffen
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
> -----Original Message-----
> From: Gerd Hoffmann <kraxel@redhat.com>
> Sent: Friday, April 21, 2023 2:56 PM
> To: devel@edk2.groups.io
> Cc: Boeuf, Sebastien <sebastien.boeuf@intel.com>; Pawel Polawski
> <ppolawsk@redhat.com>; Ard Biesheuvel <ardb+tianocore@kernel.org>;
> Yao, Jiewen <jiewen.yao@intel.com>; Justen, Jordan L
> <jordan.l.justen@intel.com>; Gerd Hoffmann <kraxel@redhat.com>; Oliver
> Steffen <osteffen@redhat.com>
> Subject: [PATCH v2 1/1] OvmfPkg: replace
> SECURE_BOOT_FEATURE_ENABLED with PcdSecureBootSupported
>
> Drop the '-D SECURE_BOOT_FEATURE_ENABLED' compile time option,
> use a new FeaturePcd instead.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> OvmfPkg/OvmfPkg.dec | 3 +++
> OvmfPkg/CloudHv/CloudHvX64.dsc | 10 +---------
> OvmfPkg/IntelTdx/IntelTdxX64.dsc | 10 +---------
> OvmfPkg/Microvm/MicrovmX64.dsc | 10 +---------
> OvmfPkg/OvmfPkgIa32.dsc | 10 +---------
> OvmfPkg/OvmfPkgIa32X64.dsc | 10 +---------
> OvmfPkg/OvmfPkgX64.dsc | 10 +---------
> OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf | 2 ++
> OvmfPkg/PlatformPei/PlatformPei.inf | 1 +
> OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c | 11 ++++-------
> OvmfPkg/PlatformPei/Platform.c | 7 ++++---
> 11 files changed, 20 insertions(+), 64 deletions(-)
>
> diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
> index 749fbd3b6bf4..03ae29e7b034 100644
> --- a/OvmfPkg/OvmfPkg.dec
> +++ b/OvmfPkg/OvmfPkg.dec
> @@ -488,6 +488,9 @@ [PcdsFeatureFlag]
> # used by OVMF, the varstore pflash chip, LockBox etc).
>
> gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire|FALSE|BOOLEAN|0x
> 1e
>
> + ## This feature flag indicates the firmware build supports secure boot.
> +
> gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|FALSE|BOOLEAN|
> 0x6d
> +
> ## Informs modules (including pre-DXE-phase modules) whether the
> platform
> # firmware contains a CSM (Compatibility Support Module).
> #
> diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc
> b/OvmfPkg/CloudHv/CloudHvX64.dsc
> index cc2dd925bc94..2a1139daaa19 100644
> --- a/OvmfPkg/CloudHv/CloudHvX64.dsc
> +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
> @@ -93,15 +93,6 @@ [BuildOptions]
> INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
> GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
>
> - #
> - # SECURE_BOOT_FEATURE_ENABLED
> - #
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> -!endif
> -
> !include NetworkPkg/NetworkBuildOptions.dsc.inc
>
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> @@ -477,6 +468,7 @@ [PcdsFeatureFlag]
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
> !endif
> !if $(SECURE_BOOT_ENABLE) == TRUE
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> !endif
>
> diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> index f73440905540..d4403f11a7c6 100644
> --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
> @@ -90,15 +90,6 @@ [BuildOptions]
> INTEL:*_*_*_CC_FLAGS = /D TDX_PEI_LESS_BOOT
> GCC:*_*_*_CC_FLAGS = -D TDX_PEI_LESS_BOOT
>
> - #
> - # SECURE_BOOT_FEATURE_ENABLED
> - #
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> -!endif
> -
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
> XCODE:*_*_*_DLINK_FLAGS = -seg1addr 0x1000 -segalign 0x1000
> @@ -387,6 +378,7 @@ [PcdsFeatureFlag]
> gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable|TRUE
> !endif
> !if $(SECURE_BOOT_ENABLE) == TRUE
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> !endif
>
> diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc
> b/OvmfPkg/Microvm/MicrovmX64.dsc
> index e9aab515592f..6fc11cc4d192 100644
> --- a/OvmfPkg/Microvm/MicrovmX64.dsc
> +++ b/OvmfPkg/Microvm/MicrovmX64.dsc
> @@ -91,15 +91,6 @@ [BuildOptions]
> INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
> GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
>
> - #
> - # SECURE_BOOT_FEATURE_ENABLED
> - #
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> -!endif
> -
> !include NetworkPkg/NetworkBuildOptions.dsc.inc
>
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> @@ -473,6 +464,7 @@ [PcdsFeatureFlag]
> gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
> gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
> !if $(SECURE_BOOT_ENABLE) == TRUE
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> !endif
>
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 86177bb94899..16916ec58247 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -94,15 +94,6 @@ [BuildOptions]
> INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
> GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
>
> - #
> - # SECURE_BOOT_FEATURE_ENABLED
> - #
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> -!endif
> -
> !include NetworkPkg/NetworkBuildOptions.dsc.inc
>
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> @@ -484,6 +475,7 @@ [PcdsFeatureFlag]
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
> !endif
> !if $(SECURE_BOOT_ENABLE) == TRUE
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> !endif
>
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 065b54450647..936d763269c1 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -98,15 +98,6 @@ [BuildOptions]
> INTEL:*_*_*_CC_FLAGS = /D DISABLE_NEW_DEPRECATED_INTERFACES
> GCC:*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
>
> - #
> - # SECURE_BOOT_FEATURE_ENABLED
> - #
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> -!endif
> -
> !include NetworkPkg/NetworkBuildOptions.dsc.inc
>
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> @@ -490,6 +481,7 @@ [PcdsFeatureFlag]
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
> !endif
> !if $(SECURE_BOOT_ENABLE) == TRUE
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> !endif
>
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index 3d405cd4ade0..1c763b27def1 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -112,15 +112,6 @@ [BuildOptions]
> INTEL:*_*_*_CC_FLAGS = /D TDX_GUEST_SUPPORTED
> GCC:*_*_*_CC_FLAGS = -D TDX_GUEST_SUPPORTED
>
> - #
> - # SECURE_BOOT_FEATURE_ENABLED
> - #
> -!if $(SECURE_BOOT_ENABLE) == TRUE
> - MSFT:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - INTEL:*_*_*_CC_FLAGS = /D SECURE_BOOT_FEATURE_ENABLED
> - GCC:*_*_*_CC_FLAGS = -D SECURE_BOOT_FEATURE_ENABLED
> -!endif
> -
> !include NetworkPkg/NetworkBuildOptions.dsc.inc
>
> [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> @@ -511,6 +502,7 @@ [PcdsFeatureFlag]
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache|FALSE
> !endif
> !if $(SECURE_BOOT_ENABLE) == TRUE
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported|TRUE
> gEfiMdeModulePkgTokenSpaceGuid.PcdRequireSelfSignedPk|TRUE
> !endif
>
> diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
> b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
> index 8cda78d0d0b4..f152c5504661 100644
> --- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
> +++ b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
> @@ -47,6 +47,8 @@ [LibraryClasses]
> [Protocols]
> gEfiSimpleFileSystemProtocolGuid ## CONSUMES
>
> +[Pcd]
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported
>
> [Guids]
> gEfiFileInfoGuid
> diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf
> b/OvmfPkg/PlatformPei/PlatformPei.inf
> index 1fadadeb5565..3934aeed9514 100644
> --- a/OvmfPkg/PlatformPei/PlatformPei.inf
> +++ b/OvmfPkg/PlatformPei/PlatformPei.inf
> @@ -94,6 +94,7 @@ [Pcd]
> gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase
> gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtr
> gUefiOvmfPkgTokenSpaceGuid.PcdXenPvhStartOfDayStructPtrSize
> + gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootSupported
> gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress
> gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
> diff --git a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
> b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
> index 72289da35819..d4139b911528 100644
> --- a/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
> +++ b/OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.c
> @@ -28,14 +28,12 @@ ConnectNvVarsToFileSystem (
> IN EFI_HANDLE FsHandle
> )
> {
> - #ifdef SECURE_BOOT_FEATURE_ENABLED
> -
> - return EFI_UNSUPPORTED;
> -
> - #else
> -
> EFI_STATUS Status;
>
> + if (FeaturePcdGet (PcdSecureBootSupported)) {
> + return EFI_UNSUPPORTED;
> + }
> +
> //
> // We might fail to load the variable, since the file system initially
> // will not have the NvVars file.
> @@ -52,7 +50,6 @@ ConnectNvVarsToFileSystem (
> }
>
> return Status;
> - #endif
> }
>
> /**
> diff --git a/OvmfPkg/PlatformPei/Platform.c
> b/OvmfPkg/PlatformPei/Platform.c
> index cc9384ba5c4e..c56247e294f2 100644
> --- a/OvmfPkg/PlatformPei/Platform.c
> +++ b/OvmfPkg/PlatformPei/Platform.c
> @@ -222,9 +222,10 @@ ReserveEmuVariableNvStore (
> VariableStore =
> (EFI_PHYSICAL_ADDRESS)(UINTN)PlatformReserveEmuVariableNvStore ();
> PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
>
> - #ifdef SECURE_BOOT_FEATURE_ENABLED
> - PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
> - #endif
> + if (FeaturePcdGet (PcdSecureBootSupported)) {
> + // restore emulated VarStore from pristine ROM copy
> + PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
> + }
>
> ASSERT_RETURN_ERROR (PcdStatus);
> }
> --
> 2.40.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-06 7:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-21 6:55 [PATCH v2 1/1] OvmfPkg: replace SECURE_BOOT_FEATURE_ENABLED with PcdSecureBootSupported Gerd Hoffmann
2023-05-04 10:09 ` Gerd Hoffmann
2023-05-04 13:57 ` [edk2-devel] " Ard Biesheuvel
2023-05-06 7:14 ` Yao, Jiewen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox