From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smarthost01c.sbp.mail.zen.net.uk (smarthost01c.sbp.mail.zen.net.uk [212.23.1.5]) by mx.groups.io with SMTP id smtpd.web12.1640.1648664953940280235 for ; Wed, 30 Mar 2022 11:29:14 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=permerror, err=parse error for token &{10 18 sdn.klaviyomail.com}: permanent DNS error (domain: starlabs.systems, ip: 212.23.1.5, mailfrom: sean@starlabs.systems) Received: from [217.155.46.38] (helo=sean-StarBook.lan) by smarthost01c.sbp.mail.zen.net.uk with esmtp (Exim 4.90_1) (envelope-from ) id 1nZd4B-0005uU-LU; Wed, 30 Mar 2022 18:29:11 +0000 From: "Sean Rhodes" To: devel@edk2.groups.io Cc: Patrick Rudolph , Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann Subject: [PATCH 2/2] OvmfPkg: Fix PciHostBridgeLibScan Date: Wed, 30 Mar 2022 19:29:03 +0100 Message-Id: <9e5f18683a8877ab4cf04210f2047e4e20157c75.1648664943.git.sean@starlabs.systems> X-Mailer: git-send-email 2.32.0 In-Reply-To: <5b99fc3587bec6bd7552ec8aeda76501f1a7b935.1648664943.git.sean@starlabs.systems> References: <5b99fc3587bec6bd7552ec8aeda76501f1a7b935.1648664943.git.sean@starlabs.systems> MIME-Version: 1.0 X-Originating-smarthost01c-IP: [217.155.46.38] Feedback-ID: 217.155.46.38 Content-Transfer-Encoding: quoted-printable From: Patrick Rudolph Don't assume a 64bit register always holds an address greater than 4GB. Check the value in the register and decide which Aperature it should be assigned to. The same code caused an issue on real hardware. It's unclear if this is an issue here as well, as it's intended to run on emulated hardware only. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Gerd Hoffmann Signed-off-by: Patrick Rudolph --- .../PciHostBridgeLibScan/ScanForRootBridges.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/OvmfPkg/Library/PciHostBridgeLibScan/ScanForRootBridges.c b/Ov= mfPkg/Library/PciHostBridgeLibScan/ScanForRootBridges.c index 5fb02a89b9..1ff96be57f 100644 --- a/OvmfPkg/Library/PciHostBridgeLibScan/ScanForRootBridges.c +++ b/OvmfPkg/Library/PciHostBridgeLibScan/ScanForRootBridges.c @@ -331,14 +331,18 @@ ScanForRootBridges ( Base =3D ((UINT32)Pci.Bridge.PrefetchableMemoryBase & 0xfff0) <= < 16;=0D Limit =3D (((UINT32)Pci.Bridge.PrefetchableMemoryLimit & 0xfff0)= =0D << 16) | 0xfffff;=0D - MemAperture =3D &Mem;=0D if (Value =3D=3D BIT0) {=0D - Base |=3D LShiftU64 (Pci.Bridge.PrefetchableBaseUpper32,= 32);=0D - Limit |=3D LShiftU64 (Pci.Bridge.PrefetchableLimitUpper32= , 32);=0D - MemAperture =3D &MemAbove4G;=0D + Base |=3D LShiftU64 (Pci.Bridge.PrefetchableBaseUpper32, 32);= =0D + Limit |=3D LShiftU64 (Pci.Bridge.PrefetchableLimitUpper32, 32)= ;=0D }=0D =0D if (Base < Limit) {=0D + if (Base < BASE_4GB) {=0D + MemAperture =3D &Mem;=0D + } else {=0D + MemAperture =3D &MemAbove4G;=0D + }=0D +=0D if (MemAperture->Base > Base) {=0D MemAperture->Base =3D Base;=0D }=0D --=20 2.32.0