From nobody Sat Nov 15 22:24:38 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747118158; cv=none; d=zohomail.com; s=zohoarc; b=cNi4+SzWmxXVzcXq4XNfMuQKq2UAtjfucWRAe/+JHYjreDY5QpZh4nH8qv9jLRk/y2ZFXPTXijQMAGbEhtUr8WcEDElONprYKqOfTfp82OszxzlNB+WuzhkNZIDEhcZB7ZLdMVG6s+lMwFpvu4ZTuTgSg+2RSasGszXODNjqSXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747118158; 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:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=nO7CcWR92+r3gtg9ECXw//xEY2wZXNoiOfqHG6er0w0=; b=ZgMiEbsA8gRWQfAow677xS0ieOVM9M5eo8QQTfVKz084uO5jLbHqRYOXvnsMTwbpLsQvhSywoMn8OIPhqjOd5dRfV11TdnOZm48qu4e5RK6FBB1gH1Br2nDzbE7FRfg9nRpW9Tp56FrXD7EBpIX+vpjuKlNCdcsoY2zoO8Gv34Q= ARC-Authentication-Results: i=1; mx.zohomail.com; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747118158768346.2177768190155; Mon, 12 May 2025 23:35:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uEjCd-0007Av-DM; Tue, 13 May 2025 02:33:32 -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 1uEjAi-0005K3-8L; Tue, 13 May 2025 02:31:39 -0400 Received: from mail.aspeedtech.com ([211.20.114.72] helo=TWMBX01.aspeed.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uEjAg-00026a-Js; Tue, 13 May 2025 02:31:24 -0400 Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Tue, 13 May 2025 14:29:06 +0800 Received: from mail.aspeedtech.com (192.168.10.10) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Tue, 13 May 2025 14:29:06 +0800 To: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Peter Maydell , Steven Lee , Troy Lee , Andrew Jeffery , "Joel Stanley" , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , "open list:ASPEED BMCs" , "open list:All patches CC here" CC: , Subject: [PATCH v2 13/25] hw/misc/aspeed_hace: Support to dump plaintext and digest for better debugging Date: Tue, 13 May 2025 14:28:43 +0800 Message-ID: <20250513062901.2256865-14-jamin_lin@aspeedtech.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250513062901.2256865-1-jamin_lin@aspeedtech.com> References: <20250513062901.2256865-1-jamin_lin@aspeedtech.com> MIME-Version: 1.0 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=211.20.114.72; envelope-from=jamin_lin@aspeedtech.com; helo=TWMBX01.aspeed.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_FAIL=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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Jamin Lin From: Jamin Lin via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1747118160749019000 Content-Type: text/plain; charset="utf-8" 1. Added "hace_hexdump()" to dump a contiguous buffer using qemu_hexdump. 2. Added "hace_iov_hexdump()" to flatten and dump scatter-gather source vec= tors. 3. Introduced a new trace event: "aspeed_hace_hexdump". Signed-off-by: Jamin Lin --- hw/misc/aspeed_hace.c | 46 +++++++++++++++++++++++++++++++++++++++++++ hw/misc/trace-events | 1 + 2 files changed, 47 insertions(+) diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c index 1ffec029dc..50607d2cfa 100644 --- a/hw/misc/aspeed_hace.c +++ b/hw/misc/aspeed_hace.c @@ -10,8 +10,10 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "qemu/log.h" #include "qemu/error-report.h" +#include "qemu/iov.h" #include "hw/misc/aspeed_hace.h" #include "qapi/error.h" #include "migration/vmstate.h" @@ -88,6 +90,42 @@ static const struct { QCRYPTO_HASH_ALGO_SHA256 }, }; =20 +static void hace_hexdump(const char *desc, const char *buf, size_t size) +{ + g_autoptr(GString) str =3D g_string_sized_new(64); + size_t len; + size_t i; + + for (i =3D 0; i < size; i +=3D len) { + len =3D MIN(16, size - i); + g_string_truncate(str, 0); + qemu_hexdump_line(str, buf + i, len, 1, 4); + trace_aspeed_hace_hexdump(desc, i, str->str); + } +} + +static void hace_iov_hexdump(const char *desc, const struct iovec *iov, + const unsigned int iov_cnt) +{ + size_t size =3D 0; + char *buf; + int i; + + for (i =3D 0; i < iov_cnt; i++) { + size +=3D iov[i].iov_len; + } + + buf =3D g_malloc(size); + + if (!buf) { + return; + } + + iov_to_buf(iov, iov_cnt, 0, buf, size); + hace_hexdump(desc, buf, size); + g_free(buf); +} + static int hash_algo_lookup(uint32_t reg) { int i; @@ -303,6 +341,10 @@ static void hash_write_digest_and_unmap_iov(AspeedHACE= State *s, __func__, digest_addr); } =20 + if (trace_event_get_state_backends(TRACE_ASPEED_HACE_HEXDUMP)) { + hace_hexdump("digest", (char *)digest_buf, digest_len); + } + for (; iov_idx > 0; iov_idx--) { address_space_unmap(&s->dram_as, iov[iov_idx - 1].iov_base, iov[iov_idx - 1].iov_len, false, @@ -396,6 +438,10 @@ static void do_hash_operation(AspeedHACEState *s, int = algo, bool sg_mode, return; } =20 + if (trace_event_get_state_backends(TRACE_ASPEED_HACE_HEXDUMP)) { + hace_iov_hexdump("plaintext", iov, iov_idx); + } + /* Executes the hash operation */ if (acc_mode) { hash_execute_acc_mode(s, algo, iov, iov_idx, acc_final_request); diff --git a/hw/misc/trace-events b/hw/misc/trace-events index b2587c37d7..70ca1bd85d 100644 --- a/hw/misc/trace-events +++ b/hw/misc/trace-events @@ -308,6 +308,7 @@ aspeed_hace_write(uint64_t offset, uint64_t data) "offs= et 0x%" PRIx64 " data 0x% aspeed_hace_hash_sg(int index, uint64_t addr, uint32_t len) "%d: addr 0x%"= PRIx64 " len 0x%" PRIx32 aspeed_hace_hash_addr(const char *s, uint64_t addr) "%s: 0x%" PRIx64 aspeed_hace_hash_execute_acc_mode(bool final_request) "final request: %d" +aspeed_hace_hexdump(const char *desc, uint32_t offset, char *s) "%s: 0x%08= x: %s" =20 # bcm2835_property.c bcm2835_mbox_property(uint32_t tag, uint32_t bufsize, size_t resplen) "mbo= x property tag:0x%08x in_sz:%u out_sz:%zu" --=20 2.43.0