Add ghes support for x86 via SCI notification
v2 cover Add ghes support for x86 via SCI notification
Hi Michael,
That's the second version of this series. First version is here:
https://lore.kernel.org/qemu-devel/[email protected]/
There was a precursor RFC patch series I sent in 2025:
https://lore.kernel.org/qemu-devel/[email protected]/
I opted to rename the subject on patch 0 to make it clearer that the goal is to add GHES support on x86.
patch 1 adds a method to allow checking if RAS support is supported in an arch-independent way.
Patch 2 creates empty DSDT and HEST tables for x86, in preparation for testing them, adding them to allowed diffs.
Patch 3 adds support for _OSC at DSDT table, adding APEI support bit on it, if RAS is enabledm adding a "ras" boolean to allow enabling ras the same way as on arm64, using SCI notification for QMP source.
Patch 4 wires SCI support to the x86 driver at ich9 and piix4.
Patch 5 adds the new DSDT and HEST binaries to be used on tests and removes them from bios allowed diffs.
Patch 6 updates acpi_hest_ghes.rst: it splits arch-dependent notes for aarch64 from the ras support, adding separate sections for ARM and x86
Finally, patche 7 and 8 add BIOS tests to check that the QMP interface is working on arm64 and on x86. This would allow checking for possible regressions on GHES on those two architectures.
---
v2:
- rebased on the top of upstream;
- patch descriptions were improved to make them clearer;
- moved an uuid on patch 3 to a macro and did an ajustment at the code that generates _OSC at DSDT;
- temporarely added SPDX macros on patch 2 just to shut up checkpatch warnings. Those are removed on patch 5 when the "empty" files will be replaced by binary ones.
Note: I've been using this patch series for a while now, to help me to release rasdaemon 1.0.0 at the end of September, which took significant changes on its code.
To ensure that my changes won't be breaking rasdaemon code, a new CI was created as a separate project, aiming to do end to end tests using QEMU, Linux Kernel and rasdaemon on an error injection and error check logic at:
https://github.com/mchehab/rasdaemon-ci
Its goal is to verify that all mechanisms are in place on hardware error handling scenarios.
The rasdaemon-ci is written to be completely independent from each project, with a primary goal of detecting regressions at the Linux Kernel and at rasdaemon. Indirectly, it also detect issues at QEMU x86 and aarch64 RAS error injection logic via QMP.
Right now, it is using my QEMU tree fork with those patches on it, together with another series I'll submit in separate carring improvements to scripts/ghes_inject.py.
The rasdaemon -ci got several regressions that were fixed at rasdaemon, and one regression due to a race condition at the Linux Kernel:
https://lore.kernel.org/all/d472a9a3ccfa8c0359d7d7acabed92c8927d8e47.1793174996.git.mchehab+huawei@kernel.org/
Mauro Carvalho Chehab (8):
acpi_dev_interface: add 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: add GHES tests on arm64 virt machine
tests: add GHES tests on x86 piix4 and q35 machines
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 | 102 +++++++++++++++++++++ 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 | 131 +++++++++++++++++++++++++++ 19 files changed, 406 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.56.0
PATCH v2 1/8 acpi_dev_interface: add ghes support state at AcpiDeviceIfClass
Currently, ghes.c assumes that GHES support can be checked by looking at GED. This is valid only for aarch64. As we're now adding support for other architectures, this needs to be done on a different way.
For instance, on x86, it needs 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 an arch-independent way.
It should be noticed that, with this change, there's no need to include anymore hw/acpi/generic_event_device.h, as this were the aarch64-specific GED interface sits and the code is now generic.
--- 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
@@ -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
@@ -324,6 +324,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);
@@ -610,6 +615,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; object_class_property_add_uint16_ptr(class, ACPI_PCIHP_IO_BASE_PROP, offsetof(AcpiGedState,
hw/acpi/ghes.c +18 -12
@@ -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
@@ -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.56.0
PATCH v2 2/8 tests/acpi: virt: reserve expected tables for PC GHES SCI support
In reply to Mauro Carvalho ChehabPrepare to modify x86 firmware files, disabling DSDT and HEST table check until we update it to new firmware file changes.
Notice that we're adding a SPDX header at the new files just to shut up checkpatch. This will be dropped when we add the BIOS binaries there.
--- tests/data/acpi/x86/pc/DSDT.ras | 1 + tests/data/acpi/x86/pc/HEST.ras | 1 + tests/data/acpi/x86/q35/DSDT.ras | 1 + tests/data/acpi/x86/q35/HEST.ras | 1 + tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++ 5 files changed, 8 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 +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
tests/data/acpi/x86/pc/HEST.ras new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
tests/data/acpi/x86/q35/DSDT.ras new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
tests/data/acpi/x86/q35/HEST.ras new file +1 -0
@@ -0,0 +1 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */
tests/qtest/bios-tables-test-allowed-diff.h +4 -0
@@ -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.56.0
PATCH v2 6/8 docs: acpi_hest_ghes: document notification mechanisms
In reply to Mauro Carvalho ChehabCurrently, 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
@@ -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.56.0
PATCH v2 7/8 tests: add GHES tests on arm64 virt machine
In reply to Mauro Carvalho ChehabQEMU 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
@@ -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-aarch64-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 = {};
@@ -2930,6 +3009,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.56.0
PATCH v2 3/8 hw/i186: add support for HEST table with SCI
In reply to Mauro Carvalho ChehabThe _OSC device configuration object evaluates some platform software specific support. Among them, there are bits there to indicate if APEI support is enabled. Those are sitting at the UUID 0811B06E-4A27-44F9-8D60-3CBBC22E7B48.
Bit 4 is APEI support. it has to be enabled to let x86 use APEI/HEST/GHES.
--- hw/i386/Kconfig | 1 + hw/i386/acpi-build.c | 102 +++++++++++++++++++++++++++++++++++++++++++ hw/i386/pc.c | 41 +++++++++++++++++ include/hw/i386/pc.h | 5 +++ 4 files changed, 149 insertions(+)
hw/i386/Kconfig +1 -0
@@ -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 +102 -0
144 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
@@ -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;
@@ -57,6 +60,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.56.0
PATCH v2 4/8 hw/i386: add GHES support at ICH9 and PIIX4 PM
In reply to Mauro Carvalho ChehabEnabling 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
@@ -223,6 +223,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 ,
@@ -245,6 +263,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
@@ -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 } };
@@ -561,6 +580,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);
@@ -617,6 +641,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; object_class_property_add_uint16_ptr(klass, ACPI_PCIHP_IO_BASE_PROP, offsetof(PIIX4PMState,
hw/isa/lpc_ich9.c +6 -0
@@ -833,6 +833,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);
@@ -900,6 +905,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; object_class_property_add_uint8_ptr(klass, ACPI_PM_PROP_SCI_INT,
include/hw/acpi/ich9.h +2 -0
@@ -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
@@ -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.56.0
PATCH v2 5/8 tests/acpi: virt: add x86 DSDT and HEST tables
In reply to Mauro Carvalho ChehabThe 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 48 -> 8818 bytes tests/data/acpi/x86/pc/HEST.ras | Bin 48 -> 132 bytes tests/data/acpi/x86/q35/DSDT.ras | Bin 48 -> 8647 bytes tests/data/acpi/x86/q35/HEST.ras | Bin 48 -> 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
tests/data/acpi/x86/pc/HEST.ras binary +0 -0
tests/data/acpi/x86/q35/DSDT.ras binary +0 -0
tests/data/acpi/x86/q35/HEST.ras binary +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +0 -4
@@ -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.56.0
PATCH v2 8/8 tests: add GHES tests on x86 piix4 and q35 machines
In reply to Mauro Carvalho ChehabAdd support to test GHES on x86 using the SCI mechanism.
--- tests/qtest/bios-tables-test.c | 67 ++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 8 deletions(-)
tests/qtest/bios-tables-test.c +59 -8
@@ -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); }
@@ -2883,6 +2931,8 @@ 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",
@@ -2921,6 +2971,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.56.0