From nobody Wed Apr 2 14:26:58 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=1742549443; cv=none; d=zohomail.com; s=zohoarc; b=m+6RKOXABMFg9NMlOO51KrQ1AIkTyJCPe/1JG0rRxSHeH9XLVnYc1+swhT36qhTJk3R9nXJc61ooG+kuV4C3n7c2c+T9IohYgKzlKnYhSi4X022gzzI4h+engw3gdDDimQ+aWpiSrDu8LiIcYmDcKRY+UoXRsoLEIo/i98TkAZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742549443; 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=o25z2Aw2XQ4HMWyGJjYrliXQ0pRCoSEywsz//LHZDb8=; b=jd4wbBADKMsx1qrUo+YWWbe9IH1wytB/1JBkjZrCZ9wyHg2dJz0RkvPzwg7PswZRIlQbQpFls0oPRXJVjS8vtnJ2P2U74CWzKLMfBSL204e6z8msYx5lcd4FejjJpTQe0pTBGTqd3LX9FNhheSxSPRee5KG41B3yGiJp+6nQNos= 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 1742549443237436.31567885189963; Fri, 21 Mar 2025 02:30:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tvYer-0006dX-JL; Fri, 21 Mar 2025 05:27:20 -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 1tvYeO-0006ON-Ly; Fri, 21 Mar 2025 05:26:48 -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 1tvYeM-00056F-P6; Fri, 21 Mar 2025 05:26:48 -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.1258.12; Fri, 21 Mar 2025 17:26:26 +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.1258.12 via Frontend Transport; Fri, 21 Mar 2025 17:26:26 +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 v1 08/22] hw/misc/aspeed_hace: Support DMA 64 bits dram address. Date: Fri, 21 Mar 2025 17:26:04 +0800 Message-ID: <20250321092623.2097234-9-jamin_lin@aspeedtech.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250321092623.2097234-1-jamin_lin@aspeedtech.com> References: <20250321092623.2097234-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: 1742549444011019000 Content-Type: text/plain; charset="utf-8" According to the AST2700 design, the data source address is 64-bit, with R_HASH_SRC_HI storing bits [63:32] and R_HASH_SRC storing bits [31:0]. Similarly, the digest address is 64-bit, with R_HASH_DEST_HI storing bits [63:32] and R_HASH_DEST storing bits [31:0]. Ideally, sg_addr should be 64-bit for the AST2700, using the following prog= ram to obtain the 64-bit sg_addr and convert it to a DRAM offset: ``` sg_addr =3D deposit64(sg_addr, 32, 32, address_space_ldl_le(&s->dram_as, src + SG_LIST_ADDR_SI= ZE, MEMTXATTRS_UNSPECIFIED, NULL); sg_addr -=3D 0x400000000; ``` To maintain compatibility with older SoCs such as the AST2600, the AST2700 = HW HACE controllers automatically set bit 34 of the 64-bit sg_addr. As a resul= t, the firmware only needs to provide a 32-bit sg_addr containing bits [31:0]. This is sufficient for the AST2700, as it uses a DRAM offset rather than a = DRAM address. Introduce a has_dma64 class attribute and set it to true for the AST2700. Signed-off-by: Jamin Lin --- include/hw/misc/aspeed_hace.h | 1 + hw/misc/aspeed_hace.c | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/hw/misc/aspeed_hace.h b/include/hw/misc/aspeed_hace.h index a4479bd383..58fb66009a 100644 --- a/include/hw/misc/aspeed_hace.h +++ b/include/hw/misc/aspeed_hace.h @@ -52,6 +52,7 @@ struct AspeedHACEClass { uint32_t src_hi_mask; uint32_t dest_hi_mask; uint32_t key_hi_mask; + bool has_dma64; }; =20 #endif /* ASPEED_HACE_H */ diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c index 51c6523fab..8f333fc97e 100644 --- a/hw/misc/aspeed_hace.c +++ b/hw/misc/aspeed_hace.c @@ -148,6 +148,7 @@ static bool has_padding(AspeedHACEState *s, struct iove= c *iov, static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode, bool acc_mode) { + AspeedHACEClass *ahc =3D ASPEED_HACE_GET_CLASS(s); bool sg_acc_mode_final_request =3D false; g_autofree uint8_t *digest_buf =3D NULL; struct iovec iov[ASPEED_HACE_MAX_SG]; @@ -182,6 +183,9 @@ static void do_hash_operation(AspeedHACEState *s, int a= lgo, bool sg_mode, } =20 src =3D deposit64(src, 0, 32, s->regs[R_HASH_SRC]); + if (ahc->has_dma64) { + src =3D deposit64(src, 32, 32, s->regs[R_HASH_SRC_HI]); + } src +=3D i * SG_LIST_ENTRY_SIZE; =20 len =3D address_space_ldl_le(&s->dram_as, src, @@ -190,6 +194,21 @@ static void do_hash_operation(AspeedHACEState *s, int = algo, bool sg_mode, sg_addr =3D address_space_ldl_le(&s->dram_as, src + SG_LIST_LE= N_SIZE, MEMTXATTRS_UNSPECIFIED, NULL); sg_addr &=3D SG_LIST_ADDR_MASK; + /* + * Ideally, sg_addr should be 64-bit for the AST2700, using the + * following program to obtain the 64-bit sg_addr and convert = it + * to a DRAM offset: + * sg_addr =3D deposit64(sg_addr, 32, 32, + * address_space_ldl_le(&s->dram_as, src + SG_ADDR_LEN_SI= ZE, + * MEMTXATTRS_UNSPECIFIED, NULL); + * sg_addr -=3D 0x400000000; + * + * To maintain compatibility with older SoCs such as the AST26= 00, + * the AST2700 HW automatically set bit 34 of the 64-bit sg_ad= dr. + * As a result, the firmware only needs to provide a 32-bit sg= _addr + * containing bits [31:0]. This is sufficient for the AST2700,= as + * it uses a DRAM offset rather than a DRAM address. + */ =20 plen =3D len & SG_LIST_LEN_MASK; haddr =3D address_space_map(&s->dram_as, sg_addr, &plen, false, @@ -218,7 +237,9 @@ static void do_hash_operation(AspeedHACEState *s, int a= lgo, bool sg_mode, } else { plen =3D s->regs[R_HASH_SRC_LEN]; src =3D deposit64(src, 0, 32, s->regs[R_HASH_SRC]); - + if (ahc->has_dma64) { + src =3D deposit64(src, 32, 32, s->regs[R_HASH_SRC_HI]); + } haddr =3D address_space_map(&s->dram_as, src, &plen, false, MEMTXATTRS_UNSPECIFIED); if (haddr =3D=3D NULL) { @@ -275,6 +296,9 @@ static void do_hash_operation(AspeedHACEState *s, int a= lgo, bool sg_mode, } =20 digest_addr =3D deposit64(digest_addr, 0, 32, s->regs[R_HASH_DEST]); + if (ahc->has_dma64) { + digest_addr =3D deposit64(digest_addr, 32, 32, s->regs[R_HASH_DEST= _HI]); + } if (address_space_write(&s->dram_as, digest_addr, MEMTXATTRS_UNSPECIFIED, digest_buf, digest_len)) { @@ -601,6 +625,7 @@ static void aspeed_ast2700_hace_class_init(ObjectClass = *klass, void *data) * has completed. It is a temporary workaround. */ ahc->raise_crypt_interrupt_workaround =3D true; + ahc->has_dma64 =3D true; } =20 static const TypeInfo aspeed_ast2700_hace_info =3D { --=20 2.43.0