From c18ac9fbcc71dd75f1f8cb84b6c929536c1ef580 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Thu, 21 Sep 2017 13:18:11 +0200 Subject: [PATCH] OvmfPkg/PciHotPlugInitDxe: clean up addr. range for non-prefetchable MMIO The non-prefetchable MMIO aperture of a bridge can never fall outside of the 32-bit address space. Namely, the MemoryBase and MemoryLimit fields in PCI_BRIDGE_CONTROL_REGISTER have type UINT16, and based on the PCI-to-PCI Bridge Architecture Spec, Chapter 3.2, the actual MMIO aperture is determined as in: NonPrefetchMemoryBase = (((MemoryBase & 0xFFF0u) >> 4) << 20) | 0x00000 NonPrefetchMemoryLimit = (((MemoryLimit & 0xFFF0u) >> 4) << 20) | 0xFFFFF In "OvmfPkg/PciHotPlugInitDxe", the "mPadding.MmioPadding.AddrSpaceGranularity" field is currently initialized to 64. According to the above, this is useless generality: a non-prefetchable MMIO reservation may only be satisfied from 32-bit address space. Update the field to 32. In practice this change makes no difference, because PciBusDxe already enforces the 32-bit limitation when it sees "non-prefetchable" from (SpecificFlag==0). Quoting commit 8aba40b79267 ("OvmfPkg: add PciHotPlugInitDxe", 2016-06-30): "regardless of our request for 64-bit MMIO reservation, it is downgraded to 32-bit". (See the Platform Init Spec 1.6, Volume 5, - Table 8. "ACPI 2.0 & 3.0 QWORD Address Space Descriptor Usage", and - Table 11. "Memory Resource Flag (Resource Type = 0) Usage", for an explanation of the "mPadding.MmioPadding" fields.) Cc: Jordan Justen Cc: Marcel Apfelbaum Cc: Ruiyu Ni Fixes: 8aba40b79267df761bd24d6874ae87f47a7bd3de Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek Reviewed-by: Jordan Justen --- OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c index 2265b8c7e1..5c98f806de 100644 --- a/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c +++ b/OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.c @@ -68,8 +68,8 @@ STATIC CONST RESOURCE_PADDING mPadding = { // ignored 0, // SpecificFlag: // non-prefetchable - 64, // AddrSpaceGranularity: - // reserve 64-bit aperture + 32, // AddrSpaceGranularity: + // reserve 32-bit aperture 0, // AddrRangeMin: // ignored SIZE_2MB - 1, // AddrRangeMax: