Skip to contentSkip to conversation

pxb: fix 64-bit MMIO allocation

PATCH Superseded Marcel Apfelbaum 2 participants 9 messages Jun 30, 2016 – Jul 1, 2016

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover pxb: fix 64-bit MMIO allocation

64-bit BARs allocations fix for devices behind PXBs/PXB-PCIEs.

In build_crs() the calculation and merging of the ranges already happens in 64-bit, but the entry boundaries are silently truncated to 32-bit in the call to aml_dword_memory(). Fix it by handling the 64-bit MMIO ranges separately.

v3 -> v4:
Addressed Igor's comments (thanks for the productive review!)
- Split pxb test patch (previously patch 3/3) into the test itself (patch 1/6) and the blobs (patch 6/6).
- New patch declaring pxb/pxb-pxie as not hot-pluggable.
- Note that it does not solve the DSDT issue, but it is a prerequisite for the next patch.
- New patch solving the DSDT issue spotted by Igor.
- Using V=1 DIFF=diff make check does make it easier to review the ACPI changes, thanks.
- Patches 4 and 5 untouched (previously patches 1/3 and 2/3)

v2 -> v3:
- split original series "pci: better support for 64-bit MMIO allocation" into 2 series:
- this is the first part dealing with correct 64-bit MMIO ACPI computation
- the second one will include 64-bit MMIO reservation for PCI hotplug
- Add pxb/pxb-pcie tests (Igor) - See diffs below (*)
- Re-based on latest master.

v1 -> v2:
- resolved some styling issues (Laszlo)
- rebase on latest master (Laszlo)

Thank you,
Marcel

Marcel Apfelbaum (6):
tests/acpi: add pxb/pxb-pcie tests
hw/pxb: declare pxb devices as not hot-pluggable hw/acpi: fix a DSDT table issue when a pxb is present.
acpi: refactor pxb crs computation
hw/apci: handle 64-bit MMIO regions correctly tests/acpi: Add pxb/pxb-pcie tests blobs

 hw/i386/acpi-build.c                   | 131 ++++++++++++++++++++++++---------
 hw/pci-bridge/pci_expander_bridge.c    |   2 +
 tests/acpi-test-data/pc/DSDT.pxb       | Bin 0 -> 6280 bytes
 tests/acpi-test-data/q35/DSDT.pxb_pcie | Bin 0 -> 9098 bytes
 tests/bios-tables-test.c               |  37 ++++++++++
 5 files changed, 134 insertions(+), 36 deletions(-)
 create mode 100644 tests/acpi-test-data/pc/DSDT.pxb
 create mode 100644 tests/acpi-test-data/q35/DSDT.pxb_pcie
Signature · 1 line
2.4.3
#1 lore raw

PATCH v4 1/6 tests/acpi: add pxb/pxb-pcie tests

Add an ivshmem device with 4G shared memory to
pxb in order to check the ACPI code of 64bit MMIO allocation.

---
 tests/bios-tables-test.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
tests/bios-tables-test.c +37 -0
index 92c90dd..3d87f9e 100644
@@ -838,6 +838,41 @@ static void test_acpi_piix4_tcg_ipmi(void)
     free_test_data(&data);
 }
 
+static void test_acpi_piix4_tcg_pxb(void)
+{
+    test_data data;
+
+    memset(&data, 0, sizeof(data));
+    data.machine = MACHINE_PC;
+    data.variant = ".pxb";
+    data.required_struct_types = base_required_struct_types;
+    data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
+    test_acpi_one("-machine accel=tcg"
+                  " -device pxb,id=pxb,bus_nr=0x80,bus=pci.0"
+                  " -object memory-backend-file,size=4G,mem-path=/tmp/shmem,share,id=mb"
+                  " -device ivshmem-plain,memdev=mb,bus=pxb",
+                  &data);
+    free_test_data(&data);
+}
+
+static void test_acpi_q35_tcg_pxb_pcie(void)
+{
+    test_data data;
+
+    memset(&data, 0, sizeof(data));
+    data.machine = MACHINE_Q35;
+    data.variant = ".pxb_pcie";
+    data.required_struct_types = base_required_struct_types;
+    data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types);
+    test_acpi_one("-machine q35,accel=tcg"
+                  " -device pxb-pcie,id=pxb,bus_nr=0x80,bus=pcie.0"
+                  " -device ioh3420,id=rp,bus=pxb,slot=1"
+                  " -object memory-backend-file,size=4G,mem-path=/tmp/shmem,share,id=mb"
+                  " -device ivshmem-plain,memdev=mb,bus=rp",
+                  &data);
+    free_test_data(&data);
+}
+
 int main(int argc, char *argv[])
 {
     const char *arch = qtest_get_arch();
@@ -856,6 +891,8 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/tcg/bridge", test_acpi_q35_tcg_bridge);
         qtest_add_func("acpi/piix4/tcg/ipmi", test_acpi_piix4_tcg_ipmi);
         qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi);
+        qtest_add_func("acpi/piix4/tcg/pxb", test_acpi_piix4_tcg_pxb);
+        qtest_add_func("acpi/q35/tcg/pxb-pcie", test_acpi_q35_tcg_pxb_pcie);
     }
     ret = g_test_run();
     boot_sector_cleanup(disk);
Signature · 1 line
2.4.3
#2 lore raw

PATCH v4 2/6 hw/pxb: declare pxb devices as not hot-pluggable

In reply to Marcel Apfelbaum

Prevent future issues when hotplug will work for devices attached to pxbs.

---
 hw/pci-bridge/pci_expander_bridge.c | 2 ++
 1 file changed, 2 insertions(+)
hw/pci-bridge/pci_expander_bridge.c +2 -0
index ba320bd..9136a23 100644
@@ -308,6 +308,7 @@ static void pxb_dev_class_init(ObjectClass *klass, void *data)
 
     dc->desc = "PCI Expander Bridge";
     dc->props = pxb_dev_properties;
+    dc->hotpluggable = false;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
@@ -341,6 +342,7 @@ static void pxb_pcie_dev_class_init(ObjectClass *klass, void *data)
 
     dc->desc = "PCI Express Expander Bridge";
     dc->props = pxb_dev_properties;
+    dc->hotpluggable = false;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
Signature · 1 line
2.4.3
#3 lore raw

PATCH v4 3/6 hw/acpi: fix a DSDT table issue when a pxb is present.

In reply to Marcel Apfelbaum

PXBs do not support hotplug so they don't have a PCNT function. Since the PXB's PCI root-bus is a child bus of bus 0, the build_dsdt code will add a call to the corresponding PCNT function.

Fix this by skipping the PCNT call for the above case. While at it skip also PCIe child buses.

---
 hw/i386/acpi-build.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/i386/acpi-build.c +4 -0
index 5a594be..675a3dc 100644
@@ -596,6 +596,10 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
         QLIST_FOREACH(sec, &bus->child, sibling) {
             int32_t devfn = sec->parent_dev->devfn;
 
+            if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) {
+                continue;
+            }
+
             aml_append(method, aml_name("^S%.02X.PCNT", devfn));
         }
     }
Signature · 1 line
2.4.3
#4 lore raw

PATCH v4 4/6 acpi: refactor pxb crs computation

In reply to Marcel Apfelbaum

Instead of always passing both IO and MEM ranges when computing CRS ranges, define a new CrsRangeSet structure that include them both.

This is done before introducing a third type of range, 64-bit MEM, so it will be easier to pass them all around.

---
 hw/i386/acpi-build.c | 82 ++++++++++++++++++++++++++++++++--------------------
 1 file changed, 51 insertions(+), 31 deletions(-)
hw/i386/acpi-build.c +51 -31
index 675a3dc..eca195d 100644
@@ -747,6 +747,23 @@ static void crs_range_free(gpointer data)
     g_free(entry);
 }
 
+typedef struct CrsRangeSet {
+    GPtrArray *io_ranges;
+    GPtrArray *mem_ranges;
+ } CrsRangeSet;
+
+static void crs_range_set_init(CrsRangeSet *range_set)
+{
+    range_set->io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
+    range_set->mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
+}
+
+static void crs_range_set_free(CrsRangeSet *range_set)
+{
+    g_ptr_array_free(range_set->io_ranges, true);
+    g_ptr_array_free(range_set->mem_ranges, true);
+}
+
 static gint crs_range_compare(gconstpointer a, gconstpointer b)
 {
      CrsRangeEntry *entry_a = *(CrsRangeEntry **)a;
@@ -831,18 +848,17 @@ static void crs_range_merge(GPtrArray *range)
     g_ptr_array_free(tmp, true);
 }
 
-static Aml *build_crs(PCIHostState *host,
-                      GPtrArray *io_ranges, GPtrArray *mem_ranges)
+static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
 {
     Aml *crs = aml_resource_template();
-    GPtrArray *host_io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
-    GPtrArray *host_mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
+    CrsRangeSet temp_range_set;
     CrsRangeEntry *entry;
     uint8_t max_bus = pci_bus_num(host->bus);
     uint8_t type;
     int devfn;
     int i;
 
+    crs_range_set_init(&temp_range_set);
     for (devfn = 0; devfn < ARRAY_SIZE(host->bus->devices); devfn++) {
         uint64_t range_base, range_limit;
         PCIDevice *dev = host->bus->devices[devfn];
@@ -866,9 +882,11 @@ static Aml *build_crs(PCIHostState *host,
             }
 
             if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
-                crs_range_insert(host_io_ranges, range_base, range_limit);
+                crs_range_insert(temp_range_set.io_ranges,
+                                 range_base, range_limit);
             } else { /* "memory" */
-                crs_range_insert(host_mem_ranges, range_base, range_limit);
+                crs_range_insert(temp_range_set.mem_ranges,
+                                 range_base, range_limit);
             }
         }
 
@@ -887,7 +905,8 @@ static Aml *build_crs(PCIHostState *host,
              * that do not support multiple root buses
              */
             if (range_base && range_base <= range_limit) {
-                crs_range_insert(host_io_ranges, range_base, range_limit);
+                crs_range_insert(temp_range_set.io_ranges,
+                                 range_base, range_limit);
             }
 
             range_base =
@@ -900,7 +919,8 @@ static Aml *build_crs(PCIHostState *host,
              * that do not support multiple root buses
              */
             if (range_base && range_base <= range_limit) {
-                crs_range_insert(host_mem_ranges, range_base, range_limit);
+                crs_range_insert(temp_range_set.mem_ranges,
+                                 range_base, range_limit);
             }
 
             range_base =
@@ -913,35 +933,36 @@ static Aml *build_crs(PCIHostState *host,
              * that do not support multiple root buses
              */
             if (range_base && range_base <= range_limit) {
-                crs_range_insert(host_mem_ranges, range_base, range_limit);
+                crs_range_insert(temp_range_set.mem_ranges,
+                                 range_base, range_limit);
             }
         }
     }
 
-    crs_range_merge(host_io_ranges);
-    for (i = 0; i < host_io_ranges->len; i++) {
-        entry = g_ptr_array_index(host_io_ranges, i);
+    crs_range_merge(temp_range_set.io_ranges);
+    for (i = 0; i < temp_range_set.io_ranges->len; i++) {
+        entry = g_ptr_array_index(temp_range_set.io_ranges, i);
         aml_append(crs,
                    aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
                                AML_POS_DECODE, AML_ENTIRE_RANGE,
                                0, entry->base, entry->limit, 0,
                                entry->limit - entry->base + 1));
-        crs_range_insert(io_ranges, entry->base, entry->limit);
+        crs_range_insert(range_set->io_ranges, entry->base, entry->limit);
     }
-    g_ptr_array_free(host_io_ranges, true);
 
-    crs_range_merge(host_mem_ranges);
-    for (i = 0; i < host_mem_ranges->len; i++) {
-        entry = g_ptr_array_index(host_mem_ranges, i);
+    crs_range_merge(temp_range_set.mem_ranges);
+    for (i = 0; i < temp_range_set.mem_ranges->len; i++) {
+        entry = g_ptr_array_index(temp_range_set.mem_ranges, i);
         aml_append(crs,
                    aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED,
                                     AML_MAX_FIXED, AML_NON_CACHEABLE,
                                     AML_READ_WRITE,
                                     0, entry->base, entry->limit, 0,
                                     entry->limit - entry->base + 1));
-        crs_range_insert(mem_ranges, entry->base, entry->limit);
+        crs_range_insert(range_set->mem_ranges, entry->base, entry->limit);
     }
-    g_ptr_array_free(host_mem_ranges, true);
+
+    crs_range_set_free(&temp_range_set);
 
     aml_append(crs,
         aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,
@@ -1898,8 +1919,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
 {
     CrsRangeEntry *entry;
     Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs;
-    GPtrArray *mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
-    GPtrArray *io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
+    CrsRangeSet crs_range_set;
     PCMachineState *pcms = PC_MACHINE(machine);
     PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(machine);
     uint32_t nr_mem = machine->ram_slots;
@@ -1988,6 +2008,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
     }
     aml_append(dsdt, scope);
 
+    crs_range_set_init(&crs_range_set);
     bus = PC_MACHINE(machine)->bus;
     if (bus) {
         QLIST_FOREACH(bus, &bus->child, sibling) {
@@ -2014,8 +2035,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
             }
 
             aml_append(dev, build_prt(false));
-            crs = build_crs(PCI_HOST_BRIDGE(BUS(bus)->parent),
-                            io_ranges, mem_ranges);
+            crs = build_crs(PCI_HOST_BRIDGE(BUS(bus)->parent), &crs_range_set);
             aml_append(dev, aml_name_decl("_CRS", crs));
             aml_append(scope, dev);
             aml_append(dsdt, scope);
@@ -2036,9 +2056,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
                     AML_POS_DECODE, AML_ENTIRE_RANGE,
                     0x0000, 0x0000, 0x0CF7, 0x0000, 0x0CF8));
 
-    crs_replace_with_free_ranges(io_ranges, 0x0D00, 0xFFFF);
-    for (i = 0; i < io_ranges->len; i++) {
-        entry = g_ptr_array_index(io_ranges, i);
+    crs_replace_with_free_ranges(crs_range_set.io_ranges, 0x0D00, 0xFFFF);
+    for (i = 0; i < crs_range_set.io_ranges->len; i++) {
+        entry = g_ptr_array_index(crs_range_set.io_ranges, i);
         aml_append(crs,
             aml_word_io(AML_MIN_FIXED, AML_MAX_FIXED,
                         AML_POS_DECODE, AML_ENTIRE_RANGE,
@@ -2051,9 +2071,10 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
                          AML_CACHEABLE, AML_READ_WRITE,
                          0, 0x000A0000, 0x000BFFFF, 0, 0x00020000));
 
-    crs_replace_with_free_ranges(mem_ranges, pci->w32.begin, pci->w32.end - 1);
-    for (i = 0; i < mem_ranges->len; i++) {
-        entry = g_ptr_array_index(mem_ranges, i);
+    crs_replace_with_free_ranges(crs_range_set.mem_ranges,
+                                 pci->w32.begin, pci->w32.end - 1);
+    for (i = 0; i < crs_range_set. mem_ranges->len; i++) {
+        entry = g_ptr_array_index(crs_range_set.mem_ranges, i);
         aml_append(crs,
             aml_dword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
                              AML_NON_CACHEABLE, AML_READ_WRITE,
@@ -2088,8 +2109,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
     aml_append(dev, aml_name_decl("_CRS", crs));
     aml_append(scope, dev);
 
-    g_ptr_array_free(io_ranges, true);
-    g_ptr_array_free(mem_ranges, true);
+    crs_range_set_free(&crs_range_set);
 
     /* reserve PCIHP resources */
     if (pm->pcihp_io_len) {
Signature · 1 line
2.4.3
#5 lore raw

PATCH v4 5/6 hw/apci: handle 64-bit MMIO regions correctly

In reply to Marcel Apfelbaum

In build_crs(), the calculation and merging of the ranges already happens in 64-bit, but the entry boundaries are silently truncated to 32-bit in the call to aml_dword_memory(). Fix it by handling the 64-bit MMIO ranges separately. This fixes 64-bit BARs behind PXBs.

---
 hw/i386/acpi-build.c | 53 +++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 44 insertions(+), 9 deletions(-)
hw/i386/acpi-build.c +44 -9
index eca195d..cfcca71 100644
@@ -750,18 +750,22 @@ static void crs_range_free(gpointer data)
 typedef struct CrsRangeSet {
     GPtrArray *io_ranges;
     GPtrArray *mem_ranges;
+    GPtrArray *mem_64bit_ranges;
  } CrsRangeSet;
 
 static void crs_range_set_init(CrsRangeSet *range_set)
 {
     range_set->io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
     range_set->mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
+    range_set->mem_64bit_ranges =
+            g_ptr_array_new_with_free_func(crs_range_free);
 }
 
 static void crs_range_set_free(CrsRangeSet *range_set)
 {
     g_ptr_array_free(range_set->io_ranges, true);
     g_ptr_array_free(range_set->mem_ranges, true);
+    g_ptr_array_free(range_set->mem_64bit_ranges, true);
 }
 
 static gint crs_range_compare(gconstpointer a, gconstpointer b)
@@ -919,8 +923,14 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
              * that do not support multiple root buses
              */
             if (range_base && range_base <= range_limit) {
-                crs_range_insert(temp_range_set.mem_ranges,
-                                 range_base, range_limit);
+                uint64_t length = range_limit - range_base + 1;
+                if (range_limit <= UINT32_MAX && length <= UINT32_MAX) {
+                    crs_range_insert(temp_range_set.mem_ranges,
+                                     range_base, range_limit);
+                } else {
+                    crs_range_insert(temp_range_set.mem_64bit_ranges,
+                                     range_base, range_limit);
+                }
             }
 
             range_base =
@@ -933,8 +943,14 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
              * that do not support multiple root buses
              */
             if (range_base && range_base <= range_limit) {
-                crs_range_insert(temp_range_set.mem_ranges,
-                                 range_base, range_limit);
+                uint64_t length = range_limit - range_base + 1;
+                if (range_limit <= UINT32_MAX && length <= UINT32_MAX) {
+                    crs_range_insert(temp_range_set.mem_ranges,
+                                     range_base, range_limit);
+                } else {
+                    crs_range_insert(temp_range_set.mem_64bit_ranges,
+                                     range_base, range_limit);
+                }
             }
         }
     }
@@ -962,6 +978,19 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
         crs_range_insert(range_set->mem_ranges, entry->base, entry->limit);
     }
 
+    crs_range_merge(temp_range_set.mem_64bit_ranges);
+    for (i = 0; i < temp_range_set.mem_64bit_ranges->len; i++) {
+        entry = g_ptr_array_index(temp_range_set.mem_64bit_ranges, i);
+        aml_append(crs,
+                   aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED,
+                                    AML_MAX_FIXED, AML_NON_CACHEABLE,
+                                    AML_READ_WRITE,
+                                    0, entry->base, entry->limit, 0,
+                                    entry->limit - entry->base + 1));
+        crs_range_insert(range_set->mem_64bit_ranges,
+                         entry->base, entry->limit);
+    }
+
     crs_range_set_free(&temp_range_set);
 
     aml_append(crs,
@@ -2083,11 +2112,17 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
     }
 
     if (pci->w64.begin) {
-        aml_append(crs,
-            aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
-                             AML_CACHEABLE, AML_READ_WRITE,
-                             0, pci->w64.begin, pci->w64.end - 1, 0,
-                             pci->w64.end - pci->w64.begin));
+        crs_replace_with_free_ranges(crs_range_set.mem_64bit_ranges,
+                                     pci->w64.begin, pci->w64.end - 1);
+        for (i = 0; i < crs_range_set.mem_64bit_ranges->len; i++) {
+            entry = g_ptr_array_index(crs_range_set.mem_64bit_ranges, i);
+            aml_append(crs,
+                       aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED,
+                                        AML_MAX_FIXED,
+                                        AML_CACHEABLE, AML_READ_WRITE,
+                                        0, entry->base, entry->limit,
+                                        0, entry->limit - entry->base + 1));
+        }
     }
 
     if (misc->tpm_version != TPM_VERSION_UNSPEC) {
Signature · 1 line
2.4.3
#6 lore raw

PATCH v4 6/6 tests/acpi: Add pxb/pxb-pcie tests blobs

In reply to Marcel Apfelbaum
---
 tests/acpi-test-data/pc/DSDT.pxb       | Bin 0 -> 6280 bytes
 tests/acpi-test-data/q35/DSDT.pxb_pcie | Bin 0 -> 9098 bytes
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 tests/acpi-test-data/pc/DSDT.pxb
 create mode 100644 tests/acpi-test-data/q35/DSDT.pxb_pcie
tests/acpi-test-data/pc/DSDT.pxb new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..1733aeceb843c449d7560d4728115b096e709da2
GIT binary patch
tests/acpi-test-data/q35/DSDT.pxb_pcie new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..838ca876dece056934ed511197c2a8fa0d27fd11
GIT binary patch
Signature · 1 line
2.4.3
Tested-by Tested-by on the v4 series
#7 lore raw
In reply to Marcel Apfelbaum
Quoted 37 lines · Marcel Apfelbaum

64-bit BARs allocations fix for devices behind PXBs/PXB-PCIEs.

In build_crs() the calculation and merging of the ranges already happens in 64-bit, but the entry boundaries are silently truncated to 32-bit in the call to aml_dword_memory(). Fix it by handling the 64-bit MMIO ranges separately.

v3 -> v4:
Addressed Igor's comments (thanks for the productive review!)
- Split pxb test patch (previously patch 3/3) into the test itself (patch 1/6) and the blobs (patch 6/6).
- New patch declaring pxb/pxb-pxie as not hot-pluggable.
- Note that it does not solve the DSDT issue, but it is a prerequisite for the next patch.
- New patch solving the DSDT issue spotted by Igor.
- Using V=1 DIFF=diff make check does make it easier to review the ACPI changes, thanks.
- Patches 4 and 5 untouched (previously patches 1/3 and 2/3)

v2 -> v3:
- split original series "pci: better support for 64-bit MMIO allocation" into 2 series:
- this is the first part dealing with correct 64-bit MMIO ACPI computation
- the second one will include 64-bit MMIO reservation for PCI hotplug
- Add pxb/pxb-pcie tests (Igor) - See diffs below (*)
- Re-based on latest master.

v1 -> v2:
- resolved some styling issues (Laszlo)
- rebase on latest master (Laszlo)

Thank you,
Marcel

Marcel Apfelbaum (6):
tests/acpi: add pxb/pxb-pcie tests
hw/pxb: declare pxb devices as not hot-pluggable hw/acpi: fix a DSDT table issue when a pxb is present.
acpi: refactor pxb crs computation
hw/apci: handle 64-bit MMIO regions correctly tests/acpi: Add pxb/pxb-pcie tests blobs

Quoted 9 lines
 hw/i386/acpi-build.c                   | 131 ++++++++++++++++++++++++---------
 hw/pci-bridge/pci_expander_bridge.c    |   2 +
 tests/acpi-test-data/pc/DSDT.pxb       | Bin 0 -> 6280 bytes
 tests/acpi-test-data/q35/DSDT.pxb_pcie | Bin 0 -> 9098 bytes
 tests/bios-tables-test.c               |  37 ++++++++++
 5 files changed, 134 insertions(+), 36 deletions(-)
 create mode 100644 tests/acpi-test-data/pc/DSDT.pxb
 create mode 100644 tests/acpi-test-data/q35/DSDT.pxb_pcie

I used the following commands to test (part of) the series:

Quoted 40 lines

VIRTIO10=1 ISO=/mnt/data/isos/iso-fedora/Fedora-Workstation-Live-x86_64-24-1.2.iso CODE=/home/virt-images/OVMF_CODE.fd TMPL=/home/virt-images/OVMF_VARS.fd
TFTP=/var/lib/dnsmasq
BF=shim.efi

if [ $VIRTIO10 -eq 0 ]; then
MODERN=disable-legacy=off,disable-modern=on
else
MODERN=disable-legacy=on,disable-modern=off
fi

cp $TMPL vars3.fd

qemu-system-x86_64 \
-m 2048 \
-M pc \
-enable-kvm \
-device qxl-vga \
-drive if=pflash,readonly,format=raw,file=$CODE \
-drive if=pflash,format=raw,file=vars3.fd \
-drive id=cdrom,if=none,readonly,format=raw,cache=writethrough,file=$ISO \
\
-debugcon file:debug3.log \
-global isa-debugcon.iobase=0x402 \
\
-chardev stdio,signal=off,mux=on,id=char0 \
-mon chardev=char0,mode=readline,default \
-serial chardev:char0 \
\
-device pxb,bus=pci.0,id=bridge1,bus_nr=11 \
-device pxb,bus=pci.0,id=bridge2,bus_nr=7 \
-device pxb,bus=pci.0,id=bridge3,bus_nr=15 \
\
-device virtio-scsi-pci,id=scsi0,$MODERN,bus=pci.0 \
-device scsi-cd,bus=scsi0.0,drive=cdrom,bootindex=1 \
\
-netdev user,id=netdev0,hostfwd=tcp:127.0.0.1:2227-:22,tftp=$TFTP,bootfile=$BF,net=10.0.2.0/24 \
-device virtio-net-pci,netdev=netdev0,romfile=,$MODERN,bootindex=2,bus=bridge1,addr=2 \

Quoted 9 lines

\
-netdev user,id=netdev1,hostfwd=tcp:127.0.0.1:2228-:22,net=10.0.3.0/24 \
-device virtio-net-pci,netdev=netdev1,romfile=,$MODERN,bootindex=3,bus=bridge2,addr=3 \
\
-netdev user,id=netdev2,hostfwd=tcp:127.0.0.1:2229-:22,net=10.0.4.0/24 \
-device virtio-net-pci,netdev=netdev2,romfile=,$MODERN,bootindex=4,bus=bridge3,addr=4 \
\
-global PIIX4_PM.disable_s3=0 \

This is /proc/iomem from within the guest:

Quoted 52 lines

00000000-00000fff : reserved
00001000-0009ffff : System RAM
000a0000-000bffff : PCI Bus 0000:00
000f0000-000fffff : System ROM
00100000-007fffff : System RAM
00800000-00807fff : ACPI Non-volatile Storage
00808000-0080ffff : System RAM
00810000-008fffff : ACPI Non-volatile Storage
00900000-7e529017 : System RAM
02000000-027d3cf3 : Kernel code
027d3cf4-02d4dfff : Kernel data
02edc000-0305dfff : Kernel bss
7e529018-7e532857 : System RAM
7e532858-7e800fff : System RAM
7e801000-7e820fff : ACPI Non-volatile Storage
7e821000-7e84afff : reserved
7e84b000-7ebe1fff : System RAM
7ebe2000-7ebfdfff : reserved
7ebfe000-7ec22fff : System RAM
7ec23000-7ec35fff : reserved
7ec36000-7ec99fff : System RAM
7ec9a000-7ee16fff : reserved
7ee17000-7fe96fff : System RAM
7fe97000-7feeefff : reserved
7feef000-7fef6fff : ACPI Tables
7fef7000-7fefafff : ACPI Non-volatile Storage
7fefb000-7ffcffff : System RAM
7ffd0000-7ffeffff : reserved
7fff0000-7fffffff : System RAM
80000000-880fffff : PCI Bus 0000:00
80000000-83ffffff : 0000:00:02.0
84000000-87ffffff : 0000:00:02.0
88000000-88001fff : 0000:00:02.0
88002000-88002fff : 0000:00:06.0
88010000-8801ffff : 0000:00:02.0
88100000-881fffff : PCI Bus 0000:07
88100000-881fffff : PCI Bus 0000:08

    88100000-88100fff : 0000:08:03.0
88200000-882fffff : PCI Bus 0000:0b
  88200000-882fffff : PCI Bus 0000:0c
    88200000-88200fff : 0000:0c:02.0
88300000-883fffff : PCI Bus 0000:0f
  88300000-883fffff : PCI Bus 0000:10
    88300000-88300fff : 0000:10:04.0

88400000-febfffff : PCI Bus 0000:00
fec00000-fec003ff : IOAPIC 0
fed00000-fed003ff : HPET 0
fed00000-fed003ff : PNP0103:00
fee00000-fee00fff : Local APIC
ffe00000-ffffffff : reserved
800000000-8007fffff : PCI Bus 0000:00
800000000-8007fffff : 0000:00:06.0

Quoted 13 lines
    800000000-8007fffff : virtio-pci-modern
800800000-800ffffff : PCI Bus 0000:07
  800800000-800ffffff : PCI Bus 0000:08
    800800000-800ffffff : 0000:08:03.0
      800800000-800ffffff : virtio-pci-modern
801000000-8017fffff : PCI Bus 0000:0b
  801000000-8017fffff : PCI Bus 0000:0c
    801000000-8017fffff : 0000:0c:02.0
      801000000-8017fffff : virtio-pci-modern
801800000-801ffffff : PCI Bus 0000:0f
  801800000-801ffffff : PCI Bus 0000:10
    801800000-801ffffff : 0000:10:04.0
      801800000-801ffffff : virtio-pci-modern

It looks good to me. I also checked the _CRS objects in the DSDT in the guest (cursorily), it seemed okay.

Guest dmesg contains no problems.

The virtio-scsi CD obviously worked (booted Fedora 24 Live off of it). I also logged into the guest through all three NICs, with ssh.

Below an excerpt from the OVMF debug log -- it appears consistent with the guest's /proc/iomem:

Quoted 223 lines

PciHostBridgeGetRootBridges: 3 extra root buses reported by QEMU
InitRootBridge: populated root bus 0, with room for 6 subordinate bus(es)
InitRootBridge: populated root bus 7, with room for 3 subordinate bus(es)
InitRootBridge: populated root bus 11, with room for 3 subordinate bus(es)
InitRootBridge: populated root bus 15, with room for 240 subordinate bus(es)
RootBridge: PciRoot(0x0)
Support/Attr: 70069 / 70069
DmaAbove4G: No
NoExtConfSpace: Yes

     AllocAttr: 3 (CombineMemPMem Mem64Decode)
           Bus: 0 - 6
            Io: C000 - FFFF
           Mem: 80000000 - FBFFFFFF
    MemAbove4G: 800000000 - FFFFFFFFF
          PMem: FFFFFFFFFFFFFFFF - 0

PMemAbove4G: FFFFFFFFFFFFFFFF - 0
PciHostBridgeDxe: IntersectMemoryDescriptor: add [800000000, 1000000000): Success
RootBridge: PciRoot(0x7)
Support/Attr: 70069 / 70069
DmaAbove4G: No
NoExtConfSpace: Yes

     AllocAttr: 3 (CombineMemPMem Mem64Decode)
           Bus: 7 - A
            Io: C000 - FFFF
           Mem: 80000000 - FBFFFFFF
    MemAbove4G: 800000000 - FFFFFFFFF
          PMem: FFFFFFFFFFFFFFFF - 0

PMemAbove4G: FFFFFFFFFFFFFFFF - 0
RootBridge: PciRoot(0xB)
Support/Attr: 70069 / 70069
DmaAbove4G: No
NoExtConfSpace: Yes
AllocAttr: 3 (CombineMemPMem Mem64Decode)
Bus: B - E
Io: C000 - FFFF
Mem: 80000000 - FBFFFFFF
MemAbove4G: 800000000 - FFFFFFFFF
PMem: FFFFFFFFFFFFFFFF - 0
PMemAbove4G: FFFFFFFFFFFFFFFF - 0
RootBridge: PciRoot(0xF)
Support/Attr: 70069 / 70069
DmaAbove4G: No
NoExtConfSpace: Yes
AllocAttr: 3 (CombineMemPMem Mem64Decode)
Bus: F - FF
Io: C000 - FFFF
Mem: 80000000 - FBFFFFFF
MemAbove4G: 800000000 - FFFFFFFFF
PMem: FFFFFFFFFFFFFFFF - 0
PMemAbove4G: FFFFFFFFFFFFFFFF - 0

[...]

PCI Bus First Scanning
PciBus: Discovered PCI @ [00|00|00]

PciBus: Discovered PCI @ [00|01|00]

PciBus: Discovered PCI @ [00|01|01]
BAR[4]: Type = Io32; Alignment = 0xF; Length = 0x10; Offset = 0x20

PciBus: Discovered PCI @ [00|01|03]

PciBus: Discovered PCI @ [00|02|00]

   BAR[0]: Type =  Mem32; Alignment = 0x3FFFFFF;	Length = 0x4000000;	Offset = 0x10
   BAR[1]: Type =  Mem32; Alignment = 0x3FFFFFF;	Length = 0x4000000;	Offset = 0x14
   BAR[2]: Type =  Mem32; Alignment = 0x1FFF;	Length = 0x2000;	Offset = 0x18

BAR[3]: Type = Io32; Alignment = 0x1F; Length = 0x20; Offset = 0x1C

PciBus: Discovered PCI @ [00|03|00]

PciBus: Discovered PCI @ [00|04|00]

PciBus: Discovered PCI @ [00|05|00]

PciBus: Discovered PCI @ [00|06|00]
BAR[1]: Type = Mem32; Alignment = 0xFFF; Length = 0x1000; Offset = 0x14
BAR[4]: Type = PMem64; Alignment = 0x7FFFFF; Length = 0x800000; Offset = 0x20

PciBus: Discovered PPB @ [07|00|00]

PciBus: Discovered PCI @ [08|03|00]
BAR[1]: Type = Mem32; Alignment = 0xFFF; Length = 0x1000; Offset = 0x14
BAR[4]: Type = PMem64; Alignment = 0x7FFFFF; Length = 0x800000; Offset = 0x20

PciBus: Discovered PPB @ [0B|00|00]

PciBus: Discovered PCI @ [0C|02|00]
BAR[1]: Type = Mem32; Alignment = 0xFFF; Length = 0x1000; Offset = 0x14
BAR[4]: Type = PMem64; Alignment = 0x7FFFFF; Length = 0x800000; Offset = 0x20

PciBus: Discovered PPB @ [0F|00|00]

PciBus: Discovered PCI @ [10|04|00]
BAR[1]: Type = Mem32; Alignment = 0xFFF; Length = 0x1000; Offset = 0x14
BAR[4]: Type = PMem64; Alignment = 0x7FFFFF; Length = 0x800000; Offset = 0x20

PciBus: Discovered PCI @ [00|00|00]

PciBus: Discovered PCI @ [00|01|00]

PciBus: Discovered PCI @ [00|01|01]
BAR[4]: Type = Io32; Alignment = 0xF; Length = 0x10; Offset = 0x20

PciBus: Discovered PCI @ [00|01|03]

PciBus: Discovered PCI @ [00|02|00]

   BAR[0]: Type =  Mem32; Alignment = 0x3FFFFFF;	Length = 0x4000000;	Offset = 0x10
   BAR[1]: Type =  Mem32; Alignment = 0x3FFFFFF;	Length = 0x4000000;	Offset = 0x14
   BAR[2]: Type =  Mem32; Alignment = 0x1FFF;	Length = 0x2000;	Offset = 0x18

BAR[3]: Type = Io32; Alignment = 0x1F; Length = 0x20; Offset = 0x1C

PciBus: Discovered PCI @ [00|03|00]

PciBus: Discovered PCI @ [00|04|00]

PciBus: Discovered PCI @ [00|05|00]

PciBus: Discovered PCI @ [00|06|00]
BAR[1]: Type = Mem32; Alignment = 0xFFF; Length = 0x1000; Offset = 0x14
BAR[4]: Type = PMem64; Alignment = 0x7FFFFF; Length = 0x800000; Offset = 0x20

PciBus: Discovered PPB @ [07|00|00]

PciBus: Discovered PCI @ [08|03|00]
BAR[1]: Type = Mem32; Alignment = 0xFFF; Length = 0x1000; Offset = 0x14
BAR[4]: Type = PMem64; Alignment = 0x7FFFFF; Length = 0x800000; Offset = 0x20

PciBus: Discovered PPB @ [0B|00|00]

PciBus: Discovered PCI @ [0C|02|00]
BAR[1]: Type = Mem32; Alignment = 0xFFF; Length = 0x1000; Offset = 0x14
BAR[4]: Type = PMem64; Alignment = 0x7FFFFF; Length = 0x800000; Offset = 0x20

PciBus: Discovered PPB @ [0F|00|00]

PciBus: Discovered PCI @ [10|04|00]
BAR[1]: Type = Mem32; Alignment = 0xFFF; Length = 0x1000; Offset = 0x14
BAR[4]: Type = PMem64; Alignment = 0x7FFFFF; Length = 0x800000; Offset = 0x20

PciHostBridge: SubmitResources for PciRoot(0x0)
I/O: Granularity/SpecificFlag = 0 / 01

      Length/Alignment = 0x1000 / 0xFFF
 Mem: Granularity/SpecificFlag = 32 / 00
      Length/Alignment = 0x8100000 / 0x3FFFFFF
 Mem: Granularity/SpecificFlag = 64 / 00
      Length/Alignment = 0x800000 / 0x7FFFFF
PciBus: HostBridge->SubmitResources() - Success
PciHostBridge: SubmitResources for PciRoot(0x7)
 Mem: Granularity/SpecificFlag = 32 / 00
      Length/Alignment = 0x100000 / 0xFFFFF
 Mem: Granularity/SpecificFlag = 64 / 00
      Length/Alignment = 0x800000 / 0x7FFFFF
PciBus: HostBridge->SubmitResources() - Success
PciHostBridge: SubmitResources for PciRoot(0xB)
 Mem: Granularity/SpecificFlag = 32 / 00
      Length/Alignment = 0x100000 / 0xFFFFF
 Mem: Granularity/SpecificFlag = 64 / 00
      Length/Alignment = 0x800000 / 0x7FFFFF
PciBus: HostBridge->SubmitResources() - Success
PciHostBridge: SubmitResources for PciRoot(0xF)
 Mem: Granularity/SpecificFlag = 32 / 00
      Length/Alignment = 0x100000 / 0xFFFFF
 Mem: Granularity/SpecificFlag = 64 / 00
      Length/Alignment = 0x800000 / 0x7FFFFF

PciBus: HostBridge->SubmitResources() - Success
PciHostBridge: NotifyPhase (AllocateResources)
RootBridge: PciRoot(0x0)
Mem: Base/Length/Alignment = 80000000/8100000/3FFFFFF - Success
Mem64: Base/Length/Alignment = 800000000/800000/7FFFFF - Success I/O: Base/Length/Alignment = C000/1000/FFF - Success
RootBridge: PciRoot(0x7)
Mem64: Base/Length/Alignment = 800800000/800000/7FFFFF - Success
Mem: Base/Length/Alignment = 88100000/100000/FFFFF - Success
RootBridge: PciRoot(0xB)
Mem64: Base/Length/Alignment = 801000000/800000/7FFFFF - Success
Mem: Base/Length/Alignment = 88200000/100000/FFFFF - Success
RootBridge: PciRoot(0xF)
Mem64: Base/Length/Alignment = 801800000/800000/7FFFFF - Success
Mem: Base/Length/Alignment = 88300000/100000/FFFFF - Success
PciBus: HostBridge->NotifyPhase(AllocateResources) - Success
PciBus: Resource Map for Root Bridge PciRoot(0x0)
Type = Io16; Base = 0xC000; Length = 0x1000; Alignment = 0xFFF
Base = 0xC000; Length = 0x20; Alignment = 0x1F; Owner = PCI [00|02|00:1C]
Base = 0xC020; Length = 0x10; Alignment = 0xF; Owner = PCI [00|01|01:20]
Type = Mem32; Base = 0x80000000; Length = 0x8100000; Alignment = 0x3FFFFFF

   Base = 0x80000000;	Length = 0x4000000;	Alignment = 0x3FFFFFF;	Owner = PCI [00|02|00:14]
   Base = 0x84000000;	Length = 0x4000000;	Alignment = 0x3FFFFFF;	Owner = PCI [00|02|00:10]

Base = 0x88000000; Length = 0x2000; Alignment = 0x1FFF; Owner = PCI [00|02|00:18]
Base = 0x88002000; Length = 0x1000; Alignment = 0xFFF; Owner = PCI [00|06|00:14]
Type = Mem64; Base = 0x800000000; Length = 0x800000; Alignment = 0x7FFFFF
Base = 0x800000000; Length = 0x800000; Alignment = 0x7FFFFF; Owner = PCI [00|06|00:20]; Type = PMem64

PciBus: Resource Map for Root Bridge PciRoot(0x7)
Type = Mem32; Base = 0x88100000; Length = 0x100000; Alignment = 0xFFFFF
Base = 0x88100000; Length = 0x100000; Alignment = 0xFFFFF; Owner = PPB [07|00|00:**]
Type = Mem64; Base = 0x800800000; Length = 0x800000; Alignment = 0x7FFFFF
Base = 0x800800000; Length = 0x800000; Alignment = 0x7FFFFF; Owner = PPB [07|00|00:**]; Type = PMem64

PciBus: Resource Map for Bridge [07|00|00]
Type = Mem32; Base = 0x88100000; Length = 0x100000; Alignment = 0xFFFFF
Base = 0x88100000; Length = 0x1000; Alignment = 0xFFF; Owner = PCI [08|03|00:14]
Type = PMem64; Base = 0x800800000; Length = 0x800000; Alignment = 0x7FFFFF
Base = 0x800800000; Length = 0x800000; Alignment = 0x7FFFFF; Owner = PCI [08|03|00:20]

PciBus: Resource Map for Root Bridge PciRoot(0xB)
Type = Mem32; Base = 0x88200000; Length = 0x100000; Alignment = 0xFFFFF
Base = 0x88200000; Length = 0x100000; Alignment = 0xFFFFF; Owner = PPB [0B|00|00:**]
Type = Mem64; Base = 0x801000000; Length = 0x800000; Alignment = 0x7FFFFF
Base = 0x801000000; Length = 0x800000; Alignment = 0x7FFFFF; Owner = PPB [0B|00|00:**]; Type = PMem64

PciBus: Resource Map for Bridge [0B|00|00]
Type = Mem32; Base = 0x88200000; Length = 0x100000; Alignment = 0xFFFFF
Base = 0x88200000; Length = 0x1000; Alignment = 0xFFF; Owner = PCI [0C|02|00:14]
Type = PMem64; Base = 0x801000000; Length = 0x800000; Alignment = 0x7FFFFF
Base = 0x801000000; Length = 0x800000; Alignment = 0x7FFFFF; Owner = PCI [0C|02|00:20]

PciBus: Resource Map for Root Bridge PciRoot(0xF)
Type = Mem32; Base = 0x88300000; Length = 0x100000; Alignment = 0xFFFFF
Base = 0x88300000; Length = 0x100000; Alignment = 0xFFFFF; Owner = PPB [0F|00|00:**]
Type = Mem64; Base = 0x801800000; Length = 0x800000; Alignment = 0x7FFFFF
Base = 0x801800000; Length = 0x800000; Alignment = 0x7FFFFF; Owner = PPB [0F|00|00:**]; Type = PMem64

Quoted 5 lines

PciBus: Resource Map for Bridge [0F|00|00]
Type = Mem32; Base = 0x88300000; Length = 0x100000; Alignment = 0xFFFFF
Base = 0x88300000; Length = 0x1000; Alignment = 0xFFF; Owner = PCI [10|04|00:14]
Type = PMem64; Base = 0x801800000; Length = 0x800000; Alignment = 0x7FFFFF
Base = 0x801800000; Length = 0x800000; Alignment = 0x7FFFFF; Owner = PCI [10|04|00:20]

For patches #2 through #5:

I also ran "make check". The "check-qtest-i386" step (like all others) succeeded, which should cover patch #1 and #6 via "bios-tables-test.c". For those as well:

Thanks
Laszlo

#8 lore raw
Quoted 405 lines · Laszlo Ersek
Quoted 37 lines · Marcel Apfelbaum

64-bit BARs allocations fix for devices behind PXBs/PXB-PCIEs.

In build_crs() the calculation and merging of the ranges already happens in 64-bit, but the entry boundaries are silently truncated to 32-bit in the call to aml_dword_memory(). Fix it by handling the 64-bit MMIO ranges separately.

v3 -> v4:
Addressed Igor's comments (thanks for the productive review!)
- Split pxb test patch (previously patch 3/3) into the test itself (patch 1/6) and the blobs (patch 6/6).
- New patch declaring pxb/pxb-pxie as not hot-pluggable.
- Note that it does not solve the DSDT issue, but it is a prerequisite for the next patch.
- New patch solving the DSDT issue spotted by Igor.
- Using V=1 DIFF=diff make check does make it easier to review the ACPI changes, thanks.
- Patches 4 and 5 untouched (previously patches 1/3 and 2/3)

v2 -> v3:
- split original series "pci: better support for 64-bit MMIO allocation" into 2 series:
- this is the first part dealing with correct 64-bit MMIO ACPI computation
- the second one will include 64-bit MMIO reservation for PCI hotplug
- Add pxb/pxb-pcie tests (Igor) - See diffs below (*)
- Re-based on latest master.

v1 -> v2:
- resolved some styling issues (Laszlo)
- rebase on latest master (Laszlo)

Thank you,
Marcel

Marcel Apfelbaum (6):
tests/acpi: add pxb/pxb-pcie tests
hw/pxb: declare pxb devices as not hot-pluggable hw/acpi: fix a DSDT table issue when a pxb is present.
acpi: refactor pxb crs computation
hw/apci: handle 64-bit MMIO regions correctly tests/acpi: Add pxb/pxb-pcie tests blobs

Quoted 9 lines
  hw/i386/acpi-build.c                   | 131 ++++++++++++++++++++++++---------
  hw/pci-bridge/pci_expander_bridge.c    |   2 +
  tests/acpi-test-data/pc/DSDT.pxb       | Bin 0 -> 6280 bytes
  tests/acpi-test-data/q35/DSDT.pxb_pcie | Bin 0 -> 9098 bytes
  tests/bios-tables-test.c               |  37 ++++++++++
  5 files changed, 134 insertions(+), 36 deletions(-)

create mode 100644 tests/acpi-test-data/pc/DSDT.pxb create mode 100644 tests/acpi-test-data/q35/DSDT.pxb_pcie

I used the following commands to test (part of) the series:

Quoted 40 lines

VIRTIO10=1 ISO=/mnt/data/isos/iso-fedora/Fedora-Workstation-Live-x86_64-24-1.2.iso CODE=/home/virt-images/OVMF_CODE.fd TMPL=/home/virt-images/OVMF_VARS.fd
TFTP=/var/lib/dnsmasq
BF=shim.efi

if [ $VIRTIO10 -eq 0 ]; then
MODERN=disable-legacy=off,disable-modern=on
else
MODERN=disable-legacy=on,disable-modern=off
fi

cp $TMPL vars3.fd

qemu-system-x86_64 \
   -m 2048 \
   -M pc \
   -enable-kvm \
   -device qxl-vga \
   -drive if=pflash,readonly,format=raw,file=$CODE \
   -drive if=pflash,format=raw,file=vars3.fd \
   -drive id=cdrom,if=none,readonly,format=raw,cache=writethrough,file=$ISO \
   \
   -debugcon file:debug3.log \
   -global isa-debugcon.iobase=0x402 \
   \
   -chardev stdio,signal=off,mux=on,id=char0 \
   -mon chardev=char0,mode=readline,default \
   -serial chardev:char0 \
   \
   -device pxb,bus=pci.0,id=bridge1,bus_nr=11 \
   -device pxb,bus=pci.0,id=bridge2,bus_nr=7 \
   -device pxb,bus=pci.0,id=bridge3,bus_nr=15 \
   \
   -device virtio-scsi-pci,id=scsi0,$MODERN,bus=pci.0 \
   -device scsi-cd,bus=scsi0.0,drive=cdrom,bootindex=1 \
   \
   -netdev user,id=netdev0,hostfwd=tcp:127.0.0.1:2227-:22,tftp=$TFTP,bootfile=$BF,net=10.0.2.0/24 \
   -device virtio-net-pci,netdev=netdev0,romfile=,$MODERN,bootindex=2,bus=bridge1,addr=2 \
Quoted 9 lines
   \
   -netdev user,id=netdev1,hostfwd=tcp:127.0.0.1:2228-:22,net=10.0.3.0/24 \
   -device virtio-net-pci,netdev=netdev1,romfile=,$MODERN,bootindex=3,bus=bridge2,addr=3 \
   \
   -netdev user,id=netdev2,hostfwd=tcp:127.0.0.1:2229-:22,net=10.0.4.0/24 \
   -device virtio-net-pci,netdev=netdev2,romfile=,$MODERN,bootindex=4,bus=bridge3,addr=4 \
   \
   -global PIIX4_PM.disable_s3=0 \

This is /proc/iomem from within the guest:

Quoted 52 lines

00000000-00000fff : reserved
00001000-0009ffff : System RAM
000a0000-000bffff : PCI Bus 0000:00
000f0000-000fffff : System ROM
00100000-007fffff : System RAM
00800000-00807fff : ACPI Non-volatile Storage
00808000-0080ffff : System RAM
00810000-008fffff : ACPI Non-volatile Storage
00900000-7e529017 : System RAM
02000000-027d3cf3 : Kernel code
027d3cf4-02d4dfff : Kernel data
02edc000-0305dfff : Kernel bss
7e529018-7e532857 : System RAM
7e532858-7e800fff : System RAM
7e801000-7e820fff : ACPI Non-volatile Storage
7e821000-7e84afff : reserved
7e84b000-7ebe1fff : System RAM
7ebe2000-7ebfdfff : reserved
7ebfe000-7ec22fff : System RAM
7ec23000-7ec35fff : reserved
7ec36000-7ec99fff : System RAM
7ec9a000-7ee16fff : reserved
7ee17000-7fe96fff : System RAM
7fe97000-7feeefff : reserved
7feef000-7fef6fff : ACPI Tables
7fef7000-7fefafff : ACPI Non-volatile Storage
7fefb000-7ffcffff : System RAM
7ffd0000-7ffeffff : reserved
7fff0000-7fffffff : System RAM
80000000-880fffff : PCI Bus 0000:00
80000000-83ffffff : 0000:00:02.0
84000000-87ffffff : 0000:00:02.0
88000000-88001fff : 0000:00:02.0
88002000-88002fff : 0000:00:06.0
88010000-8801ffff : 0000:00:02.0
88100000-881fffff : PCI Bus 0000:07
88100000-881fffff : PCI Bus 0000:08

     88100000-88100fff : 0000:08:03.0
88200000-882fffff : PCI Bus 0000:0b
   88200000-882fffff : PCI Bus 0000:0c
     88200000-88200fff : 0000:0c:02.0
88300000-883fffff : PCI Bus 0000:0f
   88300000-883fffff : PCI Bus 0000:10
     88300000-88300fff : 0000:10:04.0

88400000-febfffff : PCI Bus 0000:00
fec00000-fec003ff : IOAPIC 0
fed00000-fed003ff : HPET 0
fed00000-fed003ff : PNP0103:00
fee00000-fee00fff : Local APIC
ffe00000-ffffffff : reserved
800000000-8007fffff : PCI Bus 0000:00
800000000-8007fffff : 0000:00:06.0

Quoted 13 lines
     800000000-8007fffff : virtio-pci-modern
800800000-800ffffff : PCI Bus 0000:07
   800800000-800ffffff : PCI Bus 0000:08
     800800000-800ffffff : 0000:08:03.0
       800800000-800ffffff : virtio-pci-modern
801000000-8017fffff : PCI Bus 0000:0b
   801000000-8017fffff : PCI Bus 0000:0c
     801000000-8017fffff : 0000:0c:02.0
       801000000-8017fffff : virtio-pci-modern
801800000-801ffffff : PCI Bus 0000:0f
   801800000-801ffffff : PCI Bus 0000:10
     801800000-801ffffff : 0000:10:04.0
       801800000-801ffffff : virtio-pci-modern

It looks good to me. I also checked the _CRS objects in the DSDT in the guest (cursorily), it seemed okay.

Guest dmesg contains no problems.

The virtio-scsi CD obviously worked (booted Fedora 24 Live off of it). I also logged into the guest through all three NICs, with ssh.

Below an excerpt from the OVMF debug log -- it appears consistent with the guest's /proc/iomem:

Quoted 223 lines

PciHostBridgeGetRootBridges: 3 extra root buses reported by QEMU
InitRootBridge: populated root bus 0, with room for 6 subordinate bus(es)
InitRootBridge: populated root bus 7, with room for 3 subordinate bus(es)
InitRootBridge: populated root bus 11, with room for 3 subordinate bus(es)
InitRootBridge: populated root bus 15, with room for 240 subordinate bus(es)
RootBridge: PciRoot(0x0)
Support/Attr: 70069 / 70069
DmaAbove4G: No
NoExtConfSpace: Yes

      AllocAttr: 3 (CombineMemPMem Mem64Decode)
            Bus: 0 - 6
             Io: C000 - FFFF
            Mem: 80000000 - FBFFFFFF
     MemAbove4G: 800000000 - FFFFFFFFF
           PMem: FFFFFFFFFFFFFFFF - 0
    PMemAbove4G: FFFFFFFFFFFFFFFF - 0

PciHostBridgeDxe: IntersectMemoryDescriptor: add [800000000, 1000000000): Success
RootBridge: PciRoot(0x7)
Support/Attr: 70069 / 70069
DmaAbove4G: No
NoExtConfSpace: Yes

      AllocAttr: 3 (CombineMemPMem Mem64Decode)
            Bus: 7 - A
             Io: C000 - FFFF
            Mem: 80000000 - FBFFFFFF
     MemAbove4G: 800000000 - FFFFFFFFF
           PMem: FFFFFFFFFFFFFFFF - 0
    PMemAbove4G: FFFFFFFFFFFFFFFF - 0

RootBridge: PciRoot(0xB)
Support/Attr: 70069 / 70069
DmaAbove4G: No
NoExtConfSpace: Yes
AllocAttr: 3 (CombineMemPMem Mem64Decode)
Bus: B - E
Io: C000 - FFFF
Mem: 80000000 - FBFFFFFF
MemAbove4G: 800000000 - FFFFFFFFF
PMem: FFFFFFFFFFFFFFFF - 0
PMemAbove4G: FFFFFFFFFFFFFFFF - 0
RootBridge: PciRoot(0xF)
Support/Attr: 70069 / 70069
DmaAbove4G: No
NoExtConfSpace: Yes
AllocAttr: 3 (CombineMemPMem Mem64Decode)
Bus: F - FF
Io: C000 - FFFF
Mem: 80000000 - FBFFFFFF
MemAbove4G: 800000000 - FFFFFFFFF
PMem: FFFFFFFFFFFFFFFF - 0
PMemAbove4G: FFFFFFFFFFFFFFFF - 0

[...]

PCI Bus First Scanning
PciBus: Discovered PCI @ [00|00|00]

PciBus: Discovered PCI @ [00|01|00]

PciBus: Discovered PCI @ [00|01|01]

    BAR[4]: Type =   Io32; Alignment = 0xF;	Length = 0x10;	Offset = 0x20

PciBus: Discovered PCI @ [00|01|03]

PciBus: Discovered PCI @ [00|02|00]

    BAR[0]: Type =  Mem32; Alignment = 0x3FFFFFF;	Length = 0x4000000;	Offset = 0x10
    BAR[1]: Type =  Mem32; Alignment = 0x3FFFFFF;	Length = 0x4000000;	Offset = 0x14
    BAR[2]: Type =  Mem32; Alignment = 0x1FFF;	Length = 0x2000;	Offset = 0x18
    BAR[3]: Type =   Io32; Alignment = 0x1F;	Length = 0x20;	Offset = 0x1C

PciBus: Discovered PCI @ [00|03|00]

PciBus: Discovered PCI @ [00|04|00]

PciBus: Discovered PCI @ [00|05|00]

PciBus: Discovered PCI @ [00|06|00]

    BAR[1]: Type =  Mem32; Alignment = 0xFFF;	Length = 0x1000;	Offset = 0x14
    BAR[4]: Type = PMem64; Alignment = 0x7FFFFF;	Length = 0x800000;	Offset = 0x20

PciBus: Discovered PPB @ [07|00|00]

PciBus: Discovered PCI @ [08|03|00]

    BAR[1]: Type =  Mem32; Alignment = 0xFFF;	Length = 0x1000;	Offset = 0x14
    BAR[4]: Type = PMem64; Alignment = 0x7FFFFF;	Length = 0x800000;	Offset = 0x20

PciBus: Discovered PPB @ [0B|00|00]

PciBus: Discovered PCI @ [0C|02|00]

    BAR[1]: Type =  Mem32; Alignment = 0xFFF;	Length = 0x1000;	Offset = 0x14
    BAR[4]: Type = PMem64; Alignment = 0x7FFFFF;	Length = 0x800000;	Offset = 0x20

PciBus: Discovered PPB @ [0F|00|00]

PciBus: Discovered PCI @ [10|04|00]

    BAR[1]: Type =  Mem32; Alignment = 0xFFF;	Length = 0x1000;	Offset = 0x14
    BAR[4]: Type = PMem64; Alignment = 0x7FFFFF;	Length = 0x800000;	Offset = 0x20

PciBus: Discovered PCI @ [00|00|00]

PciBus: Discovered PCI @ [00|01|00]

PciBus: Discovered PCI @ [00|01|01]

    BAR[4]: Type =   Io32; Alignment = 0xF;	Length = 0x10;	Offset = 0x20

PciBus: Discovered PCI @ [00|01|03]

PciBus: Discovered PCI @ [00|02|00]

    BAR[0]: Type =  Mem32; Alignment = 0x3FFFFFF;	Length = 0x4000000;	Offset = 0x10
    BAR[1]: Type =  Mem32; Alignment = 0x3FFFFFF;	Length = 0x4000000;	Offset = 0x14
    BAR[2]: Type =  Mem32; Alignment = 0x1FFF;	Length = 0x2000;	Offset = 0x18
    BAR[3]: Type =   Io32; Alignment = 0x1F;	Length = 0x20;	Offset = 0x1C

PciBus: Discovered PCI @ [00|03|00]

PciBus: Discovered PCI @ [00|04|00]

PciBus: Discovered PCI @ [00|05|00]

PciBus: Discovered PCI @ [00|06|00]

    BAR[1]: Type =  Mem32; Alignment = 0xFFF;	Length = 0x1000;	Offset = 0x14
    BAR[4]: Type = PMem64; Alignment = 0x7FFFFF;	Length = 0x800000;	Offset = 0x20

PciBus: Discovered PPB @ [07|00|00]

PciBus: Discovered PCI @ [08|03|00]

    BAR[1]: Type =  Mem32; Alignment = 0xFFF;	Length = 0x1000;	Offset = 0x14
    BAR[4]: Type = PMem64; Alignment = 0x7FFFFF;	Length = 0x800000;	Offset = 0x20

PciBus: Discovered PPB @ [0B|00|00]

PciBus: Discovered PCI @ [0C|02|00]

    BAR[1]: Type =  Mem32; Alignment = 0xFFF;	Length = 0x1000;	Offset = 0x14
    BAR[4]: Type = PMem64; Alignment = 0x7FFFFF;	Length = 0x800000;	Offset = 0x20

PciBus: Discovered PPB @ [0F|00|00]

PciBus: Discovered PCI @ [10|04|00]

    BAR[1]: Type =  Mem32; Alignment = 0xFFF;	Length = 0x1000;	Offset = 0x14
    BAR[4]: Type = PMem64; Alignment = 0x7FFFFF;	Length = 0x800000;	Offset = 0x20

PciHostBridge: SubmitResources for PciRoot(0x0)
I/O: Granularity/SpecificFlag = 0 / 01

       Length/Alignment = 0x1000 / 0xFFF
  Mem: Granularity/SpecificFlag = 32 / 00
       Length/Alignment = 0x8100000 / 0x3FFFFFF
  Mem: Granularity/SpecificFlag = 64 / 00
       Length/Alignment = 0x800000 / 0x7FFFFF
PciBus: HostBridge->SubmitResources() - Success
PciHostBridge: SubmitResources for PciRoot(0x7)
  Mem: Granularity/SpecificFlag = 32 / 00
       Length/Alignment = 0x100000 / 0xFFFFF
  Mem: Granularity/SpecificFlag = 64 / 00
       Length/Alignment = 0x800000 / 0x7FFFFF
PciBus: HostBridge->SubmitResources() - Success
PciHostBridge: SubmitResources for PciRoot(0xB)
  Mem: Granularity/SpecificFlag = 32 / 00
       Length/Alignment = 0x100000 / 0xFFFFF
  Mem: Granularity/SpecificFlag = 64 / 00
       Length/Alignment = 0x800000 / 0x7FFFFF
PciBus: HostBridge->SubmitResources() - Success
PciHostBridge: SubmitResources for PciRoot(0xF)
  Mem: Granularity/SpecificFlag = 32 / 00
       Length/Alignment = 0x100000 / 0xFFFFF
  Mem: Granularity/SpecificFlag = 64 / 00
       Length/Alignment = 0x800000 / 0x7FFFFF

PciBus: HostBridge->SubmitResources() - Success
PciHostBridge: NotifyPhase (AllocateResources)
RootBridge: PciRoot(0x0)
Mem: Base/Length/Alignment = 80000000/8100000/3FFFFFF - Success
Mem64: Base/Length/Alignment = 800000000/800000/7FFFFF - Success I/O: Base/Length/Alignment = C000/1000/FFF - Success
RootBridge: PciRoot(0x7)
Mem64: Base/Length/Alignment = 800800000/800000/7FFFFF - Success
Mem: Base/Length/Alignment = 88100000/100000/FFFFF - Success
RootBridge: PciRoot(0xB)
Mem64: Base/Length/Alignment = 801000000/800000/7FFFFF - Success
Mem: Base/Length/Alignment = 88200000/100000/FFFFF - Success
RootBridge: PciRoot(0xF)
Mem64: Base/Length/Alignment = 801800000/800000/7FFFFF - Success
Mem: Base/Length/Alignment = 88300000/100000/FFFFF - Success
PciBus: HostBridge->NotifyPhase(AllocateResources) - Success
PciBus: Resource Map for Root Bridge PciRoot(0x0)
Type = Io16; Base = 0xC000; Length = 0x1000; Alignment = 0xFFF

    Base = 0xC000;	Length = 0x20;	Alignment = 0x1F;	Owner = PCI [00|02|00:1C]
    Base = 0xC020;	Length = 0x10;	Alignment = 0xF;	Owner = PCI [00|01|01:20]
Type =  Mem32; Base = 0x80000000;	Length = 0x8100000;	Alignment = 0x3FFFFFF
    Base = 0x80000000;	Length = 0x4000000;	Alignment = 0x3FFFFFF;	Owner = PCI [00|02|00:14]
    Base = 0x84000000;	Length = 0x4000000;	Alignment = 0x3FFFFFF;	Owner = PCI [00|02|00:10]
    Base = 0x88000000;	Length = 0x2000;	Alignment = 0x1FFF;	Owner = PCI [00|02|00:18]
    Base = 0x88002000;	Length = 0x1000;	Alignment = 0xFFF;	Owner = PCI [00|06|00:14]
Type =  Mem64; Base = 0x800000000;	Length = 0x800000;	Alignment = 0x7FFFFF
    Base = 0x800000000;	Length = 0x800000;	Alignment = 0x7FFFFF;	Owner = PCI [00|06|00:20]; Type = PMem64

PciBus: Resource Map for Root Bridge PciRoot(0x7)
Type = Mem32; Base = 0x88100000; Length = 0x100000; Alignment = 0xFFFFF

    Base = 0x88100000;	Length = 0x100000;	Alignment = 0xFFFFF;	Owner = PPB [07|00|00:**]
Type =  Mem64; Base = 0x800800000;	Length = 0x800000;	Alignment = 0x7FFFFF
    Base = 0x800800000;	Length = 0x800000;	Alignment = 0x7FFFFF;	Owner = PPB [07|00|00:**]; Type = PMem64

PciBus: Resource Map for Bridge [07|00|00]
Type = Mem32; Base = 0x88100000; Length = 0x100000; Alignment = 0xFFFFF

    Base = 0x88100000;	Length = 0x1000;	Alignment = 0xFFF;	Owner = PCI [08|03|00:14]
Type = PMem64; Base = 0x800800000;	Length = 0x800000;	Alignment = 0x7FFFFF
    Base = 0x800800000;	Length = 0x800000;	Alignment = 0x7FFFFF;	Owner = PCI [08|03|00:20]

PciBus: Resource Map for Root Bridge PciRoot(0xB)
Type = Mem32; Base = 0x88200000; Length = 0x100000; Alignment = 0xFFFFF

    Base = 0x88200000;	Length = 0x100000;	Alignment = 0xFFFFF;	Owner = PPB [0B|00|00:**]
Type =  Mem64; Base = 0x801000000;	Length = 0x800000;	Alignment = 0x7FFFFF
    Base = 0x801000000;	Length = 0x800000;	Alignment = 0x7FFFFF;	Owner = PPB [0B|00|00:**]; Type = PMem64

PciBus: Resource Map for Bridge [0B|00|00]
Type = Mem32; Base = 0x88200000; Length = 0x100000; Alignment = 0xFFFFF

    Base = 0x88200000;	Length = 0x1000;	Alignment = 0xFFF;	Owner = PCI [0C|02|00:14]
Type = PMem64; Base = 0x801000000;	Length = 0x800000;	Alignment = 0x7FFFFF
    Base = 0x801000000;	Length = 0x800000;	Alignment = 0x7FFFFF;	Owner = PCI [0C|02|00:20]

PciBus: Resource Map for Root Bridge PciRoot(0xF)
Type = Mem32; Base = 0x88300000; Length = 0x100000; Alignment = 0xFFFFF

    Base = 0x88300000;	Length = 0x100000;	Alignment = 0xFFFFF;	Owner = PPB [0F|00|00:**]
Type =  Mem64; Base = 0x801800000;	Length = 0x800000;	Alignment = 0x7FFFFF
    Base = 0x801800000;	Length = 0x800000;	Alignment = 0x7FFFFF;	Owner = PPB [0F|00|00:**]; Type = PMem64
Quoted 5 lines

PciBus: Resource Map for Bridge [0F|00|00]
Type = Mem32; Base = 0x88300000; Length = 0x100000; Alignment = 0xFFFFF

    Base = 0x88300000;	Length = 0x1000;	Alignment = 0xFFF;	Owner = PCI [10|04|00:14]
Type = PMem64; Base = 0x801800000;	Length = 0x800000;	Alignment = 0x7FFFFF
    Base = 0x801800000;	Length = 0x800000;	Alignment = 0x7FFFFF;	Owner = PCI [10|04|00:20]
Quoted 7 lines

For patches #2 through #5:

I also ran "make check". The "check-qtest-i386" step (like all others) succeeded, which should cover patch #1 and #6 via "bios-tables-test.c". For those as well:

Very appreciated!

Also for patch #5 that actually solves the problem:

Thanks,
Marcel

Quoted 4 lines

Thanks
Laszlo