OvmfPkg/RiscVVirt/PlatformPei: Do not set PcdTpmBaseAddress to garbage

If there is no TPM device in the device tree, the TpmBase variable is not
initialized and contains garbage.

Instead of using 0 as sentinel (which may be a valid address), check the
size instead, which cannot be 0 for a memory-mapped device.

Signed-off-by: Fabian Vogt <fvogt@suse.de>
This commit is contained in:
Fabian Vogt 2026-03-06 14:19:59 +01:00 committed by mergify[bot]
parent 4d38389e0f
commit b5d1689447

View file

@ -119,6 +119,11 @@ SetupTPMResources (
UINT64 TpmBase;
UINT64 TpmBaseSize;
//
// Empty TpmBaseSize indicates no TPM found.
//
TpmBaseSize = 0;
//
// Set Parent to suppress incorrect compiler/analyzer warnings.
//
@ -200,7 +205,7 @@ SetupTPMResources (
}
}
if (TpmBase) {
if (TpmBaseSize > 0) {
BuildResourceDescriptorHob (
EFI_RESOURCE_MEMORY_MAPPED_IO,
EFI_RESOURCE_ATTRIBUTE_PRESENT |