From nobody Sun Jan 25 11:58:47 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1769175459; cv=none; d=zohomail.com; s=zohoarc; b=MLGld+VoNU8D+ZKmAsYoErea/AiLAQO6c2WvvbstEVlbJNgjPIv6bOOSA24LKYytpRhIzDyCdowRAje9q6hqrnADpeddDYGP2psmoPPdvha5EUnYj0ToMwIq6jLqyELDSiB1u6H/nNZpMInipW/+SMixIgGv2x4LJxg1Lkb4bNs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769175459; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CI8MlYY/xBWZvm9fO7KRdNt9JepBlVHdaoALTzi/alU=; b=W7d7+UDRcR9NjX1qqL1g50WsImLg9ui6gRFsYy8znjUJe4BTDnE20Sf9Elmjlv8XKzdeLFgIV3NccG/ZCfSKVKnR8oScdkn6pn2O8rSthvsVsUfRU54p/qp5IgtY0KmL11GTR90ux0XAyZtn77/Gek3DioCJ8CBp5AzupuJg91E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769175459053520.4289574093277; Fri, 23 Jan 2026 05:37:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vjHKl-0007nj-5C; Fri, 23 Jan 2026 08:36:19 -0500 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 1vjHKY-0007gI-NW for qemu-devel@nongnu.org; Fri, 23 Jan 2026 08:36:08 -0500 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vjHKT-0004fw-Kw for qemu-devel@nongnu.org; Fri, 23 Jan 2026 08:36:04 -0500 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id E76B260135; Fri, 23 Jan 2026 13:36:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75928C4CEF1; Fri, 23 Jan 2026 13:36:00 +0000 (UTC) Received: from localhost ([::1]) by mail.kernel.org with esmtp (Exim 4.99.1) (envelope-from ) id 1vjHKP-000000063KX-1l7q; Fri, 23 Jan 2026 14:35:58 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769175360; bh=Hq0k9nQ+3YTLX7MeUDpF/YKj4jUzRbJabQ9UNor/cDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j9ME++wJvVqNwfjVKaQLl8aGAM6scEfZf/Xeg6QeSuI//eZQOvfs5TnrJ7sBl/9NL YXqjBADk3ClWPygk2pfsflXoPb5Ml8v8cZD8Q2E7/YfzQlO7YUGJCyKhkJf0+kZz9N 4JU1zj47XeZELPCv8u0iUuoJuDL3iDujSoDSOUZ0ZkJTRDT3F5Sm4thQHPQTxTRVxJ 2vFQR/QIcS1f/w64FRWbdqbBYwGm5mVc8qHOPqb4V6KraDWkmGdAeD8QVvI0M3H4BF RN8B8EGsaW83KV+qfi35tB9kQLlQWQxpfNBwFnGUq0vZ9ax7GnkHebEAFnbqVPTG2w u/q4KFxYKDX8A== From: Mauro Carvalho Chehab To: "Michael S. Tsirkin" Cc: Mauro Carvalho Chehab , qemu-devel@nongnu.org, Cleber Rosa , John Snow , Jonathan Cameron Subject: [PATCH v2 11/13] scripts/ghes_inject: add a raw error inject command Date: Fri, 23 Jan 2026 14:35:25 +0100 Message-ID: <8a8d1f55bc592c8f367fe948d4954dfefe59253d.1769175070.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2600:3c04:e001:324:0:1991:8:25; envelope-from=mchehab+huawei@kernel.org; helo=tor.source.kernel.org X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.079, 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 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1769175460822154100 Add a command to repeat a raw CPER record. This helps to reproduce some condition that happened before. The input format of the file is identical to the hexadecimal dump generated by ghes_inject tool. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- MAINTAINERS | 1 + scripts/ghes_inject.py | 2 + scripts/raw_error.py | 175 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 178 insertions(+) create mode 100644 scripts/raw_error.py diff --git a/MAINTAINERS b/MAINTAINERS index 967aafc35a92..2e48df7abfb5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2231,6 +2231,7 @@ F: scripts/arm_processor_error.py F: scripts/fuzzy_error.py F: scripts/pci_bus_error.py F: scripts/qmp_helper.py +F: scripts/raw_error.py =20 ppc4xx L: qemu-ppc@nongnu.org diff --git a/scripts/ghes_inject.py b/scripts/ghes_inject.py index bcbfffc586e1..63a8b28002e7 100755 --- a/scripts/ghes_inject.py +++ b/scripts/ghes_inject.py @@ -14,6 +14,7 @@ from arm_processor_error import ArmProcessorEinj from pci_bus_error import PciBusError from fuzzy_error import FuzzyError +from raw_error import RawError =20 EINJ_DESC =3D """ Handle ACPI GHESv2 error injection logic QEMU QMP interface. @@ -44,6 +45,7 @@ def main(): ArmProcessorEinj(subparsers) PciBusError(subparsers) FuzzyError(subparsers) + RawError(subparsers) =20 args =3D parser.parse_args() if "func" in args: diff --git a/scripts/raw_error.py b/scripts/raw_error.py new file mode 100644 index 000000000000..f5e77bdfcead --- /dev/null +++ b/scripts/raw_error.py @@ -0,0 +1,175 @@ +#!/usr/bin/env python3 +# +# pylint: disable=3DC0114,R0903,R0912,R0914,R0915,R1732 +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2024 Mauro Carvalho Chehab + +import argparse +import os +import re +import sys + +from time import sleep + +from qmp_helper import qmp, guid + +class RawError: + """ + Injects errors from a file containing raw data + """ + + SCRIPT_NAME =3D sys.argv[0] + + HELP=3Df""" + Inject a CPER record from a previously recorded one. + + One or more CPER records can be recorded. The records to be + injected are read from an specified file or from stdin and should + have the format produced by this script when using --debug, e.g.: + + GUID: e19e3d16-bc11-11e4-9caa-c2051d5d46b0 + CPER: + 00000000 04 00 00 00 02 00 01 00 88 00 00 00 00 00 00 00 ......= .......... + 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ......= .......... + 00000020 00 00 00 00 00 00 00 00 00 20 05 00 08 02 00 03 ......= ... ...... + 00000030 ff 0f 46 d6 80 00 00 00 ef be ad de 00 00 00 00 ..F...= .......... + 00000040 ad 0b ba ab 00 00 00 00 00 20 04 00 04 01 00 03 ......= ... ...... + 00000050 7f 00 54 00 00 00 00 00 ef be ad de 00 00 00 00 ..T...= .......... + 00000060 ad 0b ba ab 00 00 00 00 00 00 05 00 18 00 00 00 ......= .......... + 00000070 ef be ad de 00 00 00 00 ab ba ba ab 00 00 00 00 ......= .......... + 00000080 00 00 00 00 00 00 00 00 ......= .. + + Multiple such records can be used. On such case, a delay will + be introduced betewen them. + + All lines that can't be parsed will be silently ignored. + As such, the output of this help can be piped to the raw-error + generator with: + + {SCRIPT_NAME} -d raw-error -h | {SCRIPT_NAME} -d raw-error + """ + + def __init__(self, subparsers): + """Initialize the error injection class and add subparser""" + + self.payload =3D bytearray() + self.inj_type =3D None + self.size =3D 0 + + parser =3D subparsers.add_parser("raw-error", aliases=3D['raw'], + description=3Dself.HELP, + formatter_class=3Dargparse.RawTextH= elpFormatter) + + parser.add_argument("-f", "--file", + help=3D"File name with the raw error data. '-'= for stdin") + parser.add_argument("-d", "--delay", type=3Dlambda x: int(x, 0), + default=3D1, + help=3D"Specify a delay between multiple CPER.= Default=3D1") + + parser.set_defaults(func=3Dself.send_cper) + + def send_cper(self, args): + """Parse subcommand arguments and send a CPER via QMP""" + + if not args.file: + args.file=3D'-' + + is_guid =3D re.compile(r"^\s*guid:\s*(\w+\-\w+\-\w+\-\w+-\w+)", re= .I) + is_gesb =3D re.compile(r"^Generic Error Status Block.*:", re.I) + is_gede =3D re.compile(r"^Generic Error Data Entry.*:", re.I) + is_raw_data =3D re.compile(r"^Raw data.*:", re.I) + is_payload =3D re.compile(r"^(Payload|CPER).*:", re.I) + is_hexdump =3D re.compile(r"^(\s*[\da-f]........\s+)(.*)\s\s+.*", = re.I) + is_hex =3D re.compile(r"\b([\da-f].)\b", re.I) + + cper =3D [] + + if args.file =3D=3D "-": + fp =3D sys.stdin + if os.isatty(0): + print("Using stdin. Press CTRL-D to finish input.") + else: + print("Reading from stdin pipe") + else: + try: + fp =3D open(args.file, encoding=3D"utf-8") + except FileNotFoundError: + sys.exit('File Not Found') + + guid_obj =3D None + gebs =3D bytearray() + gede =3D bytearray() + raw_data =3D bytearray() + payload =3D bytearray() + ln_used =3D 0 + ln =3D 0 + + cur =3D payload + + for ln, line in enumerate(fp): + if match :=3D is_guid.search(line): + if guid_obj and payload: + cper.append({"guid": guid_obj, "raw-data": payload}) + guid_obj =3D None + payload =3D bytearray() + gebs =3D bytearray() + gede =3D bytearray() + + guid_obj =3D guid.UUID(match.group(1)) + + ln_used +=3D 1 + continue + + if match :=3D is_gesb.match(line): + cur =3D gebs + continue + + if match :=3D is_gede.match(line): + cur =3D gede + continue + + if match :=3D is_payload.match(line): + cur =3D payload + continue + + if match :=3D is_raw_data.match(line): + cur =3D raw_data + continue + + new =3D is_hexdump.sub(r"\2", line) + if new !=3D line: + if match :=3D is_hex.findall(new): + for m in match: + cur.extend(bytes.fromhex(m)) + ln_used +=3D 1 + continue + continue + + if guid_obj and payload: + cper.append({"guid": guid_obj, + "payload": payload, + "gede": gede, + "gebs": gebs, + "raw-data": raw_data}) + + print(f"{ln} lines read, {ln - ln_used} lines ignored.") + + if fp is not sys.stdin: + fp.close() + + qmp_cmd =3D qmp(args.host, args.port, args.debug) + + if not cper: + sys.exit("Format of the file not recognized.") + + for i, c in enumerate(cper): + if i: + sleep(args.delay) + + ret =3D qmp_cmd.send_cper(c["guid"], c["payload"], gede=3Dc["g= ede"], + gebs=3Dc["gebs"], raw_data=3Dc["raw-da= ta"]) + if not ret: + return ret + + return True --=20 2.52.0