From c0ca3b6b8e301c2ea6738a238d0abc7012ddacad Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Mon, 30 Sep 2019 14:12:36 +0100 Subject: [PATCH] arch: acpi, layout: Correctly calculate and expose PCI MMCONFIG area The PCI MMCONFIG area must be below 4GiB and must not be part of the device space. Shrink the device area and put the PCI MMCONFIG region above it. Signed-off-by: Rob Bradford --- arch/src/x86_64/acpi.rs | 2 +- arch/src/x86_64/layout.rs | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/src/x86_64/acpi.rs b/arch/src/x86_64/acpi.rs index aee840d6a..60e54ccd0 100644 --- a/arch/src/x86_64/acpi.rs +++ b/arch/src/x86_64/acpi.rs @@ -306,7 +306,7 @@ pub fn create_acpi_tables( // 32-bit PCI enhanced configuration mechanism mcfg.append(PCIRangeEntry { - base_address: layout::MEM_32BIT_DEVICES_START.0, + base_address: layout::PCI_MMCONFIG_START.0, segment: 0, start: 0, end: 0xff, diff --git a/arch/src/x86_64/layout.rs b/arch/src/x86_64/layout.rs index bbf112f57..735a9eba8 100644 --- a/arch/src/x86_64/layout.rs +++ b/arch/src/x86_64/layout.rs @@ -69,9 +69,14 @@ pub const MEM_32BIT_RESERVED_SIZE: GuestUsize = (1024 << 20); // == Fixed constants within the "32-bit reserved" range == -// Sub range: 32-bit PCI devices (start: 3GiB, length: 768Mib) +// Sub range: 32-bit PCI devices (start: 3GiB, length: 640Mib) pub const MEM_32BIT_DEVICES_START: GuestAddress = MEM_32BIT_RESERVED_START; -pub const MEM_32BIT_DEVICES_SIZE: GuestUsize = (768 << 20); +pub const MEM_32BIT_DEVICES_SIZE: GuestUsize = (640 << 20); + +// PCI MMCONFIG space (start: after the device space, length: 256MiB) +pub const PCI_MMCONFIG_START: GuestAddress = + GuestAddress(MEM_32BIT_DEVICES_START.0 + MEM_32BIT_DEVICES_SIZE); +pub const PCI_MMCONFIG_SIZE: GuestUsize = (256 << 20); // IOAPIC pub const IOAPIC_START: GuestAddress = GuestAddress(0xfec0_0000);