From 24d835a13157137258f256730bd373742d09bb8b Mon Sep 17 00:00:00 2001 From: Alexander Gryanko Date: Sat, 5 Oct 2024 03:17:17 +0300 Subject: [PATCH] OvmfPkg/Library/HardwareInfoLib: Fix memory allocation for a root bridge Currently, PciHostBridgeUtilityGetRootBridgesHostProvided allocates memory for aperture structures without clearing memory. This causes garbage in the Translation field, but the Base and Limit fields have the correct values because they are copied from the HOST_BRIDGE_INFO fields in the HardwareInfoPciHostBridgeHostBridgeHostBridgeGetApertures function. RootBridge: PciRoot(0x0) Support/Attr: 70069 / 70069 DmaAbove4G: No NoExtConfSpace: No AllocAttr: 3 (CombineMemPMem Mem64Decode) Bus: 0 - 80 Translation=0 Io: 6000 - FFFF Translation=5E9EB018 Mem: 80000000 - DFFFFFFF Translation=0 MemAbove4G: 600000000000 - 7FFFFFFFFFFF Translation=0 PMem: FFFFFFFFFFFFFFFF - 0 Translation=0 PMemAbove4G: FFFFFFFFFFFFFFFF - 0 Translation=0 Signed-off-by: Alexander Gryanko --- .../PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c index 0424aa5df1..4708b5c81c 100644 --- a/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c +++ b/OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.c @@ -444,6 +444,12 @@ PciHostBridgeUtilityGetRootBridgesHostProvided ( PCI_ROOT_BRIDGE_APERTURE PMem; PCI_ROOT_BRIDGE_APERTURE PMemAbove4G; + ZeroMem (&Io, sizeof (Io)); + ZeroMem (&Mem, sizeof (Mem)); + ZeroMem (&MemAbove4G, sizeof (MemAbove4G)); + ZeroMem (&PMem, sizeof (PMem)); + ZeroMem (&PMemAbove4G, sizeof (PMemAbove4G)); + // // Initialize the Hardware Info list head to start with an empty but valid // list head.