Skip to contentSkip to conversation

hw/arm: FW first ARM processor error injection

PATCH In review [email protected] 2 participants 2 messages Jun 24, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hw/arm: FW first ARM processor error injection

From: Shiju Jose <[email protected]>

Add support for QEMU based FW first ARM processor error injection.

Compliance with N.2.4.4 ARM Processor Error Section in UEFI 2.9A/2.10 specs.

Examples,
{ "execute": "arm-inject-error",

      "arguments": {
        "errortypes": ['cache-error']
      }
}

{ "execute": "arm-inject-error",

      "arguments": {
        "errortypes": ['tlb-error']
      }
}

{ "execute": "arm-inject-error",

      "arguments": {
        "errortypes": ['bus-error']
      }
}

{ "execute": "arm-inject-error",

      "arguments": {
        "errortypes": ['cache-error', 'tlb-error']
      }
}

{ "execute": "arm-inject-error",

      "arguments": {
        "errortypes": ['cache-error', 'tlb-error', 'bus-error', 'micro-arch-error']
      }
}

etc.

The patch is added on top of the FW-first error reporting supporting in the following Jonathan's repo.
http://gitlab.com/jic23/qemu/ cxl-2024-06-21

Mauro Carvalho added some instructions about how to use it under rasdaemon
page: https://github.com/mchehab/rasdaemon/wiki/Error-injection-testing

Change History:
v1 -> V2
1. Updated patch header.
2. Fix the issues reported by Peter Maydell. Thanks.

---
 configs/targets/aarch64-softmmu.mak |   1 +
 hw/acpi/ghes.c                      | 170 +++++++++++++++++++++++++++-
 hw/arm/Kconfig                      |   4 +
 hw/arm/arm_error_inject.c           |  35 ++++++
 hw/arm/arm_error_inject_stubs.c     |  22 ++++
 hw/arm/meson.build                  |   4 +
 include/hw/acpi/ghes.h              |   1 +
 qapi/arm-error-inject.json          |  44 +++++++
 qapi/meson.build                    |   1 +
 qapi/qapi-schema.json               |   1 +
 10 files changed, 282 insertions(+), 1 deletion(-)
 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
configs/targets/aarch64-softmmu.mak +1 -0
index 84cb32dc2f..b4b3cd9793 100644
@@ -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 +169 -1

206 lines not on this page · raw message

hw/arm/Kconfig +4 -0
index 5279162287..fb31a57c20 100644
@@ -717,3 +717,7 @@ config ARMSSE
     select UNIMP
     select SSE_COUNTER
     select SSE_TIMER
+
+config CXL_ARM_EINJ
+    bool
+    default y if AARCH64
hw/arm/arm_error_inject.c new file +35 -0
new file mode 100644
index 0000000000..8a76a31733
@@ -0,0 +1,35 @@
+/*
+ * 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/qapi-commands-arm-error-inject.h"
+#include "qapi/error.h"
+#include "hw/boards.h"
+#include "hw/acpi/ghes.h"
+
+/* For ARM processor errors */
+void qmp_arm_inject_error(ArmProcessorErrorTypeList *errortypes, Error **errp)
+{
+    MachineState *machine = MACHINE(qdev_get_machine());
+    MachineClass *mc = MACHINE_GET_CLASS(machine);
+    uint8_t error_types = 0;
+
+    while (errortypes) {
+        error_types |= BIT(errortypes->value);
+        errortypes = errortypes->next;
+    }
+
+    ghes_record_arm_errors(error_types, ACPI_GHES_NOTIFY_GPIO);
+    if (mc->set_error) {
+        mc->set_error();
+    }
+
+    return;
+}
hw/arm/arm_error_inject_stubs.c new file +22 -0
new file mode 100644
index 0000000000..065a15cfb4
@@ -0,0 +1,22 @@
+/*
+ * ARM  Processor errors QMP stubs
+ *
+ * Copyright(C) 2024 Huawei LTD.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2. See the
+ * COPYING file in the top-level directory.
+ *
+ * SPDX-License-Identifier: GPL-v2-only
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qapi/qapi-commands-arm-error-inject.h"
+
+
+typedef struct ArmProcessorErrorTypeList ArmProcessorErrorTypeList;
+
+void qmp_arm_inject_error(ArmProcessorErrorTypeList *type, Error **errp)
+{
+    error_setg(errp, "ARM processor error support is not compiled in");
+}
hw/arm/meson.build +4 -0
index 0c07ab522f..59666b9d4e 100644
@@ -60,6 +60,10 @@ 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'))
+system_ss.add(when: 'CONFIG_ARM_EINJ', if_true: files('arm_error_inject.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'))
+
 
 system_ss.add(when: 'CONFIG_ARM_SMMUV3', if_true: files('smmu-common.c'))
 system_ss.add(when: 'CONFIG_CHEETAH', if_true: files('palm.c'))
include/hw/acpi/ghes.h +1 -0
index a12d6a7b22..2ff89edb3c 100644
@@ -78,6 +78,7 @@ int acpi_ghes_record_errors(uint8_t notify, uint64_t error_physical_addr);
 
 typedef struct PCIDevice PCIDevice;
 bool ghes_record_aer_errors(PCIDevice *dev, uint32_t notify);
+bool ghes_record_arm_errors(uint8_t type, uint32_t notify);
 
 typedef struct CXLError CXLError;
 typedef struct PCIEAERErr PCIEAERErr;
qapi/arm-error-inject.json new file +44 -0

44 lines not on this page · raw message

qapi/meson.build +1 -0
index e7bc54e5d0..5927932c4b 100644
@@ -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
index b1581988e4..479a22de7e 100644
@@ -81,3 +81,4 @@
 { 'include': 'vfio.json' }
 { 'include': 'cryptodev.json' }
 { 'include': 'cxl.json' }
+{ 'include': 'arm-error-inject.json' }
Signature · 1 line
2.34.1
#1 lore raw
Quoted 8 lines · On Mon, 24 Jun 2024 at 16:40, <[email protected]> wrote:

From: Shiju Jose <[email protected]>

Add support for QEMU based FW first ARM processor error injection.

+++ b/hw/arm/arm_error_inject_stubs.c

hw/arm/arm_error_inject_stubs.c line 9

Quoted 9 lines
hw/arm/arm_error_inject_stubs.c new file +9 -0
@@ -0,0 +1,22 @@
+/*
+ * ARM  Processor errors QMP stubs
+ *
+ * Copyright(C) 2024 Huawei LTD.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2. See the
+ * COPYING file in the top-level directory.
+ *
+ * SPDX-License-Identifier: GPL-v2-only

You missed an instance of gpl-v2-only (but you don't need to respin immediately just for this).

thanks
-- PMM