Re: [PATCH v3 4/7] acpi/ghes: Add a logic to handle block addresses and FW first ARM processor error injection

From: Markus Armbruster
Date: Thu Jul 25 2024 - 05:48:42 EST


Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx> writes:

> From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
>
> 1. Some GHES functions require handling addresses. Add a helper function
> to support it.
>
> 2. Add support for ACPI CPER (firmware-first) ARM processor error injection.
>
> Compliance with N.2.4.4 ARM Processor Error Section in UEFI 2.6 and
> upper specs, using error type bit encoding as detailed at UEFI 2.9A
> errata.
>
> Error injection examples:
>
> { "execute": "qmp_capabilities" }
>
> { "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']
> }
> }
> ...
>
> Co-authored-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>
> Co-authored-by: Shiju Jose <shiju.jose@xxxxxxxxxx>
> For Add a logic to handle block addresses,
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>
> For FW first ARM processor error injection,
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>
> Signed-off-by: Shiju Jose <shiju.jose@xxxxxxxxxx>
> ---
> configs/targets/aarch64-softmmu.mak | 1 +
> hw/acpi/ghes.c | 258 ++++++++++++++++++++++++++--
> hw/arm/Kconfig | 4 +
> hw/arm/arm_error_inject.c | 35 ++++
> hw/arm/arm_error_inject_stubs.c | 18 ++
> hw/arm/meson.build | 3 +
> include/hw/acpi/ghes.h | 2 +
> qapi/arm-error-inject.json | 49 ++++++
> qapi/meson.build | 1 +
> qapi/qapi-schema.json | 1 +
> 10 files changed, 361 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

Since the new file not covered in MAINTAINERS, get_maintainer.pl will
blame it on the QAPI maintainers alone. No good.

[...]

> diff --git a/qapi/arm-error-inject.json b/qapi/arm-error-inject.json
> new file mode 100644
> index 000000000000..430e6cea6b60
> --- /dev/null
> +++ b/qapi/arm-error-inject.json
> @@ -0,0 +1,49 @@
> +# -*- Mode: Python -*-
> +# vim: filetype=python
> +
> +##
> +# = ARM Processor Errors
> +##
> +
> +##
> +# @ArmProcessorErrorType:
> +#
> +# Type of ARM processor error to inject
> +#
> +# @unknown-error: Unknown error

Removed in PATCH 7, and unused until then. Why add it in the first
place?

> +#
> +# @cache-error: Cache error
> +#
> +# @tlb-error: TLB error
> +#
> +# @bus-error: Bus error.
> +#
> +# @micro-arch-error: Micro architectural error.
> +#
> +# Since: 9.1
> +##
> +{ 'enum': 'ArmProcessorErrorType',
> + 'data': ['unknown-error',
> + 'cache-error',

Tab in this line. Please convert to spaces.

> + 'tlb-error',
> + 'bus-error',
> + 'micro-arch-error']
> +}
> +
> +##
> +# @arm-inject-error:
> +#
> +# Inject ARM Processor error.
> +#
> +# @errortypes: ARM processor error types to inject
> +#
> +# Features:
> +#
> +# @unstable: This command is experimental.
> +#
> +# Since: 9.1
> +##
> +{ 'command': 'arm-inject-error',
> + 'data': { 'errortypes': ['ArmProcessorErrorType'] },

Please separate words with dashes: 'error-types'.

> + 'features': [ 'unstable' ]
> +}

Is this used only with TARGET_ARM?

Why is being able to inject multiple error types at once useful?

I'd expect at least some of these errors to come with additional
information. For instance, I imagine a bus error is associated with
some address.

If we encode the the error to inject as an enum value, adding more will
be hard.

If we wrap the enum in a struct

{ 'struct': 'ArmProcessorError',
'data': { 'type': 'ArmProcessorErrorType' } }

we can later extend it like

{ 'union': 'ArmProcessorError',
'base: { 'type': 'ArmProcessorErrorType' }
'data': {
'bus-error': 'ArmProcessorBusErrorData' } }

{ 'struct': 'ArmProcessorBusErrorData',
'data': ... }

> diff --git a/qapi/meson.build b/qapi/meson.build
> index e7bc54e5d047..5927932c4be3 100644
> --- a/qapi/meson.build
> +++ b/qapi/meson.build
> @@ -22,6 +22,7 @@ if have_system or have_tools or have_ga
> endif
>
> qapi_all_modules = [
> + 'arm-error-inject',
> 'authz',
> 'block',
> 'block-core',
> diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
> index b1581988e4eb..479a22de7e43 100644
> --- a/qapi/qapi-schema.json
> +++ b/qapi/qapi-schema.json
> @@ -81,3 +81,4 @@
> { 'include': 'vfio.json' }
> { 'include': 'cryptodev.json' }
> { 'include': 'cxl.json' }
> +{ 'include': 'arm-error-inject.json' }