[edk2-devel] [PATCH] OvmfPkg: Report proper address space width for Cloud Hypervisor

Boeuf, Sebastien posted 1 patch 1 year, 3 months ago
Failed in applying to current master (apply log)
OvmfPkg/Library/PlatformInitLib/MemDetect.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
[edk2-devel] [PATCH] OvmfPkg: Report proper address space width for Cloud Hypervisor
Posted by Boeuf, Sebastien 1 year, 3 months ago
From: Sebastien Boeuf <sebastien.boeuf@intel.com>

The address space width isn't properly calculated when the platform is
Cloud Hypervisor. The function PlatformAddressWidthFromCpuid() must not
be invoked with the QemuQuirk boolean set to true in the Cloud
Hypervisor case.

Relying on the host bridge identifier, we can set the QemuQuirk to the
appropriate value, which results in the address space size to be
correctly returned for Cloud Hypervisor.

Having the correct address space width allows the code to calculate
dynamically the MMIO space available for devices in the 64-bit address
space, preventing it to fallback onto the default value (32GiB).

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
---
 OvmfPkg/Library/PlatformInitLib/MemDetect.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
index 5aeeeff89f..a14e5c4247 100644
--- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c
+++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
@@ -838,6 +838,7 @@ PlatformAddressWidthInitialization (
 {
   UINT8       PhysMemAddressWidth;
   EFI_STATUS  Status;
+  BOOLEAN     QemuQuirk;
 
   if (PlatformInfoHob->HostBridgeDevId == 0xffff /* microvm */) {
     PlatformAddressWidthFromCpuid (PlatformInfoHob, FALSE);
@@ -863,7 +864,13 @@ PlatformAddressWidthInitialization (
     PlatformGetFirstNonAddress (PlatformInfoHob);
   }
 
-  PlatformAddressWidthFromCpuid (PlatformInfoHob, TRUE);
+  if (PlatformInfoHob->HostBridgeDevId == CLOUDHV_DEVICE_ID) {
+    QemuQuirk = FALSE;
+  } else {
+    QemuQuirk = TRUE;
+  }
+
+  PlatformAddressWidthFromCpuid (PlatformInfoHob, QemuQuirk);
   if (PlatformInfoHob->PhysMemAddressWidth != 0) {
     // physical address width is known
     PlatformDynamicMmioWindow (PlatformInfoHob);
-- 
2.37.2

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 5 208 026.16 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#98809): https://edk2.groups.io/g/devel/message/98809
Mute This Topic: https://groups.io/mt/96354531/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH] OvmfPkg: Report proper address space width for Cloud Hypervisor
Posted by Gerd Hoffmann 1 year, 3 months ago
On Wed, Jan 18, 2023 at 03:20:15PM +0100, sebastien.boeuf@intel.com wrote:
> From: Sebastien Boeuf <sebastien.boeuf@intel.com>
> 
> The address space width isn't properly calculated when the platform is
> Cloud Hypervisor. The function PlatformAddressWidthFromCpuid() must not
> be invoked with the QemuQuirk boolean set to true in the Cloud
> Hypervisor case.
> 
> Relying on the host bridge identifier, we can set the QemuQuirk to the
> appropriate value, which results in the address space size to be
> correctly returned for Cloud Hypervisor.
> 
> Having the correct address space width allows the code to calculate
> dynamically the MMIO space available for devices in the 64-bit address
> space, preventing it to fallback onto the default value (32GiB).
> 
> Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>

Acked-by: Gerd Hoffmann <kraxel@redhat.com>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#98870): https://edk2.groups.io/g/devel/message/98870
Mute This Topic: https://groups.io/mt/96354531/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-