Skip to contentSkip to conversation

Add SCI support for APEI on x86

PATCH Superseded Mauro Carvalho Chehab 1 participant 9 messages Sep 5 EDAC-core

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Add SCI support for APEI on x86

Hi Igor,

After a long time, I finally found some time to finish x86 support for APEI. Right now, it supports only QMP error inject.

I did local tests here with q35 and it works fine. I also added tests for both piix4 and q35 at tests/qtest/bios-tables-test.

My end goal is to do functional tests with:
- upstream Kernel + QEMU + rasdaemon.

I'm already working on a temporary tree to implement it.

NOTE: this series is based on v11.1.1. I tried to base it on the top of master, but there's currently a problem with a docker.py script that it is causing compilation issues here:

$ ./tests/docker/docker.py
Traceback (most recent call last):
  File "/new_devel/edac/qemu/./tests/docker/docker.py", line 657, in <module>
    sys.exit(main())
             ~~~~^^
  File "/new_devel/edac/qemu/./tests/docker/docker.py", line 653, in main
    return args.cmdobj.run(args, argv)
           ^^^^^^^^^^^
AttributeError: 'Namespace' object has no attribute 'cmdobj'

As this is a separate problem, I'm opting for now to keep it based on v11.1.1, to make easier for you to review.

There will be a couple of trivial conflicts to be solved when porting to upstream.

Mauro Carvalho Chehab (8):
acpi_dev_interface: a ghes support state at AcpiDeviceIfClass tests/acpi: virt: reserve expected tables for PC GHES SCI support hw/i186: add support for HEST table with SCI
hw/i386: add GHES support at ICH9 and PIIX4 PM tests/acpi: virt: add x86 DSDT and HEST tables
docs: acpi_hest_ghes: document notification mechanisms
tests: test GHES notifications on arm64 virt machine
tests: add GHES tests for x86 piix4 and q35

 docs/specs/acpi_hest_ghes.rst        |  44 +++++++--
 hw/acpi/acpi_interface.c             |   7 ++
 hw/acpi/generic_event_device.c       |   6 ++
 hw/acpi/ghes.c                       |  30 ++++---
 hw/acpi/ich9.c                       |  19 ++++
 hw/acpi/piix4.c                      |  25 ++++++
 hw/i386/Kconfig                      |   1 +
 hw/i386/acpi-build.c                 |  99 ++++++++++++++++++++
 hw/i386/pc.c                         |  41 +++++++++
 hw/isa/lpc_ich9.c                    |   6 ++
 include/hw/acpi/acpi_dev_interface.h |   6 ++
 include/hw/acpi/ich9.h               |   2 +
 include/hw/acpi/piix4.h              |   2 +
 include/hw/i386/pc.h                 |   5 ++
 tests/data/acpi/x86/pc/DSDT.ras      | Bin 0 -> 8818 bytes
 tests/data/acpi/x86/pc/HEST.ras      | Bin 0 -> 132 bytes
 tests/data/acpi/x86/q35/DSDT.ras     | Bin 0 -> 8647 bytes
 tests/data/acpi/x86/q35/HEST.ras     | Bin 0 -> 132 bytes
 tests/qtest/bios-tables-test.c       | 130 +++++++++++++++++++++++++++
 19 files changed, 402 insertions(+), 21 deletions(-)
 create mode 100644 tests/data/acpi/x86/pc/DSDT.ras
 create mode 100644 tests/data/acpi/x86/pc/HEST.ras
 create mode 100644 tests/data/acpi/x86/q35/DSDT.ras
 create mode 100644 tests/data/acpi/x86/q35/HEST.ras
Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/8 acpi_dev_interface: a ghes support state at AcpiDeviceIfClass

For x86, we'll need to have a way to detect if GHES is supported inside ICH9 and PIIX4 PM.

Add an ancillary method at acpi_dev_interface to share information if ghes is supported on a common arch-independent place.

---
 hw/acpi/acpi_interface.c             |  7 +++++++
 hw/acpi/generic_event_device.c       |  6 ++++++
 hw/acpi/ghes.c                       | 30 +++++++++++++++++-----------
 include/hw/acpi/acpi_dev_interface.h |  6 ++++++
 4 files changed, 37 insertions(+), 12 deletions(-)
hw/acpi/acpi_interface.c +7 -0
index a44679017ead..bf11acfbb54b 100644
@@ -3,6 +3,13 @@
 #include "hw/acpi/acpi_aml_interface.h"
 #include "qemu/module.h"
 
+AcpiGhesState *acpi_device_get_ghes_state(AcpiDeviceIf *adev)
+{
+    AcpiDeviceIfClass *klass = ACPI_DEVICE_IF_GET_CLASS(adev);
+
+    return klass->get_ghes_state ? klass->get_ghes_state(adev) : NULL;
+}
+
 static void register_types(void)
 {
     static const TypeInfo acpi_dev_if_info = {
hw/acpi/generic_event_device.c +6 -0
index 9e9416d4067d..2c5abe2a54f5 100644
@@ -322,6 +322,11 @@ static void acpi_ged_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)
     acpi_cpu_ospm_status(&s->cpuhp_state, list);
 }
 
+static AcpiGhesState *acpi_ged_get_ghes_state(AcpiDeviceIf *adev)
+{
+    return &ACPI_GED(adev)->ghes_state;
+}
+
 static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
 {
     AcpiGedState *s = ACPI_GED(adev);
@@ -608,6 +613,7 @@ static void acpi_ged_class_init(ObjectClass *class, const void *data)
 
     adevc->ospm_status = acpi_ged_ospm_status;
     adevc->send_event = acpi_ged_send_event;
+    adevc->get_ghes_state = acpi_ged_get_ghes_state;
 }
 
 static const TypeInfo acpi_ged_info = {
hw/acpi/ghes.c +18 -12
index b2d5e3499320..3989fd4d7e91 100644
@@ -24,7 +24,7 @@
 #include "hw/acpi/ghes.h"
 #include "hw/acpi/aml-build.h"
 #include "qemu/error-report.h"
-#include "hw/acpi/generic_event_device.h"
+#include "hw/acpi/acpi_dev_interface.h"
 #include "hw/nvram/fw_cfg.h"
 #include "qemu/uuid.h"
 #include "exec/cpu-common.h"
@@ -587,21 +587,27 @@ bool acpi_ghes_memory_errors(AcpiGhesState *ags, uint16_t source_id,
                                    source_id, errp);
 }
 
-AcpiGhesState *acpi_ghes_get_state(void)
+static int acpi_ghes_find_state(Object *obj, void *opaque)
 {
-    AcpiGedState *acpi_ged_state;
+    Object *adev = object_dynamic_cast(obj, TYPE_ACPI_DEVICE_IF);
     AcpiGhesState *ags;
 
-    acpi_ged_state = ACPI_GED(object_resolve_path_type("", TYPE_ACPI_GED,
-                                                       NULL));
-
-    if (!acpi_ged_state) {
-        return NULL;
+    if (!adev) {
+        return 0;
     }
-    ags = &acpi_ged_state->ghes_state;
-
-    if (!ags->hw_error_le && !ags->hest_addr_le) {
-        return NULL;
+    ags = acpi_device_get_ghes_state(ACPI_DEVICE_IF(adev));
+    if (!ags || (!ags->hw_error_le && !ags->hest_addr_le)) {
+        return 0;
     }
+    *(AcpiGhesState **)opaque = ags;
+    return 1;
+}
+
+AcpiGhesState *acpi_ghes_get_state(void)
+{
+    AcpiGhesState *ags = NULL;
+
+    object_child_foreach_recursive(object_get_root(), acpi_ghes_find_state,
+                                   &ags);
     return ags;
 }
include/hw/acpi/acpi_dev_interface.h +6 -0
index 65debb90a8d4..644e0006ff6a 100644
@@ -26,6 +26,7 @@ DECLARE_CLASS_CHECKERS(AcpiDeviceIfClass, ACPI_DEVICE_IF,
                      TYPE_ACPI_DEVICE_IF)
 
 typedef struct AcpiDeviceIf AcpiDeviceIf;
+typedef struct AcpiGhesState AcpiGhesState;
 
 /**
  * AcpiDeviceIfClass:
@@ -33,6 +34,7 @@ typedef struct AcpiDeviceIf AcpiDeviceIf;
  * ospm_status: returns status of ACPI device objects, reported
  *              via _OST method if device supports it.
  * send_event: inject a specified event into guest
+ * get_ghes_state: returns the controller's GHES state, if supported
  * madt_cpu: fills @entry with Interrupt Controller Structure
  *           for CPU indexed by @uid in @apic_ids array,
  *           returned structure types are:
@@ -50,5 +52,9 @@ struct AcpiDeviceIfClass {
     /* <public> */
     void (*ospm_status)(AcpiDeviceIf *adev, ACPIOSTInfoList ***list);
     void (*send_event)(AcpiDeviceIf *adev, AcpiEventStatusBits ev);
+
+    AcpiGhesState *(*get_ghes_state)(AcpiDeviceIf *adev);
 };
+
+AcpiGhesState *acpi_device_get_ghes_state(AcpiDeviceIf *adev);
 #endif
Signature · 1 line
2.55.0
#6 lore raw

PATCH 6/8 docs: acpi_hest_ghes: document notification mechanisms

In reply to Mauro Carvalho Chehab

Currently, the HEST spec mixes generic support with arch dependent notification mechanisms.

Move the arm-specific notifications to a separate chapter and add a new one describing x86 mechanisms.

---
 docs/specs/acpi_hest_ghes.rst | 44 ++++++++++++++++++++++++++++-------
 1 file changed, 35 insertions(+), 9 deletions(-)
docs/specs/acpi_hest_ghes.rst +35 -9
index aaf7b1ad11a5..1a32550ef3a1 100644
@@ -7,6 +7,7 @@ APEI tables generating and CPER record
    This work is licensed under the terms of the GNU GPL, version 2 or later.
    See the COPYING file in the top-level directory.
 
+
 Design Details
 --------------
 
@@ -105,14 +106,39 @@ Design Details
     firmware will write back the start address of either "etc/hardware_errors"
     or HEST table at the corresponding fw_cfg file.
 
-(9) When QEMU gets a SIGBUS from the kernel, QEMU writes CPER into corresponding
-    "Error Status Data Block", guest memory, and then injects platform specific
-    interrupt (in case of arm/virt machine it's Synchronous External Abort) as a
-    notification which is necessary for notifying the guest.
+.. note::
 
-(10) This notification (in virtual hardware) will be handled by the guest
-     kernel, on receiving notification, guest APEI driver could read the CPER error
-     and take appropriate action.
+    GHES support requires ACPI and ``-machine ras=on``.
 
-(11) kvm_arch_on_sigbus_vcpu() reports RAS errors via a SEA notifications,
-     when a SIGBUS event is triggered.
+Notifications on ARM64
+----------------------
+
+The ARM64 ``virt`` machine supports two GHESv2 notification sources:
+
+* source 0: Synchronous External Abort (SEA);
+* source 1: GPIO notification delivered through a Generic Event Device (GED).
+
+Source 0 reports hardware-memory RAS events on the ``virt`` machine:
+
+* When QEMU receives a ``SIGBUS`` from the kernel, it writes the CPER into the
+  corresponding ``Error Status Data Block`` in guest memory and reports the
+  event through a Synchronous External Abort (SEA). The guest kernel handle
+  the SEA,
+
+* The guest APEI driver can read and process the CPER record.
+
+* ``kvm_arch_on_sigbus_vcpu()`` reports these RAS events through SEA.
+
+When source 1 is available, QEMU supports GHES error injection through the QMP
+interface.
+
+
+Notifications on x86
+--------------------
+
+The ``pc`` and ``q35`` machines support one GHESv2 source:
+
+* source 1: System Control Interrupt (SCI).
+
+When source 1 is available, QEMU supports GHES error injection through
+the QMP interface.
Signature · 1 line
2.55.0
#7 lore raw

PATCH 7/8 tests: test GHES notifications on arm64 virt machine

In reply to Mauro Carvalho Chehab

QEMU has support for HEST table since version 9.2. Yet, it currently lacks a test to check if the HEST table is working.

Add tests for arm64 error inject mechanism, implemented at QEMU version 10.2.

---
 tests/qtest/bios-tables-test.c | 80 ++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
tests/qtest/bios-tables-test.c +80 -0
index 5cc526510ac1..5582b1dd72e4 100644
@@ -68,6 +68,7 @@
 
 #define MACHINE_PC "pc"
 #define MACHINE_Q35 "q35"
+#define VIRT_ACPI_GED_BASE 0x09080000
 
 #define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML"
 
@@ -913,6 +914,84 @@ static uint8_t base_required_struct_types[] = {
     0, 1, 3, 4, 16, 17, 19, 32, 127
 };
 
+static void test_acpi_ghes_v2_injection(test_data *data)
+{
+    const uint8_t cper[20] = { [0] = 2, [16] = 2 }; /* corrected GESB */
+    g_autofree char *payload = g_base64_encode(cper, sizeof(cper));
+    uint64_t status_addr, ack_addr;
+    uint8_t actual[sizeof(cper)];
+    QTestState *qts = data->qts;
+    const uint8_t *ghes = NULL;
+    AcpiSdtTable *hest = NULL;
+    AcpiSdtTable *table;
+
+    for (unsigned i = 0; i < data->tables->len; i++) {
+        table = &g_array_index(data->tables, AcpiSdtTable, i);
+
+        if (compare_signature(table, "HEST")) {
+            hest = table;
+            break;
+        }
+    }
+    g_assert_nonnull(hest);
+
+    for (unsigned i = 0; i < ldl_le_p(hest->aml + 36); i++) {
+        const uint8_t *entry = hest->aml + 40 + i * 92;
+
+        g_assert_cmpuint(lduw_le_p(entry), ==, 10); /* GHESv2 */
+        if (lduw_le_p(entry + 2) == 1) { /* QMP source */
+            ghes = entry;
+            break;
+        }
+    }
+    g_assert_nonnull(ghes);
+    g_assert_cmpuint(ghes[32], ==, 7); /* GPIO notification */
+    status_addr = qtest_readq(qts, ldq_le_p(ghes + 24));
+    ack_addr = ldq_le_p(ghes + 68);
+    g_assert_cmphex(status_addr, !=, 0);
+    g_assert_cmphex(ack_addr, !=, 0);
+    g_assert_cmpuint(qtest_readq(qts, ack_addr), ==, 1);
+
+    for (unsigned i = 0; i < 3; i++) {
+        qtest_qmp_assert_success(qts,
+            "{'execute': 'inject-ghes-v2-error', 'arguments': {'cper': %s}}",
+            payload);
+        g_assert_cmpuint(qtest_readq(qts, ack_addr), ==, 0);
+        qtest_memread(qts, status_addr, actual, sizeof(actual));
+        g_assert_cmpmem(actual, sizeof(actual), cper, sizeof(cper));
+
+        /* GED converts the GPIO notification into an Error event. */
+        g_assert_cmphex(qtest_readl(qts, VIRT_ACPI_GED_BASE), ==, 0x20);
+        g_assert_cmphex(qtest_readl(qts, VIRT_ACPI_GED_BASE), ==, 0);
+
+        /* A second injection must wait for OSPM's acknowledgement. */
+        qobject_unref(qtest_qmp_assert_failure_ref(qts,
+            "{'execute': 'inject-ghes-v2-error', 'arguments': {'cper': %s}}",
+            payload));
+        qtest_writeq(qts, ack_addr, 1);
+    }
+}
+
+static void test_acpi_aarch64_virt_ras(void)
+{
+    test_data data = {
+        .machine = "virt",
+        .arch = "aarch64",
+        .tcg_only = true,
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 128ULL * MiB,
+    };
+
+    test_vm_prepare("-cpu cortex-a57 -machine ras=on", &data);
+    process_acpi_tables_noexit(&data);
+    test_acpi_ghes_v2_injection(&data);
+    qtest_quit(data.qts);
+    free_test_data(&data);
+}
+
 static void test_acpi_piix4_tcg(void)
 {
     test_data data = {};
@@ -2922,6 +3001,7 @@ int main(int argc, char *argv[])
     } else if (strcmp(arch, "aarch64") == 0) {
         if (has_tcg && qtest_has_device("virtio-blk-pci")) {
             qtest_add_func("acpi/virt", test_acpi_aarch64_virt_tcg);
+            qtest_add_func("acpi/virt/ras", test_acpi_aarch64_virt_ras);
             qtest_add_func("acpi/virt/acpihmatvirt",
                            test_acpi_aarch64_virt_tcg_acpi_hmat);
             qtest_add_func("acpi/virt/topology",
Signature · 1 line
2.55.0
#8 lore raw

PATCH 8/8 tests: add GHES tests for x86 piix4 and q35

In reply to Mauro Carvalho Chehab

Add support to test GHES on x86 using the SCI mechanism.

---
 tests/qtest/bios-tables-test.c | 66 +++++++++++++++++++++++++++++-----
 1 file changed, 58 insertions(+), 8 deletions(-)
tests/qtest/bios-tables-test.c +58 -8
index 5582b1dd72e4..77399e9100d9 100644
@@ -914,7 +914,8 @@ static uint8_t base_required_struct_types[] = {
     0, 1, 3, 4, 16, 17, 19, 32, 127
 };
 
-static void test_acpi_ghes_v2_injection(test_data *data)
+static void test_acpi_ghes_v2_injection(test_data *data, bool sci,
+                                        int notif_type)
 {
     const uint8_t cper[20] = { [0] = 2, [16] = 2 }; /* corrected GESB */
     g_autofree char *payload = g_base64_encode(cper, sizeof(cper));
@@ -923,14 +924,18 @@ static void test_acpi_ghes_v2_injection(test_data *data)
     QTestState *qts = data->qts;
     const uint8_t *ghes = NULL;
     AcpiSdtTable *hest = NULL;
+    AcpiSdtTable *fadt = NULL;
     AcpiSdtTable *table;
+    uint8_t gpe_len;
+    uint32_t gpe0;
 
     for (unsigned i = 0; i < data->tables->len; i++) {
         table = &g_array_index(data->tables, AcpiSdtTable, i);
 
         if (compare_signature(table, "HEST")) {
             hest = table;
-            break;
+        } else if (compare_signature(table, "FACP")) {
+            fadt = table;
         }
     }
     g_assert_nonnull(hest);
@@ -945,29 +950,51 @@ static void test_acpi_ghes_v2_injection(test_data *data)
         }
     }
     g_assert_nonnull(ghes);
-    g_assert_cmpuint(ghes[32], ==, 7); /* GPIO notification */
+    g_assert_cmpuint(ghes[32], ==, notif_type);
     status_addr = qtest_readq(qts, ldq_le_p(ghes + 24));
     ack_addr = ldq_le_p(ghes + 68);
     g_assert_cmphex(status_addr, !=, 0);
     g_assert_cmphex(ack_addr, !=, 0);
     g_assert_cmpuint(qtest_readq(qts, ack_addr), ==, 1);
 
+    if (sci) {
+        g_assert_nonnull(fadt);
+        gpe0 = ldl_le_p(fadt->aml + 80);
+        gpe_len = fadt->aml[92];
+        qtest_irq_intercept_in(qts, "ioapic");
+        qtest_outb(qts, gpe0, 0xff);
+        qtest_outb(qts, gpe0 + gpe_len / 2, 0x80);
+    }
+
     for (unsigned i = 0; i < 3; i++) {
+        if (sci) {
+            g_assert_false(qtest_get_irq(qts, 9));
+        }
         qtest_qmp_assert_success(qts,
             "{'execute': 'inject-ghes-v2-error', 'arguments': {'cper': %s}}",
             payload);
         g_assert_cmpuint(qtest_readq(qts, ack_addr), ==, 0);
         qtest_memread(qts, status_addr, actual, sizeof(actual));
         g_assert_cmpmem(actual, sizeof(actual), cper, sizeof(cper));
-
-        /* GED converts the GPIO notification into an Error event. */
-        g_assert_cmphex(qtest_readl(qts, VIRT_ACPI_GED_BASE), ==, 0x20);
-        g_assert_cmphex(qtest_readl(qts, VIRT_ACPI_GED_BASE), ==, 0);
+        if (sci) {
+            g_assert_cmphex(qtest_inb(qts, gpe0) & 0x80, ==, 0x80);
+            g_assert_true(qtest_get_irq(qts, 9));
+        } else {
+            /* GED converts the GPIO notification into an Error event. */
+            g_assert_cmphex(qtest_readl(qts, VIRT_ACPI_GED_BASE), ==, 0x20);
+            g_assert_cmphex(qtest_readl(qts, VIRT_ACPI_GED_BASE), ==, 0);
+        }
 
         /* A second injection must wait for OSPM's acknowledgement. */
         qobject_unref(qtest_qmp_assert_failure_ref(qts,
             "{'execute': 'inject-ghes-v2-error', 'arguments': {'cper': %s}}",
             payload));
+
+        if (sci) {
+            /* Emulate OSPM clearing the edge GPE. */
+            qtest_outb(qts, gpe0, 0x80);
+            g_assert_false(qtest_get_irq(qts, 9));
+        }
         qtest_writeq(qts, ack_addr, 1);
     }
 }
@@ -987,7 +1014,28 @@ static void test_acpi_aarch64_virt_ras(void)
 
     test_vm_prepare("-cpu cortex-a57 -machine ras=on", &data);
     process_acpi_tables_noexit(&data);
-    test_acpi_ghes_v2_injection(&data);
+    test_acpi_ghes_v2_injection(&data, false, 7);
+    qtest_quit(data.qts);
+    free_test_data(&data);
+}
+
+static void test_acpi_x86_ras(const void *opaque)
+{
+    test_data data = {
+        .machine = opaque,
+        .arch = "x86",
+        .variant = ".ras",
+    };
+
+    test_vm_prepare("-machine ras=on", &data);
+    process_acpi_tables_noexit(&data);
+    test_acpi_ghes_v2_injection(&data, true, 3);
+    free_test_data(&data);
+
+    /* Check if fw restored error buffer, then write back HEST on reset. */
+    qtest_system_reset(data.qts);
+    process_acpi_tables_noexit(&data);
+    test_acpi_ghes_v2_injection(&data, true, 3);
     qtest_quit(data.qts);
     free_test_data(&data);
 }
@@ -2875,6 +2923,7 @@ int main(int argc, char *argv[])
         }
         if (qtest_has_machine(MACHINE_PC)) {
             qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
+            qtest_add_data_func("acpi/piix4/ras", MACHINE_PC, test_acpi_x86_ras);
             qtest_add_func("acpi/piix4/oem-fields", test_acpi_piix4_oem_fields);
             qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
             qtest_add_func("acpi/piix4/pci-hotplug/no_root_hotplug",
@@ -2913,6 +2962,7 @@ int main(int argc, char *argv[])
         }
         if (qtest_has_machine(MACHINE_Q35)) {
             qtest_add_func("acpi/q35", test_acpi_q35_tcg);
+            qtest_add_data_func("acpi/q35/ras", MACHINE_Q35, test_acpi_x86_ras);
             qtest_add_func("acpi/q35/oem-fields", test_acpi_q35_oem_fields);
             if (tpm_model_is_available("-machine q35", "tpm-tis")) {
                 qtest_add_func("acpi/q35/tpm2-tis", test_acpi_q35_tcg_tpm2_tis);
Signature · 1 line
2.55.0
#2 lore raw

PATCH 2/8 tests/acpi: virt: reserve expected tables for PC GHES SCI support

In reply to Mauro Carvalho Chehab

Prepare to modify x86 firmware files, disabling DSDT and HEST table check until we update it to new firmware file changes.

---
 tests/data/acpi/x86/pc/DSDT.ras             | 0
 tests/data/acpi/x86/pc/HEST.ras             | 0
 tests/data/acpi/x86/q35/DSDT.ras            | 0
 tests/data/acpi/x86/q35/HEST.ras            | 0
 tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++
 5 files changed, 4 insertions(+)
 create mode 100644 tests/data/acpi/x86/pc/DSDT.ras
 create mode 100644 tests/data/acpi/x86/pc/HEST.ras
 create mode 100644 tests/data/acpi/x86/q35/DSDT.ras
 create mode 100644 tests/data/acpi/x86/q35/HEST.ras
tests/data/acpi/x86/pc/DSDT.ras new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
tests/data/acpi/x86/pc/HEST.ras new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
tests/data/acpi/x86/q35/DSDT.ras new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
tests/data/acpi/x86/q35/HEST.ras new file +0 -0
new file mode 100644
index 000000000000..e69de29bb2d1
tests/qtest/bios-tables-test-allowed-diff.h +4 -0
index dfb8523c8bf4..b3761468accc 100644
@@ -1 +1,5 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/x86/pc/DSDT.ras",
+"tests/data/acpi/x86/pc/HEST.ras",
+"tests/data/acpi/x86/q35/DSDT.ras",
+"tests/data/acpi/x86/q35/HEST.ras",
Signature · 1 line
2.55.0
#3 lore raw

PATCH 3/8 hw/i186: add support for HEST table with SCI

In reply to Mauro Carvalho Chehab

Added needed bits at x86 architecture to allow both pb and q32 machines to support GHESv2 via HEST tables.

To do that, add needed _OSC capability bits to enable APEI support.

---
 hw/i386/Kconfig      |  1 +
 hw/i386/acpi-build.c | 99 ++++++++++++++++++++++++++++++++++++++++++++
 hw/i386/pc.c         | 41 ++++++++++++++++++
 include/hw/i386/pc.h |  5 +++
 4 files changed, 146 insertions(+)
hw/i386/Kconfig +1 -0
index e27d8816e5bb..b1fbfaf33f9b 100644
@@ -47,6 +47,7 @@ config PC
     select MC146818RTC
     # For ACPI builder:
     select SERIAL_ISA
+    select ACPI_APEI
     select ACPI_PCI
     select ACPI_VMGENID
     select ACPI_VMCLOCK
hw/i386/acpi-build.c +99 -0

141 lines not on this page · raw message

hw/i386/pc.c +41 -0

71 lines not on this page · raw message

include/hw/i386/pc.h +5 -0
index d4b6d3ed57fa..52b4e18ab7db 100644
@@ -30,6 +30,9 @@ typedef struct PCMachineState {
     /* State for other subsystems/APIs: */
     Notifier machine_done;
 
+    /* Triggered when a new SCI GHES error raises */
+    Notifier ghes_sci_notifier;
+
     /* Pointers to devices and objects: */
     PCIBus *pcibus;
     I2CBus *smbus;
@@ -52,6 +55,8 @@ typedef struct PCMachineState {
     bool i8042_enabled;
     bool default_bus_bypass_iommu;
     bool fd_bootchk;
+    bool ras;
+
     uint64_t max_fw_size;
 
     /* ACPI Memory hotplug IO base address */
Signature · 1 line
2.55.0
#4 lore raw

PATCH 4/8 hw/i386: add GHES support at ICH9 and PIIX4 PM

In reply to Mauro Carvalho Chehab

Enabling GHES support on x86 means that both PIIX4 and ICH9 PM controllers need to expose ghes state.

Implement that, as suggested by Igor.

---
 hw/acpi/ich9.c          | 19 +++++++++++++++++++
 hw/acpi/piix4.c         | 25 +++++++++++++++++++++++++
 hw/isa/lpc_ich9.c       |  6 ++++++
 include/hw/acpi/ich9.h  |  2 ++
 include/hw/acpi/piix4.h |  2 ++
 5 files changed, 54 insertions(+)
hw/acpi/ich9.c +19 -0
index 5e8f8a7eafa3..7e2199891431 100644
@@ -222,6 +222,24 @@ static const VMStateDescription vmstate_pcihp_state = {
     }
 };
 
+static bool ich9_hest_needed(void *opaque)
+{
+    ICH9LPCPMRegs *pm = opaque;
+
+    return pm->ghes_state.hest_addr_le != 0;
+}
+
+static const VMStateDescription vmstate_ich9_hest = {
+    .name = "ich9_pm/hest",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = ich9_hest_needed,
+    .fields = (const VMStateField[]) {
+        VMSTATE_UINT64(ghes_state.hest_addr_le, ICH9LPCPMRegs),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 const VMStateDescription vmstate_ich9_pm = {
     .name = "ich9_pm",
     .version_id = 1,
@@ -244,6 +262,7 @@ const VMStateDescription vmstate_ich9_pm = {
         &vmstate_tco_io_state,
         &vmstate_cpuhp_state,
         &vmstate_pcihp_state,
+        &vmstate_ich9_hest,
         NULL
     }
 };
hw/acpi/piix4.c +25 -0
index 9b7f50c7afac..48fa833c66ef 100644
@@ -224,6 +224,24 @@ static bool vmstate_test_migrate_acpi_index(void *opaque, int version_id)
            !s->not_migrate_acpi_index;
 }
 
+static bool piix4_hest_needed(void *opaque)
+{
+    PIIX4PMState *s = opaque;
+
+    return s->ghes_state.hest_addr_le != 0;
+}
+
+static const VMStateDescription vmstate_piix4_hest = {
+    .name = "piix4_pm/hest",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = piix4_hest_needed,
+    .fields = (const VMStateField[]) {
+        VMSTATE_UINT64(ghes_state.hest_addr_le, PIIX4PMState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 /* qemu-kvm 1.2 uses version 3 but advertised as 2
  * To support incoming qemu-kvm 1.2 migration, change version_id
  * and minimum_version_id to 2 below (which breaks migration from
@@ -259,6 +277,7 @@ static const VMStateDescription vmstate_acpi = {
     .subsections = (const VMStateDescription * const []) {
          &vmstate_memhp_state,
          &vmstate_cpuhp_state,
+         &vmstate_piix4_hest,
          NULL
     }
 };
@@ -551,6 +570,11 @@ static void piix4_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)
     acpi_cpu_ospm_status(&s->cpuhp_state, list);
 }
 
+static AcpiGhesState *piix4_get_ghes_state(AcpiDeviceIf *adev)
+{
+    return &PIIX4_PM(adev)->ghes_state;
+}
+
 static void piix4_send_gpe(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
 {
     PIIX4PMState *s = PIIX4_PM(adev);
@@ -607,6 +631,7 @@ static void piix4_pm_class_init(ObjectClass *klass, const void *data)
     hc->is_hotpluggable_bus = piix4_is_hotpluggable_bus;
     adevc->ospm_status = piix4_ospm_status;
     adevc->send_event = piix4_send_gpe;
+    adevc->get_ghes_state = piix4_get_ghes_state;
 }
 
 static const TypeInfo piix4_pm_info = {
hw/isa/lpc_ich9.c +6 -0
index edf9783ec8d4..00d940f16314 100644
@@ -847,6 +847,11 @@ static const Property ich9_lpc_properties[] = {
                      pm.periodic_timer_enabled, true),
 };
 
+static AcpiGhesState *ich9_get_ghes_state(AcpiDeviceIf *adev)
+{
+    return &ICH9_LPC_DEVICE(adev)->pm.ghes_state;
+}
+
 static void ich9_send_gpe(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
 {
     ICH9LPCState *s = ICH9_LPC_DEVICE(adev);
@@ -911,6 +916,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data)
     hc->is_hotpluggable_bus = ich9_pm_is_hotpluggable_bus;
     adevc->ospm_status = ich9_pm_ospm_status;
     adevc->send_event = ich9_send_gpe;
+    adevc->get_ghes_state = ich9_get_ghes_state;
     amldevc->build_dev_aml = build_ich9_isa_aml;
 }
 
include/hw/acpi/ich9.h +2 -0
index 30990fcef53f..772f1a8937d7 100644
@@ -27,6 +27,7 @@
 #include "hw/acpi/memory_hotplug.h"
 #include "hw/acpi/acpi_dev_interface.h"
 #include "hw/acpi/ich9_tco.h"
+#include "hw/acpi/ghes.h"
 #include "hw/acpi/cpu.h"
 
 #define ACPI_PCIHP_ADDR_ICH9 0x0cc0
@@ -38,6 +39,7 @@ typedef struct ICH9LPCPMRegs {
      * PM1a_CNT_BLK = 2 in FADT so it is defined as uint16_t.
      */
     ACPIREGS acpi_regs;
+    AcpiGhesState ghes_state;
 
     MemoryRegion io;
     MemoryRegion io_gpe;
include/hw/acpi/piix4.h +2 -0
index 863382a814ad..8732574e9c03 100644
@@ -29,6 +29,7 @@
 #include "hw/i2c/pm_smbus.h"
 #include "hw/isa/apm.h"
 #include "hw/acpi/cpu.h"
+#include "hw/acpi/ghes.h"
 
 #define TYPE_PIIX4_PM "PIIX4_PM"
 OBJECT_DECLARE_SIMPLE_TYPE(PIIX4PMState, PIIX4_PM)
@@ -43,6 +44,7 @@ struct PIIX4PMState {
 
     MemoryRegion io_gpe;
     ACPIREGS ar;
+    AcpiGhesState ghes_state;
 
     APMState apm;
 
Signature · 1 line
2.55.0
#5 lore raw

PATCH 5/8 tests/acpi: virt: add x86 DSDT and HEST tables

In reply to Mauro Carvalho Chehab

The following DSDT changes affect both:

-"tests/data/acpi/x86/pc/DSDT.ras",
-"tests/data/acpi/x86/q35/DSDT.ras",

--- /tmp/DSDT_old.dsl
+++ /tmp/DSDT.dsl
@@
+ Method (_OSC, 4, Serialized) // _OSC: Operating System Capabilities
+ {
+ If ((SizeOf (Arg3) < 0x08))
+ {
+ Return (Buffer (0x08) { 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00 })
+ }
+
+ CreateDWordField (Arg3, Zero, CDW1)
+ CreateDWordField (Arg3, 0x04, CDW2)
+ If ((Arg0 != ToUUID ("0811b06e-4a27-44f9-8d60-3cbbc22e7b48")))
+ {
+ CDW1 |= 0x04
+ Return (Arg3)
+ }
+ If ((Arg1 != One))
+ {
+ CDW1 |= 0x08
+ Return (Arg3)
+ }
+ If ((Arg2 != 0x02))
+ {
+ CDW1 |= 0x02
+ Return (Arg3)
+ }
+
+ Local0 = (CDW2 & 0xFFFFFFFF)
+ If ((CDW2 != Local0))
+ {
+ CDW1 |= 0x10
+ }
+ CDW2 = Local0
+ Return (Arg3)
+ }
+
+ Device (GEDD)
+ {
+ Name (_HID, "PNP0C33" /* Error Device */)
+ Name (_UID, Zero)
+ }
+ }
+
+ Scope (_GPE)
+ {
+ Method (_E07, 0, NotSerialized)
+ {
+ Notify (\_SB.GEDD, 0x80) // Status Change
+ }
+ }

The x86 HEST table now contains a GHESv2 source:

    --- /tmp/HEST_old.dsl
    +++ /tmp/HEST.dsl
    @@
    +[024h 0036   4]           Error Source Count : 00000001
    +
    +[028h 0040   2]                Subtable Type : 000A [Generic Hardware Error Source V2]
    +[02Ah 0042   2]                    Source Id : 0001
    +[02Ch 0044   2]            Related Source Id : FFFF
    +[02Eh 0046   1]                     Reserved : 00
    +[02Fh 0047   1]                      Enabled : 01
    +[030h 0048   4]       Records To Preallocate : 00000001
    +[034h 0052   4]      Max Sections Per Record : 00000001
    +[038h 0056   4]          Max Raw Data Length : 00000400
    +
    +[03Ch 0060  12]         Error Status Address : [Generic Address Structure]
    +[03Ch 0060   1]                     Space ID : 00 [SystemMemory]
    +[03Dh 0061   1]                    Bit Width : 40
    +[03Fh 0063   1]         Encoded Access Width : 04 [QWord Access:64]
    +
    +[048h 0072  28]                       Notify : [Hardware Error Notification Structure]
---
 tests/data/acpi/x86/pc/DSDT.ras             | Bin 0 -> 8818 bytes
 tests/data/acpi/x86/pc/HEST.ras             | Bin 0 -> 132 bytes
 tests/data/acpi/x86/q35/DSDT.ras            | Bin 0 -> 8647 bytes
 tests/data/acpi/x86/q35/HEST.ras            | Bin 0 -> 132 bytes
 tests/qtest/bios-tables-test-allowed-diff.h |   4 ----
 5 files changed, 4 deletions(-)
tests/data/acpi/x86/pc/DSDT.ras binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ee99b20fd6e9d95ad2690e20573cd8bd5ca0d90f 100644
GIT binary patch
tests/data/acpi/x86/pc/HEST.ras binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6dfeb1d3704523f5ee7c81f442c4f51bbd10282d 100644
GIT binary patch
tests/data/acpi/x86/q35/DSDT.ras binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f7626f56ceda77aeb0ca04e8913d76bf57177a45 100644
GIT binary patch
tests/data/acpi/x86/q35/HEST.ras binary +0 -0
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..6dfeb1d3704523f5ee7c81f442c4f51bbd10282d 100644
GIT binary patch
tests/qtest/bios-tables-test-allowed-diff.h +0 -4
index b3761468accc..dfb8523c8bf4 100644
@@ -1,5 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/x86/pc/DSDT.ras",
-"tests/data/acpi/x86/pc/HEST.ras",
-"tests/data/acpi/x86/q35/DSDT.ras",
-"tests/data/acpi/x86/q35/HEST.ras",
Signature · 1 line
2.55.0