From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 31F774555B; Wed, 3 Jul 2024 12:27:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1DBA042D92; Wed, 3 Jul 2024 12:27:26 +0200 (CEST) Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011002.outbound.protection.outlook.com [52.101.65.2]) by mails.dpdk.org (Postfix) with ESMTP id D315542D7F; Wed, 3 Jul 2024 12:27:23 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CZKGNZOV+czJ6a5GUm9c2eAQ4yDhqWX5dzKox6cJ9PL/Jd0nhnzTfgd8G6+3GmyikIJRICn0BBa7xz8DRaH/+w7TbVCFvHFZJxLSzuxCkNvUBGnSpqXebGgdOIbl/H014VbeTaWLX1QcldJ+1yCTlM+JnOLmWt3oMz9AC8miB+oxSHH120p7aQF2kgF1/+H+OaOwLLBmHtxpD+nFujPHA1d/miuzaABM2xGnyPQdGSEcjNhravAoryb7Vr+MDl5MQN3M+JMeDxZ29butAsPUyOFLCfsZzM+BB4VvGak2wKxiuH6s9xGwujuqwQnS+tKs/QIh3gJU9X7JABThP+MeCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=FzrsO6RDG5lT0mk3EgYOzwYnRpuW5jdY6LQva8aFqNk=; b=lgrzAaqW2jjrJ1s2B+QLwZDWy7DKVzQfOvv+VAjXUo0dIwb9UfFCMalXG7BHRG9r9lqnHSJFHGnbNrMX9PD8ubKElT47/XTPpw78FysS5n8NQHhw+HM5qSw1WQV0cPGgtEglTkz2qSopeXHXAlDHezTho6PhSDfWfds9CXk8LMymphbPDp2n/5D2XGk5udTlzwQwDnFEXaEokp8a4w42yK6fHNfTDbw9FTUiNNMUj1kx9Lch+4/4IWdl0baHYPcps9sxIwmV9auXNH94D7FIPqmyk55+f9tIb6MY96N+r+Jqxg+6NWNHeIGotab71PCeHw7dHyp4/KCZp1eMjoRufw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FzrsO6RDG5lT0mk3EgYOzwYnRpuW5jdY6LQva8aFqNk=; b=GBOvv8oU7Ldmpr7qKZpU2oPcu+hn/2lRzHG5Pau8WAecCta0Zl15/km4iZbFbnhjkY4IB7TZ/Yt0W973YffptOoUFigsFkTEWIf3EePKM1m2+VEjvotx2HIe6p2Rj1rhqd1vcDagIhFt0APl2wySCMKEbi/zDPo4mLlrba0nVag= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8SPR01MB0024.eurprd04.prod.outlook.com (2603:10a6:20b:3d0::24) by PA2PR04MB10238.eurprd04.prod.outlook.com (2603:10a6:102:404::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.25; Wed, 3 Jul 2024 10:27:22 +0000 Received: from AS8SPR01MB0024.eurprd04.prod.outlook.com ([fe80::c634:479e:8f8a:a325]) by AS8SPR01MB0024.eurprd04.prod.outlook.com ([fe80::c634:479e:8f8a:a325%4]) with mapi id 15.20.7741.017; Wed, 3 Jul 2024 10:27:22 +0000 From: Gagandeep Singh To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena , Akhil Goyal Cc: stable@dpdk.org Subject: [PATCH 03/11] crypto/dpaa: fix SEC err due to an wrong desc Date: Wed, 3 Jul 2024 15:56:41 +0530 Message-Id: <20240703102649.3096530-4-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240703102649.3096530-1-g.singh@nxp.com> References: <20240703102649.3096530-1-g.singh@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SGBP274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::22) To AS8SPR01MB0024.eurprd04.prod.outlook.com (2603:10a6:20b:3d0::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8SPR01MB0024:EE_|PA2PR04MB10238:EE_ X-MS-Office365-Filtering-Correlation-Id: 62166861-346e-463f-ea4d-08dc9b4ab9a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?BWNfDsNelwUfL7ZerAru6KbwWGr45DrJ8GKQAtqlY2vRwnMtOTW3ffKzO754?= =?us-ascii?Q?VZieS41Eg5WfF5Bzk1oGnbI3Q9Z6wkviNbCCYP0oxW27ErxBdLViuarD3gbr?= =?us-ascii?Q?sJSub85rNuTYkxuxS9iincj+WzzuTpKMcrkZQx+Kl6Xs61QhT4/aFAlR2uVP?= =?us-ascii?Q?9O3Zdq8qrnDJU+F6n00HrnD8BIkqNslAc2DEZ/d99oO0zr//zoOCIuJpvDZ6?= =?us-ascii?Q?9Pqx8rf9Rk87GntzJ06xrLC4hAi0dqBoezrsrtK8Q0f94KtZlb7+NMWMiHHB?= =?us-ascii?Q?KPmval3EvVoXDy/rMDglL0dorvmm9UbZXV6bx48KyPa3In/CXJaZpCugnva0?= =?us-ascii?Q?MFXZC8tMa99IlydLR+MCp58Jj6iCllAHInLIMgxt/DggrSd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7caUrBcgmLcKvXxrMYElVPQgt7OvyAVbIn8MQQx3MSE?= =?us-ascii?Q?UPMuAnb2MCs3eHducLkuI2C+dIp5AoCwA+1e8gK836nuqtfwWZkqDid9mijH?= =?us-ascii?Q?r492W4O+Ku7gI0wBJ/V0JkIxodGhyFhiChhEcZ7dtDG6XqThEg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8SPR01MB0024.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(52116014)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?mggL4lcZO39U5dzm4XQ9DA0ghyDubF1O90mr+dI42Q8MaHl45azdX4jwXrbE?= =?us-ascii?Q?uPemcAwTxQESgh2sMY/znidl7WtyDyc5d6zd63XJEiXhTkU3AEiXEGvlamRr?= =?us-ascii?Q?KrAPpegmx4oW4Af0IEf8wRD5VtenIcfIb168wAHgyHHeUyI7wNhHAeI/gyu2?= =?us-ascii?Q?dN40GhTxiVcJKX4K+kYydpA/BjYzrW/zgRsn6kYGhvcQrw0yf1fO4Ho4nFFA?= =?us-ascii?Q?3NcyXxysVcNha/skPUeE8uiuJF+K+w2Bcfww8zub+0TuRsYowtfFO5To3zJP?= =?us-ascii?Q?YVm8Y/MD2iq7XI+s+Lq8M4NwSwrFWqioADzPi+eXM3rLBYcOQdF7+FAH9g62?= =?us-ascii?Q?8D1gX6EC7gmzhKDr3950tZ0GMf/BXDnOKTH1/N2DBLupb2TetFWeb9BtvuI/?= =?us-ascii?Q?2DY0A7WGfRSUzXgbd8u97M83KuyMLIKR7FPfUV1fgWzCX4urAkRL5oPAzTJj?= =?us-ascii?Q?E5DGYgSH9Tc69pIeLJeJsbQpZuZ2ySdgmHi83fUS6Bvrx24c3IxOrnFMjYE6?= =?us-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rt5BX71WkAT9grM3Q?= =?us-ascii?Q?j828F4oCXmRJrgZGRUMO9FHZhW3DtoFFyRJ7VnMuRoLeqXmRfgnjxJQ2kVLB?= =?us-ascii?Q?sJe7ViJUyGuhKroVm0jAc7bEI/8wYIlKZjjfMWrjqngq7ohTk28kX1wleg/o?= =?us-ascii?Q?9h8EdfREQNWDhP01G+IyeY4XozavvG4FV6rIIyOl?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62166861-346e-463f-ea4d-08dc9b4ab9a8 X-MS-Exchange-CrossTenant-AuthSource: AS8SPR01MB0024.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2024 10:27:22.6249 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wiGp3Dre3EjFk3QZx0Tr+mIgcQWDaJoDBHeleoCFmuip+iWH3F+aKu9XMuLTdkXn X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA2PR04MB10238 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org During IPsec operations, driver code pre-check whether KEYS can be inlined to limited size descriptor or not and based on that it decides to copy the complete KEY in descriptor or just give the memory pointer of KEY in descriptor. This pre-check code does not take care of padding required for security engine to make the KEYs inline which results in incorrect length descriptor for some algorithms. This patch fixes this issue by updating the pre-check code with proper padding size included for each supported algorithm. Fixes: 453b9593a3cf ("crypto/dpaax_sec: fix inline query for descriptors") Cc: stable@dpdk.org Signed-off-by: Gagandeep Singh --- drivers/common/dpaax/caamflib/desc/ipsec.h | 73 ++++++++++++++++++++++ drivers/crypto/dpaa_sec/dpaa_sec.c | 4 +- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/drivers/common/dpaax/caamflib/desc/ipsec.h b/drivers/common/dpaax/caamflib/desc/ipsec.h index eff26f6f8b..b902873970 100644 --- a/drivers/common/dpaax/caamflib/desc/ipsec.h +++ b/drivers/common/dpaax/caamflib/desc/ipsec.h @@ -728,6 +728,79 @@ static inline void __gen_auth_key(struct program *program, authdata->key, authdata->key_type); } +/** + * rta_inline_ipsec_query() - Provide indications on which data items can be inlined + * and which shall be referenced in IPsec shared descriptor. + * @sd_base_len: Shared descriptor base length - bytes consumed by the commands, + * excluding the data items to be inlined (or corresponding + * pointer if an item is not inlined). Each cnstr_* function that + * generates descriptors should have a define mentioning + * corresponding length. + * @jd_len: Maximum length of the job descriptor(s) that will be used + * together with the shared descriptor. + * @data_len: Array of lengths of the data items trying to be inlined + * @inl_mask: 32bit mask with bit x = 1 if data item x can be inlined, 0 + * otherwise. + * @count: Number of data items (size of @data_len array); must be <= 32 + * @auth_algtype: Authentication algorithm type. + * @auth_index: Index value of data_len for authentication key length. + * -1 if authentication key length is not present in data_len. + * + * Return: 0 if data can be inlined / referenced, negative value if not. If 0, + * check @inl_mask for details. + */ +static inline int +rta_inline_ipsec_query(unsigned int sd_base_len, + unsigned int jd_len, + unsigned int *data_len, + uint32_t *inl_mask, + unsigned int count, + uint32_t auth_algtype, + int32_t auth_index) +{ + uint32_t dkp_protid; + + switch (auth_algtype & OP_PCL_IPSEC_AUTH_MASK) { + case OP_PCL_IPSEC_HMAC_MD5_96: + case OP_PCL_IPSEC_HMAC_MD5_128: + dkp_protid = OP_PCLID_DKP_MD5; + break; + case OP_PCL_IPSEC_HMAC_SHA1_96: + case OP_PCL_IPSEC_HMAC_SHA1_160: + dkp_protid = OP_PCLID_DKP_SHA1; + break; + case OP_PCL_IPSEC_HMAC_SHA2_256_128: + dkp_protid = OP_PCLID_DKP_SHA256; + break; + case OP_PCL_IPSEC_HMAC_SHA2_384_192: + dkp_protid = OP_PCLID_DKP_SHA384; + break; + case OP_PCL_IPSEC_HMAC_SHA2_512_256: + dkp_protid = OP_PCLID_DKP_SHA512; + break; + case OP_PCL_IPSEC_HMAC_SHA2_224_96: + case OP_PCL_IPSEC_HMAC_SHA2_224_112: + case OP_PCL_IPSEC_HMAC_SHA2_224_224: + dkp_protid = OP_PCLID_DKP_SHA224; + break; + default: + return rta_inline_query(sd_base_len, + jd_len, + data_len, + inl_mask, count); + } + + /* Updating the maximum supported inline key length */ + if (auth_index != -1) { + if (split_key_len(dkp_protid) > data_len[auth_index]) + data_len[auth_index] = split_key_len(dkp_protid); + } + return rta_inline_query(sd_base_len, + jd_len, + data_len, + inl_mask, count); +} + /** * cnstr_shdsc_ipsec_encap - IPSec ESP encapsulation protocol-level shared * descriptor. diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c index 44528eaf7f..679f78c4b9 100644 --- a/drivers/crypto/dpaa_sec/dpaa_sec.c +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c @@ -395,10 +395,10 @@ dpaa_sec_prep_ipsec_cdb(dpaa_sec_session *ses) cdb->sh_desc[0] = cipherdata.keylen; cdb->sh_desc[1] = authdata.keylen; - err = rta_inline_query(IPSEC_AUTH_VAR_AES_DEC_BASE_DESC_LEN, + err = rta_inline_ipsec_query(IPSEC_AUTH_VAR_AES_DEC_BASE_DESC_LEN, DESC_JOB_IO_LEN, (unsigned int *)cdb->sh_desc, - &cdb->sh_desc[2], 2); + &cdb->sh_desc[2], 2, authdata.algtype, 1); if (err < 0) { DPAA_SEC_ERR("Crypto: Incorrect key lengths"); -- 2.25.1