Skip to contentSkip to conversation

microvm: fix PCIe IRQs in APIC table.

PATCH In review Gerd Hoffmann 2 participants 9 messages Oct 16, 2020 – Oct 23, 2020

lore
Share & tools
lore
#0 lore raw

cover microvm: fix PCIe IRQs in APIC table.

Gerd Hoffmann (7):
tests/acpi: allow changes for microvm/APIC.pcie tests/acpi: add empty microvm/APIC.pcie
x86: make pci irqs runtime configurable
microvm: set pci_irq_mask
apci: drop has_pci arg for acpi_build_madt tests/acpi: update expected data files tests/acpi: disallow changes for microvm/APIC.pcie

 hw/i386/acpi-common.h             |   3 +--
 include/hw/i386/x86.h             |   2 ++
 hw/i386/acpi-build.c              |   2 +-
 hw/i386/acpi-common.c             |  26 +++++++++++---------------
 hw/i386/acpi-microvm.c            |   2 +-
 hw/i386/microvm.c                 |   6 ++++++
 hw/i386/x86.c                     |   1 +
 tests/data/acpi/microvm/APIC.pcie | Bin 0 -> 110 bytes
 8 files changed, 23 insertions(+), 19 deletions(-)
 create mode 100644 tests/data/acpi/microvm/APIC.pcie
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/7 tests/acpi: allow changes for microvm/APIC.pcie

---
 tests/qtest/bios-tables-test-allowed-diff.h | 1 +
 1 file changed, 1 insertion(+)
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
index dfb8523c8bf4..0c37ccebc5ba 100644
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/microvm/APIC.pcie",
Signature · 1 line
2.27.0
#2 lore raw

PATCH 2/7 tests/acpi: add empty microvm/APIC.pcie

In reply to Gerd Hoffmann
---
 tests/data/acpi/microvm/APIC.pcie | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 tests/data/acpi/microvm/APIC.pcie
tests/data/acpi/microvm/APIC.pcie new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
Signature · 1 line
2.27.0
#3 lore raw

PATCH 3/7 x86: make pci irqs runtime configurable

In reply to Gerd Hoffmann

Add a variable to x86 machine state instead of
hard-coding the PCI interrupts.

---
 include/hw/i386/x86.h | 2 ++
 hw/i386/acpi-common.c | 3 +--
 hw/i386/x86.c         | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)
include/hw/i386/x86.h +2 -0
index d5dcf7a07fdc..bfa9cb2a258b 100644
@@ -58,6 +58,7 @@ struct X86MachineState {
 
     /* CPU and apic information: */
     bool apic_xrupt_override;
+    unsigned pci_irq_mask;
     unsigned apic_id_limit;
     uint16_t boot_cpus;
     unsigned smp_dies;
@@ -114,6 +115,7 @@ bool x86_machine_is_acpi_enabled(const X86MachineState *x86ms);
 /* Global System Interrupts */
 
 #define GSI_NUM_PINS IOAPIC_NUM_PINS
+#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11))
 
 typedef struct GSIState {
     qemu_irq i8259_irq[ISA_NUM_IRQS];
hw/i386/acpi-common.c +1 -2
index ab9b00581a15..1584abb3e6b0 100644
@@ -115,8 +115,7 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *linker,
 
     if (has_pci) {
         for (i = 1; i < 16; i++) {
-#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11))
-            if (!(ACPI_BUILD_PCI_IRQS & (1 << i))) {
+            if (!(x86ms->pci_irq_mask & (1 << i))) {
                 /* No need for a INT source override structure. */
                 continue;
             }
hw/i386/x86.c +1 -0
index 3137a2008588..5944fc44edca 100644
@@ -1178,6 +1178,7 @@ static void x86_machine_initfn(Object *obj)
     x86ms->smm = ON_OFF_AUTO_AUTO;
     x86ms->acpi = ON_OFF_AUTO_AUTO;
     x86ms->smp_dies = 1;
+    x86ms->pci_irq_mask = ACPI_BUILD_PCI_IRQS;
 }
 
 static void x86_machine_class_init(ObjectClass *oc, void *data)
Signature · 1 line
2.27.0
#4 lore raw

PATCH 4/7 microvm: set pci_irq_mask

In reply to Gerd Hoffmann

Makes sure the PCI interrupt overrides are added to the APIC table in case PCIe is enabled.

---
 hw/i386/acpi-microvm.c | 2 +-
 hw/i386/microvm.c      | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
hw/i386/acpi-microvm.c +1 -1
index f16f2311955c..8e2d2b7cff83 100644
@@ -196,7 +196,7 @@ static void acpi_build_microvm(AcpiBuildTables *tables,
 
     acpi_add_table(table_offsets, tables_blob);
     acpi_build_madt(tables_blob, tables->linker, X86_MACHINE(machine),
-                    ACPI_DEVICE_IF(x86ms->acpi_dev), false);
+                    ACPI_DEVICE_IF(x86ms->acpi_dev), x86ms->pci_irq_mask != 0);
 
     xsdt = tables_blob->len;
     build_xsdt(tables_blob, tables->linker, table_offsets, NULL, NULL);
hw/i386/microvm.c +6 -0
index 73a7a142b44a..9dd74458aca4 100644
@@ -210,6 +210,12 @@ static void microvm_devices_init(MicrovmMachineState *mms)
         mms->gpex.ecam.size   = PCIE_ECAM_SIZE;
         mms->gpex.irq         = PCIE_IRQ_BASE;
         create_gpex(mms);
+        x86ms->pci_irq_mask = ((1 << (PCIE_IRQ_BASE + 0)) |
+                               (1 << (PCIE_IRQ_BASE + 1)) |
+                               (1 << (PCIE_IRQ_BASE + 2)) |
+                               (1 << (PCIE_IRQ_BASE + 3)));
+    } else {
+        x86ms->pci_irq_mask = 0;
     }
 
     if (mms->pic == ON_OFF_AUTO_ON || mms->pic == ON_OFF_AUTO_AUTO) {
Signature · 1 line
2.27.0
#5 lore raw

PATCH 5/7 apci: drop has_pci arg for acpi_build_madt

In reply to Gerd Hoffmann

Setting x86ms->pci_irq_mask to zero has the same effect, so we don't need the has_pci argument any more.

---
 hw/i386/acpi-common.h  |  3 +--
 hw/i386/acpi-build.c   |  2 +-
 hw/i386/acpi-common.c  | 25 +++++++++++--------------
 hw/i386/acpi-microvm.c |  2 +-
 4 files changed, 14 insertions(+), 18 deletions(-)
hw/i386/acpi-common.h +1 -2
index 9cac18dddf5b..c30e461f1854 100644
@@ -9,7 +9,6 @@
 #define ACPI_BUILD_IOAPIC_ID 0x0
 
 void acpi_build_madt(GArray *table_data, BIOSLinker *linker,
-                     X86MachineState *x86ms, AcpiDeviceIf *adev,
-                     bool has_pci);
+                     X86MachineState *x86ms, AcpiDeviceIf *adev);
 
 #endif
hw/i386/acpi-build.c +1 -1
index 45ad2f953341..e3a4bc206c4e 100644
@@ -2477,7 +2477,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
 
     acpi_add_table(table_offsets, tables_blob);
     acpi_build_madt(tables_blob, tables->linker, x86ms,
-                    ACPI_DEVICE_IF(x86ms->acpi_dev), true);
+                    ACPI_DEVICE_IF(x86ms->acpi_dev));
 
     vmgenid_dev = find_vmgenid_dev();
     if (vmgenid_dev) {
hw/i386/acpi-common.c +11 -14
index 1584abb3e6b0..8a769654060e 100644
@@ -72,8 +72,7 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid,
 }
 
 void acpi_build_madt(GArray *table_data, BIOSLinker *linker,
-                     X86MachineState *x86ms, AcpiDeviceIf *adev,
-                     bool has_pci)
+                     X86MachineState *x86ms, AcpiDeviceIf *adev)
 {
     MachineClass *mc = MACHINE_GET_CLASS(x86ms);
     const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(MACHINE(x86ms));
@@ -113,19 +112,17 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *linker,
         intsrcovr->flags  = cpu_to_le16(0); /* conforms to bus specifications */
     }
 
-    if (has_pci) {
-        for (i = 1; i < 16; i++) {
-            if (!(x86ms->pci_irq_mask & (1 << i))) {
-                /* No need for a INT source override structure. */
-                continue;
-            }
-            intsrcovr = acpi_data_push(table_data, sizeof *intsrcovr);
-            intsrcovr->type   = ACPI_APIC_XRUPT_OVERRIDE;
-            intsrcovr->length = sizeof(*intsrcovr);
-            intsrcovr->source = i;
-            intsrcovr->gsi    = cpu_to_le32(i);
-            intsrcovr->flags  = cpu_to_le16(0xd); /* active high, level triggered */
+    for (i = 1; i < 16; i++) {
+        if (!(x86ms->pci_irq_mask & (1 << i))) {
+            /* No need for a INT source override structure. */
+            continue;
         }
+        intsrcovr = acpi_data_push(table_data, sizeof *intsrcovr);
+        intsrcovr->type   = ACPI_APIC_XRUPT_OVERRIDE;
+        intsrcovr->length = sizeof(*intsrcovr);
+        intsrcovr->source = i;
+        intsrcovr->gsi    = cpu_to_le32(i);
+        intsrcovr->flags  = cpu_to_le16(0xd); /* active high, level triggered */
     }
 
     if (x2apic_mode) {
hw/i386/acpi-microvm.c +1 -1
index 8e2d2b7cff83..5efa89c32709 100644
@@ -196,7 +196,7 @@ static void acpi_build_microvm(AcpiBuildTables *tables,
 
     acpi_add_table(table_offsets, tables_blob);
     acpi_build_madt(tables_blob, tables->linker, X86_MACHINE(machine),
-                    ACPI_DEVICE_IF(x86ms->acpi_dev), x86ms->pci_irq_mask != 0);
+                    ACPI_DEVICE_IF(x86ms->acpi_dev));
 
     xsdt = tables_blob->len;
     build_xsdt(tables_blob, tables->linker, table_offsets, NULL, NULL);
Signature · 1 line
2.27.0
#6 lore raw

PATCH 6/7 tests/acpi: update expected data files

In reply to Gerd Hoffmann
---
 tests/data/acpi/microvm/APIC.pcie | Bin 0 -> 110 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)
tests/data/acpi/microvm/APIC.pcie binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6c51081b50beb061c5f4e5baa134585d82db4c39 100644
GIT binary patch
Signature · 1 line
2.27.0
#7 lore raw

PATCH 7/7 tests/acpi: disallow changes for microvm/APIC.pcie

In reply to Gerd Hoffmann
---
 tests/qtest/bios-tables-test-allowed-diff.h | 1 -
 1 file changed, 1 deletion(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
index 0c37ccebc5ba..dfb8523c8bf4 100644
@@ -1,2 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/microvm/APIC.pcie",
Signature · 1 line
2.27.0
Reviewed-by on the v1 series
#8 lore raw
In reply to Gerd Hoffmann
Quoted 9 lines · On Fri, 16 Oct 2020 13:38:28 +0200 Gerd Hoffmann <[email protected]> wrote:

Gerd Hoffmann (7):
tests/acpi: allow changes for microvm/APIC.pcie tests/acpi: add empty microvm/APIC.pcie
x86: make pci irqs runtime configurable
microvm: set pci_irq_mask
apci: drop has_pci arg for acpi_build_madt tests/acpi: update expected data files tests/acpi: disallow changes for microvm/APIC.pcie

Quoted 11 lines
 hw/i386/acpi-common.h             |   3 +--
 include/hw/i386/x86.h             |   2 ++
 hw/i386/acpi-build.c              |   2 +-
 hw/i386/acpi-common.c             |  26 +++++++++++---------------
 hw/i386/acpi-microvm.c            |   2 +-
 hw/i386/microvm.c                 |   6 ++++++
 hw/i386/x86.c                     |   1 +
 tests/data/acpi/microvm/APIC.pcie | Bin 0 -> 110 bytes
 8 files changed, 23 insertions(+), 19 deletions(-)
 create mode 100644 tests/data/acpi/microvm/APIC.pcie

for series: