Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp189443lqp; Tue, 11 Jun 2024 20:30:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUgU8W1Rd/pIYYPh1dAZ9L3TBSsHptYBGbT/F70HVp0q7/vGvmT/bpJNHYPWsLvGCbuIDyPQC5KzkLLHb12JpV1VFKzavVapi6h0+popw== X-Google-Smtp-Source: AGHT+IHWB1fFU09OPTipvIqxKSXQAEB7GYP6ObLw+QglaVCJvMBKoLzrjo/J7k1UJIHdgbm+a+SY X-Received: by 2002:a05:6808:1455:b0:3d2:18c1:bf35 with SMTP id 5614622812f47-3d23e048508mr807472b6e.33.1718163033409; Tue, 11 Jun 2024 20:30:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718163033; cv=pass; d=google.com; s=arc-20160816; b=sffRJFBQFXBI3DXU5s3W6RFr9OKAnJHpUrBeFuo9+7WayPOV3KMTkFBY0q7QAp09Fn 4nwU5S+wJAF2BtV/LWq9IgsY9PvkcvekF9K489QmZ9PY6OhTyDKJIfxB0OEU/T+eIvOK 0141q1vzGpoPFgzX2PZITrSf5z1+wKpOucKdzMUbje7JvhavBp5s6WIHQM2KJ4cQAB7S oQGW4AOJDX7XR86rzkGZwg5FhRE6OGVz6RQk0E2dTNrvDmTD9XrooZsyc2au/YhZIUP9 QNI96zthTJI5wD0QW6RyRuPW508vsFS9tABS3RSeYxWP8QL2Y2M5d9zkh8ciNNqXarWR 6UhQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=scps7QjWxyvhdV/XQdV2Qq/ZG9XRdCPzgPYFH2sd2iE=; fh=adkI9VuQbWqkVTK2cZCXrfrsFecUIk4U750gH+XJGn8=; b=LhaDNtNDw9hvr00ep5NdkE4iMdgrZcjTy1sPUIey2gihmDQKILIMFWqtfNfqa6bRqR iq77svRv+XwO+oMY8pUmaWKou70xF9W4ej1NwqqFO7VXo987UbFP/xX/KVnNYbnu6UT/ 3g2yWWQkjERaJueh4AuMjLZZBIyInI6g7Ego1PB4tf/wM625ynEQEoPNFUNJMNpMY4AS ys1mnMlZfrhXP5W82tGQkYRR3I+23xO2GLK56CNx78RvAYkXjw/nj6k1snmLwpTi71CM wCkW9k1aqnzNiA+FAI+kvFYeneCxJyH+d9h6gShhBXZ7lQ8gh80dlw7mgPv3QQXkyIF2 zAyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com); spf=pass (google.com: domain of linux-crypto+bounces-4909-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4909-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-704cc9a5a92si5122309b3a.350.2024.06.11.20.30.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 20:30:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4909-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=starfivetech.com); spf=pass (google.com: domain of linux-crypto+bounces-4909-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4909-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 32F9D282560 for ; Wed, 12 Jun 2024 03:30:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E14B18E02; Wed, 12 Jun 2024 03:30:29 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2111.outbound.protection.partner.outlook.cn [139.219.146.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0773EF4FA; Wed, 12 Jun 2024 03:30:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.219.146.111 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718163028; cv=none; b=EIL3nzmO0dXVmdeYV7M6DlH5S0SRF8njznfLKbTUuKMmU8JmEvXUpgIOOPrwlTbGt8x7iuojRgV/ltwqTESRKqT49tg+sQ2EcwLhXrzblz14Bnw2ganDnV6yjdevQzk76Y8XJWu2fWTOgeydepZvSM/tZvua6qtsTwhG8V6v6WU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718163028; c=relaxed/simple; bh=kLKAbzi0xsqXvRGTpQFmPAYjqFrDThP5VWGEQnR2Icw=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=UtdBKit8mDuFyg6FUwvp1lIezUypelhUnmcOZxtgE5trEtwLdfAnZ3qZjLf16EG/KvFB88T/KFNCCYc6fm3Xcp3N8BK6VWMsiyWc5qWUBzRKkZTBAXW68/j3y6yU34Yj6TZNpcAqf7n+0j7xPHC6O8qK82U0mwn3u5BjFJ4kwAc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com; spf=pass smtp.mailfrom=starfivetech.com; arc=none smtp.client-ip=139.219.146.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com Received: from NT0PR01MB1182.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:10::10) by NT0PR01MB1023.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.38; Wed, 12 Jun 2024 02:58:19 +0000 Received: from NT0PR01MB1182.CHNPR01.prod.partner.outlook.cn ([fe80::e3b:43f8:2e6d:ecce]) by NT0PR01MB1182.CHNPR01.prod.partner.outlook.cn ([fe80::e3b:43f8:2e6d:ecce%7]) with mapi id 15.20.7611.039; Wed, 12 Jun 2024 02:58:18 +0000 From: JiaJie Ho To: Herbert Xu CC: "David S . Miller" , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] crypto: starfive - Align rsa input data to 32-bit Thread-Topic: [PATCH] crypto: starfive - Align rsa input data to 32-bit Thread-Index: AQHasV7JGIR2o9Gsw0quf+yEyIC5HbG8Na+AgAdOR4A= Date: Wed, 12 Jun 2024 02:58:18 +0000 Message-ID: References: <20240529002553.1372257-1-jiajie.ho@starfivetech.com> In-Reply-To: Accept-Language: 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=starfivetech.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: NT0PR01MB1182:EE_|NT0PR01MB1023:EE_ x-ms-office365-filtering-correlation-id: 00809498-56e6-4ffe-bcac-08dc8a8b8364 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0;ARA:13230032|41320700005|366008|1800799016|38070700010; x-microsoft-antispam-message-info: 6BoecWKvpDpVjmNu8LUkwK6zwPA9uEmbO3qvlGVeHNPr88Q9UPxSlDZMUjw58AWJnrwYfhs2Zh5ccZ9HoM+d0g8N8BCcCP70ckGMXG2ArZW0cUreNEtFa+zGqVQZSDMksfDL7ALEVQ2rAxGiVLWaPVRPxVFo26IdR9hThbZJ/tapYhfMjTsRxW0Vgimfw7APubWSGBq68t2chXuQ8KBiKyGEj5v3d4MLnmWiGIrC6a/SgqmV3oZinRYLi75Z4XHbUfmNY4/ju9XQ88cOpClh2Zf6cMnBTathTx2f0Myct4rVhRSvV2aotUZBLVOclzfAcc4m3XRHGylEYhvqz9J2i6nzvL53hrvafM+s0d7PuVahljwjEWWnFs0aoEu814cYQXoYCbNc8VydbxoS40ay9/HGJBg40w0JW1LzX/UOYLujQHcLuF7WOpAeqZkYf1kx15JAogA+ulL6Yzjd/Rn7rsxYRelx1WBqQMSTX2o1QXezp/rjZrNiux73dDKQUR4SzQx95rWwTBr8gqhexduGQPl4P1tb2j7nI8gAq4JfjRBjNDHAUD049odPvPI+noJdEJ1fm75igpEHmJ95rltB2/wIIC/ARtWdeojnx19ZkMrwnIP89o6YDYHdr57CSjws x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:NT0PR01MB1182.CHNPR01.prod.partner.outlook.cn;PTR:;CAT:NONE;SFS:(13230032)(41320700005)(366008)(1800799016)(38070700010);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?lW/5V8zycOjf4o3J2rWMKA2F98T1zCsR2wFwRdkDT7UF3xLDlq/K1UrIkzf+?= =?us-ascii?Q?nImXyR1pmQYkhR5ydxcIQv+8OK7BrFkxbhyBWTpkS5bFhZ6Pu1026UODyBkb?= =?us-ascii?Q?nMjpYLqbHeE7EAHZhIwK5CdkFsJ36jwc+sd1HfO/vAvax1nn6sSzVBF1Sn+7?= =?us-ascii?Q?IYddaf7Q4olGZh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/qi?= =?us-ascii?Q?QA/U3sIE5j+/RzwQTiisq6FpUxrMSb4GC5PMJKnVsjcPkk+jKe13z/s9ApGa?= =?us-ascii?Q?ZS9dLdAsbMiHTNRQT/uVIegi8a+AtFA88mo1vO+8X9DRADBkDgdZennYFNUN?= =?us-ascii?Q?7HbIbWtgcxauAYJoH7DaodhgcjvjlpArb1zrwDezsPQQxRUr88tlJS1YxjM6?= =?us-ascii?Q?D5GCfuKFnVvuwHAj4SM9UGEPzkhqGagMBfCQudSTgL4LsTfash7zeedQEvuT?= =?us-ascii?Q?RV9IlhgdyQHsa1Ay2DzfsjPm2+7Vi/GRo+RX5Oia3cLEGjm3SyNmOFJwzsNF?= =?us-ascii?Q?QFnUijbvCpFazexgZdEeuzLYMknu/RxCPIS7Uk/uFKcvNW3n5YtUnuK3/3N9?= =?us-ascii?Q?Yj4o4kbVQvBf9a90xPi76P+jmdut5tIPlz4zdldtAeLSOM9oQjOUNIfx6IYV?= =?us-ascii?Q?SWZSE9oyKwUUYDTAjXBPtziEqm5TT/Zqt81ma2j1swPTm3xw/qCGilu1CAkm?= =?us-ascii?Q?AtZjThcg9XBYrlUubaO2d5VO5aADxb+ZfuQ02jcXhN8T/qPQvjt2Zkjnjw+W?= =?us-ascii?Q?lA=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: NT0PR01MB1182.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-Network-Message-Id: 00809498-56e6-4ffe-bcac-08dc8a8b8364 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jun 2024 02:58:18.9125 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: zt44A0KgQ86sjgO5RCVvzzLEJsp44L3oqx1hcRqmIHeWozRqbmLtbCmTU8BtDzhKYVzZjZvxJFm8nbxai4Sqo0xMZ1emJYbEvJybZOQRS1Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: NT0PR01MB1023 > On Wed, May 29, 2024 at 08:25:53AM +0800, Jia Jie Ho wrote: > > Hardware expects RSA input plain/ciphertext to be 32-bit aligned. > > Allocate aligned buffer and shift data accordingly. > > > > Signed-off-by: Jia Jie Ho > > --- > > drivers/crypto/starfive/jh7110-cryp.h | 3 +-- > > drivers/crypto/starfive/jh7110-rsa.c | 17 ++++++++++------- > > 2 files changed, 11 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/crypto/starfive/jh7110-cryp.h > > b/drivers/crypto/starfive/jh7110-cryp.h > > index 494a74f52706..eeb4e2b9655f 100644 > > --- a/drivers/crypto/starfive/jh7110-cryp.h > > +++ b/drivers/crypto/starfive/jh7110-cryp.h > > @@ -217,12 +217,11 @@ struct starfive_cryp_request_ctx { > > struct scatterlist *out_sg; > > struct ahash_request ahash_fbk_req; > > size_t total; > > - size_t nents; > > unsigned int blksize; > > unsigned int digsize; > > unsigned long in_sg_len; > > unsigned char *adata; > > - u8 rsa_data[] __aligned(sizeof(u32)); > > + u8 *rsa_data; >=20 > You didn't explain why this is moving from a pre-allocated buffer to one = that's > allocated on the run. It would appear that there is no reason why you ca= n't > build the extra space used for shifting into reqsize. >=20 Hi Herbert, Can I fix the buffer length of the pre-allocated buffer to 256 bytes instea= d of the current variable length buffer?=20 - u8 rsa_data[] __aligned(sizeof(u32)); + u8 rsa_data[STARFIVE_RSA_MAX_KEYSZ]; That's the maximum length supported by the hardware and=20 most applications now use rsa2048 and above. Thanks, Jia Jie