From nobody Sun Jan 25 12:01:03 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=1769175390; cv=none; d=zohomail.com; s=zohoarc; b=g4i6ug1SNVKiHlFafSK9EBUshKNKMxdKytKRvWO6wihg3hk10b0o0+QWGSkErylXHdOQdAfF6WFCBHk0uQWAu8V/b+HBNYk/UBXiEnaHMdMQrqeMiGoQgkJtQ5uwaim8yeO2fx1aqUCbN2JCmIWmz3lQks0KUtq2c25TqbU1LIs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769175390; 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=VY+A1EoEGaD40dYKxnZRElZyYCfi+wEglmC3qZ45ZFQ=; b=FYLGVn61U3RFKbn20198pWBf0aGP4fTGRAEia8JuC/JtKYWoaFQJhMCaJ8UHT4XUQWhvx2mlZmfBra339TLPt6JP3xPDLAzdhgg90y0MFfMIj3Q0GBVslXcO4XmPOLt/hjKk6qzSpmaFQ0bqe6H02+QBOT2tSpc7cbGFRXmOMVg= 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 1769175390543778.5649997222697; Fri, 23 Jan 2026 05:36:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vjHKI-0007TL-BW; Fri, 23 Jan 2026 08:35:50 -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 1vjHKG-0007Sa-OX for qemu-devel@nongnu.org; Fri, 23 Jan 2026 08:35:48 -0500 Received: from tor.source.kernel.org ([172.105.4.254]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vjHKF-0004cr-4E for qemu-devel@nongnu.org; Fri, 23 Jan 2026 08:35:48 -0500 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 65BEE60010; Fri, 23 Jan 2026 13:35:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C77CC4CEF1; Fri, 23 Jan 2026 13:35:46 +0000 (UTC) Received: from localhost ([::1]) by mail.kernel.org with esmtp (Exim 4.99.1) (envelope-from ) id 1vjHKC-000000063Jq-00lE; Fri, 23 Jan 2026 14:35:44 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769175346; bh=NSF4+GKR0V5cB7F6q50hhNhNi8+rvzQwctVgiwbj0n8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lw+XpFyfAm9NmkFJ4sLFhb5Yr4qsQqgRT2cgF6e+cD64TjXSv+00DQyHUsLW6bI9w 708x5LvLJNDrxlNrRxWKBWEHlDfB6IuqZyf7XyKa2Wr78Iy7K24E1XlyhffEfsn25L hqa61UiBy/+/7BC4o3RESFkk5wKo0K57PbmRFD9svr67YfC/ZYpo7WnXGIHBmBtpVR /3Es2EYAmZzVi2+j4vPEoCuiLg01+FDOvEOveSCIu6dzqOZ+IJ8L4Dd/7lHS9kPty4 FgvLJA2uZ220tJZcbiG5KZ9It/0aXlr826DEtOzmh7vn/f3mNlNx9BwCNpqf+jrZp6 Ya7C9AgRNenpw== 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 05/13] scripts/qmp_helper: fix raw_data logic Date: Fri, 23 Jan 2026 14:35:19 +0100 Message-ID: <20b027d157808867689d1f9a8ecc6f10559d90c6.1769175069.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=172.105.4.254; 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1769175392961154100 According with UEFI 6.4 spec Table 18.11 Generic Error Status Block: Raw Data Offset: Offset in bytes from the beginning of the Error Status Block to raw error data. The raw data must follow any Generic Error Data Entries. Data Length: Length in bytes of the generic error data. So, basically, we have: +----------+ / | GEBS | | +----------+ / | | GEDE | | | | header | | +--> raw data +----------+ +--> data | offset | GEDE | | length | | payload | | | +----------+ / / | Raw data | +----------+ where: - raw data offset is relative to the beginning of GEBS; - data length is only for GEDE header and payload. The previous code was not calculating it right, as it was filling it with the size of GEBS and placing raw data before payload. This is not a problem with default values, as they set raw data length to zero, but, at the moment raw data is filled, the generated CPERs becomes invalid. Fix the code to calculate the offset according with the specs. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- scripts/qmp_helper.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/scripts/qmp_helper.py b/scripts/qmp_helper.py index ac3abc794c69..1587492807fe 100755 --- a/scripts/qmp_helper.py +++ b/scripts/qmp_helper.py @@ -411,6 +411,7 @@ def _connect(self): "simulated": util.bit(2), } =20 + GENERIC_ERROR_STATUS_SIZE =3D 20 GENERIC_DATA_SIZE =3D 72 =20 def argparse(parser): @@ -551,7 +552,7 @@ def send_cper_raw(self, cper_data): =20 return False =20 - def get_gede(self, notif_type, cper_length): + def get_gede(self, notif_type, payload_length): """ Return a Generic Error Data Entry bytearray """ @@ -563,22 +564,27 @@ def get_gede(self, notif_type, cper_length): util.data_add(gede, 0x300, 2) util.data_add(gede, self.validation_bits, 1) util.data_add(gede, self.flags, 1) - util.data_add(gede, cper_length, 4) + util.data_add(gede, payload_length, 4) gede.extend(self.fru_id) gede.extend(self.fru_text) gede.extend(self.timestamp) =20 return gede =20 - def get_gebs(self, data_length): + def get_gebs(self, payload_length): """ Return a Generic Error Status Block bytearray """ =20 + data_length =3D payload_length + data_length +=3D self.GENERIC_DATA_SIZE + gebs =3D bytearray() =20 if self.raw_data: - raw_data_offset =3D len(gebs) + raw_data_offset =3D payload_length + raw_data_offset +=3D self.GENERIC_ERROR_STATUS_SIZE + raw_data_offset +=3D self.GENERIC_DATA_SIZE else: raw_data_offset =3D 0 =20 @@ -617,8 +623,7 @@ def send_cper(self, notif_type, payload, if raw_data: self.raw_data =3D raw_data =20 - cper_length =3D len(payload) - data_length =3D cper_length + len(self.raw_data) + self.GENERIC_DA= TA_SIZE + payload_length =3D len(payload) =20 if gede and len(gede) !=3D 72: print(f"Invalid Generic Error Data Entry length: {len(gede)}. = Ignoring it") @@ -629,16 +634,16 @@ def send_cper(self, notif_type, payload, gebs =3D None =20 if not gede: - gede =3D self.get_gede(notif_type, cper_length) + gede =3D self.get_gede(notif_type, payload_length) =20 if not gebs: - gebs =3D self.get_gebs(data_length) + gebs =3D self.get_gebs(payload_length) =20 cper_data =3D bytearray() cper_data.extend(gebs) cper_data.extend(gede) - cper_data.extend(bytearray(self.raw_data)) cper_data.extend(bytearray(payload)) + cper_data.extend(bytearray(self.raw_data)) =20 if self.debug: print(f"GUID: {notif_type}") --=20 2.52.0