From nobody Mon Sep 21 07:41:08 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; arc=pass (i=1 dmarc=pass fromdomain=aspeedtech.com); dmarc=pass(p=quarantine dis=none) header.from=aspeedtech.com ARC-Seal: i=2; a=rsa-sha256; t=1784014269; cv=pass; d=zohomail.com; s=zohoarc; b=kbY52I1HWay7SGuNzFE8MLpPfGrZb5CAsaD7n4N2wLdFnCzynct6aliFw5TkQp0rg0B/w9OJdKelJQMq8/IKwCjKVGTNS7IdUPMHql2qkkTE405FpUwzlXWgzLuHRnDQnX8Agpw6/rmK2tDd824egpaZckP07zyFHiIgyA6pONQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784014269; 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=7mB/X1sLtCLXw4NUEl52xUoO6i3d2KP9FJ3Onnh6CnY=; b=dYV4Gc3VcW4REqa8cEtozaPvpQpaElsakFiESxOZ7cs4rNiOIYX70BduDSIr2kGCBBdocZe2/qK/FK8tAksFo2GkaE/4zNHeAiPZtGKujkZuE3/BGvCJulsd9FR3k+pWzJk1uuwzmV/IzEk8LyQRUzrjIye5Wwk58CCXF0cFHDw= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=aspeedtech.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784014269811175.05380355115437; Tue, 14 Jul 2026 00:31:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wjXZz-0005n3-DO; Tue, 14 Jul 2026 03:29:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wjXZy-0005md-6s; Tue, 14 Jul 2026 03:29:22 -0400 Received: from mail-japaneastazlp170120005.outbound.protection.outlook.com ([2a01:111:f403:c405::5] helo=TYPPR03CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wjXZw-0006WV-Ep; Tue, 14 Jul 2026 03:29:21 -0400 Received: from TYZPR06MB4980.apcprd06.prod.outlook.com (2603:1096:400:1cc::10) by SEZPR06MB6117.apcprd06.prod.outlook.com (2603:1096:101:f3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.202.18; Tue, 14 Jul 2026 07:29:06 +0000 Received: from TYZPR06MB4980.apcprd06.prod.outlook.com ([fe80::ea8a:7cb7:4822:2fb3]) by TYZPR06MB4980.apcprd06.prod.outlook.com ([fe80::ea8a:7cb7:4822:2fb3%6]) with mapi id 15.21.0202.014; Tue, 14 Jul 2026 07:29:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=L/f8oBUzOSmgKcyBXWTppmXLGohY+s0qWy9Mdv8hgiPmzgzsaGI7BATpnfDsU+zbya6HDdxorrBjTsRqqT6iELmqAvozNAJSen2bZpcnOPcTEgQoyGZGeHpNlo8DWhYJ5ss5ZJpTvdu5CU5J4TJQojYiWIw8GGGaUis3UKAZbFje9eqxy9kItkV0X5hOLq/oufg75muXdsr/M62sdbjvyaUBf7PZkPnsGf4tp716UAqOduOHA9yzfDMnQCNMUNI8phLOFcsnIn0jAaEn2rE53e6tjhWEo5gxDdWVdSUBSqd19H9d0E3DwbiZBBhE4ZWnXwnQhmvQl3dMrOLAtQGs8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7mB/X1sLtCLXw4NUEl52xUoO6i3d2KP9FJ3Onnh6CnY=; b=p9zLuLqdz8yGJ1trvMxnG6+D6fMqHKk+Uc3FmKwVbXb8bAzMWGXtsKL4FfCTDYz6f4GKZgmRSWziqLxXLAWHnS56653hTccKR6YJ6icys+7Lj9g2vQMSsD1cTJy8lhmvMPm+/Xp6hqXe7IpdJNKVKxhDRYJDH7YsfTu3obTb7+KSvoqUd4xycE5Qn7DKLGtEF40prKvYdw2SYStybeKSMj0EieDj8Ve7trfgIvDCoYS0OOn7y3pW/06l2+2A8CqhcaooEk/YwrOec1+nameI2fmAvxp5v6jov5/9dpKqt+g2rsVCtMVTAULM8GhHdGGI/uc4UTnhayvjvUJjTbGoTw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=aspeedtech.com; dmarc=pass action=none header.from=aspeedtech.com; dkim=pass header.d=aspeedtech.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aspeedtech.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7mB/X1sLtCLXw4NUEl52xUoO6i3d2KP9FJ3Onnh6CnY=; b=SK3U/4rznUQvTUJ0FUY87wvOiPSpQhEEnANPGGNX6hTp57lru2svg8rfO6R4VzKXvxX/chdCh8RsL4+bvV8o2SaxiT+jQkIhzhXCgiktZQIWqFTNhTOTb2WC52WH/37BPY5Wb1vI84IxCreWgtd2feVuWbBiygDUomg5+5ClVYPT2ryXPvj1yzOydTc8w2QUceOQ41dg8jJGp4Ky4RsxHcSHqFCincrgWqwGlyiDQuR6rI1EvMH7GFt8F7MNjeGSLytp2EHKNtTQ3P9U8XX778Iapgio5hOF7IHhgDPHZPGtPwmUp+bIiVoSm21saTjLpURei/E8dqGmcQgWY7cw9w== From: Jamin Lin To: =?iso-8859-1?Q?Daniel_P=2E_Berrang=E9?= , =?iso-8859-1?Q?C=E9dric_Le_Goater?= , Peter Maydell , Steven Lee , Troy Lee , Kane Chen , Andrew Jeffery , Joel Stanley , Eric Blake , Markus Armbruster , Fabiano Rosas , Laurent Vivier , Paolo Bonzini , "open list:All patches CC here" , "open list:ASPEED BMCs" CC: Jamin Lin , Troy Lee Subject: [PATCH v1 03/15] hw/misc/aspeed_hace: Support scatter-gather mode for the crypto command Thread-Topic: [PATCH v1 03/15] hw/misc/aspeed_hace: Support scatter-gather mode for the crypto command Thread-Index: AQHdE2Jz+hmGiS6Ae06EvHD/bqTxuA== Date: Tue, 14 Jul 2026 07:29:05 +0000 Message-ID: <20260714072900.3023742-4-jamin_lin@aspeedtech.com> References: <20260714072900.3023742-1-jamin_lin@aspeedtech.com> In-Reply-To: <20260714072900.3023742-1-jamin_lin@aspeedtech.com> Accept-Language: zh-TW, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=aspeedtech.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: TYZPR06MB4980:EE_|SEZPR06MB6117:EE_ x-ms-office365-filtering-correlation-id: 42dcd676-37b9-44ec-35d3-08dee1799635 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|23010399003|7416014|376014|1800799024|921020|38070700021|18002099003|22082099003|56012099006; x-microsoft-antispam-message-info: 3jXePj215uezzJxXN9zx9N1NTU9YhEy9EoX8/vg93EUV/or2Xwdktkpc0JN42E/11IjcnS8TsL1RtPacnp77csxq3P2EMlRF+8ihX0KDn35NRNhbthZwy3uHiho+tLOjC/LoSm74gsdK6NIZgytYbhAYuKlm9pxgTUeiR+c4AXgtCHx72/uCbhsyb8ttSozZnZCd5OV3MSi5APnlM2StfDs/3ipGryCNOQMGGYTfDw1Qal651uAU55WraBcyLOwrPKQTpL2kdS727jxTlrce9JJLHh2b/qUKkosOKI4qC3pc+6mEWrSxjAWxcIFYjjDoQJyaziRjH84dRocVTg8i9yLlut6GiCSkypfoSbr0TkMgUvhKv0GtARe1wIb+I6upD5/zk3EcqIp0dha6uDPFoKI1cweJ0dukOlz4B4dlLjVeXByWc736yRiA3cWWZQi7wTbOFVm9WDtcIs86aLV4gkLAhPbcgWBGQN6aeTk5KyXKttg9eQ/0wO/JEL28+rD3FFpqCe3X9lLo662WPECcl2GhbNTPBHFza1Dpa7w+/6KnUyg5lV9IyQ2JCXFTAECJW8XVepiTEfji8grkhG4N/CizoAlcsrOK43kbTU85MypIXVYcoF9VpgZU1IZFPAj1VzXJGG7RxJuF1pAP648U3oNc9z4Dh4ex35cf2o6riYWjVkHrDsndvzQxnwcy/NEbqSOo8r62pVrXmTiugZ/g2NdgfnKUopfldY6L3JE+Bn6M+8YFquMomjM6v4aSNvd7 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYZPR06MB4980.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(23010399003)(7416014)(376014)(1800799024)(921020)(38070700021)(18002099003)(22082099003)(56012099006); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?Tf8Ixwx7V5aeh65NS1flIfldvW/1ZifyE7/7rPhkZhO/CkJ2PaCE0/RxCH?= =?iso-8859-1?Q?s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QMsaxs6g=3D=3D?= Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Exchange-RoutingPolicyChecked: iICdY6UJj5gxBiA2Ayo84d4wTkej+bJB7GAOLtR4Yg/S/dfQybJl/GqCaJ91gBTloddtxYaz9paEbug6O4PMKYsx/GVnP5tTeDaVGX/KT/IUySSNWWYL1glE+jJRJFPsA9YXENvJKaO1PhY67urKlbxAG2YJuZfLUOhlwq7xPpxmgpjLStTqhpEPd0Z3PsmbNZSOE8v+76VkUBqSBykdfaqxd+cDQjg1+AWlBQ9vh64eRQZLCVOGfjTjPH55isRAEPHwtdtovPmaoIIAdSiUgOK5f940IU2PK6ovREzvOWeODb7MU8UOLZ6zk1KOOWIaPInUV9du6EbGsIIYr2Z1Kw== X-OriginatorOrg: aspeedtech.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB4980.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42dcd676-37b9-44ec-35d3-08dee1799635 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jul 2026 07:29:06.0109 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43d4aa98-e35b-4575-8939-080e90d5a249 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Gj3rpixeHXO52g1LmWETyFqXgot4cw83nvFJKnMo61NPsncs5w6NWoB4zR0bhCK+CtZY4Lg/6RtQJ9Q+IcdzU/Ln7bBbkxa8n63FxZVK1KA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB6117 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:111:f403:c405::5; envelope-from=jamin_lin@aspeedtech.com; helo=TYPPR03CU001.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-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 @aspeedtech.com) X-ZM-MESSAGEID: 1784014271388158500 Content-Type: text/plain; charset="utf-8" The AST2600 and later crypto engines drive the source and destination through scatter-gather lists (HACE10[18]/[19]) rather than the single contiguous buffers used by the AST2500 direct access mode. Each SG list entry is a length word (SG_LIST_LEN_LAST marks the final entry) followed by a DRAM address, matching the hash engine layout. Add a crypt_prepare_sg() helper that gathers the source into / scatters the destination out of the bounce buffer by walking the SG list, and select it or the existing crypt_prepare_direct() from do_crypt_operation based on HACE10[18], mirroring the hash engine's direct/scatter-gather dispatch. Signed-off-by: Jamin Lin --- hw/misc/aspeed_hace.c | 70 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 6 deletions(-) diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c index 42d8b38be3..59eb1aeae3 100644 --- a/hw/misc/aspeed_hace.c +++ b/hw/misc/aspeed_hace.c @@ -610,13 +610,58 @@ static bool crypt_prepare_direct(AspeedHACEState *s, = uint64_t addr, } =20 /* - * Perform an AES/DES/3DES ECB/CBC operation in direct access mode: the so= urce - * and destination are single contiguous buffers (HACE00/HACE04) and the I= V/key - * come from the context buffer (HACE08). For CBC the resulting chaining I= V is - * written back to the context buffer so the driver can continue the chain. + * Scatter-gather mode: the source/destination register points at an SG li= st + * whose entries are a length word (SG_LIST_LEN_LAST flags the final entry) + * followed by a DRAM address, matching the hash engine layout. Gather @len + * bytes into @buf, or scatter @buf back out when @to_dram is true. + * Returns true on success. + */ +static bool crypt_prepare_sg(AspeedHACEState *s, uint64_t addr, + uint8_t *buf, uint32_t len, bool to_dram) +{ + uint32_t copied =3D 0; + uint32_t sg_addr; + uint32_t sg_len; + uint32_t entry; + int i; + + for (i =3D 0; i < ASPEED_HACE_MAX_SG && copied < len; i++) { + entry =3D address_space_ldl_le(&s->dram_as, addr, + MEMTXATTRS_UNSPECIFIED, NULL); + sg_addr =3D address_space_ldl_le(&s->dram_as, addr + SG_LIST_LEN_S= IZE, + MEMTXATTRS_UNSPECIFIED, NULL); + sg_len =3D entry & SG_LIST_LEN_MASK; + + sg_addr &=3D SG_LIST_ADDR_MASK; + addr +=3D SG_LIST_ENTRY_SIZE; + + if (sg_len > len - copied) { + sg_len =3D len - copied; + } + if (address_space_rw(&s->dram_as, sg_addr, MEMTXATTRS_UNSPECIFIED, + buf + copied, sg_len, to_dram)) { + return false; + } + copied +=3D sg_len; + + if (entry & SG_LIST_LEN_LAST) { + break; + } + } + + return copied =3D=3D len; +} + +/* + * Perform an AES/DES/3DES ECB/CBC operation. The source and destination a= re + * either single contiguous buffers (direct access mode) or scatter-gather + * lists (HACE10[18]/[19]), addressed by HACE00/HACE04; the IV/key come fr= om + * the context buffer (HACE08). For CBC the resulting chaining IV is writt= en + * back to the context buffer so the driver can continue the chain. */ static void do_crypt_operation(AspeedHACEState *s, uint32_t cmd) { + bool sg_mode =3D cmd & CRYPT_CMD_SRC_SG_CTRL; uint32_t len =3D s->regs[R_CRYPT_DATA_LEN]; bool encrypt =3D cmd & CRYPT_CMD_ENCRYPT; g_autoptr(QCryptoCipher) cipher =3D NULL; @@ -633,6 +678,7 @@ static void do_crypt_operation(AspeedHACEState *s, uint= 32_t cmd) size_t iv_offset; size_t blocklen; size_t keylen; + bool status; =20 if (len =3D=3D 0) { return; @@ -679,8 +725,14 @@ static void do_crypt_operation(AspeedHACEState *s, uin= t32_t cmd) src_buf =3D g_malloc0(len); dst_buf =3D g_malloc0(len); =20 + /* Gather the source into the bounce buffer, per the selected mode. */ src_addr =3D s->regs[R_CRYPT_SRC]; - if (!crypt_prepare_direct(s, src_addr, src_buf, len, false)) { + if (sg_mode) { + status =3D crypt_prepare_sg(s, src_addr, src_buf, len, false); + } else { + status =3D crypt_prepare_direct(s, src_addr, src_buf, len, false); + } + if (!status) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to read src, addr=3D0x%" HWADDR_PRIx "\n= ", __func__, src_addr); @@ -709,8 +761,14 @@ static void do_crypt_operation(AspeedHACEState *s, uin= t32_t cmd) } } =20 + /* Scatter the result back out, per the selected mode. */ dst_addr =3D s->regs[R_CRYPT_DEST]; - if (!crypt_prepare_direct(s, dst_addr, dst_buf, len, true)) { + if (sg_mode) { + status =3D crypt_prepare_sg(s, dst_addr, dst_buf, len, true); + } else { + status =3D crypt_prepare_direct(s, dst_addr, dst_buf, len, true); + } + if (!status) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Failed to write dst, addr=3D0x%" HWADDR_PRIx "\= n", __func__, dst_addr); --=20 2.43.0