summaryrefslogtreecommitdiffstats
path: root/OvmfPkg
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2022-10-04 15:47:27 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-10-07 18:14:05 +0000
commitecb778d0ac62560aa172786ba19521f27bc3f650 (patch)
tree8201bddf1ac6a14249d42afbb16845512068a9cd /OvmfPkg
parentbbda386d25e5316445a9bd67c45b47ce248eeb25 (diff)
downloadedk2-ecb778d0ac62560aa172786ba19521f27bc3f650.tar.gz
edk2-ecb778d0ac62560aa172786ba19521f27bc3f650.tar.bz2
edk2-ecb778d0ac62560aa172786ba19521f27bc3f650.zip
OvmfPkg/PlatformInitLib: dynamic mmio window size
In case we have a reliable PhysMemAddressWidth use that to dynamically size the 64bit address window. Allocate 1/8 of the physical address space and place the window at the upper end of the address space. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'OvmfPkg')
-rw-r--r--OvmfPkg/Library/PlatformInitLib/MemDetect.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
index 16ecbfadc3..ae217d0242 100644
--- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c
+++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
@@ -604,6 +604,33 @@ PlatformAddressWidthFromCpuid (
}
}
+VOID
+EFIAPI
+PlatformDynamicMmioWindow (
+ IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob
+ )
+{
+ UINT64 AddrSpace, MmioSpace;
+
+ AddrSpace = LShiftU64 (1, PlatformInfoHob->PhysMemAddressWidth);
+ MmioSpace = LShiftU64 (1, PlatformInfoHob->PhysMemAddressWidth - 3);
+
+ if ((PlatformInfoHob->PcdPciMmio64Size < MmioSpace) &&
+ (PlatformInfoHob->PcdPciMmio64Base + MmioSpace < AddrSpace))
+ {
+ DEBUG ((DEBUG_INFO, "%a: using dynamic mmio window\n", __func__));
+ DEBUG ((DEBUG_INFO, "%a: Addr Space 0x%Lx (%Ld GB)\n", __func__, AddrSpace, RShiftU64 (AddrSpace, 30)));
+ DEBUG ((DEBUG_INFO, "%a: MMIO Space 0x%Lx (%Ld GB)\n", __func__, MmioSpace, RShiftU64 (MmioSpace, 30)));
+ PlatformInfoHob->PcdPciMmio64Size = MmioSpace;
+ PlatformInfoHob->PcdPciMmio64Base = AddrSpace - MmioSpace;
+ } else {
+ DEBUG ((DEBUG_INFO, "%a: using classic mmio window\n", __func__));
+ }
+
+ DEBUG ((DEBUG_INFO, "%a: Pci64 Base 0x%Lx\n", __func__, PlatformInfoHob->PcdPciMmio64Base));
+ DEBUG ((DEBUG_INFO, "%a: Pci64 Size 0x%Lx\n", __func__, PlatformInfoHob->PcdPciMmio64Size));
+}
+
/**
Iterate over the PCI host bridges resources information optionally provided
in fw-cfg and find the highest address contained in the PCI MMIO windows. If
@@ -765,6 +792,7 @@ PlatformAddressWidthInitialization (
if (PlatformInfoHob->PhysMemAddressWidth != 0) {
// physical address width is known
PlatformInfoHob->FirstNonAddress = FirstNonAddress;
+ PlatformDynamicMmioWindow (PlatformInfoHob);
return;
}