From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 2002:a17:505:1116:b0:1be9:327d:8ee3 with SMTP id pu22csp664398njb; Sat, 24 Aug 2024 20:48:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXnWjMv2aMaygrvdC8yqBB+h3oKY4aVHAptcwLzIVT8afuMhbhwEK+FYRfE1zFOYB6YpiKwJyds4vOapg==@linaro.org X-Google-Smtp-Source: AGHT+IGaUbow3MaCkj7lVBiF1u7g35t2pT7ZEfgRfIGM5GokiJqcBvE0CbhrOR1PykzusuU+VHtN X-Received: by 2002:a05:6902:154f:b0:e13:d0dd:b21 with SMTP id 3f1490d57ef6-e17a83dff7emr7265714276.20.1724557697793; Sat, 24 Aug 2024 20:48:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724557697; cv=none; d=google.com; s=arc-20160816; b=g28opUUZRTl/QNdkECBIF2cHajbmmKaOtMphSL/8pcurNE+ZWuRereokq6hEYyWN9m LXSr4x7fgk71lsJzHzOY9S9vlx1nVut0ROF64J8XjgbpeloCJRKRrXj9/e2sLIWTgdxU du+naQlRxDBVM06ajtQy7X87HQr3S33ID1LlgPt7AteHIqay8466txN4qgN2vVTRmszH RS4yeB4nBCic2cQN9jyFJAMB21qNp+HnYofaAfzLUsKkTXd01hc7+4+NCiBKf31Z2oEh Tkn19dUPtrAN/P4ILGQsrEpAOeq8gZ880tuGcZHitsCuWta18YMtos7pHtxTwlTDw0iv UUjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=omaxonl9uFLMYktgJn2IcN2q48vkUtpdZTNBzM6Y/Uw=; fh=KmYLVQsi9AXJlWSrRl9jRwxkjjf215NqZ66fTPTj6AA=; b=VWl9IceKQq6ejTGtqL9tFhG6QF0/efED3Byt7JgwUHc8/GUO9B7dQ4gBB4JUA0xhn/ W8WymFJXPYZDKjXmLbujxJlCp+pOYN8NUw/6vHBJnklsaazsh3Uu8Z5ix0RmjFsZ3hhF 7i5k1jYuPLyw9uGKJLAHb3dbUhslzXSyVzem8lejsB2wOTvA0x/W2HqwXrt7l+yN++mz uBJnRnbmyCR1bJxfDrqNezZe6jFFlPBhf+OSjF8RKEimreAt5sv0vChEz9jKjZrGVLx2 k+Rb/2x1KWkm12DChgkv+ia6eQNKs5N0dmeWy8yMIiziiOcqPHjbIk0lvAMaF4QOrbE6 +95g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q7HAFj8k; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kernel.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6c162e4036csi79659726d6.513.2024.08.24.20.48.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 24 Aug 2024 20:48:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q7HAFj8k; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kernel.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1si4EW-0000HW-IY; Sat, 24 Aug 2024 23:48:04 -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 1si4EU-0008Du-AL; Sat, 24 Aug 2024 23:48:02 -0400 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1si4EL-0004tN-Pt; Sat, 24 Aug 2024 23:47:56 -0400 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 0F7A7A40409; Sun, 25 Aug 2024 03:47:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC762C32782; Sun, 25 Aug 2024 03:47:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724557672; bh=cwotV459PaV3Ve/HitSaedrlUF8y42brdmvLbhIUyaQ=; h=From:To:Cc:Subject:Date:From; b=q7HAFj8koZV/+5SuxuSLG1pfajDqQZY+JYRMlGGJ9/YIjn1Ih85UBcqNLZ0OAbqhW LIib0PZnOnCkVFAf7iTxDzH2vIFkVVD4JzWIe7KEgnUNwVyGfsYdV8rA3Zi1ZZ1tIl PZnlD/IU/xTmUdpBOt51vFGZ+BJOjqeBrUqf8OFck/zgzRb67SgNGfi1XxXNKdTGj8 /g/AKMzjDUSzbkyh75qHJCzwcXDYw0Y+aGF0Q6wZB2VZ2AzaxvCEbDjCWGpMkLaTKv RO6CIR+VDGr6+oHseBZq+X+M5ukbdK1D2Qpx7xF67oJT/YIR0Z2PuNteKKBK57Xuez YdsvnbDJp5kZA== Received: from mchehab by mail.kernel.org with local (Exim 4.98) (envelope-from ) id 1si4Ch-00000001RMU-24kO; Sun, 25 Aug 2024 05:46:11 +0200 From: Mauro Carvalho Chehab To: Cc: Mauro Carvalho Chehab , "Michael S. Tsirkin" , Ani Sinha , Cleber Rosa , Dongjiu Geng , Eric Blake , Igor Mammedov , John Snow , Markus Armbruster , Michael Roth , Paolo Bonzini , Peter Maydell , Shannon Zhao , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v9 00/12] Add ACPI CPER firmware first error injection on ARM emulation Date: Sun, 25 Aug 2024 05:45:55 +0200 Message-ID: X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2604:1380:45d1:ec00::3; envelope-from=mchehab@kernel.org; helo=nyc.source.kernel.org X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: D/fd1JF0joxb This series add support for injecting generic CPER records. Such records are generated outside QEMU via a provided script. On this version, patches were reorganized to follow this pattern: 1. Addition of hest_add_le, mapping to the beginning of the HEST error source structure size. This is the part of the HEST table that contains the error source IDs to be notified; 2. GHESv2 code rework. It is basically a merge of all changes from v8, except for GPIO notify, QEMU notifier and renames; 3. cleanups and renames for hw/acpi/ghes.c; 4. GPIO GED device creation logic; 5. Logic to inject errors via QMP; 6. Error injection script On this version, the logic now better navigates the source IDs, double-checking them at error injecting time. It is now easier to add other HEST types if ever needed. Also, the source ID is now guest-OS specific: ARM will use SEA and GPIO, but x86 will likely use other notifiers and source IDs. Same will apply to other processor types. --- v9: - Patches reorganized to make easier for reviewers; - source ID is now guest-OS specific; - Some patches got a revision history since v8; - Several minor cleanups. v8: - Fix one of the BIOS links that were incorrect; - Changed mem error internal injection to use a common code; - No more hardcoded values for CPER: instead of using just the payload at the QAPI, it now has the full raw CPER there; - Error injection script now supports changing fields at the Generic Error Data section of the CPER; - Several minor cleanups. 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. Example of generating a CPER record: $ scripts/ghes_inject.py -d arm -p 0xdeadbeef GUID: e19e3d16-bc11-11e4-9caa-c2051d5d46b0 Generic Error Status Block (20 bytes): 00000000 01 00 00 00 00 00 00 00 00 00 00 00 90 00 00 00 ................ 00000010 00 00 00 00 .... Generic Error Data Entry (72 bytes): 00000000 16 3d 9e e1 11 bc e4 11 9c aa c2 05 1d 5d 46 b0 .=...........]F. 00000010 00 00 00 00 00 03 00 00 48 00 00 00 00 00 00 00 ........H....... 00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00000040 00 00 00 00 00 00 00 00 ........ Payload (72 bytes): 00000000 05 00 00 00 01 00 00 00 48 00 00 00 00 00 00 00 ........H....... 00000010 00 00 00 80 00 00 00 00 10 05 0f 00 00 00 00 00 ................ 00000020 00 00 00 00 00 00 00 00 00 20 14 00 02 01 00 03 ......... ...... 00000030 0f 00 91 00 00 00 00 00 ef be ad de 00 00 00 00 ................ 00000040 ef be ad de 00 00 00 00 ........ Error injected. [ 9.358364] {1}[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1 [ 9.359027] {1}[Hardware Error]: event severity: recoverable [ 9.359586] {1}[Hardware Error]: Error 0, type: recoverable [ 9.360124] {1}[Hardware Error]: section_type: ARM processor error [ 9.360561] {1}[Hardware Error]: MIDR: 0x00000000000f0510 [ 9.361160] {1}[Hardware Error]: Multiprocessor Affinity Register (MPIDR): 0x0000000080000000 [ 9.361643] {1}[Hardware Error]: running state: 0x0 [ 9.362142] {1}[Hardware Error]: Power State Coordination Interface state: 0 [ 9.362682] {1}[Hardware Error]: Error info structure 0: [ 9.363030] {1}[Hardware Error]: num errors: 2 [ 9.363656] {1}[Hardware Error]: error_type: 0x02: cache error [ 9.364163] {1}[Hardware Error]: error_info: 0x000000000091000f [ 9.364834] {1}[Hardware Error]: transaction type: Data Access [ 9.365599] {1}[Hardware Error]: cache error, operation type: Data write [ 9.366441] {1}[Hardware Error]: cache level: 2 [ 9.367005] {1}[Hardware Error]: processor context not corrupted [ 9.367753] {1}[Hardware Error]: physical fault address: 0x00000000deadbeef [ 9.374267] Memory failure: 0xdeadb: recovery action for free buddy page: Recovered Such script currently supports arm processor error CPER, but can easily be extended to other GHES notification types. Mauro Carvalho Chehab (12): acpi/ghes: add a firmware file with HEST address acpi/ghes: rework the logic to handle HEST source ID acpi/ghes: rename etc/hardware_error file macros acpi/ghes: better name GHES memory error function acpi/ghes: add a notifier to notify when error data is ready 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 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 | 2 +- hw/acpi/ghes.c | 309 +++++++---- hw/acpi/ghes_cper.c | 32 ++ hw/acpi/ghes_cper_stub.c | 19 + hw/acpi/meson.build | 2 + hw/arm/Kconfig | 5 + hw/arm/virt-acpi-build.c | 12 +- 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 | 28 +- include/hw/arm/virt.h | 10 + qapi/acpi-hest.json | 36 ++ qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + scripts/arm_processor_error.py | 388 ++++++++++++++ scripts/ghes_inject.py | 51 ++ scripts/qmp_helper.py | 702 +++++++++++++++++++++++++ target/arm/cpu.c | 1 + target/arm/cpu.h | 1 + target/arm/helper.c | 10 +- target/arm/kvm.c | 3 +- 28 files changed, 1539 insertions(+), 129 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 -- 2.46.0