From patchwork Tue Aug 13 23:23:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 13762682 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DAD7C52D7B for ; Tue, 13 Aug 2024 23:25:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1se0sK-0000Pb-PC; Tue, 13 Aug 2024 19:24:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1se0sH-00008u-Er; Tue, 13 Aug 2024 19:24:21 -0400 Received: from dfw.source.kernel.org ([139.178.84.217]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1se0sA-0006q7-9V; Tue, 13 Aug 2024 19:24:21 -0400 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4F2A461920; Tue, 13 Aug 2024 23:24:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 427D4C32782; Tue, 13 Aug 2024 23:24:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723591451; bh=AuvDaEpkg8Dd+AtWRbawo7H6pFNp1avVScl/m/f3ec8=; h=From:To:Cc:Subject:Date:From; b=Qv3/jBCBmEXgq0+3f8LuI12WNzsxaXJja3yvTJd2PIlCSrf/QdW+JNOGYD/w6Ln1L 22ujuTSG3MjakSgA3qlQr35u1TblCVdBiLa0gJDJIn2SDwYUav3nY0IdD/9thjo1Ek Zav+8lpDcRGY6mP0A9Pd6/I5IrJpoLI+fY28peODiVZMiXUUudUdzg63Si/XOIxMBL wlrb609x9QaO2e5EE5y77Xuwvum5Bjp+5bM/zOSGCTSmcHqm/mJRWpvxThAkNWl6CK f4nrIN7WeMh3/k/y4dlhpQcFwZb1FvaIWL6ttA417XQzLuDzO2GvVKCkuF/zji9Z/M ZXH+vjV4Blu1w== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1se0s5-00000002as7-16ER; Wed, 14 Aug 2024 01:24:09 +0200 From: Mauro Carvalho Chehab To: Cc: Jonathan Cameron , Shiju Jose , Mauro Carvalho Chehab , Ani Sinha , Dongjiu Geng , Paolo Bonzini , Peter Maydell , Shannon Zhao , qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v7 00/10] Add ACPI CPER firmware first error injection on ARM emulation Date: Wed, 14 Aug 2024 01:23:22 +0200 Message-ID: X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Received-SPF: pass client-ip=139.178.84.217; envelope-from=mchehab+huawei@kernel.org; helo=dfw.source.kernel.org X-Spam_score_int: -71 X-Spam_score: -7.2 X-Spam_bar: ------- X-Spam_report: (-7.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.125, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 injecting CPER records on ARM emulation. The QEMU side changes add a QAPI able to do CPER error injection on ARM, with a raw data parameter, making it very flexible. A script is provided at the final patch implementing support for ARM Processor CPER error injection according with ACPI 6.x and UEFI 2.9A/2.10 specs, via QMP. Injecting such errors can be done using the provided script: $ ./scripts/ghes_inject.py arm Error injected. Produces a simple CPER register, properly handled by the Linux Kernel: [ 794.983753] {4}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1 [ 794.984150] {4}[Hardware Error]: event severity: recoverable [ 794.984391] {4}[Hardware Error]: Error 0, type: recoverable [ 794.984652] {4}[Hardware Error]: section_type: ARM processor error [ 794.984926] {4}[Hardware Error]: MIDR: 0x0000000000000000 [ 794.985184] {4}[Hardware Error]: running state: 0x0 [ 794.985411] {4}[Hardware Error]: Power State Coordination Interface state: 0 [ 794.985720] {4}[Hardware Error]: Error info structure 0: [ 794.985960] {4}[Hardware Error]: num errors: 2 [ 794.986175] {4}[Hardware Error]: error_type: 0x02: cache error [ 794.986442] {4}[Hardware Error]: error_info: 0x000000000091000f [ 794.986755] {4}[Hardware Error]: transaction type: Data Access [ 794.987027] {4}[Hardware Error]: cache error, operation type: Data write [ 794.987310] {4}[Hardware Error]: cache level: 2 [ 794.987529] {4}[Hardware Error]: processor context not corrupted [ 794.987867] [Firmware Warn]: GHES: Unhandled processor error type 0x02: cache error More complex use cases can be done, like: $ ./scripts/ghes_inject.py arm --mpidr 0x444 --running --affinity 1 \ --error-info 12345678 --vendor 0x13,123,4,5,1 --ctx-array 0,1,2,3,4,5 \ -t cache tlb bus micro-arch tlb,micro-arch Error injected. [ 899.181246] {5}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1 [ 899.181769] {5}[Hardware Error]: event severity: recoverable [ 899.182069] {5}[Hardware Error]: Error 0, type: recoverable [ 899.182370] {5}[Hardware Error]: section_type: ARM processor error [ 899.182689] {5}[Hardware Error]: MIDR: 0x0000000000000000 [ 899.182980] {5}[Hardware Error]: Multiprocessor Affinity Register (MPIDR): 0x0000000000000000 [ 899.183395] {5}[Hardware Error]: error affinity level: 0 [ 899.183683] {5}[Hardware Error]: running state: 0x1 [ 899.183962] {5}[Hardware Error]: Power State Coordination Interface state: 0 [ 899.184332] {5}[Hardware Error]: Error info structure 0: [ 899.184610] {5}[Hardware Error]: num errors: 2 [ 899.184864] {5}[Hardware Error]: error_type: 0x02: cache error [ 899.185181] {5}[Hardware Error]: error_info: 0x0000000000bc614e [ 899.185504] {5}[Hardware Error]: cache level: 2 [ 899.185771] {5}[Hardware Error]: processor context not corrupted [ 899.186082] {5}[Hardware Error]: Error info structure 1: [ 899.186366] {5}[Hardware Error]: num errors: 2 [ 899.186613] {5}[Hardware Error]: error_type: 0x04: TLB error [ 899.186929] {5}[Hardware Error]: error_info: 0x000000000054007f [ 899.187236] {5}[Hardware Error]: transaction type: Instruction [ 899.187588] {5}[Hardware Error]: TLB error, operation type: Instruction fetch [ 899.187962] {5}[Hardware Error]: TLB level: 1 [ 899.188209] {5}[Hardware Error]: processor context not corrupted [ 899.188535] {5}[Hardware Error]: the error has not been corrected [ 899.188853] {5}[Hardware Error]: PC is imprecise [ 899.189114] {5}[Hardware Error]: Error info structure 2: [ 899.189404] {5}[Hardware Error]: num errors: 2 [ 899.189653] {5}[Hardware Error]: error_type: 0x08: bus error [ 899.189967] {5}[Hardware Error]: error_info: 0x00000080d6460fff [ 899.190293] {5}[Hardware Error]: transaction type: Generic [ 899.190611] {5}[Hardware Error]: bus error, operation type: Generic read (type of instruction or data request cannot be determined) [ 899.191174] {5}[Hardware Error]: affinity level at which the bus error occurred: 1 [ 899.191563] {5}[Hardware Error]: processor context corrupted [ 899.191872] {5}[Hardware Error]: the error has been corrected [ 899.192185] {5}[Hardware Error]: PC is imprecise [ 899.192445] {5}[Hardware Error]: Program execution can be restarted reliably at the PC associated with the error. [ 899.192939] {5}[Hardware Error]: participation type: Local processor observed [ 899.193324] {5}[Hardware Error]: request timed out [ 899.193596] {5}[Hardware Error]: address space: External Memory Access [ 899.193945] {5}[Hardware Error]: memory access attributes:0x20 [ 899.194273] {5}[Hardware Error]: access mode: secure [ 899.194544] {5}[Hardware Error]: Error info structure 3: [ 899.194838] {5}[Hardware Error]: num errors: 2 [ 899.195088] {5}[Hardware Error]: error_type: 0x10: micro-architectural error [ 899.195456] {5}[Hardware Error]: error_info: 0x0000000078da03ff [ 899.195782] {5}[Hardware Error]: Error info structure 4: [ 899.196070] {5}[Hardware Error]: num errors: 2 [ 899.196331] {5}[Hardware Error]: error_type: 0x14: TLB error|micro-architectural error [ 899.196733] {5}[Hardware Error]: Context info structure 0: [ 899.197024] {5}[Hardware Error]: register context type: AArch64 EL1 context registers [ 899.197427] {5}[Hardware Error]: 00000000: 00000000 00000000 [ 899.197741] {5}[Hardware Error]: Vendor specific error info has 5 bytes: [ 899.198096] {5}[Hardware Error]: 00000000: 13 7b 04 05 01 .{... [ 899.198610] [Firmware Warn]: GHES: Unhandled processor error type 0x02: cache error [ 899.199000] [Firmware Warn]: GHES: Unhandled processor error type 0x04: TLB error [ 899.199388] [Firmware Warn]: GHES: Unhandled processor error type 0x08: bus error [ 899.199767] [Firmware Warn]: GHES: Unhandled processor error type 0x10: micro-architectural error [ 899.200194] [Firmware Warn]: GHES: Unhandled processor error type 0x14: TLB error|micro-architectural error --- v7: - Change the way offsets are calculated and used on HEST table. Now, it is compatible with migrations as all offsets are relative to the HEST table; - GHES interface is now more generic: the entire CPER is sent via QMP, instead of just the payload; - Some code cleanups to make the code more robust; - The python script now uses QEMUMonitorProtocol class. v6: - PNP0C33 device creation moved to aml-build.c; - acpi_ghes record functions now use ACPI notify parameter, instead of source ID; - the number of source IDs is now automatically calculated; - some code cleanups and function/var renames; - some fixes and cleanups at the error injection script; - ghes cper stub now produces an error if cper JSON is not compiled; - Offset calculation logic for GHES was refactored; - Updated documentation to reflect the GHES allocated size; - Added a x-mpidr object for QOM usage; - Added a patch making usage of x-mpidr field at ARM injection script; v5: - CPER guid is now passing as string; - raw-data is now passed with base64 encode; - Removed several GPIO left-overs from arm/virt.c changes; - Lots of cleanups and improvements at the error injection script. It now better handles QMP dialog and doesn't print debug messages. Also, code was split on two modules, to make easier to add more error injection commands. v4: - CPER generation moved to happen outside QEMU; - One patch adding support for mpidr query was removed. 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 (1): acpi/ghes: Add support for GED error device Mauro Carvalho Chehab (9): acpi/generic_event_device: add an APEI error device arm/virt: Wire up a GED error device for ACPI / GHES qapi/acpi-hest: add an interface to do generic CPER error injection acpi/ghes: rework the logic to handle HEST source ID acpi/ghes: add support for generic error injection via QAPI docs: acpi_hest_ghes: fix documentation for CPER size scripts/ghes_inject: add a script to generate GHES error inject target/arm: add an experimental mpidr arm cpu property object scripts/arm_processor_error.py: retrieve mpidr if not filled MAINTAINERS | 10 + docs/specs/acpi_hest_ghes.rst | 6 +- hw/acpi/Kconfig | 5 + hw/acpi/aml-build.c | 10 + hw/acpi/generic_event_device.c | 8 + hw/acpi/ghes-stub.c | 3 +- hw/acpi/ghes.c | 250 +++++++++---- hw/acpi/ghes_cper.c | 33 ++ hw/acpi/ghes_cper_stub.c | 19 + hw/acpi/meson.build | 2 + hw/arm/Kconfig | 5 + hw/arm/virt-acpi-build.c | 6 +- hw/arm/virt.c | 12 +- include/hw/acpi/acpi_dev_interface.h | 1 + include/hw/acpi/aml-build.h | 2 + include/hw/acpi/generic_event_device.h | 1 + include/hw/acpi/ghes.h | 23 +- include/hw/arm/virt.h | 1 + qapi/acpi-hest.json | 36 ++ qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + scripts/arm_processor_error.py | 382 +++++++++++++++++++ scripts/ghes_inject.py | 51 +++ scripts/qmp_helper.py | 486 +++++++++++++++++++++++++ target/arm/cpu.c | 1 + target/arm/cpu.h | 1 + target/arm/helper.c | 10 +- 27 files changed, 1276 insertions(+), 90 deletions(-) create mode 100644 hw/acpi/ghes_cper.c create mode 100644 hw/acpi/ghes_cper_stub.c create mode 100644 qapi/acpi-hest.json create mode 100644 scripts/arm_processor_error.py create mode 100755 scripts/ghes_inject.py create mode 100644 scripts/qmp_helper.py