From nobody Sun Apr 12 02:50:46 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=1771847542; cv=none; d=zohomail.com; s=zohoarc; b=m4AVaJzKD+iFM+4PM3AZy+3bS1IEKCmH1IKHql+ydwVjG5TA7O0JOwHzfJ2nLl5zAwbj+trXrP1t+MGe2au9mXFSaZmGcl6yfy0obJnJiPtgaXhOyLIyokM3GrkD6h9XmWkHk70Wfuwqr6EBnKM1k4JYF0N9B6HpOJlNYA+C8Lo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771847542; 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=ZLKfPJaMVz8FEHB0VjuJKtK4VZG4dMFfx62/7ZQs8Lc=; b=PWTZe08WNTlVSgeWdG0uSOY7osFPoj8SafeKmy12kxn55m8fVN6GFdVaX1kTEREqOz7oMG2DFvxOrWHE8gPyNOZ11831jhYES1bfxcz05FVE9/y0JbnviAQxflRhD9cK+yqNDXxE2NKz4vCXxtgms9FNN2V3tnnOkdSl/dV5crQ= 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 1771847542458193.42638132722175; Mon, 23 Feb 2026 03:52:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vuUSp-0004VR-21; Mon, 23 Feb 2026 06:50:59 -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 1vuUSe-0004Sj-H6 for qemu-devel@nongnu.org; Mon, 23 Feb 2026 06:50:48 -0500 Received: from sea.source.kernel.org ([172.234.252.31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuUSa-0004sZ-9D for qemu-devel@nongnu.org; Mon, 23 Feb 2026 06:50:47 -0500 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 476AB4456B; Mon, 23 Feb 2026 11:50:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02A1EC116C6; Mon, 23 Feb 2026 11:50:34 +0000 (UTC) Received: from mchehab by mail.kernel.org with local (Exim 4.99.1) (envelope-from ) id 1vuUSO-00000007Joz-0vnJ; Mon, 23 Feb 2026 12:50:32 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771847434; bh=Guhgq+hfI9g8CsVIoMrPzkV9dYROxSFNlKQmri6ehks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QT+hCBFrbSe9uhHFfuDQS8762M0reczlSvxQHfUq7rhXellCnbY/fYUasm6yAtOw8 /Fb8S6hn9ryMCHWhrIT3udgDxpGkRcnS1b3S+CxXya9zD+FClPgL/qjoiKr8HacvmT Ud0Nwg5RaI6QXTNijdkWSzRBJZbv0dioQbUd9TAVEDnndnZUtJOisknkKornfI64Us 6qPrQWgO6kQZ2vn16Zrlk6SaVzVX2Y7j+TW28rp8a1YRM/tGQ0j71vDB+mdL53Bs5N Yy9UOfQ+to89j8sEpE1OSxeVND9Aa1Z0R+LQEnRgtLzNmc7ILvITfxDtVeK6E3y3zZ /zH/JDMmc6d4w== From: Mauro Carvalho Chehab To: Michael S Tsirkin Cc: Jonathan Cameron , Shiju Jose , qemu-devel@nongnu.org, Igor Mammedov , Mauro Carvalho Chehab , Cleber Rosa , John Snow Subject: [PATCH v3 12/14] scripts/ghes_inject: add a raw error inject command Date: Mon, 23 Feb 2026 12:50:28 +0100 Message-ID: X-Mailer: git-send-email 2.53.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=172.234.252.31; envelope-from=mchehab+huawei@kernel.org; helo=sea.source.kernel.org X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=1.179, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.717, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1771847544371158500 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 --- 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 e553f8252f14..9d74d057048e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2231,6 +2231,7 @@ F: scripts/arm_processor_error.py F: scripts/fuzzy_error.py F: scripts/pcie_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 9b0a2443fc97..781b37cc68af 100755 --- a/scripts/ghes_inject.py +++ b/scripts/ghes_inject.py @@ -14,6 +14,7 @@ from arm_processor_error import ArmProcessorEinj from pcie_bus_error import PcieBusError 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) PcieBusError(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..0490adb25042 --- /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-or-later +# +# 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.53.0