Skip to contentSkip to conversation

pxb: fix 64-bit MMIO allocation

PATCH In review Marcel Apfelbaum 7 participants 31 messages Jul 17, 2016 – Jul 27, 2016

lore
Share & tools
lore
#0 lore raw

v5 cover pxb: fix 64-bit MMIO allocation

v4 -> v5:
Addressed the pull request issues: (Peter Maydell)
See: https://lists.gnu.org/archive/html/qemu-devel/2016-07/msg00882.html
- cland warning -> "hw/pci/pci.c:196:23: runtime error: shift exponent -1 is negative":
The PCIe Root port was not initialized properly, the interrupt pin was left 0. This is a long standing issue exposed by the new test. (Patch 1/7)
- 'make check' fails on 32-bit:
Fix it by changing the ivshmem mem size from 4G
to 1G, since 4G is not a valid value on 32-bit archs. (Patch 2/7)
(4G is truncated to 0 on 32-bit systems)
- Rebased on mst's pci branch.
Since all the new changes are not related to the series, I kept the existing "Reviewed-by"/"Tested-by" signatures.

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)

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.

Thank you,
Marcel

Marcel Apfelbaum (7):
hw/pcie-root-port: Fix PCIe root port initialization 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/ioh3420.c                |   1 +
 hw/pci-bridge/pci_expander_bridge.c    |   2 +
 tests/acpi-test-data/pc/DSDT.pxb       | Bin 0 -> 6286 bytes
 tests/acpi-test-data/q35/DSDT.pxb_pcie | Bin 0 -> 9098 bytes
 tests/bios-tables-test.c               |  37 ++++++++++
 6 files changed, 135 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 v5 1/7 hw/pcie-root-port: Fix PCIe root port initialization

Specify the root port interrupt pin as part of the init process for cases when msi/msix are not enabled.

Fixes "hw/pci/pci.c:196:23: runtime error: shift exponent -1 is negative" warning from clang's sanitizer.

---
 hw/pci-bridge/ioh3420.c | 1 +
 1 file changed, 1 insertion(+)
hw/pci-bridge/ioh3420.c +1 -0
index 93c6f0b..d88cae5 100644
@@ -100,6 +100,7 @@ static int ioh3420_initfn(PCIDevice *d)
     int rc;
     Error *err = NULL;
 
+    pci_config_set_interrupt_pin(d->config, 1);
     pci_bridge_initfn(d, TYPE_PCIE_BUS);
     pcie_port_init_reg(d);
 
Signature · 1 line
2.4.3
#2 lore raw

PATCH v5 2/7 tests/acpi: add pxb/pxb-pcie tests

In reply to Marcel Apfelbaum

Add an ivshmem device with 1G 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 de4019e..b23c6b0 100644
@@ -864,6 +864,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=1G,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=1G,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();
@@ -884,6 +919,8 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi);
         qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp);
         qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp);
+        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
#22 lore raw

PATCH v5 3/7 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 ab86121..b4f8ca2 100644
@@ -310,6 +310,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);
 }
 
@@ -343,6 +344,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
#23 lore raw

PATCH v5 4/7 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 fbba461..5ed2bbd 100644
@@ -597,6 +597,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
#24 lore raw

PATCH v5 5/7 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 | 81 ++++++++++++++++++++++++++++++++--------------------
 1 file changed, 50 insertions(+), 31 deletions(-)
hw/i386/acpi-build.c +50 -31
index 5ed2bbd..d8b3543 100644
@@ -748,6 +748,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;
@@ -832,18 +849,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];
@@ -867,9 +883,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);
             }
         }
 
@@ -888,7 +906,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 =
@@ -901,7 +920,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 =
@@ -914,35 +934,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,
@@ -1899,8 +1920,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;
@@ -1989,6 +2009,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) {
@@ -2015,8 +2036,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);
@@ -2037,9 +2057,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,
@@ -2052,11 +2072,11 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
                          AML_CACHEABLE, AML_READ_WRITE,
                          0, 0x000A0000, 0x000BFFFF, 0, 0x00020000));
 
-    crs_replace_with_free_ranges(mem_ranges,
+    crs_replace_with_free_ranges(crs_range_set.mem_ranges,
                                  range_lob(pci_hole),
                                  range_upb(pci_hole));
-    for (i = 0; i < mem_ranges->len; i++) {
-        entry = g_ptr_array_index(mem_ranges, i);
+    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,
@@ -2091,8 +2111,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
#25 lore raw

PATCH v5 6/7 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 | 54 +++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 45 insertions(+), 9 deletions(-)
hw/i386/acpi-build.c +45 -9
index d8b3543..b1adf04 100644
@@ -751,18 +751,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)
@@ -920,8 +924,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 =
@@ -934,8 +944,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);
+                }
             }
         }
     }
@@ -963,6 +979,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,
@@ -2085,11 +2114,18 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
     }
 
     if (!range_is_empty(pci_hole64)) {
-        aml_append(crs,
-            aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
-                             AML_CACHEABLE, AML_READ_WRITE,
-                             0, range_lob(pci_hole64), range_upb(pci_hole64), 0,
-                             range_upb(pci_hole64) + 1 - range_lob(pci_hole64)));
+        crs_replace_with_free_ranges(crs_range_set.mem_64bit_ranges,
+                                     range_lob(pci_hole64),
+                                     range_upb(pci_hole64));
+        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
#26 lore raw

PATCH v5 7/7 tests/acpi: Add pxb/pxb-pcie tests blobs

In reply to Marcel Apfelbaum
---
 tests/acpi-test-data/pc/DSDT.pxb       | Bin 0 -> 6286 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..8839fcfe4246cdca093c5890c98e64dc5a10f8b8
GIT binary patch
tests/acpi-test-data/q35/DSDT.pxb_pcie new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..afcb5314a298ab9d4a1fd07dade044b164d56411
GIT binary patch
Signature · 1 line
2.4.3
#3 lore raw

Re: [Qemu-devel] [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests

In reply to Marcel Apfelbaum
Quoted 2 lines · On Sun, 17 Jul 2016 19:53:09 +0300 Marcel Apfelbaum <[email protected]> wrote:

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

what is forcing ivshmem to be mapped above 4G?

Quoted 63 lines
---
 tests/bios-tables-test.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
tests/bios-tables-test.c +37 -0
index de4019e..b23c6b0 100644
@@ -864,6 +864,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=1G,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=1G,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();
@@ -884,6 +919,8 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi);
         qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp);
         qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp);
+        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);
#4 lore raw

Re: [Qemu-devel] [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests

Quoted 6 lines · Igor Mammedov
Quoted 2 lines · On Sun, 17 Jul 2016 19:53:09 +0300 Marcel Apfelbaum <[email protected]> wrote:

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

what is forcing ivshmem to be mapped above 4G?

For PC machine: nothing -> ivshmem gets mapped in 32-bit area For Q35 machine: there is not enough space for mapping 1G
in 32-bit area, and maybe there are also alignment constrains. You can use this test in verbose mode and see exactly how the ranges are distributed. If you want me to run it and add the output, please let me know.

Thanks,
Marcel

Quoted 65 lines
Quoted 64 lines
---
  tests/bios-tables-test.c | 37 +++++++++++++++++++++++++++++++++++++
  1 file changed, 37 insertions(+)
tests/bios-tables-test.c +37 -0
index de4019e..b23c6b0 100644
@@ -864,6 +864,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=1G,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=1G,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();
@@ -884,6 +919,8 @@ int main(int argc, char *argv[])
          qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi);
          qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp);
          qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp);
+        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);
#5 lore raw

Re: [Qemu-devel] [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests

Quoted 6 lines · On Mon, 18 Jul 2016 17:17:48 +0300 Marcel Apfelbaum <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
Quoted 2 lines · On Sun, 17 Jul 2016 19:53:09 +0300 Marcel Apfelbaum <[email protected]> wrote:

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

Quoted 8 lines
Quoted 1 line

what is forcing ivshmem to be mapped above 4G?

For PC machine: nothing -> ivshmem gets mapped in 32-bit area For Q35 machine: there is not enough space for mapping 1G
in 32-bit area, and maybe there are also alignment constrains. You can use this test in verbose mode and see exactly how the ranges are distributed. If you want me to run it and add the output, please let me know.

No need to post diff, I can do V=1 manually,
the question though is: doesn't PC need ivshmem to go above 4G as well?

Quoted 71 lines

Thanks,
Marcel

Quoted 65 lines
Quoted 64 lines
---
  tests/bios-tables-test.c | 37 +++++++++++++++++++++++++++++++++++++
  1 file changed, 37 insertions(+)
tests/bios-tables-test.c +37 -0
index de4019e..b23c6b0 100644
@@ -864,6 +864,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=1G,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=1G,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();
@@ -884,6 +919,8 @@ int main(int argc, char *argv[])
          qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi);
          qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp);
          qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp);
+        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);  
#7 lore raw

Re: [Qemu-devel] [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests

In reply to Igor Mammedov
Quoted 6 lines · Igor Mammedov
Quoted 2 lines · On Sun, 17 Jul 2016 19:53:09 +0300 Marcel Apfelbaum <[email protected]> wrote:

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

what is forcing ivshmem to be mapped above 4G?

Speaking for OVMF: unlike SeaBIOS, the edk2 PCI bus driver prefers to map 64-bit BARs outside of 32-bit address space, regardless of how much room is left in the 32-bit MMIO aperture.

Thanks
Laszlo

#6 lore raw

Re: [Qemu-devel] [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests

In reply to Igor Mammedov
Quoted 11 lines · Igor Mammedov
Quoted 8 lines · On Mon, 18 Jul 2016 17:17:48 +0300 Marcel Apfelbaum <[email protected]> wrote:
Quoted 6 lines · Igor Mammedov
Quoted 2 lines · On Sun, 17 Jul 2016 19:53:09 +0300 Marcel Apfelbaum <[email protected]> wrote:

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

what is forcing ivshmem to be mapped above 4G?

Quoted 8 lines
Quoted 6 lines

For PC machine: nothing -> ivshmem gets mapped in 32-bit area For Q35 machine: there is not enough space for mapping 1G
in 32-bit area, and maybe there are also alignment constrains. You can use this test in verbose mode and see exactly how the ranges are distributed. If you want me to run it and add the output, please let me know.

No need to post diff, I can do V=1 manually,
the question though is: doesn't PC need ivshmem to go above 4G as well?

We have ivshmem in the PC, but if doesn't go over 4G.
I left it that way in order to show what happens in both cases. (32-bit and 64-bit) Since is the same code for PC/Q35 it should be enough.

Thanks,
Marcel

Quoted 73 lines
Quoted 72 lines

Thanks,
Marcel

Quoted 65 lines
Quoted 64 lines
---
   tests/bios-tables-test.c | 37 +++++++++++++++++++++++++++++++++++++
   1 file changed, 37 insertions(+)
tests/bios-tables-test.c +37 -0
index de4019e..b23c6b0 100644
@@ -864,6 +864,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=1G,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=1G,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();
@@ -884,6 +919,8 @@ int main(int argc, char *argv[])
           qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi);
           qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp);
           qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp);
+        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);
#8 lore raw

Re: [Qemu-devel] [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests

In reply to Laszlo Ersek
Quoted 11 lines · Laszlo Ersek
Quoted 6 lines · Igor Mammedov
Quoted 2 lines · On Sun, 17 Jul 2016 19:53:09 +0300 Marcel Apfelbaum <[email protected]> wrote:

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

what is forcing ivshmem to be mapped above 4G?

Speaking for OVMF: unlike SeaBIOS, the edk2 PCI bus driver prefers to map 64-bit BARs outside of 32-bit address space, regardless of how much room is left in the 32-bit MMIO aperture.

Thanks Laszlo, we need to support make check with ovmf (not immediate, of course). There is no integration yet with QEMU, right? Having a set of binaries like with SeaBIOS makes sense? Are there any licensing issues?

Thanks,
Marcel

Quoted 4 lines

Thanks
Laszlo

#9 lore raw

Re: [Qemu-devel] [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests

Adding Gerd

Quoted 13 lines · Marcel Apfelbaum
Quoted 11 lines · Laszlo Ersek
Quoted 6 lines · Igor Mammedov
Quoted 2 lines · On Sun, 17 Jul 2016 19:53:09 +0300 Marcel Apfelbaum <[email protected]> wrote:

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

what is forcing ivshmem to be mapped above 4G?

Speaking for OVMF: unlike SeaBIOS, the edk2 PCI bus driver prefers to map 64-bit BARs outside of 32-bit address space, regardless of how much room is left in the 32-bit MMIO aperture.

Quoted 5 lines

Thanks Laszlo, we need to support make check with ovmf (not immediate, of course).
There is no integration yet with QEMU, right? Having a set of binaries like with SeaBIOS
makes sense?

Yes, it makes sense.

Quoted 1 line

Are there any licensing issues?

If QEMU can bundle 2-clause BSDL binaries, then there shouldn't be.

For the legally inclined, it might be safest to review the *Pkg/License.txt files, for all the *Pkg top-level directories from which OVMF pulls in at least one module.

Thanks
Laszlo

#27 lore raw
In reply to Marcel Apfelbaum
Quoted 5 lines · Marcel Apfelbaum

v4 -> v5:
Addressed the pull request issues: (Peter Maydell)
See: https://lists.gnu.org/archive/html/qemu-devel/2016-07/msg00882.html
- cland warning -> "hw/pci/pci.c:196:23: runtime error: shift exponent -1 is negative":
The PCIe Root port was not initialized properly, the interrupt pin was left 0. This

Quoted 9 lines

is a long standing issue exposed by the new test. (Patch 1/7)
- 'make check' fails on 32-bit:
Fix it by changing the ivshmem mem size from 4G
to 1G, since 4G is not a valid value on 32-bit archs. (Patch 2/7) (4G is truncated to 0 on 32-bit systems)
- Rebased on mst's pci branch.
Since all the new changes are not related to the series, I kept the existing "Reviewed-by"/"Tested-by" signatures.

Hi Michael,

Can you please add this series to your pull request for 2.7 ? It is an important fix already reviewed and tested.

The only problems with the series were a test issue and another long-standing bug exposed by the test and both were fixed.

Thanks,
Marcel

Quoted 51 lines

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)

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.

Thank you,
Marcel

Marcel Apfelbaum (7):
hw/pcie-root-port: Fix PCIe root port initialization 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/ioh3420.c                |   1 +
  hw/pci-bridge/pci_expander_bridge.c    |   2 +
  tests/acpi-test-data/pc/DSDT.pxb       | Bin 0 -> 6286 bytes
  tests/acpi-test-data/q35/DSDT.pxb_pcie | Bin 0 -> 9098 bytes
  tests/bios-tables-test.c               |  37 ++++++++++
  6 files changed, 135 insertions(+), 36 deletions(-)

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

Reviewed-by on v5 2/7
#20 lore raw

Re: [Qemu-devel] [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests

In reply to Marcel Apfelbaum
Quoted 6 lines · On Sun, 17 Jul 2016 19:53:09 +0300 Marcel Apfelbaum <[email protected]> wrote:

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

Quoted 59 lines
---
 tests/bios-tables-test.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
tests/bios-tables-test.c +37 -0
index de4019e..b23c6b0 100644
@@ -864,6 +864,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=1G,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=1G,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();
@@ -884,6 +919,8 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi);
         qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp);
         qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp);
+        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);
#21 lore raw

Re: [Qemu-devel] [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests

Quoted 10 lines · Igor Mammedov
Quoted 6 lines · On Sun, 17 Jul 2016 19:53:09 +0300 Marcel Apfelbaum <[email protected]> wrote:

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

Thanks Igor!
Marcel

Quoted 61 lines
Quoted 60 lines
---
  tests/bios-tables-test.c | 37 +++++++++++++++++++++++++++++++++++++
  1 file changed, 37 insertions(+)
tests/bios-tables-test.c +37 -0
index de4019e..b23c6b0 100644
@@ -864,6 +864,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=1G,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=1G,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();
@@ -884,6 +919,8 @@ int main(int argc, char *argv[])
          qtest_add_func("acpi/q35/tcg/ipmi", test_acpi_q35_tcg_ipmi);
          qtest_add_func("acpi/piix4/tcg/cpuhp", test_acpi_piix4_tcg_cphp);
          qtest_add_func("acpi/q35/tcg/cpuhp", test_acpi_q35_tcg_cphp);
+        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);
#10 lore raw

[Qemu-devel] edk2 submodule + binaries (Re: [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests)

In reply to Laszlo Ersek

Hi,

Quoted 5 lines
Quoted 3 lines

There is no integration yet with QEMU, right? Having a set of binaries like with SeaBIOS
makes sense?

Yes, it makes sense.

Indeed. edk2 isn't exactly small though. Adding the submodule would make the release tarballs noticable larger, and the prebuild binaries are not exactly small too ...

I remember we discussed moving all the pre-built binaries to a separate repo a while back. Maybe we should think about that idea again?

Quoted 3 lines
Quoted 1 line

Are there any licensing issues?

If QEMU can bundle 2-clause BSDL binaries, then there shouldn't be.

I think with the FatPkg issue finally solved now there shouldn't be fundamental roadblocks any more.

Next question would be which architectures we want build edk2 for?

(1) x64 ovmf is clear.

(2) ia32 ovmf too? Will anybody use it?

(3) ArmVirtPkg for aarch64 should be built IMO.

(4) What about ArmVirtPkg for 32bit arm?

(5) There is ArmPlatformPkg/ArmVExpressPkg.
Anyone tried that with qemu-system-{arm,aarch64} -M vexpress-* ?

While being at it: Is there any way to setup a 32bit arm guest with a bootloader, so you don't have to somehow copy the guest kernel from the image to boot?

At least the upstream kernel doesn't support acpi @ 32bit arm, so the guest kernel can't find and use the hardware info provided by ArmVirtPkg. Instead it depends on the bootloader passing a fdt. But the bootloaders (grub+uboot) expect a file with the fdt somewhere. There isn't a file in the first place for -M virt. There is one for the vexpress boards, which actually works (for v9). But it lists only the hardware physical vexpress boards have, any virtio-mmio devices you add are not listed there. So sdcard storage is the only option. Hmm.

Comments?

cheers,
Gerd

#11 lore raw

Re: [Qemu-devel] edk2 submodule + binaries (Re: [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests)

Quoted 9 lines · Gerd Hoffmann

Next question would be which architectures we want build edk2 for?

(1) x64 ovmf is clear.

(2) ia32 ovmf too? Will anybody use it?

(3) ArmVirtPkg for aarch64 should be built IMO.

(4) What about ArmVirtPkg for 32bit arm?

I think this would be a good idea.

Quoted 7 lines

(5) There is ArmPlatformPkg/ArmVExpressPkg.
Anyone tried that with qemu-system-{arm,aarch64} -M vexpress-* ?

While being at it: Is there any way to setup a 32bit arm guest with a bootloader, so you don't have to somehow copy the guest kernel from the image to boot?

Quoted 8 lines

At least the upstream kernel doesn't support acpi @ 32bit arm, so the guest kernel can't find and use the hardware info provided by ArmVirtPkg. Instead it depends on the bootloader passing a fdt. But the bootloaders (grub+uboot) expect a file with the fdt somewhere. There isn't a file in the first place for -M virt. There is one for the vexpress boards, which actually works (for v9). But it lists only the hardware physical vexpress boards have, any virtio-mmio devices you add are not listed there. So sdcard storage is the only option. Hmm.

We should be aiming to get 'virt' to work for the 32-bit case. vexpress-a9/a15 is trying to model real hardware and has a lot of irritating constraints as a result (like no PCI, only SD card storage).

This probably means sorting out passing through the DTB from QEMU into UEFI and then into the boot loader.

thanks
-- PMM

#14 lore raw

Re: [Qemu-devel] edk2 submodule + binaries (Re: [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests)

In reply to Gerd Hoffmann
Quoted 19 lines · Gerd Hoffmann

Hi,

Quoted 5 lines
Quoted 3 lines

There is no integration yet with QEMU, right? Having a set of binaries like with SeaBIOS
makes sense?

Yes, it makes sense.

Indeed. edk2 isn't exactly small though. Adding the submodule would make the release tarballs noticable larger, and the prebuild binaries are not exactly small too ...

I remember we discussed moving all the pre-built binaries to a separate repo a while back. Maybe we should think about that idea again?

Quoted 3 lines
Quoted 1 line

Are there any licensing issues?

If QEMU can bundle 2-clause BSDL binaries, then there shouldn't be.

Quoted 8 lines

I think with the FatPkg issue finally solved now there shouldn't be fundamental roadblocks any more.

Next question would be which architectures we want build edk2 for?

(1) x64 ovmf is clear.

(2) ia32 ovmf too? Will anybody use it?

There are three bitness-combinations:
- Ia32: both PEI and DXE phases are 32-bit
- Ia32X64: PEI is 32-bit, DXE is 64-bit
- X64: both PEI and DXE are 64-bit

The bitness of the DXE phase must match the bitness of the operatig system. So Ia32 can only boot 32-bit OSes (*), and the other two can only boot 64-bit OSes.

(*) This is a bit relaxed for Linux guests, because Linux supports being booted on a 32-bit DXE phase firmware, and then switches to 64-bit itself. IIRC the idea here was to enable 64-bit Linux to run on tablets and similar hardware that has a 64-bit CPU, but only comes with a fully 32-bit firmware (see
<https://blogs.intel.com/evangelists/2015/07/22/why-cheap-systems-run-32-bit-uefi-on-x64-systems/>).
But, without such OS-level tricks, in general Ia32 DXE implies 32-bit OS.

Then the next question is, what's the status of 32-bit UEFI OSes? Simple:

- 32-bit UEFI Windows exists, but it doesn't boot on OVMF. I don't know why. I've spend a lot of time debugging it, on and off, with the (sporadic) help of a Microsoft developer. We narrowed it down somewhat, but it remains unsolved.

- 32-bit Linux may exist, but the distros I tried are either not official (see Fedlet
<https://www.happyassassin.net/fedlet-a-fedora-remix-for-bay-trail-tablets/>)
or I didn't get any usable results with them (IIRC I tried 32-bit UEFI Debain once before, and it didn't work at all; but I'm fuzzy on that, sorry).

Matthew Garrett also advises against (fully) 32-bit firmware:
<https://mjg59.dreamwidth.org/26734.html>

The distinction between Ia32X64 and X64 is less clear cut. The difference between them is inivisible to the user (the bitness of the PEI phase is not exposed to the OS), but in practice there is one visible difference: the combination

SMM driver stack + X64 PEI + S3 resume enabled on QEMU

is not supported by edk2 at the moment. So if the binary should support SMM + S3, and allow the user not to bother about disabling S3 on the QEMU command line, then Ia32X64 is the better choice.

Furthermore, the SMM driver stack limits the firmware to pc-q35-2.5+ machine types (no i440fx at all, and no q35 earlier than 2.5). This might not be useful for everyone, I'm not sure.

CSM should never be enabled (SeaBIOS is bundled with QEMU already).

Enabling Secure Boot in the OVMF binary is orthogonal to all of the above, but it has a licensing impact. It embeds (a subset of) OpenSSL in the binary, and changes the terms from "2-clause BSDL" to "2-clause BSDL and OpenSSL license" ("and" in the restrictive, not permissive, sense). I'm unsure if QEMU is willing and able to distribute such binaries.

For the widest and simplest usability, X64 (without the SMM driver stack and without Secure Boot) is likely the best.

Quoted 1 line

(3) ArmVirtPkg for aarch64 should be built IMO.

Yup.

Quoted 1 line

(4) What about ArmVirtPkg for 32bit arm?

It is a supported configuration in edk2, but I don't know how useful it would be. We should ask Ard I guess.

Quoted 2 lines

(5) There is ArmPlatformPkg/ArmVExpressPkg.
Anyone tried that with qemu-system-{arm,aarch64} -M vexpress-* ?

Historically I may have used it I think, but that was before the arrival of ArmVirtPkg (nee ArmPlatformPkg/ArmVirtualizationPkg) for the "virt" machine type.

Quoted 3 lines

While being at it: Is there any way to setup a 32bit arm guest with a bootloader, so you don't have to somehow copy the guest kernel from the image to boot?

I'm unaware of any limitation in ArmVirtPkg or edk2 that would prevent this; I just think OS bother to support 32-bit UEFI even less on ARM than they do on x86.

Quoted 4 lines

At least the upstream kernel doesn't support acpi @ 32bit arm, so the guest kernel can't find and use the hardware info provided by ArmVirtPkg. Instead it depends on the bootloader passing a fdt. But the bootloaders (grub+uboot) expect a file with the fdt somewhere.

ArmVirtPkg gets a generated DTB from QEMU at the base of system memory, stashes it safely, uses it, and (unless disabled explicitly by a node in the DTB) exposes it to the UEFI OS through a dedicated UEFI system configuration table. Linux is capable of using this sysconfig table already, so those boot loaders should be taught the same, assuming 32-bit UEFI ARM is so important.

QEMU ArmVirtQemu

 | ----- DT via RAM ------> |
 | --- ACPI via fw_cfg ---> |
 | -- SMBIOS via fw_cfg --> |                               guest kernel
                            | ---- DT via UEFI config table ----> |
                            | --- ACPI via UEFI config table ---> |
                            | -- SMBIOS via UEFI config table --> |

(According to my last information, the upstream kernel still prefers DT over ACPI. I'm aware of two methods to talk it out of that:
- "acpi=force" on the guest kernel cmdline (dynamically),
- the "-D PURE_ACPI_BOOT_ENABLE" ArmVirtQemu build option
<https://github.com/tianocore/edk2/commit/b359fb9115b2>, which statically removes the right hand side "DT" edge from the above diagram.)

Anyway, I digress. Point is, GRUB is already UEFI capable (I don't know uboot), so GRUB should be able to look up the DTB sysconfig table, and use that. The sysconfig table in question is identified by the GUID

B1B621D5-F19C-41A5-830B-D9152C69AAE0

(or written in C:
<https://github.com/tianocore/edk2/blob/master/EmbeddedPkg/Include/Guid/Fdt.h>.)

Quoted 1 line

There isn't a file in the first place for -M virt.

It's not necessary, see above. If you would like to investigate the DTB that QEMU generates, you can use:

  $ qemu-system-(arm|aarch64) \
      -nographic -machine virt,dumpdtb=virt-dump.dtb
  $ dtc -I dtb -O dts <virt-dump.dtb | less

but that's not the right way to carry the DTB from QEMU to guest code (at least on the "virt" machine type).

Quoted 4 lines

There is one for the
vexpress boards, which actually works (for v9). But it lists only the hardware physical vexpress boards have, any virtio-mmio devices you add are not listed there.

Right, the generated DTB lists all the virtio-mmio transports.

Quoted 1 line

So sdcard storage is the only option. Hmm.

Not necessarily; it can be considered a UEFI GRUB enhancement IMO.

Thanks,
Laszlo

#12 lore raw

Re: [Qemu-devel] edk2 submodule + binaries (Re: [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests)

In reply to Peter Maydell

Hi,

Quoted 11 lines
Quoted 1 line

(4) What about ArmVirtPkg for 32bit arm?

I think this would be a good idea.

We should be aiming to get 'virt' to work for the 32-bit case. vexpress-a9/a15 is trying to model real hardware and has a lot of irritating constraints as a result (like no PCI, only SD card storage).

This probably means sorting out passing through the DTB from QEMU into UEFI and then into the boot loader.

Looking at aarch64 it looks like the guest kernel doesn't use acpi but got a fdt somehow. Dunno how that happened. I guess ArmVirtPkg exports the FDT using EFI interfaces, then either the kernel gets it directly or grub is able to get and pass on the FDT. In any case it seems think the same should work for 32bit without too much trouble.

cheers,
Gerd

#15 lore raw

Re: [Qemu-devel] edk2 submodule + binaries (Re: [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests)

In reply to Laszlo Ersek

thinko:

Quoted 4 lines · Laszlo Ersek

ArmVirtPkg gets a generated DTB from QEMU at the base of system memory, stashes it safely, uses it, and (unless disabled explicitly by a node in the DTB) exposes it to the UEFI OS through a dedicated UEFI system configuration table.

replace

unless disabled explicitly by a node in the DTB

with

unless disabled explicitly with "-D PURE_ACPI_BOOT_ENABLE", mentioned elsewhere in the message

Thanks
Laszlo

#13 lore raw

Re: [Qemu-devel] edk2 submodule + binaries (Re: [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests)

In reply to Gerd Hoffmann
Quoted 13 lines · Gerd Hoffmann

Hi,

Quoted 11 lines
Quoted 1 line

(4) What about ArmVirtPkg for 32bit arm?

I think this would be a good idea.

We should be aiming to get 'virt' to work for the 32-bit case. vexpress-a9/a15 is trying to model real hardware and has a lot of irritating constraints as a result (like no PCI, only SD card storage).

This probably means sorting out passing through the DTB from QEMU into UEFI and then into the boot loader.

Yes, the piece that is missing is that the boot loader should be capable of looking up the UEFI sysconfig table with the well-known GUID that exposes the DTB.

(NB: such a sysconfig table is not *required* by any means, especially not on aarch64. It is valid for the firmware to not expose any DTB to stuff that comes after it, in an "ACPI only" configuration.)

... Actually, I'm getting confused about this. I just suggested that the boot loader look up the right UEFI sysconfig table. But, if the boot loader is already UEFI capable, why does it need the DTB at all? Gerd named the virtio-mmio nodes in the DTB, but now I don't see how they are relevant -- the boot loader should just use the UEFI services to load and start the OS. Why does it need to know about virtio-mmio at all?

Quoted 2 lines

Looking at aarch64 it looks like the guest kernel doesn't use acpi but got a fdt somehow. Dunno how that happened.

The aarch64 upstream kernel (to my knowledge) defaults to DTB, unless it gets "acpi=force" on the command line, or ArmVirtQemu is built with -D PURE_ACPI_BOOT_ENABLE" (in which case the kernel will have no DTB to look at, only ACPI).

Quoted 2 lines

I guess ArmVirtPkg exports
the FDT using EFI interfaces,

Yes (unless built with "-D PURE_ACPI_BOOT_ENABLE").

Quoted 1 line

then either the kernel gets it directly

The DTB is installed as a UEFI sysconfig table with a well-known GUID. All guest code that can look up UEFI sysconfig tables can locate and read it.

Quoted 3 lines

or
grub is able to get and pass on the FDT. In any case it seems think the same should work for 32bit without too much trouble.

It should be possible, but as I said, now I'm doubting that grub should be involved in this at all.

First, the DTB reaches the kernel, from the firmware, without any assitance from grub, through the sysconfig table.

Second, grub should not need the DTB for its own purposes *at all* -- a boot loader on a UEFI system should use UEFI services only, for booting the OS. The DTB might be necessary for low-level hardware drivers, I guess, but in a UEFI guest, grub should not use low-level hw drivers.

... I mean, this is how grub already works in x86_64 and aarch64 UEFI guests. I think we're sitting on the horse backwards. DTB has probably been a "last resort" for 32-bit ARM GRUB, because there used to be no UEFI, hence no UEFI services, hence only the DTB allowed GRUB to do something with the hardware

But now that there *is* UEFI for 32-bit ARM (guests, anyway), the bootloader should not use UEFI only as a means to fetch the DTB, and then do whatever it's been doing earlier. Instead, UEFI should be used to boot the OS.

Thanks
Laszlo

#16 lore raw

Re: [Qemu-devel] edk2 submodule + binaries (Re: [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests)

In reply to Laszlo Ersek

Hi,

Quoted 5 lines
Quoted 1 line

(2) ia32 ovmf too? Will anybody use it?

Then the next question is, what's the status of 32-bit UEFI OSes? Simple:

[ summary: bad ]

Yep, that matches the impression I have.
Guess we don't want bother then.

Quoted 8 lines

Enabling Secure Boot in the OVMF binary is orthogonal to all of the above, but it has a licensing impact. It embeds (a subset of) OpenSSL in the binary, and changes the terms from "2-clause BSDL" to "2-clause BSDL and OpenSSL license" ("and" in the restrictive, not permissive, sense). I'm unsure if QEMU is willing and able to distribute such binaries.

For the widest and simplest usability, X64 (without the SMM driver stack and without Secure Boot) is likely the best.

Yes (also note the smm-enabled one doesn't run on i440fx).

So the options I see are (a) build without smm or (b) build two variants.

Quoted 5 lines

Anyway, I digress. Point is, GRUB is already UEFI capable (I don't know uboot), so GRUB should be able to look up the DTB sysconfig table, and use that. The sysconfig table in question is identified by the GUID

B1B621D5-F19C-41A5-830B-D9152C69AAE0

grub already does that on aarch64, but not on arm. So that should be fixable without too much effort.

u-boot is out for -M virt due to missing virtio drivers.

Quoted 5 lines
  $ qemu-system-(arm|aarch64) \
      -nographic -machine virt,dumpdtb=virt-dump.dtb
  $ dtc -I dtb -O dts <virt-dump.dtb | less

but that's not the right way to carry the DTB from QEMU to guest code

Exactly. That just creates a reverse problem. Instead of copying the kernel from the image you now have to copy the dtb file to the image.

Quoted 6 lines
Quoted 4 lines

There is one for the
vexpress boards, which actually works (for v9). But it lists only the hardware physical vexpress boards have, any virtio-mmio devices you add are not listed there.

Right, the generated DTB lists all the virtio-mmio transports.

But u-boot looks for dtb files in /boot/dtbs/$kernelver/ instead of using the one provided by qemu. So virtio isn't there (virtio-mmio @ vexpress works for a direct kernel boot).

cheers,
Gerd

#17 lore raw

Re: [Qemu-devel] edk2 submodule + binaries (Re: [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests)

Quoted 17 lines · Gerd Hoffmann

Hi,

Quoted 5 lines
Quoted 1 line

(2) ia32 ovmf too? Will anybody use it?

Then the next question is, what's the status of 32-bit UEFI OSes? Simple:

[ summary: bad ]

Yep, that matches the impression I have.
Guess we don't want bother then.

Quoted 6 lines

Enabling Secure Boot in the OVMF binary is orthogonal to all of the above, but it has a licensing impact. It embeds (a subset of) OpenSSL in the binary, and changes the terms from "2-clause BSDL" to "2-clause BSDL and OpenSSL license" ("and" in the restrictive, not permissive, sense). I'm unsure if QEMU is willing and able to distribute such binaries.

Quoted 7 lines
Quoted 2 lines

For the widest and simplest usability, X64 (without the SMM driver stack and without Secure Boot) is likely the best.

Yes (also note the smm-enabled one doesn't run on i440fx).

So the options I see are (a) build without smm or (b) build two variants.

I think people who just want to run "UEFI payloads" are served well enough by SMM-less. There are some developers who would benefit from a -D SMM_REQUIRE build as well, but that would be because they actually focus on SMM, I believe, so they can build their own firmware.

If this is about the convenience of QEMU end-users, then I vote (a). I'd certainly like to avoid fielding bug reports that boil down to "I booted the -D SMM_REQUIRE build on i440fx".

Quoted 7 lines
Quoted 5 lines

Anyway, I digress. Point is, GRUB is already UEFI capable (I don't know uboot), so GRUB should be able to look up the DTB sysconfig table, and use that. The sysconfig table in question is identified by the GUID

B1B621D5-F19C-41A5-830B-D9152C69AAE0

grub already does that on aarch64,

Huh, indeed. I see "grub-core/loader/arm64/fdt.c". What does UEFI grub need the DTB for in the first place?

Hm... looks like it pokes initrd information into it. Interesting.

Quoted 2 lines

but not on arm.
So that should be fixable without too much effort.

I guess so.

I'll mention though that "just" for passing in the initrd, the DTB shouldn't be necessary, at least if the kernel is built with the EFI stub. Then "initrd=filename" can be passed on the kernel command line, and the EFI stub should load it, using UEFI services, from the same directory that the vmlinuz binary (= itself) came from.

... I can never keep the 37 ways to boot the linux kernel in my mind for longer than 2 minutes. :/

Thanks
Laszlo

#18 lore raw

Re: [Qemu-devel] edk2 submodule + binaries (Re: [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests)

Hi,

Quoted 10 lines
Quoted 2 lines

but not on arm.
So that should be fixable without too much effort.

I guess so.

I'll mention though that "just" for passing in the initrd, the DTB shouldn't be necessary, at least if the kernel is built with the EFI stub. Then "initrd=filename" can be passed on the kernel command line, and the EFI stub should load it, using UEFI services, from the same directory that the vmlinuz binary (= itself) came from.

Well, the kernel command line is passed via fdt too ...

Anyway, it's working.

cheers,
Gerd

From 91c1e9a92a75e34da3aad8184b298654b30cdf6f Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <[email protected]>
Date: Thu, 14 Jul 2016 08:16:06 +0200
Subject: [PATCH 1/2] arm: lookup devicetree via efi

arm64 already does this, arm should support it too.

---
 grub-core/loader/arm/linux.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
grub-core/loader/arm/linux.c +42 -0
index 5b39f02..106cfc3 100644
@@ -221,6 +221,31 @@ failure:
   return grub_error (GRUB_ERR_BAD_ARGUMENT, "unable to prepare FDT");
 }
 
+#ifdef GRUB_MACHINE_EFI
+/* from ../arm64/fdt.c */
+static void *
+get_firmware_fdt (void)
+{
+  grub_efi_configuration_table_t *tables;
+  grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID;
+  void *firmware_fdt = NULL;
+  unsigned int i;
+
+  /* Look for FDT in UEFI config tables. */
+  tables = grub_efi_system_table->configuration_table;
+
+  for (i = 0; i < grub_efi_system_table->num_table_entries; i++)
+    if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0)
+      {
+        firmware_fdt = tables[i].vendor_table;
+        grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt);
+        break;
+      }
+
+  return firmware_fdt;
+}
+#endif
+
 static grub_err_t
 linux_boot (void)
 {
@@ -237,6 +262,23 @@ linux_boot (void)
 		(char *) fdt_addr,
 		(char *) fdt_addr + 1);
 
+#ifdef GRUB_MACHINE_EFI
+  if (!fdt_valid) {
+    void *ptr = get_firmware_fdt();
+    int size = ptr ? grub_fdt_get_totalsize(ptr) : 0;
+    int extra = grub_strlen (linux_args) + 0x100;
+    if (ptr && size) {
+      fdt_addr = grub_efi_allocate_loader_memory (LINUX_FDT_PHYS_OFFSET, size + extra);
+      if (fdt_addr) {
+        grub_memcpy (fdt_addr, ptr, size);
+        fdt_valid = (fdt_addr && grub_fdt_check_header_nosize (fdt_addr) == 0);
+        grub_dprintf ("loader", "firmware fdt: memcpy(%p, %p, %d)\n",
+                      fdt_addr, ptr, size);
+      }
+    }
+  }
+#endif
+
   if (!fdt_valid && machine_type == GRUB_ARM_MACHINE_TYPE_FDT)
     return grub_error (GRUB_ERR_FILE_NOT_FOUND,
 		       N_("device tree must be supplied (see `devicetree' command)"));
Signature · 1 line
1.8.3.1

From b311f8043c5718018c6d361092524d74208c458a Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <[email protected]>
Date: Tue, 19 Jul 2016 14:14:26 +0200
Subject: [PATCH 2/2] arm: make room for larger devicetree

"qemu-system-arm -M virt" devicetree is > 64k.
Make sure we have enough space for it.

---
 grub-core/loader/arm/linux.c | 2 ++
 include/grub/arm/linux.h     | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
grub-core/loader/arm/linux.c +2 -0
index 106cfc3..5ac0014 100644
@@ -49,9 +49,11 @@ typedef void (*kernel_entry_t) (int, unsigned long, void *);
 #define LINUX_ZIMAGE_OFFSET	0x24
 #define LINUX_ZIMAGE_MAGIC	0x016f2818
 
+#if 0 /* declared in include/grub/arm/linux.h */
 #define LINUX_PHYS_OFFSET        (0x00008000)
 #define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000)
 #define LINUX_FDT_PHYS_OFFSET    (LINUX_INITRD_PHYS_OFFSET - 0x10000)
+#endif
 
 static grub_size_t
 get_atag_size (grub_uint32_t *atag)
include/grub/arm/linux.h +2 -2
index 059dbba..deb8a9c 100644
@@ -37,9 +37,9 @@
 # include <grub/machine/loader.h>
 /* On UEFI platforms - load the images at the lowest available address not
    less than *_PHYS_OFFSET from the first available memory location. */
-# define LINUX_PHYS_OFFSET        (0x00008000)
+# define LINUX_PHYS_OFFSET        (0x00020000)
 # define LINUX_INITRD_PHYS_OFFSET (LINUX_PHYS_OFFSET + 0x02000000)
-# define LINUX_FDT_PHYS_OFFSET    (LINUX_INITRD_PHYS_OFFSET - 0x10000)
+# define LINUX_FDT_PHYS_OFFSET    (LINUX_INITRD_PHYS_OFFSET - 0x20000)
 static inline grub_addr_t
 grub_arm_firmware_get_boot_data (void)
 {
Signature · 1 line
1.8.3.1
#19 lore raw

Re: [Qemu-devel] edk2 submodule + binaries (Re: [PATCH V5 2/7] tests/acpi: add pxb/pxb-pcie tests)

In reply to Laszlo Ersek
Quoted 26 lines · Laszlo Ersek
Quoted 17 lines · Gerd Hoffmann
   Hi,
Quoted 5 lines
Quoted 1 line

(2) ia32 ovmf too? Will anybody use it?

Then the next question is, what's the status of 32-bit UEFI OSes? Simple:

[ summary: bad ]

Yep, that matches the impression I have.
Guess we don't want bother then.

Quoted 6 lines

Enabling Secure Boot in the OVMF binary is orthogonal to all of the above, but it has a licensing impact. It embeds (a subset of) OpenSSL in the binary, and changes the terms from "2-clause BSDL" to "2-clause BSDL and OpenSSL license" ("and" in the restrictive, not permissive, sense). I'm unsure if QEMU is willing and able to distribute such binaries.

Quoted 7 lines
Quoted 2 lines

For the widest and simplest usability, X64 (without the SMM driver stack and without Secure Boot) is likely the best.

Yes (also note the smm-enabled one doesn't run on i440fx).

So the options I see are (a) build without smm or (b) build two variants.

Quoted 9 lines

I think people who just want to run "UEFI payloads" are served well enough by SMM-less. There are some developers who would benefit from a -D SMM_REQUIRE build as well, but that would be because they actually focus on SMM, I believe, so they can build their own firmware.

If this is about the convenience of QEMU end-users, then I vote (a). I'd certainly like to avoid fielding bug reports that boil down to "I booted the -D SMM_REQUIRE build on i440fx".

I agree. For x86_64, OVMF 64-bit binaries without SMM or secure-boot support are enough for a wide "audience".

Thanks,
Marcel

[...]

#28 lore raw
In reply to Marcel Apfelbaum
Quoted 14 lines · Marcel Apfelbaum

v4 -> v5:
Addressed the pull request issues: (Peter Maydell)
See: https://lists.gnu.org/archive/html/qemu-devel/2016-07/msg00882.html
- cland warning -> "hw/pci/pci.c:196:23: runtime error: shift exponent -1 is negative":
The PCIe Root port was not initialized properly, the interrupt pin was left 0. This is a long standing issue exposed by the new test. (Patch 1/7)
- 'make check' fails on 32-bit:
Fix it by changing the ivshmem mem size from 4G
to 1G, since 4G is not a valid value on 32-bit archs. (Patch 2/7)
(4G is truncated to 0 on 32-bit systems)
- Rebased on mst's pci branch.
Since all the new changes are not related to the series, I kept the existing "Reviewed-by"/"Tested-by" signatures.

Applied, but dropped tests for now - from experience they are too likely to break on weird platforms.
Pls post new tests after 2.7.

Also, I would really like to see options to speed tests up. How about running them under kvm?
There are a couple of minor acpi differences when running with kvm, we'll need to white-list them in some way.

Quoted 53 lines

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)

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.

Thank you,
Marcel

Marcel Apfelbaum (7):
hw/pcie-root-port: Fix PCIe root port initialization 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/ioh3420.c                |   1 +
 hw/pci-bridge/pci_expander_bridge.c    |   2 +
 tests/acpi-test-data/pc/DSDT.pxb       | Bin 0 -> 6286 bytes
 tests/acpi-test-data/q35/DSDT.pxb_pcie | Bin 0 -> 9098 bytes
 tests/bios-tables-test.c               |  37 ++++++++++
 6 files changed, 135 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
#29 lore raw
Quoted 16 lines · Michael S. Tsirkin
Quoted 14 lines · Marcel Apfelbaum

v4 -> v5:
Addressed the pull request issues: (Peter Maydell)
See: https://lists.gnu.org/archive/html/qemu-devel/2016-07/msg00882.html
- cland warning -> "hw/pci/pci.c:196:23: runtime error: shift exponent -1 is negative":
The PCIe Root port was not initialized properly, the interrupt pin was left 0. This is a long standing issue exposed by the new test. (Patch 1/7)
- 'make check' fails on 32-bit:
Fix it by changing the ivshmem mem size from 4G
to 1G, since 4G is not a valid value on 32-bit archs. (Patch 2/7)
(4G is truncated to 0 on 32-bit systems)
- Rebased on mst's pci branch.
Since all the new changes are not related to the series, I kept the existing "Reviewed-by"/"Tested-by" signatures.

Hi Michael,

Quoted 1 line

Applied,

Thanks!

Can you please apply also '[PATCH V3] hw/virtio-pci: fix virtio behaviour'?
(https://lists.gnu.org/archive/html/qemu-devel/2016-07/msg04744.html)

I think it worth having it in QEMU 2.7.

but dropped tests for now - from experience they are too likely

Quoted 3 lines

to break on weird platforms.
Pls post new tests after 2.7.

Sure, I'll do that.

Quoted 5 lines

Also, I would really like to see options to speed tests up. How about running them under kvm?
There are a couple of minor acpi differences when running with kvm, we'll need to white-list them in some way.

Sure, we can do kvm 'variant' maybe for for 2.8.

Thanks,
Marcel

Quoted 56 lines
Quoted 56 lines

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)

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.

Thank you,
Marcel

Marcel Apfelbaum (7):
hw/pcie-root-port: Fix PCIe root port initialization 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/ioh3420.c                |   1 +
 hw/pci-bridge/pci_expander_bridge.c    |   2 +
 tests/acpi-test-data/pc/DSDT.pxb       | Bin 0 -> 6286 bytes
 tests/acpi-test-data/q35/DSDT.pxb_pcie | Bin 0 -> 9098 bytes
 tests/bios-tables-test.c               |  37 ++++++++++
 6 files changed, 135 insertions(+), 36 deletions(-)
 create mode 100644 tests/acpi-test-data/pc/DSDT.pxb
 create mode 100644 tests/acpi-test-data/q35/DSDT.pxb_pcie

--
2.4.3

#30 lore raw
Quoted 36 lines · Marcel Apfelbaum
Quoted 16 lines · Michael S. Tsirkin
Quoted 14 lines · Marcel Apfelbaum

v4 -> v5:
Addressed the pull request issues: (Peter Maydell)
See: https://lists.gnu.org/archive/html/qemu-devel/2016-07/msg00882.html
- cland warning -> "hw/pci/pci.c:196:23: runtime error: shift exponent -1 is negative":
The PCIe Root port was not initialized properly, the interrupt pin was left 0. This is a long standing issue exposed by the new test. (Patch 1/7)
- 'make check' fails on 32-bit:
Fix it by changing the ivshmem mem size from 4G
to 1G, since 4G is not a valid value on 32-bit archs. (Patch 2/7)
(4G is truncated to 0 on 32-bit systems)
- Rebased on mst's pci branch.
Since all the new changes are not related to the series, I kept the existing "Reviewed-by"/"Tested-by" signatures.

Hi Michael,

Quoted 1 line

Applied,

Thanks!

Can you please apply also '[PATCH V3] hw/virtio-pci: fix virtio behaviour'?
(https://lists.gnu.org/archive/html/qemu-devel/2016-07/msg04744.html)

I think it worth having it in QEMU 2.7.

but dropped tests for now - from experience they are too likely

Quoted 3 lines

to break on weird platforms.
Pls post new tests after 2.7.

Sure, I'll do that.

Quoted 7 lines
Quoted 5 lines

Also, I would really like to see options to speed tests up. How about running them under kvm?
There are a couple of minor acpi differences when running with kvm, we'll need to white-list them in some way.

Sure, we can do kvm 'variant' maybe for for 2.8.

Yes but without maintaining two variants o expected files please.

Quoted 60 lines

Thanks,
Marcel

Quoted 56 lines
Quoted 56 lines

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)

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.

Thank you,
Marcel

Marcel Apfelbaum (7):
hw/pcie-root-port: Fix PCIe root port initialization 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/ioh3420.c                |   1 +
 hw/pci-bridge/pci_expander_bridge.c    |   2 +
 tests/acpi-test-data/pc/DSDT.pxb       | Bin 0 -> 6286 bytes
 tests/acpi-test-data/q35/DSDT.pxb_pcie | Bin 0 -> 9098 bytes
 tests/bios-tables-test.c               |  37 ++++++++++
 6 files changed, 135 insertions(+), 36 deletions(-)
 create mode 100644 tests/acpi-test-data/pc/DSDT.pxb
 create mode 100644 tests/acpi-test-data/q35/DSDT.pxb_pcie

--
2.4.3