From nobody Thu Sep 24 23:33:31 2026 Received: from canpmsgout08.his.huawei.com (canpmsgout08.his.huawei.com [113.46.200.223]) (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 EA08A3CCFD4; Fri, 18 Sep 2026 12:27:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.223 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734455; cv=none; b=VAVM+R5J1Mgpd5CWx+k4CL5lw+XqqOnqzSIqFs2hhpKUodV45wybTN2pR5ZzS8WRUNjWIeLWzv4DOUcnGCwB+s9qY5h3kJg3OAAqVDuOoPjDE85IGG5alNoGDmmFXmXPxNw5a47qcXL8i7K8lnm7PgYXth+e3TFV+WNywkoU6Gk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734455; c=relaxed/simple; bh=0RLQ+Nw7W6ws5/BQWRF35FYRoL1AA3tMEctto32L4OI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ltgw4QJSEq8dltYVGist5OobmysfWL75B2igB4SX2wkrE5UWkyqYZiO8MWvOKnreVel354NS5oFli87PReHg5J4JbUXR1+eRfqy3PXfxtbvApRS/UYSde1QhJ31N0ZTgSs/mQHQqO7NiW1uEm7gcJnzwWCyycmFSPYp+xwL8GgY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=cfIiJp6O; arc=none smtp.client-ip=113.46.200.223 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="cfIiJp6O" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=89vysMK0wCmlF4ELxDP7tvpUD5j4NQPkhelV2nSX49I=; b=cfIiJp6OSAKWMblccZamCZKUI9jQphMaIJMI6WdzkXAoPJOC4su71gKDpG/Ju3GSpNr7hEqKF 5H8+O8vO+yvVNDbgGe0p6HSrmVuLNF+sBx1X3xv8pOUKrlTektVi53FPeZPaxHmoegLUgdxKKP4 HFWdPq6e6d40b8pdRY/kPro= Received: from mail.maildlp.com (unknown [172.19.163.127]) by canpmsgout08.his.huawei.com (SkyGuard) with ESMTPS id 4hmWnR6mDkzmV8f; Fri, 18 Sep 2026 20:16:27 +0800 (CST) Received: from kwepemf200011.china.huawei.com (unknown [7.202.181.237]) by mail.maildlp.com (Postfix) with ESMTPS id 1E267402AB; Fri, 18 Sep 2026 20:27:28 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemf200011.china.huawei.com (7.202.181.237) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Fri, 18 Sep 2026 20:27:27 +0800 From: Weili Qian To: CC: , , Subject: [PATCH 1/7] crypto: hisilicon/hpre - fix pointer dereference before length check Date: Fri, 18 Sep 2026 20:27:20 +0800 Message-ID: <20260918122726.3014899-2-qianweili@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918122726.3014899-1-qianweili@huawei.com> References: <20260918122726.3014899-1-qianweili@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemf200011.china.huawei.com (7.202.181.237) Content-Type: text/plain; charset="utf-8" In hpre_rsa_drop_leading_zeros(), the loop condition dereferences *ptr before checking *len, causing an out-of-bounds read when *len is zero. Swap to while (*len && !**ptr) to test length first. Fixes: c8b4b477079d ("crypto: hisilicon - add HiSilicon HPRE accelerator") Cc: stable@vger.kernel.org Signed-off-by: Weili Qian --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/h= isilicon/hpre/hpre_crypto.c index 09077abbf6ad..7894211b9972 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -720,7 +720,7 @@ static void hpre_dh_exit_tfm(struct crypto_kpp *tfm) =20 static void hpre_rsa_drop_leading_zeros(const char **ptr, size_t *len) { - while (!**ptr && *len) { + while (*len && !**ptr) { (*ptr)++; (*len)--; } --=20 2.43.0 From nobody Thu Sep 24 23:33:31 2026 Received: from canpmsgout10.his.huawei.com (canpmsgout10.his.huawei.com [113.46.200.225]) (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 AF2A6376BD9; Fri, 18 Sep 2026 12:27:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.225 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734456; cv=none; b=Crkyth6gwRMJwPe1OJYcIfG5h5xo7zE0oha86jP6lD4lLgo5nD1g7860FJcVMW3QLEamj+f51+JOL4+O5J1TcZjW0+CEApUZ5yyK24H5BRcorNrcgmdG7cmvx5DjIlPbE4lUHpAy4TqQku/lAH1+2JVu69t93S+KMwezSPAKOQA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734456; c=relaxed/simple; bh=8oQxtXU54VAPeYYR8e8fB9bERuTq9TTxLa2/SL3QoGQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X6Z7490i4sgrbEI84I8PEt0eTzEy/1otCl1bWvp23fhsoDxCcg/zImnIXEtKvvifHZP5N+EGoIxdukewGTCuWRThD0OfY6vpN4dNx1wnIVU+fauIL37JtQ78tWosV6aM8gl0N3KW5uaHqyzLynaSKCWL4HIkjSdvlHBw8pkry3Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=JCn7tzIk; arc=none smtp.client-ip=113.46.200.225 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="JCn7tzIk" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=8KQLO/3WGiDHJQbt1e7LoBrA6C7xR9CjUl6+/I3E0jQ=; b=JCn7tzIk0pTwwiFMeHmNSoIaZ6NtKoxuGcGZ2Qf1IZpdwsCpEvDv2AcPT83mC71bRIzcl5X9C sUN9wT3Oex27ZTLuiAHwhS1P5CeqfLytE5VN7eHyKd+tADwrLFqrPbcq6gmP3Hr27kR4V1npU42 /as8EZIYNb96e/j4A/J5ezE= Received: from mail.maildlp.com (unknown [172.19.163.127]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4hmWnS1qXLz1K96s; Fri, 18 Sep 2026 20:16:28 +0800 (CST) Received: from kwepemf200011.china.huawei.com (unknown [7.202.181.237]) by mail.maildlp.com (Postfix) with ESMTPS id 68307402AB; Fri, 18 Sep 2026 20:27:28 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemf200011.china.huawei.com (7.202.181.237) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Fri, 18 Sep 2026 20:27:27 +0800 From: Weili Qian To: CC: , , Subject: [PATCH 2/7] crypto: hisilicon/hpre - remove dma_free_coherent on NULL req->dst in ECDH Date: Fri, 18 Sep 2026 20:27:21 +0800 Message-ID: <20260918122726.3014899-3-qianweili@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918122726.3014899-1-qianweili@huawei.com> References: <20260918122726.3014899-1-qianweili@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemf200011.china.huawei.com (7.202.181.237) Content-Type: text/plain; charset="utf-8" In hpre_ecdh_hw_data_clr_all(), req->dst is always NULL because hpre_ecdh_dst_data_init() sets hpre_req->dst =3D NULL before mapping the user buffer with dma_map_single(). The dma_free_coherent() call on req->dst is therefore dead code. Remove it. Fixes: 05e7b906aa7c ("crypto: hisilicon/hpre - add 'ECDH' algorithm") Signed-off-by: Weili Qian --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/h= isilicon/hpre/hpre_crypto.c index 7894211b9972..8551d6ccb78d 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -1407,8 +1407,6 @@ static void hpre_ecdh_hw_data_clr_all(struct hpre_ctx= *ctx, if (unlikely(dma_mapping_error(dev, dma))) return; =20 - if (req->dst) - dma_free_coherent(dev, ctx->key_sz << 1, req->dst, dma); if (dst) dma_unmap_single(dev, dma, ctx->key_sz << 1, DMA_FROM_DEVICE); } --=20 2.43.0 From nobody Thu Sep 24 23:33:31 2026 Received: from canpmsgout04.his.huawei.com (canpmsgout04.his.huawei.com [113.46.200.219]) (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 6BB083C3F66; Fri, 18 Sep 2026 12:27:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.219 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734455; cv=none; b=u4GjQyYcnxymibmEmLBOZn7K/Kjha8XO/YCytdsSxmehJYmUJzZuJa1cylzCFmXRsXyhiLwQQpBiEIwMXLp8raidyO82oy2qSDYn6jU2b3/LyHFO2oGeWWggTQjealp62gPfDZh90JECkKrc1q25MoxA/qOVPA1FDnygp1Lb1ZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734455; c=relaxed/simple; bh=LI+Uhva6eJJpMwwRaASsp69sBznwxkQNwrdv8aJfCiw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EojXWt1DKm0f2Hkgwk1PFYb2FvOUWgpBnnq/vSIU7t3Z3E0OZqHNuyTjfXkHiC6yDGeReXY0/O+RQ7le1GcFW25LHkV4ETgmoqIc/Gqjg/nNQ5krVCLVfEOZMsmf8FE7qdNannpp0zzH5fMcwxU+0nnSSH9JL79ITaP7RtqENlI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=gKF6OXE0; arc=none smtp.client-ip=113.46.200.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="gKF6OXE0" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=vuCDgkswYZewxfTmNHghToleKyEAFZUP8mxAdm+1/sw=; b=gKF6OXE0N4RePI0U1kTrjB17qrHclmzuDJfAA6JQ7GVxdHvw7USV9/g2PjjoJ3ZiI2aqRhQtn W0rMgv0rt6ojK4wvN2E9IKJfgaa5MZzxPqxD6fjKiiykYceKQFVKfl3Vb8kOsldJGF1SjBBx1Ay DTHqIq5Siflyme/fUTWEtkI= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4hmWnR2FDCz1prN6; Fri, 18 Sep 2026 20:16:27 +0800 (CST) Received: from kwepemf200011.china.huawei.com (unknown [7.202.181.237]) by mail.maildlp.com (Postfix) with ESMTPS id A404D4058C; Fri, 18 Sep 2026 20:27:28 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemf200011.china.huawei.com (7.202.181.237) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Fri, 18 Sep 2026 20:27:28 +0800 From: Weili Qian To: CC: , , Subject: [PATCH 3/7] crypto: hisilicon/hpre - return -EOVERFLOW for small ECDH output buffer Date: Fri, 18 Sep 2026 20:27:22 +0800 Message-ID: <20260918122726.3014899-4-qianweili@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918122726.3014899-1-qianweili@huawei.com> References: <20260918122726.3014899-1-qianweili@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemf200011.china.huawei.com (7.202.181.237) Content-Type: text/plain; charset="utf-8" hpre_ecdh_msg_request_set() returns -EINVAL when the output buffer is too small, after setting req->dst_len to the required size. -EINVAL is misleading because the caller can retry with a larger buffer. Return -EOVERFLOW as other kpp implementations do. Fixes: 05e7b906aa7c ("crypto: hisilicon/hpre - add 'ECDH' algorithm") Cc: stable@vger.kernel.org Signed-off-by: Weili Qian --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/h= isilicon/hpre/hpre_crypto.c index 8551d6ccb78d..6dea9ce5bae2 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -1450,7 +1450,7 @@ static int hpre_ecdh_msg_request_set(struct hpre_ctx = *ctx, =20 if (req->dst_len < ctx->key_sz << 1) { req->dst_len =3D ctx->key_sz << 1; - return -EINVAL; + return -EOVERFLOW; } =20 tmp =3D kpp_request_ctx(req); --=20 2.43.0 From nobody Thu Sep 24 23:33:31 2026 Received: from canpmsgout03.his.huawei.com (canpmsgout03.his.huawei.com [113.46.200.218]) (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 ED38B4B66FB; Fri, 18 Sep 2026 12:27:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734456; cv=none; b=AkjO3TkeNWi/gIIqWAYYJ7tlueNZGE7rYGpsOH5VL8Swu+Vfrrb18SKdQ1XxV5TmSZ/qD+QilOgdz9gRJhjWP7Xz+Ih5181v4kcu57s7oZbZIVZWyiDIyZsiDz4t6q+CN2lZtCzopJ/PZqViLfpFM5Ffy8Ok4FG+iEmEpm9pZig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734456; c=relaxed/simple; bh=92jXGMKovCA19ofPyQriIYvTntbQFOLIJcDnE3C6Mk0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TI2YiC2ocIdaXbagBvsn/RFqKClQTQmg9+maQRlricqBBIp0SZBP5JgO8w9wJYleTwNgSq5tdoUUIuTJAH4uiljVHLCdXFmpMEXF4Vkw0gocyR0I7THQrCg4L1lCgkpLG3h1fUPMR1/TaWKyiTVj4Bqjj0tKyTIQHZ5043CwwTE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=OM7NORuF; arc=none smtp.client-ip=113.46.200.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="OM7NORuF" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=yLtzeMx/3TAcS4LrB7aZaDkHiUpoWcI1JJIq7RkxACU=; b=OM7NORuFf1qGpgY3gV6t/jIBfbIC1kePRFZMvdcW6LX1WLOKTELXSG0EvMMBui8h9AIt1rG8A YEmPovOAtgt5A7bIvvPlrL14+lYernNWwFSzDJmvu0HSzMQV05IfkcMyexklXU+E+upiT8RsBeh b036RsC2YMSbgg244pUM8UI= Received: from mail.maildlp.com (unknown [172.19.162.140]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4hmWmW4jVszpStW; Fri, 18 Sep 2026 20:15:39 +0800 (CST) Received: from kwepemf200011.china.huawei.com (unknown [7.202.181.237]) by mail.maildlp.com (Postfix) with ESMTPS id EF37320333; Fri, 18 Sep 2026 20:27:28 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemf200011.china.huawei.com (7.202.181.237) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Fri, 18 Sep 2026 20:27:28 +0800 From: Weili Qian To: CC: , , Subject: [PATCH 4/7] crypto: hisilicon/hpre - fix ECDH destination DMA mapping Date: Fri, 18 Sep 2026 20:27:23 +0800 Message-ID: <20260918122726.3014899-5-qianweili@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918122726.3014899-1-qianweili@huawei.com> References: <20260918122726.3014899-1-qianweili@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemf200011.china.huawei.com (7.202.181.237) Content-Type: text/plain; charset="utf-8" hpre_ecdh_dst_data_init() rejects valid requests whose output length does not equal ctx->key_sz << 1, and maps the user buffer using the user-provided len instead of the hardware transfer size. Drop the redundant length check and use ctx->key_sz << 1 for dma_map_single() so the whole hardware output is mapped. Fixes: 05e7b906aa7c ("crypto: hisilicon/hpre - add 'ECDH' algorithm") Cc: stable@vger.kernel.org Signed-off-by: Weili Qian --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/h= isilicon/hpre/hpre_crypto.c index 6dea9ce5bae2..f77c318caa35 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -1510,13 +1510,13 @@ static int hpre_ecdh_dst_data_init(struct hpre_asym= _request *hpre_req, struct device *dev =3D ctx->dev; dma_addr_t dma; =20 - if (unlikely(!data || !sg_is_last(data) || len !=3D ctx->key_sz << 1)) { - dev_err(dev, "data or data length is illegal!\n"); + if (unlikely(!data || !sg_is_last(data))) { + dev_err(dev, "data is illegal!\n"); return -EINVAL; } =20 hpre_req->dst =3D NULL; - dma =3D dma_map_single(dev, sg_virt(data), len, DMA_FROM_DEVICE); + dma =3D dma_map_single(dev, sg_virt(data), ctx->key_sz << 1, DMA_FROM_DEV= ICE); if (unlikely(dma_mapping_error(dev, dma))) { dev_err(dev, "dma map data err!\n"); return -ENOMEM; --=20 2.43.0 From nobody Thu Sep 24 23:33:31 2026 Received: from canpmsgout04.his.huawei.com (canpmsgout04.his.huawei.com [113.46.200.219]) (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 A72054B5CD0; Fri, 18 Sep 2026 12:27:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.219 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734455; cv=none; b=ZfKlq9qgr28DuTCnqeeIlR4JOHYsSQa/ATwVSA7Q34Oz3RFLKr17OzIyi6Ru/PhwYM9S/+G83Vr5JiZasgVYlB5wmvNlHtCyqjWstG0NwMNJ/LZQ3ivoSQmGAWQKak6Rg49RJAHWvGgJwf2noUZt7EJsBTvELuN+gbXrUCj323k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734455; c=relaxed/simple; bh=ZTA2yq+xKCIgjYdHHld2+CkUR+CD5y4Lx5nxLGlNS6w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IuhEBcQcJ7MHOgXSb1zdERJOhXWBUkwYdus0OdjY0rw7blUe5XDxSPZS1gw+5vAjhY1olUozcID5FcldJtNb0sX8fOl6KrED7cCohN95C2N/H1Wmx0jdhUx8yxKpbRtLDaWO0z1TRrhzC0KXW62TjNHC1j2IcJr28kRiqtq58TE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=xIn8Ys7+; arc=none smtp.client-ip=113.46.200.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="xIn8Ys7+" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=hvW4+Oqcg/pgFFd6QfLNFWFWT9SevP0LL6+aVDTAX8E=; b=xIn8Ys7+KH++OO/zF4N1o8XSXGLi9DxbeJYBU4a9UruQxrKXXIZ0df28JD6FwCN0n39TbpyFg 0JCjt3kXaUJj+Gm0Aosg3VIWkOfwuGmfVKsjbCaU5dm8SFrvoqh9K/aTiJQklrru1Kjj8LEcc// lff0PXnebrnnB236Xp+Tb4o= Received: from mail.maildlp.com (unknown [172.19.162.144]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4hmWnR6RMmz1prLc; Fri, 18 Sep 2026 20:16:27 +0800 (CST) Received: from kwepemf200011.china.huawei.com (unknown [7.202.181.237]) by mail.maildlp.com (Postfix) with ESMTPS id 400C240538; Fri, 18 Sep 2026 20:27:29 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemf200011.china.huawei.com (7.202.181.237) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Fri, 18 Sep 2026 20:27:28 +0800 From: Weili Qian To: CC: , , Subject: [PATCH 5/7] crypto: hisilicon/hpre - fix GFP flags for dma_alloc_coherent Date: Fri, 18 Sep 2026 20:27:24 +0800 Message-ID: <20260918122726.3014899-6-qianweili@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918122726.3014899-1-qianweili@huawei.com> References: <20260918122726.3014899-1-qianweili@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemf200011.china.huawei.com (7.202.181.237) Content-Type: text/plain; charset="utf-8" The HPRE driver hard-codes GFP_ATOMIC for RSA/DH and GFP_KERNEL for ECDH. This may cause "scheduling while atomic" in atomic context or unnecessary allocation failures under memory pressure. Select GFP flags dynamically based on CRYPTO_TFM_REQ_MAY_SLEEP and store them in hpre_asym_request::flags. The areq field is a union of rsa/dh/ecdh request pointers; reading base.flags through any union member other than the one that was written would be type-punning, so a dedicated flags field avoids that. Fixes: 98dfa9343f37 ("crypto: hisilicon/hpre - don't use GFP_KERNEL to allo= c mem during softirq") Cc: stable@vger.kernel.org Signed-off-by: Weili Qian --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/h= isilicon/hpre/hpre_crypto.c index f77c318caa35..6ca34f3bf9ff 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -138,6 +138,7 @@ struct hpre_asym_request { int err; hpre_cb cb; struct timespec64 req_time; + u32 flags; }; =20 static inline unsigned int hpre_align_sz(void) @@ -186,6 +187,7 @@ static int hpre_prepare_dma_buf(struct hpre_asym_reques= t *hpre_req, struct scatterlist *data, unsigned int len, int is_src, dma_addr_t *tmp) { + gfp_t gfp =3D hpre_req->flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : G= FP_ATOMIC; struct hpre_ctx *ctx =3D hpre_req->ctx; struct device *dev =3D ctx->dev; void *ptr; @@ -195,7 +197,7 @@ static int hpre_prepare_dma_buf(struct hpre_asym_reques= t *hpre_req, if (unlikely(shift < 0)) return -EINVAL; =20 - ptr =3D dma_alloc_coherent(dev, ctx->key_sz, tmp, GFP_ATOMIC); + ptr =3D dma_alloc_coherent(dev, ctx->key_sz, tmp, gfp); if (unlikely(!ptr)) return -ENOMEM; =20 @@ -419,6 +421,7 @@ static int hpre_msg_request_set(struct hpre_ctx *ctx, v= oid *req, bool is_rsa) h_req =3D PTR_ALIGN(tmp, hpre_align_sz()); h_req->cb =3D hpre_rsa_cb; h_req->areq.rsa =3D akreq; + h_req->flags =3D akreq->base.flags; msg =3D &h_req->req; memset(msg, 0, sizeof(*msg)); } else { @@ -433,6 +436,7 @@ static int hpre_msg_request_set(struct hpre_ctx *ctx, v= oid *req, bool is_rsa) h_req =3D PTR_ALIGN(tmp, hpre_align_sz()); h_req->cb =3D hpre_dh_cb; h_req->areq.dh =3D kreq; + h_req->flags =3D kreq->base.flags; msg =3D &h_req->req; memset(msg, 0, sizeof(*msg)); msg->key =3D cpu_to_le64(ctx->dh.dma_xa_p); @@ -1457,6 +1461,7 @@ static int hpre_ecdh_msg_request_set(struct hpre_ctx = *ctx, h_req =3D PTR_ALIGN(tmp, hpre_align_sz()); h_req->cb =3D hpre_ecdh_cb; h_req->areq.ecdh =3D req; + h_req->flags =3D req->base.flags; msg =3D &h_req->req; memset(msg, 0, sizeof(*msg)); msg->in =3D cpu_to_le64(DMA_MAPPING_ERROR); @@ -1475,6 +1480,7 @@ static int hpre_ecdh_msg_request_set(struct hpre_ctx = *ctx, static int hpre_ecdh_src_data_init(struct hpre_asym_request *hpre_req, struct scatterlist *data, unsigned int len) { + gfp_t gfp =3D hpre_req->flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : G= FP_ATOMIC; struct hpre_sqe *msg =3D &hpre_req->req; struct hpre_ctx *ctx =3D hpre_req->ctx; struct device *dev =3D ctx->dev; @@ -1488,7 +1494,7 @@ static int hpre_ecdh_src_data_init(struct hpre_asym_r= equest *hpre_req, if (unlikely(shift < 0)) return -EINVAL; =20 - ptr =3D dma_alloc_coherent(dev, ctx->key_sz << 2, &dma, GFP_KERNEL); + ptr =3D dma_alloc_coherent(dev, ctx->key_sz << 2, &dma, gfp); if (unlikely(!ptr)) return -ENOMEM; =20 --=20 2.43.0 From nobody Thu Sep 24 23:33:31 2026 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (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 056BE41A4E7; Fri, 18 Sep 2026 12:27:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734457; cv=none; b=IUjMAkaqwZbAcjpkhrUh/o2dZBcwflaDhWM+glB8hwkDmARjK4HlJyyCykcmIyZ3+QZ0xWia96LuDwcH741WbT1U0jlBQ7Jk1Oz97zvN4aeelPW3hA+ypTqDUJj+WHyvqJu/yvvXRyP314skmAmr17ALK6KxzmgBldFtwRp/UtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734457; c=relaxed/simple; bh=EW7V11/lMMSW3K8uKw2nnVN9ED/jd6XZ3ulvpPDzj/M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CvD/UiSUZ8UHbSQFH71XHmE+yerhnb8mtVfQ+R51woR+NaQhxSQ+rUnz/ay8j5x7HClaLmWB2iRhrW+kIulk/3/2GD/utJ4zlqIFq+TOtte+T8PAXTNYg1dufkfwic/MlIytyhWY/2h9jda29SMXncUcVpDMGYqIxfnp29fkYjU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=t87tOstc; arc=none smtp.client-ip=113.46.200.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="t87tOstc" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=Zhld7CbpOTpaqLQdi9ubdIS0fNQVsZiiVJDx/3SQYRE=; b=t87tOstc+fUnGCICoS7wIWO4WJfrK/sq+GTbdp59DreLH7U8r5GAISj8LXK7mhCMuP01f9Enl 1B73ANwjbwLlkBhTN5vl6ErEPQg4lWu/7KeKe1AmnRbNMIRhtq2Zq5/7u8n9P11UzDA700noAWK BizxLL7iWmDLbyGghbeA0do= Received: from mail.maildlp.com (unknown [172.19.163.214]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4hmWnP6YZpzKmT6; Fri, 18 Sep 2026 20:16:25 +0800 (CST) Received: from kwepemf200011.china.huawei.com (unknown [7.202.181.237]) by mail.maildlp.com (Postfix) with ESMTPS id 91B2D4057C; Fri, 18 Sep 2026 20:27:29 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemf200011.china.huawei.com (7.202.181.237) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Fri, 18 Sep 2026 20:27:29 +0800 From: Weili Qian To: CC: , , Subject: [PATCH 6/7] crypto: hisilicon/hpre - extract clusters num into inline function Date: Fri, 18 Sep 2026 20:27:25 +0800 Message-ID: <20260918122726.3014899-7-qianweili@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918122726.3014899-1-qianweili@huawei.com> References: <20260918122726.3014899-1-qianweili@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemf200011.china.huawei.com (7.202.181.237) Content-Type: text/plain; charset="utf-8" Seven functions in hpre_main.c open-code the same cluster number extraction from HPRE_CORE_INFO. Extract into hpre_get_clusters_num(). hpre_pre_store_cap_reg() uses a local hpre_cap[] array rather than qm->cap_tables.dev_cap_table[] and is therefore not converted. Signed-off-by: Weili Qian --- drivers/crypto/hisilicon/hpre/hpre_main.c | 43 ++++++++--------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/his= ilicon/hpre/hpre_main.c index b6903fce6071..e1a567383de5 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -381,6 +381,14 @@ static const char *hpre_channel_name[HPRE_MAX_CHANNEL_= NUM] =3D { =20 static const struct hisi_qm_err_ini hpre_err_ini; =20 +static inline u8 hpre_get_clusters_num(struct hisi_qm *qm) +{ + u32 cap =3D qm->cap_tables.dev_cap_table[HPRE_CORE_INFO].cap_val; + + return (cap >> hpre_basic_info[HPRE_CLUSTER_NUM_CAP].shift) & + hpre_basic_info[HPRE_CLUSTER_NUM_CAP].mask; +} + bool hpre_check_alg_support(struct hisi_qm *qm, u32 alg) { u32 cap_val; @@ -557,15 +565,12 @@ static int hpre_set_cluster(struct hisi_qm *qm) struct device *dev =3D &qm->pdev->dev; u32 cluster_core_mask; unsigned long offset; - u32 hpre_core_info; u8 clusters_num; u32 val =3D 0; int ret, i; =20 cluster_core_mask =3D qm->cap_tables.dev_cap_table[HPRE_CORE_EN].cap_val; - hpre_core_info =3D qm->cap_tables.dev_cap_table[HPRE_CORE_INFO].cap_val; - clusters_num =3D (hpre_core_info >> hpre_basic_info[HPRE_CLUSTER_NUM_CAP]= .shift) & - hpre_basic_info[HPRE_CLUSTER_NUM_CAP].mask; + clusters_num =3D hpre_get_clusters_num(qm); for (i =3D 0; i < clusters_num; i++) { offset =3D i * HPRE_CLSTR_ADDR_INTRVL; =20 @@ -659,7 +664,6 @@ static void hpre_enable_clock_gate(struct hisi_qm *qm) { unsigned long offset; u8 clusters_num, i; - u32 hpre_core_info; u32 val; =20 if (qm->ver < QM_HW_V3) @@ -673,9 +677,7 @@ static void hpre_enable_clock_gate(struct hisi_qm *qm) val |=3D HPRE_PEH_CFG_AUTO_GATE_EN; writel(val, qm->io_base + HPRE_PEH_CFG_AUTO_GATE); =20 - hpre_core_info =3D qm->cap_tables.dev_cap_table[HPRE_CORE_INFO].cap_val; - clusters_num =3D (hpre_core_info >> hpre_basic_info[HPRE_CLUSTER_NUM_CAP]= .shift) & - hpre_basic_info[HPRE_CLUSTER_NUM_CAP].mask; + clusters_num =3D hpre_get_clusters_num(qm); for (i =3D 0; i < clusters_num; i++) { offset =3D (unsigned long)i * HPRE_CLSTR_ADDR_INTRVL; val =3D readl(qm->io_base + offset + HPRE_CLUSTER_DYN_CTL); @@ -692,7 +694,6 @@ static void hpre_disable_clock_gate(struct hisi_qm *qm) { unsigned long offset; u8 clusters_num, i; - u32 hpre_core_info; u32 val; =20 if (qm->ver < QM_HW_V3) @@ -706,9 +707,7 @@ static void hpre_disable_clock_gate(struct hisi_qm *qm) val &=3D ~HPRE_PEH_CFG_AUTO_GATE_EN; writel(val, qm->io_base + HPRE_PEH_CFG_AUTO_GATE); =20 - hpre_core_info =3D qm->cap_tables.dev_cap_table[HPRE_CORE_INFO].cap_val; - clusters_num =3D (hpre_core_info >> hpre_basic_info[HPRE_CLUSTER_NUM_CAP]= .shift) & - hpre_basic_info[HPRE_CLUSTER_NUM_CAP].mask; + clusters_num =3D hpre_get_clusters_num(qm); for (i =3D 0; i < clusters_num; i++) { offset =3D (unsigned long)i * HPRE_CLSTR_ADDR_INTRVL; val =3D readl(qm->io_base + offset + HPRE_CLUSTER_DYN_CTL); @@ -782,14 +781,11 @@ static int hpre_set_user_domain_and_cache(struct hisi= _qm *qm) static void hpre_cnt_regs_clear(struct hisi_qm *qm) { unsigned long offset; - u32 hpre_core_info; u8 clusters_num; int i; =20 /* clear clusterX/cluster_ctrl */ - hpre_core_info =3D qm->cap_tables.dev_cap_table[HPRE_CORE_INFO].cap_val; - clusters_num =3D (hpre_core_info >> hpre_basic_info[HPRE_CLUSTER_NUM_CAP]= .shift) & - hpre_basic_info[HPRE_CLUSTER_NUM_CAP].mask; + clusters_num =3D hpre_get_clusters_num(qm); for (i =3D 0; i < clusters_num; i++) { offset =3D HPRE_CLSTR_BASE + i * HPRE_CLSTR_ADDR_INTRVL; writel(0x0, qm->io_base + offset + HPRE_CLUSTER_INQURY); @@ -1072,13 +1068,10 @@ static int hpre_cluster_debugfs_init(struct hisi_qm= *qm) char buf[HPRE_DBGFS_VAL_MAX_LEN]; struct debugfs_regset32 *regset; struct dentry *tmp_d; - u32 hpre_core_info; u8 clusters_num; int i, ret; =20 - hpre_core_info =3D qm->cap_tables.dev_cap_table[HPRE_CORE_INFO].cap_val; - clusters_num =3D (hpre_core_info >> hpre_basic_info[HPRE_CLUSTER_NUM_CAP]= .shift) & - hpre_basic_info[HPRE_CLUSTER_NUM_CAP].mask; + clusters_num =3D hpre_get_clusters_num(qm); for (i =3D 0; i < clusters_num; i++) { ret =3D snprintf(buf, HPRE_DBGFS_VAL_MAX_LEN, "cluster%d", i); if (ret >=3D HPRE_DBGFS_VAL_MAX_LEN) @@ -1308,13 +1301,10 @@ static int hpre_show_last_regs_init(struct hisi_qm = *qm) int com_dfx_regs_num =3D ARRAY_SIZE(hpre_com_dfx_regs); struct qm_debug *debug =3D &qm->debug; void __iomem *io_base; - u32 hpre_core_info; u8 clusters_num; int i, j, idx; =20 - hpre_core_info =3D qm->cap_tables.dev_cap_table[HPRE_CORE_INFO].cap_val; - clusters_num =3D (hpre_core_info >> hpre_basic_info[HPRE_CLUSTER_NUM_CAP]= .shift) & - hpre_basic_info[HPRE_CLUSTER_NUM_CAP].mask; + clusters_num =3D hpre_get_clusters_num(qm); debug->last_words =3D kcalloc(cluster_dfx_regs_num * clusters_num + com_dfx_regs_num, sizeof(unsigned int), GFP_KERNEL); if (!debug->last_words) @@ -1354,7 +1344,6 @@ static void hpre_show_last_dfx_regs(struct hisi_qm *q= m) struct qm_debug *debug =3D &qm->debug; struct pci_dev *pdev =3D qm->pdev; void __iomem *io_base; - u32 hpre_core_info; u8 clusters_num; int i, j, idx; u32 val; @@ -1370,9 +1359,7 @@ static void hpre_show_last_dfx_regs(struct hisi_qm *q= m) hpre_com_dfx_regs[i].name, debug->last_words[i], val); } =20 - hpre_core_info =3D qm->cap_tables.dev_cap_table[HPRE_CORE_INFO].cap_val; - clusters_num =3D (hpre_core_info >> hpre_basic_info[HPRE_CLUSTER_NUM_CAP]= .shift) & - hpre_basic_info[HPRE_CLUSTER_NUM_CAP].mask; + clusters_num =3D hpre_get_clusters_num(qm); for (i =3D 0; i < clusters_num; i++) { io_base =3D qm->io_base + hpre_cluster_offsets[i]; for (j =3D 0; j < cluster_dfx_regs_num; j++) { --=20 2.43.0 From nobody Thu Sep 24 23:33:31 2026 Received: from canpmsgout03.his.huawei.com (canpmsgout03.his.huawei.com [113.46.200.218]) (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 769BE3537C8; Fri, 18 Sep 2026 12:27:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734455; cv=none; b=Y2BT+F/Qdf7C7d4S/91NqOj4GScwcCWOGZWzZlO9Bylk3CTMN4WDuMAzKqAJubRyekefasJWvYijbuzWiNCK/2otBFLuxiUBAwtKOlKCSMAA480V8TwvRMWMNcCcImC3AeZjrmUcJ6hrqHxgiw8E8rVQG52QDRA2J/njS3hns00= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789734455; c=relaxed/simple; bh=cjIGCpEQupSduZjIIDxu56kjnjPr13DJidN1ey56U4I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HW+6e+9ea6y4uuoGqCVPtYGh11LhDwTeqaIz63bzjQwppONWjJYiwT/9P/pGbh+ekuktMXMRHWPjZmEBKB4Bp7dHOzHt2tRqrKUlx7kTLHACX5qWAXOdaPF1mPWAC1D1ZRQ559l42ERByXi4dNocfJjR4NklnJmsHApHDDIjZeQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=4C1h6OAV; arc=none smtp.client-ip=113.46.200.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="4C1h6OAV" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=ANp+T+1gS2OpRb7OkktyO+gN2A1T3woUSp4JeFk/BKg=; b=4C1h6OAVck1bHR4Jy/tRdj5VnU0lrN+Dp9qmtVKvLmcG5DoEHqA6t17oGGKpbRaWP4eLYYEQZ kUDdolGZwvwOhs6Wjh2SlMXbIiLEMWxmqlyzft5o/vIHosVoaFiDQJcbGl+nGBycEMkTzI3kwXH oKBHtzPqnyRpGagxsVxx7Iw= Received: from mail.maildlp.com (unknown [172.19.162.140]) by canpmsgout03.his.huawei.com (SkyGuard) with ESMTPS id 4hmWmX3XlPzpStW; Fri, 18 Sep 2026 20:15:40 +0800 (CST) Received: from kwepemf200011.china.huawei.com (unknown [7.202.181.237]) by mail.maildlp.com (Postfix) with ESMTPS id CB4E620333; Fri, 18 Sep 2026 20:27:29 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemf200011.china.huawei.com (7.202.181.237) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Fri, 18 Sep 2026 20:27:29 +0800 From: Weili Qian To: CC: , , Subject: [PATCH 7/7] crypto: hisilicon/hpre - remove unused macros and struct fields Date: Fri, 18 Sep 2026 20:27:26 +0800 Message-ID: <20260918122726.3014899-8-qianweili@huawei.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260918122726.3014899-1-qianweili@huawei.com> References: <20260918122726.3014899-1-qianweili@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemf200011.china.huawei.com (7.202.181.237) Content-Type: text/plain; charset="utf-8" Several macros, the hpre_asym_request::err field and the hpre::status field are defined but never referenced. Remove them. Signed-off-by: Weili Qian --- drivers/crypto/hisilicon/hpre/hpre.h | 1 - drivers/crypto/hisilicon/hpre/hpre_crypto.c | 6 ------ drivers/crypto/hisilicon/hpre/hpre_main.c | 4 ---- 3 files changed, 11 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre.h b/drivers/crypto/hisilico= n/hpre/hpre.h index 021dbd9a1d48..f73d01f6da87 100644 --- a/drivers/crypto/hisilicon/hpre/hpre.h +++ b/drivers/crypto/hisilicon/hpre/hpre.h @@ -70,7 +70,6 @@ struct hpre_debug { struct hpre { struct hisi_qm qm; struct hpre_debug debug; - unsigned long status; }; =20 enum hpre_alg_type { diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/h= isilicon/hpre/hpre_crypto.c index 6ca34f3bf9ff..66a276786a7d 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -21,19 +21,15 @@ struct hpre_ctx; #define HPRE_CRYPTO_ALG_PRI 1000 #define HPRE_ALIGN_SZ 64 #define HPRE_BITS_2_BYTES_SHIFT 3 -#define HPRE_RSA_512BITS_KSZ 64 -#define HPRE_RSA_1536BITS_KSZ 192 #define HPRE_CRT_PRMS 5 #define HPRE_CRT_Q 2 #define HPRE_CRT_P 3 #define HPRE_CRT_INV 4 #define HPRE_DH_G_FLAG 0x02 #define HPRE_TRY_SEND_TIMES 100 -#define HPRE_INVLD_REQ_ID (-1) =20 #define HPRE_SQE_ALG_BITS 5 #define HPRE_SQE_DONE_SHIFT 30 -#define HPRE_DH_MAX_P_SZ 512 =20 #define HPRE_DFX_SEC_TO_US 1000000 #define HPRE_DFX_US_TO_NS 1000 @@ -56,7 +52,6 @@ struct hpre_ctx; #define HPRE_DRV_RSA_MASK_CAP BIT(0) #define HPRE_DRV_DH_MASK_CAP BIT(1) #define HPRE_DRV_ECDH_MASK_CAP BIT(2) -#define HPRE_DRV_X25519_MASK_CAP BIT(5) =20 static DEFINE_MUTEX(hpre_algs_lock); static unsigned int hpre_available_devs; @@ -135,7 +130,6 @@ struct hpre_asym_request { struct kpp_request *dh; struct kpp_request *ecdh; } areq; - int err; hpre_cb cb; struct timespec64 req_time; u32 flags; diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/his= ilicon/hpre/hpre_main.c index e1a567383de5..03aa11a7a3b4 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -16,7 +16,6 @@ #define CAP_FILE_PERMISSION 0444 #define HPRE_CTRL_CNT_CLR_CE_BIT BIT(0) #define HPRE_CTRL_CNT_CLR_CE 0x301000 -#define HPRE_FSM_MAX_CNT 0x301008 #define HPRE_VFG_AXQOS 0x30100c #define HPRE_VFG_AXCACHE 0x301010 #define HPRE_RDCHN_INI_CFG 0x301014 @@ -41,7 +40,6 @@ #define HPRE_HAC_INT_SET 0x301500 #define HPRE_AXI_ERROR_MASK GENMASK(21, 10) #define HPRE_RNG_TIMEOUT_NUM 0x301A34 -#define HPRE_CORE_INT_ENABLE 0 #define HPRE_RDCHN_INI_ST 0x301a00 #define HPRE_CLSTR_BASE 0x302000 #define HPRE_CORE_EN_OFFSET 0x04 @@ -61,8 +59,6 @@ #define HPRE_CORE_ENB (HPRE_CLSTR_BASE + HPRE_CORE_EN_OFFSET) #define HPRE_CORE_INI_CFG (HPRE_CLSTR_BASE + HPRE_CORE_INI_CFG_OFFSET) #define HPRE_CORE_INI_STATUS (HPRE_CLSTR_BASE + HPRE_CORE_INI_STATUS_OFFSE= T) -#define HPRE_HAC_ECC1_CNT 0x301a04 -#define HPRE_HAC_ECC2_CNT 0x301a08 #define HPRE_HAC_SOURCE_INT 0x301600 #define HPRE_CLSTR_ADDR_INTRVL 0x1000 #define HPRE_CLUSTER_INQURY 0x100 --=20 2.43.0