Add ACPI CPER firmware first error injection for Arm Processor
PATCH v4 1/6 arm/virt: place power button pin number on a define
In reply to Mauro Carvalho ChehabHaving magic numbers inside the code is not a good idea, as it is error-prone. So, instead, create a macro with the number definition.
--- hw/arm/virt-acpi-build.c | 6 +++--- hw/arm/virt.c | 7 ++++--- include/hw/arm/virt.h | 3 +++ 3 files changed, 10 insertions(+), 6 deletions(-)
hw/arm/virt-acpi-build.c +3 -3
@@ -154,10 +154,10 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap,aml_append (dev,aml_name_decl ("_CRS" , crs));Aml *aei =aml_resource_template (); -/* Pin 3 for power button */ -const uint32_t pin_list[1 ] = {3 }; + +const uint32_t pin =GPIO_PIN_POWER_BUTTON ;aml_append (aei,aml_gpio_int (AML_CONSUMER ,AML_EDGE ,AML_ACTIVE_HIGH , -AML_EXCLUSIVE ,AML_PULL_UP ,0 , pin_list,1 , +AML_EXCLUSIVE ,AML_PULL_UP ,0 , &pin,1 ,"GPO0" ,NULL ,0 ));aml_append (dev,aml_name_decl ("_AEI" , aei));
hw/arm/virt.c +4 -3
@@ -1004,7 +1004,7 @@ static void virt_powerdown_req(Notifier *n, void *opaque)if (s->acpi_dev) {acpi_send_event (s->acpi_dev,ACPI_POWER_DOWN_STATUS ); }else { -/* use gpio Pin 3 for power button event */ +/* use gpio Pin for power button event */ qemu_set_irq (qdev_get_gpio_in (gpio_key_dev,0 ),1 ); } }
@@ -1013,7 +1013,8 @@ static void create_gpio_keys(char *fdt, DeviceState *pl061_dev, uint32_t phandle) { gpio_key_dev =sysbus_create_simple ("gpio-key" ,-1 , -qdev_get_gpio_in (pl061_dev,3 )); +qdev_get_gpio_in (pl061_dev, +GPIO_PIN_POWER_BUTTON ));qemu_fdt_add_subnode (fdt,"/gpio-keys" );qemu_fdt_setprop_string (fdt,"/gpio-keys" ,"compatible" ,"gpio-keys" );
@@ -1024,7 +1025,7 @@ static void create_gpio_keys(char *fdt, DeviceState *pl061_dev,qemu_fdt_setprop_cell (fdt,"/gpio-keys/poweroff" ,"linux,code" ,KEY_POWER );qemu_fdt_setprop_cells (fdt,"/gpio-keys/poweroff" , -"gpios" , phandle,3 ,0 ); +"gpios" , phandle,GPIO_PIN_POWER_BUTTON ,0 ); }#define SECURE_GPIO_POWEROFF 0
include/hw/arm/virt.h +3 -0
@@ -47,6 +47,9 @@/* See Linux kernel arch/arm64/include/asm/pvclock-abi.h */ #define PVTIME_SIZE_PER_CPU 64 +/* GPIO pins */ +#define GPIO_PIN_POWER_BUTTON 3 +enum {VIRT_FLASH ,VIRT_MEM ,
Signature · 1 line
2.45.2
PATCH v4 2/6 arm/virt: Wire up GPIO error source for ACPI / GHES
In reply to Mauro Carvalho ChehabFrom: Jonathan Cameron <[email protected]>
Creates a Generic Event Device (GED) as specified at ACPI 6.5 specification at 18.3.2.7.2:
https://uefi.org/specs/ACPI/6.5/18_Platform_Error_Interfaces.html#event-notification-for-generic-error-sources
with HID PNP0C33.
The PNP0C33 device is used to report hardware errors to the bios via ACPI APEI Generic Hardware Error Source (GHES).
It is aligned with Linux Kernel patch:
https://lore.kernel.org/lkml/[email protected]/
--- hw/arm/virt-acpi-build.c | 30 ++++++++++++++++++++++++++---- hw/arm/virt.c | 14 ++++++++++++-- include/hw/arm/virt.h | 1 + include/hw/boards.h | 1 + 4 files changed, 40 insertions(+), 6 deletions(-)
hw/arm/virt-acpi-build.c +26 -4
@@ -63,6 +63,7 @@#define ARM_SPI_BASE 32 +#define ACPI_GENERIC_EVENT_DEVICE "GEDD"#define ACPI_BUILD_TABLE_SIZE 0x20000static void acpi_dsdt_add_cpus (Aml *scope,VirtMachineState *vms)
@@ -142,6 +143,8 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,static void acpi_dsdt_add_gpio (Aml *scope,const MemMapEntry *gpio_memmap,uint32_t gpio_irq) { +uint32_t pin; +Aml *dev =aml_device ("GPO0" );aml_append (dev,aml_name_decl ("_HID" ,aml_string ("ARMH0061" )));aml_append (dev,aml_name_decl ("_UID" ,aml_int (0 )));
@@ -155,7 +158,12 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap,Aml *aei =aml_resource_template (); -const uint32_t pin =GPIO_PIN_POWER_BUTTON ; + pin =GPIO_PIN_POWER_BUTTON ; +aml_append (aei,aml_gpio_int (AML_CONSUMER ,AML_EDGE ,AML_ACTIVE_HIGH , +AML_EXCLUSIVE ,AML_PULL_UP ,0 , &pin,1 , +"GPO0" ,NULL ,0 )); +/* Pin for generic error */ + pin =GPIO_PIN_GENERIC_ERROR ;aml_append (aei,aml_gpio_int (AML_CONSUMER ,AML_EDGE ,AML_ACTIVE_HIGH ,AML_EXCLUSIVE ,AML_PULL_UP ,0 , &pin,1 ,"GPO0" ,NULL ,0 ));
@@ -166,6 +174,11 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap,aml_append (method,aml_notify (aml_name (ACPI_POWER_BUTTON_DEVICE ),aml_int (0x80 )));aml_append (dev, method); + method =aml_method ("_E06" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_notify (aml_name (ACPI_GENERIC_EVENT_DEVICE ), +aml_int (0x80 ))); +aml_append (dev, method); +aml_append (scope, dev); }
@@ -800,6 +813,15 @@ static void build_fadt_rev6(GArray *table_data, BIOSLinker *linker,build_fadt (table_data, linker, &fadt, vms->oem_id, vms->oem_table_id); } +static void acpi_dsdt_add_generic_event_device (Aml *scope) +{ +Aml *dev =aml_device (ACPI_GENERIC_EVENT_DEVICE ); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("PNP0C33" ))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (0 ))); +aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xF ))); +aml_append (scope, dev); +} +/* DSDT */ static void build_dsdt (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms)
@@ -841,10 +863,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)HOTPLUG_HANDLER (vms->acpi_dev), irqmap[VIRT_ACPI_GED ] +ARM_SPI_BASE ,AML_SYSTEM_MEMORY , memmap[VIRT_ACPI_GED].base); - }else { -acpi_dsdt_add_gpio (scope, &memmap[VIRT_GPIO ], - (irqmap[VIRT_GPIO ] +ARM_SPI_BASE )); } +acpi_dsdt_add_gpio (scope, &memmap[VIRT_GPIO ], + (irqmap[VIRT_GPIO ] +ARM_SPI_BASE ));if (vms->acpi_dev) { uint32_t event = object_property_get_uint(OBJECT(vms->acpi_dev),
@@ -858,6 +879,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) }acpi_dsdt_add_power_button (scope); +acpi_dsdt_add_generic_event_device (scope);#ifdef CONFIG_TPM acpi_dsdt_add_tpm (scope, vms);#endif
hw/arm/virt.c +12 -2
@@ -997,6 +997,13 @@ static void create_rtc(const VirtMachineState *vms) }static DeviceState *gpio_key_dev; + +static DeviceState *gpio_error_dev; +static void virt_set_error (void ) +{ +qemu_set_irq (qdev_get_gpio_in (gpio_error_dev,0 ),1 ); +} +static void virt_powerdown_req (Notifier *n,void *opaque) {VirtMachineState *s =container_of (n, VirtMachineState, powerdown_notifier);
@@ -1015,6 +1022,9 @@ static void create_gpio_keys(char *fdt, DeviceState *pl061_dev, gpio_key_dev =sysbus_create_simple ("gpio-key" ,-1 ,qdev_get_gpio_in (pl061_dev,GPIO_PIN_POWER_BUTTON )); + gpio_error_dev =sysbus_create_simple ("gpio-key" ,-1 , +qdev_get_gpio_in (pl061_dev, +GPIO_PIN_GENERIC_ERROR ));qemu_fdt_add_subnode (fdt,"/gpio-keys" );qemu_fdt_setprop_string (fdt,"/gpio-keys" ,"compatible" ,"gpio-keys" );
@@ -2385,9 +2395,8 @@ static void machvirt_init(MachineState *machine)if (has_ged && aarch64 && firmware_loaded &&virt_is_acpi_enabled (vms)) { vms->acpi_dev =create_acpi_ged (vms); - }else { -create_gpio_devices (vms,VIRT_GPIO , sysmem); } +create_gpio_devices (vms,VIRT_GPIO , sysmem);if (vms->secure && !vmc->no_secure_gpio) {create_gpio_devices (vms,VIRT_SECURE_GPIO , secure_sysmem);
@@ -3101,6 +3110,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->default_ram_id ="mach-virt.ram" ; mc->default_nic ="virtio-net-pci" ; + mc->generic_error_device_notify = virt_set_error;object_class_property_add (oc,"acpi" ,"OnOffAuto" , virt_get_acpi, virt_set_acpi,NULL ,NULL );
include/hw/arm/virt.h +1 -0
@@ -49,6 +49,7 @@/* GPIO pins */ #define GPIO_PIN_POWER_BUTTON 3 +#define GPIO_PIN_GENERIC_ERROR 6enum {VIRT_FLASH ,
include/hw/boards.h +1 -0
@@ -308,6 +308,7 @@ struct MachineClass {int64_t (*get_default_cpu_node_id)(const MachineState *ms,int idx);ram_addr_t (*fixup_ram_size)(ram_addr_t size);uint64_t smbios_memory_device_size; +void (*generic_error_device_notify)(void ); };/**
Signature · 1 line
2.45.2
PATCH v4 3/6 target/arm: preserve mpidr value
In reply to Mauro Carvalho ChehabThere is a logic at helper to properly fill the mpidr information. This is needed for ARM Processor error injection, so store the value inside a cpu opaque value, to allow it to be used.
--- target/arm/cpu.h | 1 + target/arm/helper.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-)
target/arm/cpu.h +1 -0
@@ -1033,6 +1033,7 @@ struct ArchCPU {uint64_t reset_pmcr_el0; } isar;uint64_t midr; +uint64_t mpidr;uint32_t revidr;uint32_t reset_fpsid;uint64_t ctr;
target/arm/helper.c +8 -2
@@ -4692,7 +4692,7 @@ static uint64_t mpidr_read_val(CPUARMState *env)return mpidr; } -static uint64_t mpidr_read (CPUARMState *env,const ARMCPRegInfo *ri) +static uint64_t mpidr_read (CPUARMState *env) {unsigned int cur_el =arm_current_el (env);
@@ -4702,6 +4702,11 @@ static uint64_t mpidr_read(CPUARMState *env, const ARMCPRegInfo *ri)return mpidr_read_val (env); } +static uint64_t mpidr_read_ri (CPUARMState *env,const ARMCPRegInfo *ri) +{ +return mpidr_read (env); +} +static const ARMCPRegInfo lpae_cp_reginfo[] = {/* NOP AMAIR0/1 */ { .name ="AMAIR0" , .state =ARM_CP_STATE_BOTH ,
@@ -9723,7 +9728,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) { .name = "MPIDR_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 5, .fgt = FGT_MPIDR_EL1, - .access = PL1_R, .readfn = mpidr_read, .type = ARM_CP_NO_RAW }, + .access = PL1_R, .readfn = mpidr_read_ri, .type = ARM_CP_NO_RAW }, };#ifdef CONFIG_USER_ONLY static const ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = {
@@ -9733,6 +9738,7 @@ void register_cp_regs_for_features(ARMCPU *cpu)modify_arm_cp_regs (mpidr_cp_reginfo, mpidr_user_cp_reginfo);#endif define_arm_cp_regs (cpu, mpidr_cp_reginfo); + cpu->mpidr =mpidr_read (env); }if (arm_feature (env,ARM_FEATURE_AUXCR )) {
Signature · 1 line
2.45.2
PATCH v4 4/6 acpi/ghes: update comments to point to newer ACPI specs
In reply to Mauro Carvalho ChehabThere is one reference to ACPI 4.0 and several references to ACPI 6.x versions.
Update them to point to ACPI 6.5 whenever possible.
There's one reference that was kept pointing to ACPI 6.4, though, with HEST revision 1.
ACPI 6.5 now defines HEST revision 2, and defined a new way to handle source types starting from 12. According with ACPI 6.5 revision history:
2312 Update to the HEST table and adding new error
source descriptor - Table 18.2.
Yet, the spec doesn't define yet any new source descriptors. It just defines a different behavior when source type is above 11.
I also double-checked GHES implementation on an open source project (Linux Kernel). Currently upstream doesn't currently handle HEST revision, ignoring such field.
In any case, revision 2 seems to be backward-compatible with revison 1 when type <= 11 and just one error is contained on a HEST record.
So, while it is probably safe to update it, there's no real need. So, let's keep the implementation using an ACPI 6.4 compatible table, e. g. HEST revision 1.
--- hw/acpi/ghes.c | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-)
hw/acpi/ghes.c +28 -20
@@ -44,9 +44,9 @@#define GAS_ADDR_OFFSET 4/* -* The total size of Generic Error Data Entry -* ACPI 6.1/6.2: 18.3.2.7.1 Generic Error Data, -* Table 18-343 Generic Error Data Entry +* The total size of Generic Error Data Entry before data field +* ACPI 6.5: 18.3.2.7.1 Generic Error Data, +* Table 18.12 Generic Error Data Entry */ #define ACPI_GHES_DATA_LENGTH 72
@@ -58,8 +58,8 @@/* * Total size for Generic Error Status Block except Generic Error Data Entries -* ACPI 6.2: 18.3.2.7.1 Generic Error Data, -* Table 18-380 Generic Error Status Block +* ACPI 6.5: 18.3.2.7.1 Generic Error Data, +* Table 18.11 Generic Error Status Block */ #define ACPI_GHES_GESB_SIZE 20
@@ -75,7 +75,8 @@ enum AcpiGenericErrorSeverity {/* * Hardware Error Notification -* ACPI 4.0: 17.3.2.7 Hardware Error Notification +* ACPI 6.5: 18.3.2.9 Hardware Error Notification, +* Table 18.14 - Hardware Error Notification Structure * Composes dummy Hardware Error Notification descriptor of specified type */ static void build_ghes_hw_error_notification (GArray *table,const uint8_t type)
@@ -105,7 +106,8 @@ static void build_ghes_hw_error_notification(GArray *table, const uint8_t type)/* * Generic Error Data Entry -* ACPI 6.1: 18.3.2.7.1 Generic Error Data +* ACPI 6.5: 18.3.2.7.1 Generic Error Data, +* Table 18.12 - Generic Error Data Entry */ static void acpi_ghes_generic_error_data(GArray *table, const uint8_t *section_type, uint32_t error_severity,
@@ -141,7 +143,8 @@ static void acpi_ghes_generic_error_data(GArray *table,/* * Generic Error Status Block -* ACPI 6.1: 18.3.2.7.1 Generic Error Data +* ACPI 6.5: 18.3.2.7.1 Generic Error Data, +* Table 18.11 - Generic Hardware Error Source Structure */ static void acpi_ghes_generic_error_status(GArray *table, uint32_t block_status, uint32_t raw_data_offset, uint32_t raw_data_length,
@@ -286,15 +289,18 @@ void build_ghes_error_table(GArray *hardware_errors, BIOSLinker *linker) 0, sizeof(uint64_t), ACPI_GHES_ERRORS_FW_CFG_FILE, 0); } -/* Build Generic Hardware Error Source version 2 (GHESv2) */ +/* +* Build Generic Hardware Error Source version 2 (GHESv2) +* ACPI 6.5: 18.3.2.8 Generic Hardware Error Source version 2 (GHESv2 - Type 10), +* Table 18.13: Generic Hardware Error Source version 2 (GHESv2) +*/ static void build_ghes_v2 (GArray *table_data,int source_id,BIOSLinker *linker) {uint64_t address_offset; -/* -* Type: -* Generic Hardware Error Source version 2(GHESv2 - Type 10) -*/ +/* Type: (GHESv2 - Type 10) */ build_append_int_noprefix (table_data,ACPI_GHES_SOURCE_GENERIC_ERROR_V2 ,2 ); + +/* ACPI 6.5: Table 18.10 - Generic Hardware Error Source Structure */ /* Source Id */ build_append_int_noprefix (table_data, source_id,2 );/* Related Source Id */
@@ -335,11 +341,8 @@ static void build_ghes_v2(GArray *table_data, int source_id, BIOSLinker *linker)/* Error Status Block Length */ build_append_int_noprefix (table_data,ACPI_GHES_MAX_RAW_DATA_LENGTH ,4 ); -/* -* Read Ack Register -* ACPI 6.1: 18.3.2.8 Generic Hardware Error Source -* version 2 (GHESv2 - Type 10) -*/ +/* ACPI 6.5: fields defined at GHESv2 table */ +/* Read Ack Register */ address_offset = table_data->len;build_append_gas (table_data,AML_AS_SYSTEM_MEMORY ,0x40 ,0 ,4 /* QWord access */ ,0 );
@@ -358,11 +361,16 @@ static void build_ghes_v2(GArray *table_data, int source_id, BIOSLinker *linker)build_append_int_noprefix (table_data,0x1 ,8 ); } -/* Build Hardware Error Source Table */ +/* +* Build Hardware Error Source Table +* ACPI 6.4: 18.3.2 ACPI Error Source +* Table 18.2: Hardware Error Source Table (HEST) +*/ void acpi_build_hest (GArray *table_data,BIOSLinker *linker,const char *oem_id,const char *oem_table_id) { -AcpiTable table = { .sig ="HEST" , .rev =1 , +AcpiTable table = { .sig ="HEST" , + .rev =1 ,/* ACPI 4.0 to 6.4 */ .oem_id = oem_id, .oem_table_id = oem_table_id };acpi_table_begin (&table, table_data);
Signature · 1 line
2.45.2
PATCH v4 5/6 acpi/ghes: Support GPIO error source.
In reply to Mauro Carvalho ChehabFrom: Jonathan Cameron <[email protected]>
Add error notification to GHES v2 using the GPIO source.
--- hw/acpi/ghes.c | 8 ++++++-- include/hw/acpi/ghes.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)
hw/acpi/ghes.c +6 -2
@@ -34,8 +34,8 @@/* The max size in bytes for one error block */ #define ACPI_GHES_MAX_RAW_DATA_LENGTH (1 * KiB) -/* Now only support ARMv8 SEA notification type error source */ -#define ACPI_GHES_ERROR_SOURCE_COUNT 1 +/* Support ARMv8 SEA notification type error source and GPIO interrupt. */ +#define ACPI_GHES_ERROR_SOURCE_COUNT 2/* Generic Hardware Error Source version 2 */ #define ACPI_GHES_SOURCE_GENERIC_ERROR_V2 10
@@ -333,6 +333,9 @@ static void build_ghes_v2(GArray *table_data, int source_id, BIOSLinker *linker)*/ build_ghes_hw_error_notification (table_data,ACPI_GHES_NOTIFY_SEA );break ; +case ACPI_HEST_SRC_ID_GPIO : +build_ghes_hw_error_notification (table_data,ACPI_GHES_NOTIFY_GPIO ); +break ;default :error_report ("Not support this error source" );abort ();
@@ -378,6 +381,7 @@ void acpi_build_hest(GArray *table_data, BIOSLinker *linker,/* Error Source Count */ build_append_int_noprefix (table_data,ACPI_GHES_ERROR_SOURCE_COUNT ,4 );build_ghes_v2 (table_data,ACPI_HEST_SRC_ID_SEA , linker); +build_ghes_v2 (table_data,ACPI_HEST_SRC_ID_GPIO , linker);acpi_table_end (linker, &table); }
include/hw/acpi/ghes.h +1 -0
@@ -58,6 +58,7 @@ enum AcpiGhesNotifyType {enum {ACPI_HEST_SRC_ID_SEA =0 , +ACPI_HEST_SRC_ID_GPIO =1 ,/* future ids go here */ ACPI_HEST_SRC_ID_RESERVED , };
Signature · 1 line
2.45.2
PATCH v4 6/6 acpi/ghes: Add a logic to inject ARM processor CPER
In reply to Mauro Carvalho ChehabAdd an ACPI APEI GHES error injection logic for ARM processor CPER, allowing to set fields at from UEFI spec 2.10 tables N.16 and N.17 to any valid value.
As some GHES functions require handling addresses, add a helper function to support it.
Before starting erorr inject, the QAPI requires to negociate QMP with:
{ "execute": "qmp_capabilities" }
Afterwards, errors can be injected with:
{ "execute": "arm-inject-error" }The error injection events supports several optional arguments, having Processor Error Information (PEI) mapped into an array.
So, it is possible to inject multiple errors at the same CPER record, as defined at UEFI spec, with:
{ "execute": "arm-inject-error", "arguments": {
"error": [ {"type": [ "cache-error" ]},
{"type": [ "tlb-error" ]} ] } }The above generates a single CPER record with two PEI info, one reporting a cache error, and the other one a TLB error, using default values for other fields.
As all fields from ARM Processor CPER are mapped, so, the error could contain physical/virtual addresses, register dumps, vendor-specific data, etc.
This patch is co-authored:
- ghes logic to inject a simple ARM record by Shiju Jose;
- generic logic to handle block addresses by Jonathan Cameron;
- logic to allow changing all fields by Mauro Carvalho Chehab;
--- MAINTAINERS | 7 + configs/targets/aarch64-softmmu.mak | 1 + hw/acpi/ghes.c | 283 ++++++++++++++++++- hw/arm/Kconfig | 4 + hw/arm/arm_error_inject.c | 420 ++++++++++++++++++++++++++++ hw/arm/arm_error_inject_stubs.c | 34 +++ hw/arm/meson.build | 3 + include/hw/acpi/ghes.h | 40 +++ qapi/arm-error-inject.json | 284 +++++++++++++++++++ qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + 11 files changed, 1067 insertions(+), 11 deletions(-) create mode 100644 hw/arm/arm_error_inject.c create mode 100644 hw/arm/arm_error_inject_stubs.c create mode 100644 qapi/arm-error-inject.json
MAINTAINERS +7 -0
@@ -2075,6 +2075,13 @@ F: hw/acpi/ghes.c F: include/hw/acpi/ghes.h F: docs/specs/acpi_hest_ghes.rst +ACPI/HEST/GHES/ARM processor CPER +R: Mauro Carvalho Chehab <[email protected]> +S: Maintained +F: hw/arm/arm_error_inject.c +F: hw/arm/arm_error_inject_stubs.c +F: qapi/arm-error-inject.json + ppc4xx L: [email protected] S: Orphan
configs/targets/aarch64-softmmu.mak +1 -0
@@ -5,3 +5,4 @@ TARGET_KVM_HAVE_GUEST_DEBUG=y TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml gdb-xml/arm-core.xml gdb-xml/arm-vfp.xml gdb-xml/arm-vfp3.xml gdb-xml/arm-vfp-sysregs.xml gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml gdb-xml/arm-m-profile-mve.xml gdb-xml/aarch64-pauth.xml # needed by boot.c TARGET_NEED_FDT=y +CONFIG_ARM_EINJ=y
hw/acpi/ghes.c +272 -11
319 lines not on this page · raw message
hw/arm/Kconfig +4 -0
@@ -712,3 +712,7 @@ config ARMSSE select UNIMP select SSE_COUNTER select SSE_TIMER + +config ARM_EINJ + bool + default y if AARCH64
hw/arm/arm_error_inject.c new file +420 -0
420 lines not on this page · raw message
hw/arm/arm_error_inject_stubs.c new file +34 -0
@@ -0,0 +1,34 @@ +/* +* QMP stub for ARM processor error injection. +* +* Copyright(C) 2024 Huawei LTD. +* +* This code is licensed under the GPL version 2 or later. See the +* COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/acpi/ghes.h" + +void qmp_arm_inject_error (bool has_validation, +ArmProcessorValidationBitsList *validation, +bool has_affinity_level, +uint8_t affinity_level, +bool has_mpidr_el1, +uint64_t mpidr_el1, +bool has_midr_el1, +uint64_t midr_el1, +bool has_running_state, +ArmProcessorRunningStateList *running_state, +bool has_psci_state, +uint32_t psci_state, +bool has_context,ArmProcessorContextList *context, +bool has_vendor_specific,uint8List *vendor_specific, +bool has_error, +ArmProcessorErrorInformationList *error, +Error **errp) +{ +error_setg (errp,"ARM processor error support is not compiled in" ); +}
hw/arm/meson.build +3 -0
@@ -60,6 +60,7 @@ arm_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmuv3.c')) arm_ss.add(when: 'CONFIG_FSL_IMX6UL', if_true: files('fsl-imx6ul.c', 'mcimx6ul-evk.c')) arm_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_soc.c')) arm_ss.add(when: 'CONFIG_XEN', if_true: files('xen_arm.c')) +arm_ss.add(when: 'CONFIG_ARM_EINJ', if_true: files('arm_error_inject.c')) system_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmu-common.c')) system_ss.add(when: 'CONFIG_CHEETAH', if_true: files('palm.c'))
@@ -77,5 +78,7 @@ system_ss.add(when: 'CONFIG_TOSA', if_true: files('tosa.c')) system_ss.add(when: 'CONFIG_VERSATILE', if_true: files('versatilepb.c')) system_ss.add(when: 'CONFIG_VEXPRESS', if_true: files('vexpress.c')) system_ss.add(when: 'CONFIG_Z2', if_true: files('z2.c')) +system_ss.add(when: 'CONFIG_ARM_EINJ', if_false: files('arm_error_inject_stubs.c')) +system_ss.add(when: 'CONFIG_ALL', if_true: files('arm_error_inject_stubs.c')) hw_arch += {'arm': arm_ss}
include/hw/acpi/ghes.h +40 -0
@@ -23,6 +23,7 @@#define ACPI_GHES_H #include "hw/acpi/bios-linker-loader.h" +#include "qapi/qapi-commands-arm-error-inject.h" /* * Values for Hardware Error Notification Type field
@@ -68,6 +69,43 @@ typedef struct AcpiGhesState {bool present;/* True if GHES is present at all on this board */ } AcpiGhesState; +typedef struct ArmPEI { +uint16_t validation; +uint8_t type; +uint16_t multiple_error; +uint8_t flags; +uint64_t error_info; +uint64_t virt_addr; +uint64_t phy_addr; +}ArmPEI ; + +typedef struct ArmContext { +uint16_t type; +uint32_t size; +uint64_t *array; +}ArmContext ; + +/* ARM processor - UEFI 2.10 table N.16 */ +typedef struct ArmError { +uint16_t validation; + +uint8_t affinity_level; +uint64_t mpidr_el1; +uint64_t midr_el1; +uint32_t running_state; +uint32_t psci_state; + +/* Those are calculated based on the input data */ +uint16_t err_info_num; +uint16_t context_info_num; +uint32_t vendor_num; +uint32_t context_length; + +ArmPEI *pei; +ArmContext *context; +uint8_t *vendor; +}ArmError ; +void build_ghes_error_table (GArray *hardware_errors,BIOSLinker *linker);void acpi_build_hest (GArray *table_data,BIOSLinker *linker,const char *oem_id,const char *oem_table_id);
@@ -75,6 +113,8 @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *vms, FWCfgState *s, GArray *hardware_errors);int acpi_ghes_record_errors (uint8_t notify,uint64_t error_physical_addr); +bool ghes_record_arm_errors (ArmError error,uint32_t notify); +/** * acpi_ghes_present: Report whether ACPI GHES table is present *
qapi/arm-error-inject.json new file +284 -0
284 lines not on this page · raw message
qapi/meson.build +1 -0
@@ -22,6 +22,7 @@ if have_system or have_tools or have_ga endif qapi_all_modules = [ + 'arm-error-inject', 'authz', 'block', 'block-core',
qapi/qapi-schema.json +1 -0
@@ -81,3 +81,4 @@ { 'include': 'vfio.json' } { 'include': 'cryptodev.json' } { 'include': 'cxl.json' } +{ 'include': 'arm-error-inject.json' }
Signature · 1 line
2.45.2
v4 cover Add ACPI CPER firmware first error injection for Arm Processor
Testing OS kernel ACPI APEI CPER support is tricky, as one depends on having hardware with special-purpose BIOS and/or hardware.
With QEMU, it becomes a lot easier, as it can be done via QMP.
This series add support for ARM Processor CPER error injection, according with ACPI 6.x and UEFI 2.9A/2.10 specs.
This series consists of:
- one patch using a define for ARM virt GPIO power pin (requested during last review);
- three patches from Jonathan (one coauthored with Shiju) with basic EINJ features, already submitted as RFC (but not merged yet) at:
https://lore.kernel.org/qemu-devel/[email protected]/
- three patches from me extending it to optionally allow to generate all sorts of possible valid combinations for ARM Processor CPER record.
I've been using it to test a Linux Kernel patch series fixing UEFI 2.9A errata and ARM processor trace event:
https://lore.kernel.org/linux-edac/3853853f820a666253ca8ed6c7c724dc3d50044a.1720679234.git.mchehab+huawei@kernel.org/T/#t
I also wrote some Wiki pages for rasdaemon (a Linux daemon widely used to monitor and react to RAS events):
https://github.com/mchehab/rasdaemon/wiki/error-injection
Being really helpful to test the Linux Kernel behavior when firmware-first RAS events for ARM processor arrives there, helping to validate how CPER and GHES driver handles them (and further testing userspace apps like rasdaemon):
Sending this command to QMP:
{ "execute": "qmp_capabilities" }
{ "execute": "arm-inject-error", "arguments": {"error": [{"type": ["cache-error"]}]} }Produces a simple CPER register, properly handled by the Linux Kernel:
[ 839.952678] {4}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1
[ 839.953145] {4}[Hardware Error]: event severity: recoverable
[ 839.953451] {4}[Hardware Error]: Error 0, type: recoverable
[ 839.953763] {4}[Hardware Error]: section_type: ARM processor error
[ 839.954094] {4}[Hardware Error]: MIDR: 0x0000000000000000
[ 839.954383] {4}[Hardware Error]: Multiprocessor Affinity Register (MPIDR): 0x0000000080000000
[ 839.954802] {4}[Hardware Error]: running state: 0x0
[ 839.955066] {4}[Hardware Error]: Power State Coordination Interface state: 0
[ 839.955424] {4}[Hardware Error]: Error info structure 0:
[ 839.955712] {4}[Hardware Error]: num errors: 1
[ 839.955983] {4}[Hardware Error]: first error captured
[ 839.956260] {4}[Hardware Error]: propagated error captured
[ 839.956561] {4}[Hardware Error]: error_type: 0x02: cache error
[ 839.956882] {4}[Hardware Error]: error_info: 0x000000000054007f
[ 839.957192] {4}[Hardware Error]: transaction type: Instruction
[ 839.957495] {4}[Hardware Error]: cache error, operation type: Instruction fetch
[ 839.957888] {4}[Hardware Error]: cache level: 1
[ 839.958166] {4}[Hardware Error]: processor context not corrupted
[ 839.958459] {4}[Hardware Error]: the error has not been corrected
[ 839.958771] {4}[Hardware Error]: PC is imprecise
[ 839.959074] [Firmware Warn]: GHES: Unhandled processor error type 0x02: cache errorrasdaemon output (rasdaemon still needs to be patched for UEFI 2.9A errata):
<...>-211 [002] d..1. 0.000129 arm_event 2024-07-11 09:50:45 +0000 affinity: -1 MPIDR: 0x80000000 MIDR: 0x0 running_state: 0 psci_state: 0 ARM Processor Err Info data len: 32
<CANT FIND FIELD buf>cpu: 0; error: 2; affinity level: 255; MPIDR: 0000000080000000; MIDR: 0000000000000000; running state: 0; PSCI state: 0; ARM Processor Err Info data len: 32; ARM Processor Err Info raw data: 00 20 06 00 02 00 00 05 7f 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00; ARM Processor Err Context Info data len: 0; ARM Processor Err Context Info raw data: ; Vendor Specific Err Info data len: 0; Vendor Specific Err Info raw data:
More complex events with multiple Processor Error Information structures can be produced like:
{ "execute": "arm-inject-error", "arguments": {
"validation": ["mpidr-valid", "affinity-valid", "running-state-valid", "vendor-specific-valid"],
"running-state": [], "psci-state": 1229279264,
"error": [{
"validation": ["multiple-error-valid", "flags-valid"],
"type": ["tlb-error", "bus-error", "micro-arch-error"],
"multiple-error": 3, "phy-addr": 57005, "virt-addr": 48879},
{"type": ["micro-arch-error"]},
{"type": ["tlb-error"]},
{"type": ["bus-error"]},
{"type": ["cache-error"]}],
"context": [{"register": [57005, 48879, 43962, 47787]}],
"vendor-specific": [12, 23, 53, 52, 3, 123, 243, 255]} }[ 925.340284] {5}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1
[ 925.340662] {5}[Hardware Error]: event severity: recoverable
[ 925.340924] {5}[Hardware Error]: Error 0, type: recoverable
[ 925.341280] {5}[Hardware Error]: section_type: ARM processor error
[ 925.341631] {5}[Hardware Error]: MIDR: 0x0000000000000000
[ 925.341893] {5}[Hardware Error]: Multiprocessor Affinity Register (MPIDR): 0x0000000080000000
[ 925.342278] {5}[Hardware Error]: error affinity level: 0
[ 925.342571] {5}[Hardware Error]: running state: 0x0
[ 925.342835] {5}[Hardware Error]: Power State Coordination Interface state: 1229279264
[ 925.343157] {5}[Hardware Error]: Error info structure 0:
[ 925.343388] {5}[Hardware Error]: num errors: 4
[ 925.343602] {5}[Hardware Error]: error_type: 0x1c: TLB error|bus error|micro-architectural error
[ 925.343960] {5}[Hardware Error]: virtual fault address: 0x000000000000beef
[ 925.344241] {5}[Hardware Error]: physical fault address: 0x000000000000dead
[ 925.344526] {5}[Hardware Error]: Error info structure 1:
[ 925.344757] {5}[Hardware Error]: num errors: 1
[ 925.344965] {5}[Hardware Error]: first error captured
[ 925.345183] {5}[Hardware Error]: propagated error captured
[ 925.345416] {5}[Hardware Error]: error_type: 0x10: micro-architectural error
[ 925.345714] {5}[Hardware Error]: Error info structure 2:
[ 925.345946] {5}[Hardware Error]: num errors: 1
[ 925.346148] {5}[Hardware Error]: first error captured
[ 925.346413] {5}[Hardware Error]: propagated error captured
[ 925.346719] {5}[Hardware Error]: error_type: 0x04: TLB error
[ 925.346988] {5}[Hardware Error]: error_info: 0x00000080d6460fff
[ 925.347248] {5}[Hardware Error]: transaction type: Generic
[ 925.347492] {5}[Hardware Error]: TLB error, operation type: Generic read (type of instruction or data request cannot be determined)
[ 925.347945] {5}[Hardware Error]: TLB level: 1
[ 925.348153] {5}[Hardware Error]: processor context corrupted
[ 925.348392] {5}[Hardware Error]: the error has been corrected
[ 925.348635] {5}[Hardware Error]: PC is imprecise
[ 925.348848] {5}[Hardware Error]: Program execution can be restarted reliably at the PC associated with the error.
[ 925.349232] {5}[Hardware Error]: Error info structure 3:
[ 925.349459] {5}[Hardware Error]: num errors: 1
[ 925.349662] {5}[Hardware Error]: first error captured
[ 925.349884] {5}[Hardware Error]: propagated error captured
[ 925.350115] {5}[Hardware Error]: error_type: 0x08: bus error
[ 925.350371] {5}[Hardware Error]: error_info: 0x0000000078da03ff
[ 925.350629] {5}[Hardware Error]: transaction type: Generic
[ 925.350878] {5}[Hardware Error]: bus error, operation type: Prefetch
[ 925.351144] {5}[Hardware Error]: affinity level at which the bus error occurred: 3
[ 925.351451] {5}[Hardware Error]: processor context not corrupted
[ 925.351702] {5}[Hardware Error]: the error has not been corrected
[ 925.351960] {5}[Hardware Error]: PC is precise
[ 925.352164] {5}[Hardware Error]: Program execution can be restarted reliably at the PC associated with the error.
[ 925.352546] {5}[Hardware Error]: participation type: Generic
[ 925.352801] {5}[Hardware Error]: address space: External Memory Access
[ 925.353071] {5}[Hardware Error]: Error info structure 4:
[ 925.353299] {5}[Hardware Error]: num errors: 1
[ 925.353502] {5}[Hardware Error]: first error captured
[ 925.353720] {5}[Hardware Error]: propagated error captured
[ 925.353963] {5}[Hardware Error]: error_type: 0x02: cache error
[ 925.354222] {5}[Hardware Error]: error_info: 0x000000000054007f
[ 925.354478] {5}[Hardware Error]: transaction type: Instruction
[ 925.354782] {5}[Hardware Error]: cache error, operation type: Instruction fetch
[ 925.355203] {5}[Hardware Error]: cache level: 1
[ 925.355495] {5}[Hardware Error]: processor context not corrupted
[ 925.355848] {5}[Hardware Error]: the error has not been corrected
[ 925.356206] {5}[Hardware Error]: PC is imprecise
[ 925.356493] {5}[Hardware Error]: Context info structure 0:
[ 925.356809] {5}[Hardware Error]: register context type: AArch64 EL1 context registers
[ 925.357282] {5}[Hardware Error]: 00000000: 0000dead 00000000 0000beef 00000000
[ 925.357800] {5}[Hardware Error]: 00000010: 0000abba 00000000 0000baab 00000000
[ 925.358267] {5}[Hardware Error]: 00000020: 00000000 00000000
[ 925.358523] {5}[Hardware Error]: Vendor specific error info has 8 bytes:
[ 925.358822] {5}[Hardware Error]: 00000000: 3435170c fff37b03 ..54.{..
[ 925.359192] [Firmware Warn]: GHES: Unhandled processor error type 0x1c: TLB error|bus error|micro-architectural error
[ 925.359590] [Firmware Warn]: GHES: Unhandled processor error type 0x10: micro-architectural error
[ 925.359935] [Firmware Warn]: GHES: Unhandled processor error type 0x04: TLB error
[ 925.360235] [Firmware Warn]: GHES: Unhandled processor error type 0x08: bus error
[ 925.360534] [Firmware Warn]: GHES: Unhandled processor error type 0x02: cache error---
v4:
- patches 4 and 7 folded;
- Several improvements at QAPI documentation: now, both man-page and html outputs look nicer and have tables to better define some fields;
- QAPI updates are now changed to QEMU version 9.2 and upper;
- Minor coding style improvements;
- added a MAINTAINERS entry for arm error inject;
- Generic Error Device notify callback renamed to generic_error_device_notify();
- GED patch description fixed;
- running_state/psci logic fixed.
v3:
- patch 1 cleanups with some comment changes and adding another place where the poweroff GPIO define should be used. No changes on other patches (except due to conflict resolution).
v2:
- added a new patch using a define for GPIO power pin;
- patch 2 changed to also use a define for generic error GPIO pin;
- a couple cleanups at patch 2 removing uneeded else clauses.
Jonathan Cameron (2):
arm/virt: Wire up GPIO error source for ACPI / GHES acpi/ghes: Support GPIO error source.
Mauro Carvalho Chehab (4):
arm/virt: place power button pin number on a define target/arm: preserve mpidr value
acpi/ghes: update comments to point to newer ACPI specs acpi/ghes: Add a logic to inject ARM processor CPER
MAINTAINERS | 7 + configs/targets/aarch64-softmmu.mak | 1 + hw/acpi/ghes.c | 339 +++++++++++++++++++--- hw/arm/Kconfig | 4 + hw/arm/arm_error_inject.c | 420 ++++++++++++++++++++++++++++ hw/arm/arm_error_inject_stubs.c | 34 +++ hw/arm/meson.build | 3 + hw/arm/virt-acpi-build.c | 34 ++- hw/arm/virt.c | 21 +- include/hw/acpi/ghes.h | 41 +++ include/hw/arm/virt.h | 4 + include/hw/boards.h | 1 + qapi/arm-error-inject.json | 284 +++++++++++++++++++ qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + target/arm/cpu.h | 1 + target/arm/helper.c | 10 +- 17 files changed, 1160 insertions(+), 46 deletions(-) create mode 100644 hw/arm/arm_error_inject.c create mode 100644 hw/arm/arm_error_inject_stubs.c create mode 100644 qapi/arm-error-inject.json
Signature · 1 line
2.45.2
Re: [PATCH v4 2/6] arm/virt: Wire up GPIO error source for ACPI / GHES
In reply to Mauro Carvalho ChehabQuoted 3 lines · On Mon, 29 Jul 2024 15:21:06 +0200 Mauro Carvalho Chehab…
From: Jonathan Cameron <[email protected]>
Creates a Generic Event Device (GED) as specified at
I wrote this a while back and wasn't aware of the naming mess around GED in the ACPI spec. This one is just referred to as 'error device' whereas there is also a Generic Event Device.
Linux solved this clash by going with Hardware Error Device I think we should do the same here.
Quoted 26 lines
ACPI 6.5 specification at 18.3.2.7.2:
https://uefi.org/specs/ACPI/6.5/18_Platform_Error_Interfaces.html#event-notification-for-generic-error-sources
with HID PNP0C33.The PNP0C33 device is used to report hardware errors to the bios via ACPI APEI Generic Hardware Error Source (GHES).
It is aligned with Linux Kernel patch:
https://lore.kernel.org/lkml/[email protected]/[mchehab: use a define for the generic event pin number and do some cleanups]Signed-off-by Jonathan Cameron <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>--- hw/arm/virt-acpi-build.c | 30 ++++++++++++++++++++++++++---- hw/arm/virt.c | 14 ++++++++++++-- include/hw/arm/virt.h | 1 + include/hw/boards.h | 1 + 4 files changed, 40 insertions(+), 6 deletions(-)hw/arm/virt-acpi-build.c +0
-0
hw/arm/virt-acpi-build.c line 66
Quoted 4 lines
hw/arm/virt-acpi-build.c +1
-0@@ -63,6 +63,7 @@#define ARM_SPI_BASE 32 +#define ACPI_GENERIC_EVENT_DEVICE "GEDD"
Ah. My mistake. This is the confusing named GENERIC_ERROR_DEVICE or HARDWARE_ERROR_DEVICE (which is what Linux called it because in the ACPI Spec it is just (all lower case) error device).
Quoted 6 lines
hw/arm/virt-acpi-build.c +0
-0#define ACPI_BUILD_TABLE_SIZE 0x20000/* DSDT */ static void
build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
hw/arm/virt-acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 868
Quoted 9 lines
hw/arm/virt-acpi-build.c +2
-3@@ -841,10 +863,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)HOTPLUG_HANDLER (vms->acpi_dev), irqmap[VIRT_ACPI_GED ] +ARM_SPI_BASE ,AML_SYSTEM_MEMORY , memmap[VIRT_ACPI_GED].base); - }else { -acpi_dsdt_add_gpio (scope, &memmap[VIRT_GPIO ], - (irqmap[VIRT_GPIO ] +ARM_SPI_BASE )); } +acpi_dsdt_add_gpio (scope, &memmap[VIRT_GPIO ], + (irqmap[VIRT_GPIO ] +ARM_SPI_BASE ));
Arguably excess brackets, but obviously this is just a code move so fine to keep it the same.
Quoted 11 lines
hw/arm/virt-acpi-build.c +1
-0if (vms->acpi_dev) { uint32_t event = object_property_get_uint(OBJECT(vms->acpi_dev),@@ -858,6 +879,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) }acpi_dsdt_add_power_button (scope); +acpi_dsdt_add_generic_event_device (scope);#ifdef CONFIG_TPM acpi_dsdt_add_tpm (scope, vms);#endif
Re: [PATCH v4 6/6] acpi/ghes: Add a logic to inject ARM processor CPER
In reply to Mauro Carvalho ChehabQuoted 40 lines · On Mon, 29 Jul 2024 15:21:10 +0200 Mauro Carvalho Chehab…
Add an ACPI APEI GHES error injection logic for ARM processor CPER, allowing to set fields at from UEFI spec 2.10 tables N.16 and N.17 to any valid value.
As some GHES functions require handling addresses, add a helper function to support it.
Before starting erorr inject, the QAPI requires to negociate QMP with:
{ "execute": "
qmp_capabilities" }Afterwards, errors can be injected with:
{ "execute": "arm-inject-error" }The error injection events supports several optional arguments, having Processor Error Information (PEI) mapped into an array.
So, it is possible to inject multiple errors at the same CPER record, as defined at UEFI spec, with:
{ "execute": "arm-inject-error", "arguments": { "error": [ {"type": [ "cache-error" ]}, {"type": [ "tlb-error" ]} ] } }The above generates a single CPER record with two PEI info, one reporting a cache error, and the other one a TLB error, using default values for other fields.
As all fields from ARM Processor CPER are mapped, so, the error could contain physical/virtual addresses, register dumps, vendor-specific data, etc.
This patch is co-authored:
- ghes logic to inject a simple ARM record by Shiju Jose;
- generic logic to handle block addresses by Jonathan Cameron;
- logic to allow changing all fields by Mauro Carvalho Chehab;
Quoted 6 lines
Co-authored-by Jonathan Cameron <[email protected]>Co-authored-by Shiju Jose <[email protected]>Co-authored-by Mauro Carvalho Chehab <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>Signed-off-by Shiju Jose <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>
A few minor comments inline.
This crossed (I think) with a reply from Markus though so there are some other bits to address from that.
Jonathan
Quoted 39 lines
configs/targets/aarch64-softmmu.mak +1
-0@@ -5,3 +5,4 @@ TARGET_KVM_HAVE_GUEST_DEBUG=y TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml gdb-xml/arm-core.xml gdb-xml/arm-vfp.xml gdb-xml/arm-vfp3.xml gdb-xml/arm-vfp-sysregs.xml gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml gdb-xml/arm-m-profile-mve.xml gdb-xml/aarch64-pauth.xml # needed by boot.c TARGET_NEED_FDT=y +CONFIG_ARM_EINJ=yhw/acpi/ghes.c +8
-0@@ -27,6 +27,7 @@#include "hw/acpi/generic_event_device.h" #include "hw/nvram/fw_cfg.h" #include "qemu/uuid.h" +#include "qapi/qapi-types-arm-error-inject.h" #define ACPI_GHES_ERRORS_FW_CFG_FILE "etc/hardware_errors"#define ACPI_GHES_DATA_ADDR_FW_CFG_FILE "etc/hardware_errors_addr"@@ -53,6 +54,12 @@/* The memory section CPER size, UEFI 2.6: N.2.5 Memory Error Section */ #define ACPI_GHES_MEM_CPER_LENGTH 80 +/* +* ARM Processor error section CPER sizes - UEFI 2.10: N.2.4.4 +*/ +#define ACPI_GHES_ARM_CPER_LENGTH 40 +#define ACPI_GHES_ARM_CPER_PEI_LENGTH 32 +/* Masks for block_status flags */ #define ACPI_GEBS_UNCORRECTABLE 1@@ -234,6 +241,152 @@ static int acpi_ghes_record_mem_error(uint64_t error_block_address,return 0 ; } +/* UEFI 2.9: N.2.4.4 ARM Processor Error Section */
hw/acpi/ghes.c static int acpi_ghes_record_mem_error(uint64_t error_block_address, · line 254
Quoted 10 lines
hw/acpi/ghes.c +10
-0+static void acpi_ghes_build_append_arm_cper (ArmError err,uint32_t cper_length, +GArray *table) +{ +unsigned int i, j; + +/* +* ARM Processor Error Record +*/ + +/* Validation Bits */
Given nice naming, maybe drop the comments where the field name makes it obvious?
Quoted 80 lines
hw/acpi/ghes.c +80
-0+build_append_int_noprefix (table, err.validation,4 ); + +/* Error Info Num */ +build_append_int_noprefix (table, err.err_info_num,2 ); + +/* Context Info Num */ +build_append_int_noprefix (table, err.context_info_num,2 ); + +/* Section length */ +build_append_int_noprefix (table, cper_length,4 ); + +/* Error affinity level */ +build_append_int_noprefix (table, err.affinity_level,1 ); + +/* Reserved */ +build_append_int_noprefix (table,0 ,3 ); + +/* MPIDR_EL1 */ +build_append_int_noprefix (table, err.mpidr_el1,8 ); + +/* MIDR_EL1 */ +build_append_int_noprefix (table, err.midr_el1,8 ); + +/* Running state */ +build_append_int_noprefix (table, err.running_state,4 ); + +/* PSCI state: only valid when running state is zero */ +build_append_int_noprefix (table, err.psci_state,4 ); + +for (i =0 ; i < err.err_info_num; i++) { +/* ARM Propcessor error information */ +/* Version */ +build_append_int_noprefix (table,0 ,1 ); + +/* Length */ +build_append_int_noprefix (table,ACPI_GHES_ARM_CPER_PEI_LENGTH ,1 ); + +/* Validation Bits */ +build_append_int_noprefix (table, err.pei[i].validation,2 ); + +/* Type */ +build_append_int_noprefix (table, err.pei[i].type,1 ); + +/* Multiple error count */ +build_append_int_noprefix (table, err.pei[i].multiple_error,2 ); + +/* Flags */ +build_append_int_noprefix (table, err.pei[i].flags,1 ); + +/* Error information */ +build_append_int_noprefix (table, err.pei[i].error_info,8 ); + +/* Virtual fault address */ +build_append_int_noprefix (table, err.pei[i].virt_addr,8 ); + +/* Physical fault address */ +build_append_int_noprefix (table, err.pei[i].phy_addr,8 ); + } + +for (i =0 ; i < err.context_info_num; i++) { +/* ARM Propcessor error context information */ +/* Version */ +build_append_int_noprefix (table,0 ,2 ); + +/* Validation type */ +build_append_int_noprefix (table, err.context[i].type,2 ); + +/* Register array size */ +build_append_int_noprefix (table, err.context[i].size *8 ,4 ); + +/* Register array (byte 8 of Context info) */ +for (j =0 ; j < err.context[i].size; j++) { +build_append_int_noprefix (table, err.context[i].array[j],8 ); + } + } + +for (i =0 ; i < err.vendor_num; i++) { +build_append_int_noprefix (table, err.vendor[i],1 ); + } +}
...
Quoted 45 lines
hw/arm/arm_error_inject.c new file +38
-0@@ -0,0 +1,420 @@ +/* +* ARM Processor error injection +* +* Copyright(C) 2024 Huawei LTD. +* +* This code is licensed under the GPL version 2 or later. See the +* COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/boards.h" +#include "hw/acpi/ghes.h" +#include "cpu.h" + +#define ACPI_GHES_ARM_CPER_CTX_DEFAULT_NREGS 74 + +/* Handle ARM Processor Error Information (PEI) */ +static const ArmProcessorErrorInformationList *default_pei = {0 }; + +static ArmPEI *qmp_arm_pei (uint16_t *err_info_num, +bool has_error, +ArmProcessorErrorInformationList const *error_list) +{ +ArmProcessorErrorInformationList const *next; +ArmPeiValidationBitsList const *validation_list; +ArmPEI *pei =NULL ; +uint16_t i; + +if (!has_error) { + error_list = default_pei; + } + + *err_info_num =0 ; + +for (next = error_list; next; next = next->next) { + (*err_info_num)++;
hw/arm/arm_error_inject.c line 48
Quoted 10 lines
hw/arm/arm_error_inject.c new file +10
-0+ +if (*err_info_num >=255 ) { +break ; + } + } + + pei =g_new0 (ArmPEI, (*err_info_num)); + +for (next = error_list, i =0 ; + i < *err_info_num; i++, next = next->next) {
Odd alignment.
Quoted 21 lines
hw/arm/arm_error_inject.c new file +21
-0+/* For ARM processor errors */ +void qmp_arm_inject_error (bool has_validation, +ArmProcessorValidationBitsList *validation_list, +bool has_affinity_level, +uint8_t affinity_level, +bool has_mpidr_el1, +uint64_t mpidr_el1, +bool has_midr_el1, +uint64_t midr_el1, +bool has_running_state, +ArmProcessorRunningStateList *running_state_list, +bool has_psci_state, +uint32_t psci_state, +bool has_context, +ArmProcessorContextList *context_list, +bool has_vendor_specific, +uint8List *vendor_specific_list, +bool has_error, +ArmProcessorErrorInformationList *error_list, +Error **errp) +{
...
hw/arm/arm_error_inject.c line 410
Quoted 2 lines
hw/arm/arm_error_inject.c new file +2
-0+ +if (error.context) {
No need for check. If context_info_num is zero their won't be a loop iteration.
Quoted 40 lines
hw/arm/arm_error_inject.c new file +10
-0+for (i =0 ; i < error.context_info_num; i++) { +g_free (error.context[i].array); + } + } +g_free (error.context); +g_free (error.pei); +g_free (error.vendor); + +return ; +}hw/arm/arm_error_inject_stubs.c new file +24
-0@@ -0,0 +1,34 @@ +/* +* QMP stub for ARM processor error injection. +* +* Copyright(C) 2024 Huawei LTD. +* +* This code is licensed under the GPL version 2 or later. See the +* COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/acpi/ghes.h" + +void qmp_arm_inject_error(bool has_validation, + ArmProcessorValidationBitsList *validation, + bool has_affinity_level, + uint8_t affinity_level, + bool has_mpidr_el1, + uint64_t mpidr_el1, + bool has_midr_el1, + uint64_t midr_el1, + bool has_running_state, + ArmProcessorRunningStateList *running_state,
hw/arm/arm_error_inject_stubs.c line 34
Quoted 10 lines
hw/arm/arm_error_inject_stubs.c new file +10
-0+ bool has_psci_state, + uint32_t psci_state, + bool has_context, ArmProcessorContextList *context, + bool has_vendor_specific, uint8List *vendor_specific, + bool has_error, + ArmProcessorErrorInformationList *error, + Error **errp) +{ + error_setg(errp, "ARM processor error support is not compiled in"); +}
Markus suggested:
Quoted 9 lines
A target-specific command like this one should be conditional. Try this:
{ 'command': 'arm-inject-error', 'data': { 'errortypes': ['ArmProcessorErrorType'] }, 'features': [ 'unstable' ], 'if': 'TARGET_ARM' }No need to provide a
qmp_arm_inject_error()stub then.
(I noticed because never knew you could do this.)
Probably crossed with your v4 posting.
Quoted 4 lines
include/hw/acpi/ghes.h +0
-0
...
include/hw/acpi/ghes.h typedef struct AcpiGhesState { · line 98
Quoted 11 lines
include/hw/acpi/ghes.h +11
-0+/* ARM processor - UEFI 2.10 table N.16 */ +typedef struct ArmError { + uint16_t validation; + + uint8_t affinity_level; + uint64_t mpidr_el1; + uint64_t midr_el1; + uint32_t running_state; + uint32_t psci_state; + + /* Those are calculated based on the input data */
/* Calculated based on the input data */
Quoted 9 lines
include/hw/acpi/ghes.h +9
-0+uint16_t err_info_num; +uint16_t context_info_num; +uint32_t vendor_num; +uint32_t context_length; + +ArmPEI *pei; +ArmContext *context; +uint8_t *vendor; +} ArmError;
Re: [PATCH v4 2/6] arm/virt: Wire up GPIO error source for ACPI / GHES
In reply to Jonathan CameronEm Mon, 29 Jul 2024 17:08:40 +0100
Jonathan Cameron <[email protected]> escreveu:
Quoted 7 lines
Quoted 3 lines · On Mon, 29 Jul 2024 15:21:06 +0200 Mauro Carvalho Chehab…
From: Jonathan Cameron <[email protected]>
Creates a Generic Event Device (GED) as specified at
Quoted 7 lines
I wrote this a while back and wasn't aware of the naming mess around GED in the ACPI spec. This one is just referred to as 'error device' whereas there is also a Generic Event Device.
Linux solved this clash by going with Hardware Error Device I think we should do the same here.
I opted to do it a little bit different to stay closer to ACPI 6.5 18.3.2.7.2. - Event Notification For Generic Error Sources.
There, it is actually talking about a General Purpose Event (GPE). Current ACPI spec doesn't mention "GED", so maybe such term was fixed on some previous ACPI spec revision.
Basically, it currently mentions:
- error device
- GPE / General Purpose Event
- Generic Hardware Error Source Structure
I guess Linux crafted the term Hardware Error device by mixing those.
As we don't need to really preserve such names here, as this appears only at the patch description, I opted to rewrite the patch description to:
arm/virt: Wire up GPIO error source for ACPI / GHES
Creates a hardware event device to support General Purpose Event (GPE) as specified at ACPI 6.5 specification at 18.3.2.7.2:
https://uefi.org/specs/ACPI/6.5/18_Platform_Error_Interfaces.html#event-notification-for-generic-error-sources
using HID PNP0C33.
The PNP0C33 device is used to report hardware errors to the bios via ACPI APEI Generic Hardware Error Source (GHES).
It is aligned with Linux Kernel patch:
https://lore.kernel.org/lkml/[email protected]/
Clearly associating "hardware event device" with ACPI GPE. That sounds good enough to be stored at the git description associated with such change.
Quoted 27 lines
Quoted 27 lines
ACPI 6.5 specification at 18.3.2.7.2:
https://uefi.org/specs/ACPI/6.5/18_Platform_Error_Interfaces.html#event-notification-for-generic-error-sources
with HID PNP0C33.The PNP0C33 device is used to report hardware errors to the bios via ACPI APEI Generic Hardware Error Source (GHES).
It is aligned with Linux Kernel patch:
https://lore.kernel.org/lkml/[email protected]/[mchehab: use a define for the generic event pin number and do some cleanups]Signed-off-by Jonathan Cameron <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>--- hw/arm/virt-acpi-build.c | 30 ++++++++++++++++++++++++++---- hw/arm/virt.c | 14 ++++++++++++-- include/hw/arm/virt.h | 1 + include/hw/boards.h | 1 + 4 files changed, 40 insertions(+), 6 deletions(-)hw/arm/virt-acpi-build.c +0
-0@@ -63,6 +63,7 @@
Quoted 7 lines
hw/arm/virt-acpi-build.c line 66
Quoted 3 lines
hw/arm/virt-acpi-build.c +1
-0#define ARM_SPI_BASE 32 +#define ACPI_GENERIC_EVENT_DEVICE "GEDD"Ah. My mistake. This is the confusing named
GENERIC_ERROR_DEVICEorHARDWARE_ERROR_DEVICE(which is what Linux called it because in the ACPI Spec it is just (all lower case) error device).
I opted to use a different name there, using just error device, together with the name of the PNP device. So:
#define PNP0C33_ERROR_DEVICE "GEDD"
This is clear enough for people just looking at the driver, and even clearer for people familiar with session 18.3.2.7.2 of the ACPI spec.
Quoted 19 lines
Quoted 7 lines
hw/arm/virt-acpi-build.c +0
-0#define ACPI_BUILD_TABLE_SIZE 0x20000/* DSDT */ static void
build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)hw/arm/virt-acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 868
Quoted 9 lines
hw/arm/virt-acpi-build.c +2
-3@@ -841,10 +863,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)HOTPLUG_HANDLER (vms->acpi_dev), irqmap[VIRT_ACPI_GED ] +ARM_SPI_BASE ,AML_SYSTEM_MEMORY , memmap[VIRT_ACPI_GED].base); - }else { -acpi_dsdt_add_gpio (scope, &memmap[VIRT_GPIO ], - (irqmap[VIRT_GPIO ] +ARM_SPI_BASE )); } +acpi_dsdt_add_gpio (scope, &memmap[VIRT_GPIO ], + (irqmap[VIRT_GPIO ] +ARM_SPI_BASE ));Arguably excess brackets, but obviously this is just a code move so fine to keep it the same.
I'll drop the extra brackets.
Quoted 9 lines
hw/arm/virt-acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 883
Quoted 9 lines
hw/arm/virt-acpi-build.c +1
-0if (vms->acpi_dev) { uint32_t event = object_property_get_uint(OBJECT(vms->acpi_dev),@@ -858,6 +879,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) }acpi_dsdt_add_power_button (scope); +acpi_dsdt_add_generic_event_device (scope);
I'm also renaming this function/function call to run away from GED, calling it as:
acpi_dsdt_add_error_device(scope);
Quoted 4 lines
Quoted 3 lines
hw/arm/virt-acpi-build.c +0
-0#ifdef CONFIG_TPM acpi_dsdt_add_tpm (scope, vms);#endif
Thanks,
Mauro
Re: [PATCH v4 6/6] acpi/ghes: Add a logic to inject ARM processor CPER
In reply to Jonathan CameronEm Mon, 29 Jul 2024 17:31:09 +0100
Jonathan Cameron <[email protected]> escreveu:
Quoted 2 lines
On Mon, 29 Jul 2024 15:21:10 +0200
Mauro Carvalho Chehab <[email protected]> wrote:
...
Quoted 10 lines
Markus suggested:
Quoted 8 lines
A target-specific command like this one should be conditional. Try this:
{ 'command': 'arm-inject-error', 'data': { 'errortypes': ['ArmProcessorErrorType'] }, 'features': [ 'unstable' ], 'if': 'TARGET_ARM' }
Quoted 5 lines
Quoted 1 line
No need to provide a
qmp_arm_inject_error()stub then.(I noticed because never knew you could do this.)
Probably crossed with your v4 posting.
Tried it, but can't figure out how to properly set it up at meson.build, as it is basically producing build time errors during qapi file generation on non-ARM platforms. For instance:
FAILED: libqemuutil.a.p/meson-generated_.._qapi_qapi-visit-arm-error-inject.c.o
cc -m64 -Ilibqemuutil.a.p -I. -I.. -Isubprojects/libvhost-user -I../subprojects/libvhost-user -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/sysprof-6 -I/usr/include/gio-unix-2.0 -I/usr/include/p11-kit-1 -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g -fstack-protector-strong -Wempty-body -Wendif-labels -Wexpansion-to-defined -Wformat-security -Wformat-y2k -Wignored-qualifiers -Wimplicit-fallthrough=2 -Winit-self -Wmissing-format-attribute -Wmissing-prototypes -Wnested-externs -Wold-style-declaration -Wold-style-definition -Wredundant-decls -Wshadow=local -Wstrict-prototypes -Wtype-limits -Wundef -Wvla -Wwrite-strings -Wno-missing-include-dirs -Wno-psabi -Wno-shift-negative-value -isystem /new_devel/edac/qemu/linux-headers -isystem linux-headers -iquote . -iquote /new_devel/edac/qemu -iquote /new_devel/edac/qemu/include -iquote /new_devel/edac/qemu/host/include/x86_64 -iquote /new_devel/edac/qemu/host/include/generic -iquote /new_devel/edac/qemu/tcg/i386 -pthread -msse2 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -ftrivial-auto-var-init=zero -fzero-call-used-regs=used-gpr -fPIE -DWITH_GZFILEOP -MD -MQ libqemuutil.a.p/meson-generated_.._qapi_qapi-visit-arm-error-inject.c.o -MF libqemuutil.a.p/meson-generated_.._qapi_qapi-visit-arm-error-inject.c.o.d -o libqemuutil.a.p/meson-generated_.._qapi_qapi-visit-arm-error-inject.c.o -c qapi/qapi-visit-arm-error-inject.c In file included from qapi/qapi-visit-arm-error-inject.h:17,
from qapi/qapi-visit-arm-error-inject.c:15:qapi/qapi-types-arm-error-inject.h:18:13: error: attempt to use poisoned "TARGET_ARM"
18 | #if defined(TARGET_ARM)
| ^
In file included from /new_devel/edac/qemu/include/exec/poison.h:7,
from /new_devel/edac/qemu/include/qemu/osdep.h:38,
from qapi/qapi-visit-arm-error-inject.c:13:
./config-poison.h:718:20: note: poisoned here
Such error is created by two files generated from qapi, due to this change:
diff --git a/qapi/meson.build b/qapi/meson.build index e7bc54e5d047..5927932c4be3 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -24,2 +24,3 @@ endif qapi_all_modules = [ + 'arm-error-inject', 'authz',
No idea how to fix it.
Thanks,
Mauro
Re: [PATCH v4 2/6] arm/virt: Wire up GPIO error source for ACPI / GHES
In reply to Mauro Carvalho ChehabHi Mauro,
Quoted 27 lines · Mauro Carvalho Chehab
Date: Mon, 29 Jul 2024 15:21:06 +0200
From: Mauro Carvalho Chehab <[email protected]>
Subject: [PATCH v4 2/6] arm/virt: Wire up GPIO error source for ACPI / GHES
X-Mailer: git-send-email 2.45.2From: Jonathan Cameron <[email protected]>
Creates a Generic Event Device (GED) as specified at ACPI 6.5 specification at 18.3.2.7.2:
https://uefi.org/specs/ACPI/6.5/18_Platform_Error_Interfaces.html#event-notification-for-generic-error-sources
with HID PNP0C33.The PNP0C33 device is used to report hardware errors to the bios via ACPI APEI Generic Hardware Error Source (GHES).
It is aligned with Linux Kernel patch:
https://lore.kernel.org/lkml/[email protected]/[mchehab: use a define for the generic event pin number and do some cleanups]Signed-off-by Jonathan Cameron <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>--- hw/arm/virt-acpi-build.c | 30 ++++++++++++++++++++++++++---- hw/arm/virt.c | 14 ++++++++++++-- include/hw/arm/virt.h | 1 + include/hw/boards.h | 1 + 4 files changed, 40 insertions(+), 6 deletions(-)
[snip]
Quoted 5 lines
hw/arm/virt.c +5
-0+static void virt_set_error (void ) +{ +qemu_set_irq (qdev_get_gpio_in (gpio_error_dev,0 ),1 ); +} +
[snip]
Quoted 1 line
+
mc->generic_error_device_notify=virt_set_error;
[snip]
include/hw/boards.h struct MachineClass { · line 311
Quoted 9 lines
include/hw/boards.h +1
-0@@ -308,6 +308,7 @@ struct MachineClass {int64_t (*get_default_cpu_node_id)(const MachineState *ms,int idx);ram_addr_t (*fixup_ram_size)(ram_addr_t size);uint64_t smbios_memory_device_size; +void (*generic_error_device_notify)(void );
The name looks inconsistent with the style of other MachineClass virtual methods. What about the name like "notify_xxx"? And pls add the comment about this new method.
BTW, I found this method is called in generic_error_device_notify() of Patch 6. And the mc->generic_error_device_notify() - as the virtual metchod of MachineClass looks just to implement a hook, and it doesn't seem to have anything to do with MachineClass/MachineState, so my question is why do we need to add this method to MachineClass?
Could we maintain a notifier list in ghes.c and expose an interface to allow arm code register a notifier? This eliminates the need to add the “notify” method to MachineClass.
Regards,
Zhao
Re: [PATCH v4 2/6] arm/virt: Wire up GPIO error source for ACPI / GHES
In reply to Mauro Carvalho ChehabQuoted 50 lines · On Tue, 30 Jul 2024 07:13:30 +0200 Mauro Carvalho Chehab…
Em Mon, 29 Jul 2024 17:08:40 +0100
Jonathan Cameron <[email protected]> escreveu:Quoted 7 lines
Quoted 3 lines · On Mon, 29 Jul 2024 15:21:06 +0200 Mauro Carvalho Chehab…
From: Jonathan Cameron <[email protected]>
Creates a Generic Event Device (GED) as specified at
Quoted 7 lines
I wrote this a while back and wasn't aware of the naming mess around GED in the ACPI spec. This one is just referred to as 'error device' whereas there is also a Generic Event Device.
Linux solved this clash by going with Hardware Error Device I think we should do the same here.
I opted to do it a little bit different to stay closer to ACPI 6.5 18.3.2.7.2. - Event Notification For Generic Error Sources.
There, it is actually talking about a General Purpose Event (GPE). Current ACPI spec doesn't mention "GED", so maybe such term was fixed on some previous ACPI spec revision.
Basically, it currently mentions:
- error device
- GPE / General Purpose Event
- Generic Hardware Error Source StructureI guess Linux crafted the term Hardware Error device by mixing those.
As we don't need to really preserve such names here, as this appears only at the patch description, I opted to rewrite the patch description to:
arm/virt: Wire up GPIO error source for ACPI / GHES
Creates a hardware event device to support General Purpose Event (GPE) as specified at ACPI 6.5 specification at 18.3.2.7.2:
https://uefi.org/specs/ACPI/6.5/18_Platform_Error_Interfaces.html#event-notification-for-generic-error-sources
using HID PNP0C33.The PNP0C33 device is used to report hardware errors to the bios via ACPI APEI Generic Hardware Error Source (GHES).
It is aligned with Linux Kernel patch:
https://lore.kernel.org/lkml/[email protected]/
Quoted 7 lines
[mchehab: use a define for the generic event pin number and do some cleanups]Signed-off-by Jonathan Cameron <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>Clearly associating "hardware event device" with ACPI GPE. That sounds good enough to be stored at the git description associated with such change.
All looks good to me.
Thanks,
Jonathan
Quoted 89 lines
Quoted 28 lines
Quoted 28 lines
ACPI 6.5 specification at 18.3.2.7.2:
https://uefi.org/specs/ACPI/6.5/18_Platform_Error_Interfaces.html#event-notification-for-generic-error-sources
with HID PNP0C33.The PNP0C33 device is used to report hardware errors to the bios via ACPI APEI Generic Hardware Error Source (GHES).
It is aligned with Linux Kernel patch:
https://lore.kernel.org/lkml/[email protected]/[mchehab: use a define for the generic event pin number and do some cleanups]Signed-off-by Jonathan Cameron <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>--- hw/arm/virt-acpi-build.c | 30 ++++++++++++++++++++++++++---- hw/arm/virt.c | 14 ++++++++++++-- include/hw/arm/virt.h | 1 + include/hw/boards.h | 1 + 4 files changed, 40 insertions(+), 6 deletions(-)hw/arm/virt-acpi-build.c +0
-0@@ -63,6 +63,7 @@Quoted 7 lines
hw/arm/virt-acpi-build.c line 66
Quoted 3 lines
hw/arm/virt-acpi-build.c +1
-0#define ARM_SPI_BASE 32 +#define ACPI_GENERIC_EVENT_DEVICE "GEDD"Ah. My mistake. This is the confusing named
GENERIC_ERROR_DEVICEorHARDWARE_ERROR_DEVICE(which is what Linux called it because in the ACPI Spec it is just (all lower case) error device).I opted to use a different name there, using just error device, together with the name of the PNP device. So:
#define PNP0C33_ERROR_DEVICE "GEDD"This is clear enough for people just looking at the driver, and even clearer for people familiar with session 18.3.2.7.2 of the ACPI spec.
Quoted 19 lines
Quoted 7 lines
hw/arm/virt-acpi-build.c +0
-0#define ACPI_BUILD_TABLE_SIZE 0x20000/* DSDT */ static void
build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)hw/arm/virt-acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 868
Quoted 9 lines
hw/arm/virt-acpi-build.c +2
-3@@ -841,10 +863,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)HOTPLUG_HANDLER (vms->acpi_dev), irqmap[VIRT_ACPI_GED ] +ARM_SPI_BASE ,AML_SYSTEM_MEMORY , memmap[VIRT_ACPI_GED].base); - }else { -acpi_dsdt_add_gpio (scope, &memmap[VIRT_GPIO ], - (irqmap[VIRT_GPIO ] +ARM_SPI_BASE )); } +acpi_dsdt_add_gpio (scope, &memmap[VIRT_GPIO ], + (irqmap[VIRT_GPIO ] +ARM_SPI_BASE ));Arguably excess brackets, but obviously this is just a code move so fine to keep it the same.
I'll drop the extra brackets.
Quoted 9 lines
hw/arm/virt-acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 883
Quoted 9 lines
hw/arm/virt-acpi-build.c +1
-0if (vms->acpi_dev) { uint32_t event = object_property_get_uint(OBJECT(vms->acpi_dev),@@ -858,6 +879,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) }acpi_dsdt_add_power_button (scope); +acpi_dsdt_add_generic_event_device (scope);I'm also renaming this function/function call to run away from GED, calling it as:
acpi_dsdt_add_error_device(scope);Quoted 4 lines
Quoted 3 lines
hw/arm/virt-acpi-build.c +0
-0#ifdef CONFIG_TPM acpi_dsdt_add_tpm (scope, vms);#endif
Thanks,
Mauro
Re: [PATCH v4 2/6] arm/virt: Wire up GPIO error source for ACPI / GHES
In reply to Zhao LiuEm Tue, 30 Jul 2024 16:11:42 +0800
Zhao Liu <[email protected]> escreveu:
Quoted 65 lines
Hi Mauro,
Quoted 27 lines · Mauro Carvalho Chehab
Date: Mon, 29 Jul 2024 15:21:06 +0200
From: Mauro Carvalho Chehab <[email protected]>
Subject: [PATCH v4 2/6] arm/virt: Wire up GPIO error source for ACPI / GHES
X-Mailer: git-send-email 2.45.2From: Jonathan Cameron <[email protected]>
Creates a Generic Event Device (GED) as specified at ACPI 6.5 specification at 18.3.2.7.2:
https://uefi.org/specs/ACPI/6.5/18_Platform_Error_Interfaces.html#event-notification-for-generic-error-sources
with HID PNP0C33.The PNP0C33 device is used to report hardware errors to the bios via ACPI APEI Generic Hardware Error Source (GHES).
It is aligned with Linux Kernel patch:
https://lore.kernel.org/lkml/[email protected]/[mchehab: use a define for the generic event pin number and do some cleanups]Signed-off-by Jonathan Cameron <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>--- hw/arm/virt-acpi-build.c | 30 ++++++++++++++++++++++++++---- hw/arm/virt.c | 14 ++++++++++++-- include/hw/arm/virt.h | 1 + include/hw/boards.h | 1 + 4 files changed, 40 insertions(+), 6 deletions(-)[snip]
Quoted 5 lines
hw/arm/virt.c +5
-0+static void virt_set_error (void ) +{ +qemu_set_irq (qdev_get_gpio_in (gpio_error_dev,0 ),1 ); +} +[snip]
Quoted 1 line
+
mc->generic_error_device_notify=virt_set_error;[snip]
include/hw/boards.h struct MachineClass { · line 311
Quoted 9 lines
include/hw/boards.h +1
-0@@ -308,6 +308,7 @@ struct MachineClass {int64_t (*get_default_cpu_node_id)(const MachineState *ms,int idx);ram_addr_t (*fixup_ram_size)(ram_addr_t size);uint64_t smbios_memory_device_size; +void (*generic_error_device_notify)(void );The name looks inconsistent with the style of other MachineClass virtual methods. What about the name like "
notify_xxx"? And pls add the comment about this new method.BTW, I found this method is called in
generic_error_device_notify()of Patch 6. And themc->generic_error_device_notify()- as the virtual metchod of MachineClass looks just to implement a hook, and it doesn't seem to have anything to do with MachineClass/MachineState, so my question is why do we need to add this method to MachineClass?
Quoted 3 lines
Could we maintain a notifier list in
ghes.cand expose an interface to allow arm code register a notifier? This eliminates the need to add the “notify” method to MachineClass.
Makes sense. I'll change the logic to use this notifier list code inside ghes.c, and drop generic_error_device_notify():
NotifierList generic_error_notifiers =
NOTIFIER_LIST_INITIALIZER(error_device_notifiers);
/* Notify BIOS about an error via Generic Error Device - GED */
static void generic_error_device_notify(void)
{
notifier_list_notify(&generic_error_notifiers, NULL);
}Regards,
Mauro
Re: [PATCH v4 6/6] acpi/ghes: Add a logic to inject ARM processor CPER
In reply to Mauro Carvalho ChehabQuoted 29 lines · Mauro Carvalho Chehab
Em Mon, 29 Jul 2024 17:31:09 +0100
Jonathan Cameron <[email protected]> escreveu:Quoted 2 lines
On Mon, 29 Jul 2024 15:21:10 +0200
Mauro Carvalho Chehab <[email protected]> wrote:...
Quoted 10 lines
Markus suggested:
Quoted 8 lines
A target-specific command like this one should be conditional. Try this:
{ 'command': 'arm-inject-error', 'data': { 'errortypes': ['ArmProcessorErrorType'] }, 'features': [ 'unstable' ], 'if': 'TARGET_ARM' }Quoted 5 lines
Quoted 1 line
No need to provide a
qmp_arm_inject_error()stub then.(I noticed because never knew you could do this.)
Probably crossed with your v4 posting.
Tried it, but can't figure out how to properly set it up at meson.build, as it is basically producing build time errors during qapi file generation on non-ARM platforms. For instance:
FAILED:
libqemuutil.a.p/meson-generated_.._qapi_qapi-visit-arm-error-inject.c.o
[...]
Quoted 22 lines
In file included from
qapi/qapi-visit-arm-error-inject.h:17,
fromqapi/qapi-visit-arm-error-inject.c:15:qapi/qapi-types-arm-error-inject.h:18:13: error: attempt to use poisoned "TARGET_ARM"
18 | #ifdefined(TARGET_ARM)
| ^
In file included from /new_devel/edac/qemu/include/exec/poison.h:7,
from /new_devel/edac/qemu/include/qemu/osdep.h:38, fromqapi/qapi-visit-arm-error-inject.c:13:
./config-poison.h:718:20: note: poisoned hereSuch error is created by two files generated from qapi, due to this change:
diff --git a/qapi/meson.build b/qapi/meson.build index e7bc54e5d047..5927932c4be3 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -24,2 +24,3 @@ endif qapi_all_modules = [ + 'arm-error-inject', 'authz',
Quoted 1 line
No idea how to fix it.
Uh, I neglected to point out an important detail. Sorry about that!
The 'if' condition uses a symbol that is poisoned in target-independent compiles. Such conditions work only in target modules. By convention, these are named FOO-target.json.
So, you can either change new module's filename to end in -target.json, or you stick the command into one of the two existing target modules, machine-target.json and misc-target.json.
Speaking of modules: i'm not sure dedicating a module just to ARM error injection is a good idea. Perhaps we could have arm-target.json for things that will only ever make sense on ARM. Same for other targets.
But I recommend to first reach consensus on Igor's objection in review of v3:
Message-ID: <[email protected]> https://lore.kernel.org/qemu-devel/[email protected]/
Re: [PATCH v4 2/6] arm/virt: Wire up GPIO error source for ACPI / GHES
In reply to Mauro Carvalho ChehabOn Wed, Jul 31, 2024 at 07:21:58AM +0200, Mauro Carvalho Chehab wrote:
[snip]
Quoted 17 lines
Quoted 10 lines
The name looks inconsistent with the style of other MachineClass virtual methods. What about the name like "
notify_xxx"? And pls add the comment about this new method.BTW, I found this method is called in
generic_error_device_notify()of Patch 6. And themc->generic_error_device_notify()- as the virtual metchod of MachineClass looks just to implement a hook, and it doesn't seem to have anything to do with MachineClass/MachineState, so my question is why do we need to add this method to MachineClass?Quoted 3 lines
Could we maintain a notifier list in
ghes.cand expose an interface to allow arm code register a notifier? This eliminates the need to add the “notify” method to MachineClass.Makes sense. I'll change the logic to use this notifier list code inside
ghes.c, and dropgeneric_error_device_notify():
Quoted 8 lines
NotifierList generic_error_notifiers =
NOTIFIER_LIST_INITIALIZER(error_device_notifiers);
/* Notify BIOS about an error via Generic Error Device - GED */
static void generic_error_device_notify(void)
{
notifier_list_notify(&generic_error_notifiers, NULL);
}Fine for me.
Regards,
Zhao