Skip to contentSkip to conversation

hw/arm: FW first ARM processor error injection.

RFC PATCH Superseded [email protected] 4 participants 5 messages Jun 21, 2024 – Jun 24, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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

From: Shiju Jose <[email protected]>

Add support for 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.

---
 configs/targets/aarch64-softmmu.mak |   1 +
 hw/acpi/ghes.c                      | 170 +++++++++++++++++++++++++++-
 hw/arm/Kconfig                      |   4 +
 hw/arm/arm_error_inject.c           |  49 ++++++++
 hw/arm/arm_error_inject_stubs.c     |  19 ++++
 hw/arm/meson.build                  |   2 +
 include/hw/acpi/ghes.h              |   1 +
 qapi/arm-error-inject.json          |  44 +++++++
 qapi/meson.build                    |   1 +
 qapi/qapi-schema.json               |   1 +
 10 files changed, 291 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 b4338e9568..6f9daa9b17 100644
@@ -3,3 +3,4 @@ TARGET_BASE_ARCH=arm
 TARGET_SUPPORTS_MTTCG=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
 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 176c407555..dd2e55f918 100644
@@ -719,3 +719,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 +49 -0

49 lines not on this page · raw message

hw/arm/arm_error_inject_stubs.c new file +19 -0
new file mode 100644
index 0000000000..b34d336867
@@ -0,0 +1,19 @@
+/*
+ * 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"
+
+void qmp_arm_inject_error(ArmProcessorErrorType type, Error **errp)
+{
+    error_setg(errp, "ARM processor error support is not compiled in");
+}
hw/arm/meson.build +2 -0
index 6808135c1f..03a2385fd3 100644
@@ -59,6 +59,8 @@ 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'))
+arm_ss.add(when: 'CONFIG_ARM_EINJ', if_false: 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 171c3e9dad..c2b507cdf1 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;
 bool ghes_record_cxl_errors(PCIDevice *dev, PCIEAERErr *err,
qapi/arm-error-inject.json new file +44 -0

44 lines not on this page · raw message

qapi/meson.build +1 -0
index 375d564277..f0f6198da6 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 8304d45625..e8ac20d75a 100644
@@ -81,3 +81,4 @@
 { 'include': 'virtio.json' }
 { 'include': 'cryptodev.json' }
 { 'include': 'cxl.json' }
+{ 'include': 'arm-error-inject.json' }
Signature · 1 line
2.34.1
#1 lore raw
Quoted 1 line · On Fri, 21 Jun 2024 17:51:15 +0100 <[email protected]> wrote:

From: Shiju Jose <[email protected]>

Thanks for posting this.

Given this is going to linux-edac, probably should mention this is QEMU based error injection. For cross postings between kernel related and qemu lists I tend to stick qemu in the [] of the patch description.

Quoted 31 lines

Add support for 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']
      }
}
Quoted 8 lines

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

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

etc.

With a few minor tweaks to build files, this is on my cxl gitlab qemu staging branch as that happens to have other injection stuff (this obviously has little to do with CXL!)

http://gitlab.com/jic23/qemu/ cxl-2024-06-21

Note I haven't tested that branch beyond a quick boot test, so it might get some revisions early next week.

Jonathan

#2 lore raw

Em Fri, 21 Jun 2024 19:33:16 +0100
Jonathan Cameron <[email protected]> escreveu:

Quoted 10 lines
Quoted 1 line · On Fri, 21 Jun 2024 17:51:15 +0100 <[email protected]> wrote:

From: Shiju Jose <[email protected]>

Thanks for posting this.

Given this is going to linux-edac, probably should mention this is QEMU based error injection. For cross postings between kernel related and qemu lists I tend to stick qemu in the [] of the patch description.

Thank you for that! It is really useful. Btw, I'm using a small script to do the error injection using netcat (nc), and assuming that the QMP interface used for error injection will be started at localhost port 4445, e. g. qemu is started with:

	-qmp tcp:localhost:4445,server=on,wait=off

Btw, I added some instructions about how to use it under rasdaemon page:

https://github.com/mchehab/rasdaemon/wiki/Error-injection-testing

Feel free to improve it.

Thanks,
Mauro

---

#!/bin/bash

trap 'catch $LINENO "$BASH_COMMAND"' ERR

catch() {
	echo "Error on line $1: $2"
	exit 1
}

ERROR_DEFAULT='"cache-error"'
ERROR=""

HELP="$0 [<-c|--cache-error> <-t|--tlb-error> <-b|--bus-error> <-v|--vendor-error>|--micro-arch-error]"

while [ "$1" != "" ]; do

	case "$1" in
		-c|--cache-error)
			if [ ! -z "$ERROR" ]; then ERROR="$ERROR, "; fi
			ERROR+='"cache-error"'
			;;
		-t|--tlb-error)
			if [ ! -z "$ERROR" ]; then ERROR="$ERROR, "; fi
			ERROR+='"tlb-error"'
			;;
		-b|--bus-error)
			if [ ! -z "$ERROR" ]; then ERROR="$ERROR, "; fi
			ERROR+='"bus-error"'
			;;
		-v|--vendor-error|--micro-arch-error)
			if [ ! -z "$ERROR" ]; then ERROR="$ERROR, "; fi
			ERROR+='"micro-arch-error"'
			;;
		help|-h|--help)
			echo $HELP
			exit 0
			;;
	esac
	shift

done

if [ -z "$ERROR" ]; then
ERROR=$ERROR_DEFAULT
fi

CACHE_MSG='{ "execute": "qmp_capabilities" } '
CACHE_MSG+='{ "execute": "arm-inject-error", "arguments": { "errortypes": ['$ERROR'] } }'

echo $CACHE_MSG
echo $CACHE_MSG | nc -v localhost 4445

#3 lore raw
In reply to [email protected]
Quoted 12 lines · shiju.jose--- via

From: Shiju Jose <[email protected]>

hw/arm/arm_error_inject.c new file +0 -0
new file mode 100644
index 0000000000..953a9d6705

hw/arm/arm_error_inject.c line 2

Quoted 2 lines
hw/arm/arm_error_inject.c new file +2 -0
@@ -0,0 +1,49 @@
+/*
+ * CXL Type 3 (memory expander) device

This doesn't seem to match what the file actually does.

hw/arm/arm_error_inject.c line 9

Quoted 7 lines
hw/arm/arm_error_inject.c new file +7 -0
+ *
+ * Copyright(C) 2020 Intel Corporation.
+ *
+ * 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

Why are these new files GPL-v2-only? Our general preference (see the LICENSE) file is for GPL-v2-or-any-later-version.

I also notice that this file is marked as copyright Intel, but you're submitting from a Huawei email address. What's the history of this code?

Quoted 8 lines
hw/arm/arm_error_inject.c new file +8 -0
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/units.h"
+#include "qemu/error-report.h"
+#include "qapi-commands-arm-error-inject.h"
+#include "hw/qdev-properties.h"
+#include "qapi/error.h"

hw/arm/arm_error_inject.c line 27

Quoted 10 lines
hw/arm/arm_error_inject.c new file +10 -0
+#include "qemu/log.h"
+#include "qemu/module.h"
+#include "qemu/pmem.h"
+#include "qemu/range.h"
+#include "qemu/rcu.h"
+#include "qemu/guest-random.h"
+#include "sysemu/hostmem.h"
+#include "sysemu/numa.h"
+#include "hw/boards.h"
+#include "hw/acpi/ghes.h"

Looking at the code here I'm pretty sure you don't need anywhere near all of these include lines.

hw/arm/arm_error_inject.c line 29

Quoted 2 lines
hw/arm/arm_error_inject.c new file +2 -0
+
+#define DWORD_BYTE 4

This seems to be unused.

thanks
-- PMM

author
#4 lore raw

Thanks Peter for the valuable comments.

Quoted 17 lines

-----Original Message-----
From: Peter Maydell <[email protected]>
Sent: 24 June 2024 14:48
To: Shiju Jose <[email protected]>
Cc: [email protected]; [email protected]; Jonathan Cameron <[email protected]>; [email protected]; tanxiaofei <[email protected]>; Zengtao (B) <[email protected]>; Linuxarm <[email protected]>
Subject: Re: [RFC PATCH 1/1] hw/arm: FW first ARM processor error injection.

Quoted 3 lines · shiju.jose--- via

From: Shiju Jose <[email protected]>

Quoted 9 lines

hw/arm/arm_error_inject.c line 2

Quoted 7 lines
hw/arm/arm_error_inject.c new renamed from hw/arm/arm_error_inject.c +0 -0

file mode 100644 index 0000000000..953a9d6705

hw/arm/arm_error_inject.c new file +2 -0
@@ -0,0 +1,49 @@
+/*
+ * CXL Type 3 (memory expander) device

This doesn't seem to match what the file actually does.

I will update.

Quoted 10 lines

hw/arm/arm_error_inject.c line 9

Quoted 9 lines
hw/arm/arm_error_inject.c new file +8 -0
+ *
+ * Copyright(C) 2020 Intel Corporation.
+ *
+ * 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
Quoted 5 lines

Why are these new files GPL-v2-only? Our general preference (see the LICENSE) file is for GPL-v2-or-any-later-version.

I also notice that this file is marked as copyright Intel, but you're submitting from a Huawei email address. What's the history of this code?

Thanks for pointing this error.
Sure I will fix in the next version.

Quoted 14 lines
Quoted 14 lines
hw/arm/arm_error_inject.c new file +13 -0
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/units.h"
+#include "qemu/error-report.h"
+#include "qapi-commands-arm-error-inject.h"
+#include "hw/qdev-properties.h"
+#include "qapi/error.h"
+#include "qemu/log.h"
+#include "qemu/module.h"
+#include "qemu/pmem.h"
+#include "qemu/range.h"
+#include "qemu/rcu.h"
Quoted 8 lines

hw/arm/arm_error_inject.c line 27

Quoted 5 lines
hw/arm/arm_error_inject.c new file +5 -0
+#include "qemu/guest-random.h"
+#include "sysemu/hostmem.h"
+#include "sysemu/numa.h"
+#include "hw/boards.h"
+#include "hw/acpi/ghes.h"

Looking at the code here I'm pretty sure you don't need anywhere near all of these include lines.

I will check this and fix.

Quoted 5 lines

hw/arm/arm_error_inject.c line 30

Quoted 3 lines
hw/arm/arm_error_inject.c new file +2 -0
+
+#define DWORD_BYTE 4

This seems to be unused.

Not used. I will delete this.

Quoted 3 lines

thanks
-- PMM

Thanks,
Shiju