From nobody Wed Nov 27 00:38:34 2024 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2040.outbound.protection.outlook.com [40.107.247.40]) (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 4AD741D9A60; Tue, 15 Oct 2024 09:05:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983140; cv=fail; b=FOXC1kh+fwNzvc6nAqdHC4/tj7uA5xS57e/Mz5RSZCfJdTazubRwYWKU3dN8P0J24Q65GccfH1k1AJbiWhvgmTf0E5XTN/86CP4VJ7RzP3Sqvq3U2CC3XGQBNBRE+1J9rqS/vU2G6zUmRaynRcJfrEiZPT0Jpm0p6qD4Yx0au/Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983140; c=relaxed/simple; bh=FwHu8HOgjdeesS4jBLvkey7Y+WnnBYkcgUp1hGR75ZU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=UDVpWXbWQ7XXCMigEMvuzrUweFHg8Kb74Jd7Kx7NwNdvHi4bMIgiKqdbBftfkpMZpT1i1io2Du62d+x5INa50Nnj9ytZ4VpPwXJMSGeb1eWI5Nro1Ky+YWk+hpz5luZpFQC//0hKEsvBanHnB14/4iaXGgesCje/Ya4HVlAmliA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=RDONsXzq; arc=fail smtp.client-ip=40.107.247.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="RDONsXzq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oiY9/AUirsKO+93dkEnntxkWC1IPm6/L73J2f3Y7W00/R65CZq0FOEUnKiLnFmXkI0H+spL4dPod3YrBbywsk53Xt9TshLH5+zG14ItA74Y/9RgEwzTDfPRPJkHkfWJeqJnVvJbztTHcB2f8+2S2DrB9mMpjt6PcFt0dAgjWq48UMuTmUfLrDCoGxtOFsTAj3pgafkS2E3Mt/K8+iItHU0hWqOgocPYMxUTXZvbuQPGl11bvuInu9EiWdgQkDCNmx12boV3I51CSdgXrSm0FtnGiGKPHdPD2BCBkF4ZokFNLwZJhyjmvFPGiFvqZlaMMxe5kSR//FcUDx6jopK9Dwg== 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=rydjPSyjFpE1b+KVUJhSPw9jPLhoKfIzwxtGoWGJhg4=; b=ydUG20sT669wdhh+FCQZ/SUVmCl92pc4EE2g6OuTK+Y7TsSsH2e4O3zHR6NPx5XPIqz/nb2gei9UFNZMquiD01Ss52gtE1uGgyLGgJ1bQUAQN4+hJ01RZWrRT/ok4DsqiOAI6J4UfqZq87b9CFtVV7I8j5G3tOPj3ffItsJGQPPPKJSPvlLSzniz0LVTSAkZtXXEZMFd7etOw99GXWJiurXRP1AaVbgE8JrNbuuQiHsqSnZWs6cPIiuPUNmas6o834M0e9VhVtLm4+/QyBMjDP96nB9uaCdctINZy9hLcIaNjxb121H1gmnkWt7wJ3TR3ci0J+EfROUF4nj2oSJPBw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rydjPSyjFpE1b+KVUJhSPw9jPLhoKfIzwxtGoWGJhg4=; b=RDONsXzqJvvNc/Uk0gKM7+zJ4SDleFdu4ShB1Hhen6MahSsspACnQIsdh6c2Z87Oqzf40J57hnbiGPy0+2/J69p4YUP8M3yqnXf00r7N1uYqiorJ75Pq4VbSor8+P+ZjrekSMI6d5TEj1waVnKweCB9N9rWrhOLNsWzpCHQBbNDq/DUP0CH81K89aJ3/O4kbDE8LGzEGW9DcP9zu53+oU6rLYBspDa0lphSw2MhXNIfov+pWkBWEnltXV48NLf1cPemv3tt5+B0J7AH2/Ft6u0X3FXw+TV0Cl3eD/n8Yp9o578t+QCK4Apw5FJ4BPj7EqxvoEu3dGf6/fkhaFzKhYQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) by PA4PR04MB9223.eurprd04.prod.outlook.com (2603:10a6:102:2a2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 09:05:35 +0000 Received: from AM9PR04MB8604.eurprd04.prod.outlook.com ([fe80::e751:223e:aa3d:5827]) by AM9PR04MB8604.eurprd04.prod.outlook.com ([fe80::e751:223e:aa3d:5827%5]) with mapi id 15.20.8048.020; Tue, 15 Oct 2024 09:05:35 +0000 From: Pankaj Gupta Date: Tue, 15 Oct 2024 14:30:59 +0530 Subject: [PATCH v8 1/5] Documentation/firmware: add imx/se to other_interfaces Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241015-imx-se-if-v8-1-915438e267d3@nxp.com> References: <20241015-imx-se-if-v8-0-915438e267d3@nxp.com> In-Reply-To: <20241015-imx-se-if-v8-0-915438e267d3@nxp.com> To: Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Pankaj Gupta , Rob Herring Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728982877; l=6679; i=pankaj.gupta@nxp.com; s=20240523; h=from:subject:message-id; bh=FwHu8HOgjdeesS4jBLvkey7Y+WnnBYkcgUp1hGR75ZU=; b=u+8NDXlnVE7athGjzhrM5LJk6qkb4yx+XAWXSln9eLk47fEqSzrKRUSryd+r0oIYZQTInMVVD Mvjrch8YcckAboplriwhB928jikXwawOuqMH0cKafkiAvWRLYpGtCXq X-Developer-Key: i=pankaj.gupta@nxp.com; a=ed25519; pk=OA0pBQoupy5lV0XfKzD8B0OOBVB6tpAoIf+0x1bYGRg= X-ClientProxiedBy: SG2P153CA0019.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::6) To AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8604:EE_|PA4PR04MB9223:EE_ X-MS-Office365-Filtering-Correlation-Id: 614c56a8-9794-4446-cfa3-08dcecf88784 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|52116014|366016|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?RkFMWFdBVFR2V2Zablc4NWdjeWFTZnBFMGZ0M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JJek5BNGRlK2Fqdz09?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8604.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(52116014)(366016)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UlV6SjMxTS9DMkNzZG9FUzdnMEpqeVFoS0RtWG5Xa0d0eXkzNk9kNlBseldr?= =?utf-8?B?VTdlQkd4L0tSWGtjWXRpb3pVM2hJN0NVbUV1eTF6ZEdSVlh2dEdXRXBRWXdl?= =?utf-8?B?NGs2T1h3a1M0d05qT0NTYmNtYlJ4NTROOENISDVSWXVtWmJKcndTclFSelZo?= =?utf-8?B?TklSMnVxUEhWdXkxdGpmSEJKNzBLa3RNSlBxZlVucmlxNm5hUGpJb3U0dHVs?= =?utf-8?B?WTFqOElZUXRJR3docDg5VmVudmV1TWRRWWEyc1VWZi95Nk9aMTM4R2JDTE96?= =?utf-8?B?Ylh4TkVsYm8zRnFpYkdmVVI1S2VDNllGVmZMUFltL3VkeXdKZXd4bC9GSndC?= =?utf-8?B?WGwwSkRNRFd0cEtONXhaMExrRDJLa1diMkRyQkJiejlMd0dSVGtkK2VVMC8y?= =?utf-8?B?V1Z3U2huOTQzaFRhYXFxaDFHZW9tNWdiOFZNMWptaGxDYXErVnNTUnBqU2l4?= =?utf-8?B?R0VhQzNUWEFJQzVuQ2FxVFI2dHBCNXlyamN0UXhBdzlMTk1jdlFQWkhxTWNZ?= =?utf-8?B?Ui9KWWxHclRackNJZGp0UlNGUkpOQ3pxOVlwSFgybWpPbWUrNXJCUUJvSUxn?= =?utf-8?B?THNIMDhlQkZNOUdFZlIzN0ZEaG9FZjg5d3NyNVZuUFFySW53R1BtOUd1bThm?= =?utf-8?B?SXV1RldhcDNZcCsxRmh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G4xQnNadDlUNEs5eVhOUDcrb25xYlR2YWhKcXFnOENO?= =?utf-8?B?R1hKTjZSWGg2OW0vRGJsVmV3TVo3Q2Z1Q2J6ZXNyZm5qWDNLMFkwRmxob0o1?= =?utf-8?B?R09BRExoK0FCY1ExeStDVmVsSWpPMUJsMW9waVlKMldhYmRPZWY2bVlNSkxI?= =?utf-8?B?MXoxYVJVUWNORUNrOXRBaU5tM1pCckhnMExBYTl1a0lqaW4zVXFjcXc3b1Iw?= =?utf-8?B?NnpOUG85YXZXSDcrSkJ3aDhrT1ZtbjB3TndzUnNpRTdFbHhhS0pTNlhJYkZr?= =?utf-8?B?YThaOXZrelVSODAweHI5ck82NlllQXJxbGtKRUJ1cjR4aGQ1dEFVUXpUSm0y?= =?utf-8?B?amF3QzhkS2VOT241Tzd6V2dacWpzd2VXSzlQK3Q1SUdDUE84REZMeGtFNVVy?= =?utf-8?B?dFFRTUlOQ3M3NUNOdWppWEl3dVV4a2dHbEMrZXZDK3BNL3RXM29XZEdzdHRx?= =?utf-8?B?ZnJ6eVEzYjRzUFdUNFh1cEZ4eVYwOGQyQTBiYjhObFZRZm1qS2lOZFg1dXh0?= =?utf-8?Q?jz9yya//CVLvGIEVotn8w4WZo?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 614c56a8-9794-4446-cfa3-08dcecf88784 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8604.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:05:35.0436 (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: 1jEapWi1WoUKkP2X2xqJ5EPbdcglHNyxdgStp0avvXtQTj+5SzGvvAK66XmNiqY/b8mKk8kI+nA2LCKxh03lMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9223 Documents i.MX SoC's Service layer and C_DEV driver for selected SoC(s) that contains the NXP hardware IP(s) for Secure Enclaves(se) like: - NXP EdgeLock Enclave on i.MX93 & i.MX8ULP Signed-off-by: Pankaj Gupta --- .../driver-api/firmware/other_interfaces.rst | 121 +++++++++++++++++= ++++ 1 file changed, 121 insertions(+) diff --git a/Documentation/driver-api/firmware/other_interfaces.rst b/Docum= entation/driver-api/firmware/other_interfaces.rst index 06ac89adaafb..a3a95b54a174 100644 --- a/Documentation/driver-api/firmware/other_interfaces.rst +++ b/Documentation/driver-api/firmware/other_interfaces.rst @@ -49,3 +49,124 @@ of the requests on to a secure monitor (EL3). =20 .. kernel-doc:: drivers/firmware/stratix10-svc.c :export: + +NXP Secure Enclave Firmware Interface +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Introduction +------------ +The NXP's i.MX HW IP like EdgeLock Enclave, V2X etc., creates an embedded = secure +enclave within the SoC boundary to enable features like + - Hardware Security Module (HSM) + - Security Hardware Extension (SHE) + - Vehicular to Anything (V2X) + +Each of the above feature is enabled through dedicated NXP H/W IP on the S= oC. +On a single SoC, multiple hardware IP (or can say more than one secure enc= lave) +can exist. + +NXP SoCs enabled with the such secure enclaves(SEs) IPs are: +i.MX93, i.MX8ULP + +To communicate with one or more co-existing SE(s) on SoC, there is/are ded= icated +messaging units(MU) per SE. Each co-existing SE can have one or multiple e= xclusive +MUs, dedicated to itself. None of the MU is shared between two SEs. +Communication of the MU is realized using the Linux mailbox driver. + +NXP Secure Enclave(SE) Interface +-------------------------------- +Although MU(s) is/are not shared between SE(s). But for SoC like i.MX95 wh= ich has +multiple SE(s) like HSM, V2X-HSM, V2X-SHE; all the SE(s) and their interfa= ces 'se-if' +that is/are dedicated to a particular SE will be enumerated and provisione= d using the +single compatible node("fsl,imx95-se"). + +Each 'se-if' comprise of twp layers: +- (C_DEV Layer) User-Space software-access interface. +- (Service Layer) OS-level software-access interface. + + +--------------------------------------------+ + | Character Device(C_DEV) | + | | + | +---------+ +---------+ +---------+ | + | | misc #1 | | misc #2 | ... | misc #n | | + | | dev | | dev | | dev | | + | +---------+ +---------+ +---------+ | + | +-------------------------+ | + | | Misc. Dev Synchr. Logic | | + | +-------------------------+ | + | | + +--------------------------------------------+ + + +--------------------------------------------+ + | Service Layer | + | | + | +-----------------------------+ | + | | Message Serialization Logic | | + | +-----------------------------+ | + | +---------------+ | + | | imx-mailbox | | + | | mailbox.c | | + | +---------------+ | + | | + +--------------------------------------------+ + +- service layer: + This layer is responsible for ensuring the communication protocol that i= s defined + for communication with firmware. + + FW Communication protocol ensures two things: + - Serializing the messages to be sent over an MU. + + - FW can handle one command message at a time. + +- c_dev: + This layer offers character device contexts, created as '/dev/_mux_c= hx'. + Using these multiple device contexts that are getting multiplexed over a= single MU, + userspace application(s) can call fops like write/read to send the comma= nd message, + and read back the command response message to/from Firmware. + fops like read & write use the above defined service layer API(s) to com= municate with + Firmware. + + Misc-device(/dev/_mux_chn) synchronization protocol: + + Non-Secure + Secure + | + | + +---------+ +-------------+ | + | se_fw.c +<---->+imx-mailbox.c| | + | | | mailbox.c +<-->+------+ +------+ + +---+-----+ +-------------+ | MU X +<-->+ ELE | + | +------+ +------+ + +----------------+ | + | | | + v v | + logical logical | + receiver waiter | + + + | + | | | + | | | + | +----+------+ | + | | | | + | | | | + device_ctx device_ctx device_ctx | + | + User 0 User 1 User Y | + +------+ +------+ +------+ | + |misc.c| |misc.c| |misc.c| | + kernel space +------+ +------+ +------+ | + | + +------------------------------------------------------ | + | | | | + userspace /dev/ele_muXch0 | | | + /dev/ele_muXch1 | | + /dev/ele_muXchY | + | + +When a user sends a command to the firmware, it registers its device_ctx +as waiter of a response from firmware. + +Enclave's Firmware owns the storage management, over Linux filesystem. +For this c_dev provisions a dedicated slave device called "receiver". + +.. kernel-doc:: drivers/firmware/imx/se_fw.c + :export: --=20 2.34.1 From nobody Wed Nov 27 00:38:34 2024 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2071.outbound.protection.outlook.com [40.107.247.71]) (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 043851DD524; Tue, 15 Oct 2024 09:05:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983145; cv=fail; b=TFZWbOK3WjBGZ+3xQEWnuqSsZapwWglsYAvLwoPyyV22Tq+T4xzzJ+R6kiVEKuKMCxsEvWvItSFeYNDfq7692FwEYC2aQJVy+eeIW2TO6vRPWow6ugXqFEXMD+PSVR/DGbJNbwbJsyxgo9r+cFQPi5Orx/DNSG2ajbCtayOinl8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983145; c=relaxed/simple; bh=c2GJVCidrhX1BXyQTcNgVT1gDrIReiQzjgNl9ktmYns=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=XIlBpMARM0itrfJZb401P2AmHKptje9lTIJyXQxnJ4THqEgmtknbHMB3y55sd3DKzc3BeeHoZMkeBzgh7AHz8Ltczbx2fF2fnMEAkdNXgZBlqeLHwZYvUXke5Yxm+bjLwCbfLEKS8psJEKpBEvWep8EqpElGr57h0J1xhNk2Vzw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=eEFYkm0C; arc=fail smtp.client-ip=40.107.247.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="eEFYkm0C" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=crB7WX7UTD/EIIO2AtYwFXQcKzJqI8rlZc9U9EdTrmwQlQIaIStNUVbiWidGeYWpMiBirycN2K75iqGs26EdntQWO3dXNN1RYJIk5EO60kWRpP5bPAKqFqwXJBi/bFMrIFNxpdWQP2B0n/CfWfxP6jTUZU8yHYw0inph9xtaMVl9Cp+2gq+R7HRYplW8O18IxWT81dez3VTgswW9uFhesrv5SRapI/CEQ3FmHYiDgiAPB/zNV+Che3kE/H7kDIVv1i1scM2a+ROE0wpQR4ACK8epTfoxLovb694kRU/UUDB1qJwCIl/4KjD/UZbe3UFS1VHNexnYUVynM1WxHJaBbA== 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=+TTFyAP5yb7hZ8l7L5ej7ELeEVEO7+opRsZB4H7s0/A=; b=dPZWPCC/ycD4g1QvZvBvwecAv4fzpxXXPQvLdmap0qILh1yZ+R713o72m9vvnwypjF5itNKKiHrGorBL2Ii1n8OIYK+/1GIjhE+NKlIFsmmiVWw08hQudwqdA0HVFV5lnsLymn7mG8/0Lj1cQuKWXxaCr7Aq8h3MUuG7NRxR1OvRq4rSQq6sgp3sldK3E2GhwKR0zpfUcI8fU8rpUsoul7zFrGk/QmJ29uxlV+lMNlU868k5jTfoew476hlVDY8m6BQ5TyKkddUws9W6Opp7TS7rY7kbjJTW/GKg3wlBhpAMZplpWcjuiByKbsa40Yik02QyAxZue+rrR7haMGEFPg== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+TTFyAP5yb7hZ8l7L5ej7ELeEVEO7+opRsZB4H7s0/A=; b=eEFYkm0CUk9UneIVFaPO5tJOpxWwktxoJxJTRbGGJnjYS0uBREODvFDD4GFcg63wuBlwOTLN4W7aEpTY2h8nE+wFSW6QC2384NX3Yz+zjsBOpF0umv5VLBvFQTgtI5akYMRXEQpu3BYeCyMpYOffuzjxuKTeQzZT494gLV8grbgHDwt+wedb+rk8yqps6XShqTxWhmvjII49pHzdftCYWX9KUljpJmI6veeYAwjOwy7qnCLCWeqMh+vlkAHOxzzcz68olINnIkTEBOZfTpocys2Wt9u5MlxXuQifv4ezVXBvt8v6TibXwnB5RyKvmiLtCrUcRy8Vdp0/uEdS8xxRfw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) by PA4PR04MB9223.eurprd04.prod.outlook.com (2603:10a6:102:2a2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 09:05:39 +0000 Received: from AM9PR04MB8604.eurprd04.prod.outlook.com ([fe80::e751:223e:aa3d:5827]) by AM9PR04MB8604.eurprd04.prod.outlook.com ([fe80::e751:223e:aa3d:5827%5]) with mapi id 15.20.8048.020; Tue, 15 Oct 2024 09:05:39 +0000 From: Pankaj Gupta Date: Tue, 15 Oct 2024 14:31:00 +0530 Subject: [PATCH v8 2/5] dt-bindings: arm: fsl: add imx-se-fw binding doc Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241015-imx-se-if-v8-2-915438e267d3@nxp.com> References: <20241015-imx-se-if-v8-0-915438e267d3@nxp.com> In-Reply-To: <20241015-imx-se-if-v8-0-915438e267d3@nxp.com> To: Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Pankaj Gupta , Rob Herring Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728982877; l=3095; i=pankaj.gupta@nxp.com; s=20240523; h=from:subject:message-id; bh=c2GJVCidrhX1BXyQTcNgVT1gDrIReiQzjgNl9ktmYns=; b=fMaL1hE8jLyU6WagFEBf5u7tBddMCZSKutvVg/m9oM1cAaswb209ns9SKfcImzGB1CwPtxc0T z2eShZwHKGdDRKzFNU4uhLrSIDPBCjELV9/HPky+Eu6Znlf/Ugz6gr5 X-Developer-Key: i=pankaj.gupta@nxp.com; a=ed25519; pk=OA0pBQoupy5lV0XfKzD8B0OOBVB6tpAoIf+0x1bYGRg= X-ClientProxiedBy: SG2P153CA0019.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::6) To AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8604:EE_|PA4PR04MB9223:EE_ X-MS-Office365-Filtering-Correlation-Id: d1153ced-a434-435e-97c4-08dcecf88a15 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|52116014|366016|7416014|921020|38350700014; X-Microsoft-Antispam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?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8604.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(52116014)(366016)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NjVacmdRMnlnWG9jSHNJMURtNnZKRCtqRGs4TkhnUFZVV2xvWVYyN0hQTjVn?= =?utf-8?B?TFFxUDRQemhiZEJpcllKZDIrbDNMKzdLVGNodm56K2VYYVg2enZNcFVRSGg4?= =?utf-8?B?SVB4Qk5ZeEt6MjBGOHpGa0NnaDcxdzRKSjhCSzgrOVVqZUliWllNVDV0N3Jp?= =?utf-8?B?VjZZNXhYb2hxdUtuMnNadWovV3dYRkl3V0ZqbEZMY2o1V3dFVUtQRXhRcVZx?= =?utf-8?B?QTRTSTBEZWhqTnJQcWtadytJWnkxZHRYczM5MGo5WEsvcEFhYTlrc1NqdVBq?= =?utf-8?B?N1liZ2poVTlPTkVjZDhEbE5NUWFRUkN4NkRod0R4M25uTGQ2UUVEQUdYUmZ0?= =?utf-8?B?NUpsVjNyWEdzVFNPY3NzenN3aEZUbkV6dWRaRkRUVDhCc0t1enl2WFJiZkYz?= =?utf-8?B?R0FSemlKRlVsc2xJcG1aL25ENi92b0taT2lXM0ZFNTBmNlpNaWNzU3NjSytW?= =?utf-8?B?UHZXWjZoMi94ZWVETWkwcDhFQXlFSHVtTFVySTJzV1VxdHJuWStqYWR0WGZo?= =?utf-8?B?QmFUcEtMbStZRjRGbU5XQUlwWDFtMmt5ZEUrekllRUFoeGVvYzZhdFRMQUR1?= =?utf-8?B?YW1FcloyZkZWb2ZCRzhycGc2Rjk3WGpKbEtIU283ME9MNFBHekNNays2WW1V?= =?utf-8?B?ai9JVkMzOUxlUEMrOTRYcXpHbEo1WnVMV3Bad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BTGZFNTNCcU9JM0NpMVhXNGk1SDNGZ1ROUDlaMkw4?= =?utf-8?B?MlZuRFpzSUtoYkU0N1U3dHpYdjdDaFhFYzJ2dzVRTnRWWDRBdDJHME9jWUY2?= =?utf-8?B?WUdCMEdXUk1JSEMza2pxM1lMTGZHTGJ5MTlkZlcwZW53Myt1YzVxWTA4dGVa?= =?utf-8?B?OFhzMmt0WGJ0cHM0c2xMMVdGcWlqZ2JEYkJvU1VzVnpaVlJSS25BV09LOG9m?= =?utf-8?B?WU1odnFpcVhKd3RvU2s5Vlk2V1JPSzAxaStLYkhndkpidDRDdEg0U29nVVdv?= =?utf-8?B?aktmMDBlZVBCMU1SS2h1UFdiTHpjK3ZWWEdwNUVJN0p2dTFQV0dYVGFMckJ4?= =?utf-8?B?a0oxTEhjSGRtQ3h0cDkvN3VUczN3Zm0yVisvZXRzZlBCeENEVnZYc2I1Y0E2?= =?utf-8?B?Rmd2YWdyNENpSmNxNnQwajM5U1pydC9tMzM5OWVyYVpDN21MejgvZDdUNyth?= =?utf-8?B?aURtRG4zVVJYL3hINnA0U0ZjWVhibTFucHFLOUw0UU4xVlg0b3VkcHoySnh1?= =?utf-8?Q?DofhOblPVk3tJvZRGJQGlq+Lh?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1153ced-a434-435e-97c4-08dcecf88a15 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8604.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:05:39.4005 (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: DRPOpKVWp/5GgtSMZjON4+YlMqwNYbV3IO0RYJSzfOz9g5MYM4VO4pnhwHsC0D0msnYOd8+H1L5xEfBDmasNjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9223 The NXP security hardware IP(s) like: i.MX EdgeLock Enclave, V2X etc., creates an embedded secure enclave within the SoC boundary to enable features like: - HSM - SHE - V2X Secure-Enclave(s) communication interface are typically via message unit, i.e., based on mailbox linux kernel driver. This driver enables communication ensuring well defined message sequence protocol between Application Core and enclave's firmware. Driver configures multiple misc-device on the MU, for multiple user-space applications, to be able to communicate over single MU. It exists on some i.MX processors. e.g. i.MX8ULP, i.MX93 etc. Signed-off-by: Pankaj Gupta Reviewed-by: Rob Herring (Arm) --- .../devicetree/bindings/firmware/fsl,imx-se.yaml | 91 ++++++++++++++++++= ++++ 1 file changed, 91 insertions(+) diff --git a/Documentation/devicetree/bindings/firmware/fsl,imx-se.yaml b/D= ocumentation/devicetree/bindings/firmware/fsl,imx-se.yaml new file mode 100644 index 000000000000..0b617f61640f --- /dev/null +++ b/Documentation/devicetree/bindings/firmware/fsl,imx-se.yaml @@ -0,0 +1,91 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/firmware/fsl,imx-se.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP i.MX HW Secure Enclave(s) EdgeLock Enclave + +maintainers: + - Pankaj Gupta + +description: | + NXP's SoC may contain one or multiple embedded secure-enclave HW + IP(s) like i.MX EdgeLock Enclave, V2X etc. These NXP's HW IP(s) + enables features like + - Hardware Security Module (HSM), + - Security Hardware Extension (SHE), and + - Vehicular to Anything (V2X) + + Communication interface to the secure-enclaves(se) is based on the + messaging unit(s). + +properties: + compatible: + enum: + - fsl,imx8ulp-se + - fsl,imx93-se + - fsl,imx95-se + + mboxes: + items: + - description: mailbox phandle to send message to se firmware + - description: mailbox phandle to receive message from se firmware + + mbox-names: + items: + - const: tx + - const: rx + + memory-region: + maxItems: 1 + + sram: + maxItems: 1 + +required: + - compatible + - mboxes + - mbox-names + +allOf: + # memory-region + - if: + properties: + compatible: + contains: + enum: + - fsl,imx8ulp-se + - fsl,imx93-se + then: + required: + - memory-region + else: + properties: + memory-region: false + + # sram + - if: + properties: + compatible: + contains: + enum: + - fsl,imx8ulp-se + then: + required: + - sram + + else: + properties: + sram: false + +additionalProperties: false + +examples: + - | + secure-enclave { + compatible =3D "fsl,imx95-se"; + mboxes =3D <&ele_mu0 0 0>, <&ele_mu0 1 0>; + mbox-names =3D "tx", "rx"; + }; +... --=20 2.34.1 From nobody Wed Nov 27 00:38:34 2024 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2071.outbound.protection.outlook.com [40.107.247.71]) (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 549911DE2A9; Tue, 15 Oct 2024 09:05:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983147; cv=fail; b=jgrn0zHX+540noyuFFlfY3VNndl/b9wMaHgBb+KN692uDzU8uep+UDcwnkMZZM/jgU3iJWcPSHiXAWyhzGRyUqIsj/qiTPIxKQVIWDKfW3hBcaEVir2ozoIcTE320AmPxqJ77gVCLPmCVtWm1Nx3e26ileizwOlSH/5JcciuGDM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983147; c=relaxed/simple; bh=pYE3/Q6exoCLJsnwweUy9J21x6w9vr/mPHeIgg5m5qc=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=WUmfAFYgCP2Qic2VC3F/WB1CKAbLmQa6sPS6tTsVT88RETeMU0YF3nUVOlIbcZbQV/5BocwBjnzWgscz6OIjp5AgqrbzcdSXGAlXm8Yp9hCuke13z8A0S0tjSUEGxXSABO+i3NYXHxsnXEbbnjunB2Hxl/PaN7APGucMYizgNvQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Zb1KIIGf; arc=fail smtp.client-ip=40.107.247.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Zb1KIIGf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wqZx+/PlRjQ9OcKmltgYCQ7sqexQGgoOHUok+Hj/x/eTTnQgXOI2xgdn1Aw0VJNpm5zZDVOhyJtvEcJABSXDObHCPZIbRTlvp8A9MquYBSVUm4gF2JsBmI+ICYk5t5eOGzMhq7wymincNCM015qx9BLUU5hja6zas/aDUrHBjk7oDOvOlQ82zmdsSuMEfMiLFwcvc7u6UbV2Te9+sWiAdTAF9ZIPt2rUkSaYx5bkasniqogSruaCYUSmlZjL4Ebed8KeqYQrKmCmgfj6ydBZMW66lEffUHFg5iGTDSOLBXUF/iq2zXwIal7YV6lXug9BbKuxUz+dOit6fl1XBkNjpA== 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=Gtkzixnwb0RPmDgVy9ypv5aH2wWPad0rOTiqgwx/eh8=; b=TEDEelsbInsAPhsoM52Kv8P34q0RM0gAc9/7CtRjUjOHn5bl73fBWfcz+VupfkcinLFVLJCGY3lrk210D4VeXtXb7N4Jntt5QfaIaKyb3kHbjCfXDqNfPQQsxb3Im5kLha3v17bxX7N849BRlSPzbGGfwLa0Kp8ld/6ycED91GnfByc2rccMtdQWAmj0d7vWTqnYV/JP4niXz8JdmAVWjf5XwmQTj7q7T7NMH6OB1rJOfKIwhIS4hWUflSoLhrIXL+o9pq6gnSSGKn+oik4Z/JcdSlHBjj6h2EZ5eGAmNEg1WxQ8jkcV1Kdw2JlAs8XQqdZXFYO1DYRLybjGn2V/hg== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Gtkzixnwb0RPmDgVy9ypv5aH2wWPad0rOTiqgwx/eh8=; b=Zb1KIIGfDTbDmorwJGGN9rQZCYd/MnpBCZazKaFnXoqt9F5m1RuNa73Wmd1qte5ogDAFMH/uy99WUGmF4bwXP6DiLePDerrxjL17Y2Ziu0ahsAvRJeR1eoLKOOJ0au0qdFrMsxrKPbDemIgSsIOVqJ++fTLJDG6nRkf0RJ0jAvNMmghXXL+GgRc0jhaVC3QzFIxZlvh9vBy7pNhWQ3oTptdwfTVWLvSrVy/G5NtMCczFvs9usGRnrMJ3FAg/8VTx54eOMZpNGzkAk+rC1tBZbI90GuZ1YNPZpCpuFvS4RCZSAB0/i3clw6GEiT1PpWHheDwG3O87LxenoBLUl7hj5g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) by PA4PR04MB9223.eurprd04.prod.outlook.com (2603:10a6:102:2a2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 09:05:43 +0000 Received: from AM9PR04MB8604.eurprd04.prod.outlook.com ([fe80::e751:223e:aa3d:5827]) by AM9PR04MB8604.eurprd04.prod.outlook.com ([fe80::e751:223e:aa3d:5827%5]) with mapi id 15.20.8048.020; Tue, 15 Oct 2024 09:05:43 +0000 From: Pankaj Gupta Date: Tue, 15 Oct 2024 14:31:01 +0530 Subject: [PATCH v8 3/5] arm64: dts: imx8ulp-evk: add nxp secure enclave firmware Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241015-imx-se-if-v8-3-915438e267d3@nxp.com> References: <20241015-imx-se-if-v8-0-915438e267d3@nxp.com> In-Reply-To: <20241015-imx-se-if-v8-0-915438e267d3@nxp.com> To: Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Pankaj Gupta , Rob Herring Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728982877; l=2640; i=pankaj.gupta@nxp.com; s=20240523; h=from:subject:message-id; bh=pYE3/Q6exoCLJsnwweUy9J21x6w9vr/mPHeIgg5m5qc=; b=8e1Z0/Ti8N9KWehTPPydtBSrd+kH5UfAUk8dTrrqfLR6hNLuE4urmzlOxD1HP0pzCTBGeQaE9 O1p6SXtc3sFDWVffxCCWJmfMMLrMeTUDD3vC4zsCJ+2i29clSlNCrgz X-Developer-Key: i=pankaj.gupta@nxp.com; a=ed25519; pk=OA0pBQoupy5lV0XfKzD8B0OOBVB6tpAoIf+0x1bYGRg= X-ClientProxiedBy: SG2P153CA0019.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::6) To AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8604:EE_|PA4PR04MB9223:EE_ X-MS-Office365-Filtering-Correlation-Id: 5344a3e8-8357-491f-62f5-08dcecf88ca8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|52116014|366016|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?V0JtL2ptY1lkQ2dWdmI3ZThoaCtkc1pidlFCZ08xVFFMdFJRdzFiNmZlWHd1?= =?utf-8?B?UW9VYVZRUjhBNnRjaG1aeFVqQTcwOURMek90TVpOOVA2TzFKL3RVVHhGVHJR?= =?utf-8?B?WVpuV2ZLYlhvU3RvSFpUY1AxYUlORDZZcmkxeTQ0MWZtWWFBaFR0T3NldTNV?= =?utf-8?B?VnRPa1Q2RDh2NnhVcTFWYTdSZHRaK3ZwQXduYmNsMDB4V1MwdExDTEJRNUI2?= =?utf-8?B?WUNTM3B6Y0JmSVNBMjQ3VC9vOUlkYVdZbjdrTFNXNUhkOWptZ0JjVGdxNUV0?= =?utf-8?B?K1A5YjFuSFp3RHZ1K29nYWF1NExpTEgxOG9Za2MrKy9IYzN3VU9xVkYyalFn?= =?utf-8?B?S0F4RW5ZTmNGdGxyVXpORDhEOUdKZm9tRmJMOG5Gcm00MCtYWTlqQXUyejRq?= =?utf-8?B?TVY0MEs5OWd6RXNodTYvL1RUVGs2cGtReGdCMUJkaUc0ekdQdFFOZGNxWTIw?= =?utf-8?B?cGhvdmFPU2hROTB2cVdJcGtubVN6a1F0MDI2QmhqcDZmWnUybGhiaWRXNHhU?= =?utf-8?B?aVJGTGVsUFVPUzdrWnBwK0k2Z01nMGJZQjNZSFM4eVVpOVJoRjNibFlqZUE3?= =?utf-8?B?Yzg0eVlCZ3E5dXpHWS95RnhFWmV3VUJpMTF0VUxkYnB5SjI4WTVmM2Y4QXl5?= =?utf-8?B?UjdadF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?TWlzSTgrSTFnYnRCQldOVm5vSFJOUUxXQjMwc2FVaU5NNHF0Nkx2b1FVY29Z?= =?utf-8?B?TEZ5aWtkRWVhb3Voa1Zrd3ZVT0ZSbnZwRFFvVzJYT3lhblhialJ1RFRvcmM5?= =?utf-8?B?M0JPS0ZWSWpKM0VrNTNEYkhHSGQzTndMNXBhUVYza0Jmb3czZ3pGVk1Lc1Bz?= =?utf-8?B?ODhiMGg0elAwZkZraFNORFdRQnhCZzZ6MFpuZkh3anBIN3FZckhoanJYQjE5?= =?utf-8?Q?pyNTIGZRN3binMz/E0gIpqOllUpEriEkPg75s=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8604.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(52116014)(366016)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NnRMRmNYTG41Q2hvZWxCNDMrU2g5MTB5OGVvU0RESVl5dE5DcFVwa2YrRFlh?= =?utf-8?B?V3d4bVRCdXNyZ2gwVmN6aXFPdzRES2NrazMwT3FrV3ptNS9tNEJQZDR1VEFW?= =?utf-8?B?dzc0SnpTWWpUb3N6dXRIR3VteENvN29aOFZKNllOcVJMLzVWbzQ5MlhEckNB?= =?utf-8?B?QSswNkRyS3I2bVc1U1JRV1R5VFNkYXNsZlYxUHFSYTBkUHBJVnpzZWZLSWVM?= =?utf-8?B?QVhScjhYK2dmcG04QjFZK0wzaUlyby9GYURmSUJ4d0JDazhWUmg0ZXVhYytx?= =?utf-8?B?bk1ydmp0dXM3Q1EzQWt0SHVPcHltUVFTTnRhOUFsRTZ3aU1RbW1rRUUxYVht?= =?utf-8?B?Rytqdm16MEVIT2l1Nm1PbEg5cEduMURzOG0zNUNBTzc4cW1FVDdSQzExdHB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cecf88ca8 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8604.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:05:43.7099 (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: I9kY+Ucn2PDyUE2N2dIRaq+UjUjt3+7DNKMhJ6DXKn2sYjzVCRIm2hahB3rhX102TYp/5DVL/v/YcYlYMdgcBA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9223 Add support for NXP secure enclave called EdgeLock Enclave firmware (se-fw) for imx8ulp-evk. EdgeLock Enclave has a hardware limitation of restricted access to DDR address: 0x80000000 to 0xAFFFFFFF, so reserve 1MB of DDR memory region from 0x80000000. Signed-off-by: Pankaj Gupta --- arch/arm64/boot/dts/freescale/imx8ulp-evk.dts | 17 ++++++++++++++++- arch/arm64/boot/dts/freescale/imx8ulp.dtsi | 13 +++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8ulp-evk.dts b/arch/arm64/boo= t/dts/freescale/imx8ulp-evk.dts index 24bb253b938d..ca8958f28a83 100644 --- a/arch/arm64/boot/dts/freescale/imx8ulp-evk.dts +++ b/arch/arm64/boot/dts/freescale/imx8ulp-evk.dts @@ -1,6 +1,6 @@ // SPDX-License-Identifier: (GPL-2.0+ OR MIT) /* - * Copyright 2021 NXP + * Copyright 2021, 2024 NXP */ =20 /dts-v1/; @@ -19,6 +19,17 @@ memory@80000000 { device_type =3D "memory"; reg =3D <0x0 0x80000000 0 0x80000000>; }; + reserved-memory { + #address-cells =3D <2>; + #size-cells =3D <2>; + ranges; + + ele_reserved: ele-reserved@90000000 { + compatible =3D "shared-dma-pool"; + reg =3D <0 0x90000000 0 0x100000>; + no-map; + }; + }; =20 reserved-memory { #address-cells =3D <2>; @@ -146,6 +157,10 @@ &usdhc0 { status =3D "okay"; }; =20 +&ele_if0 { + memory-region =3D <&ele_reserved>; +}; + &fec { pinctrl-names =3D "default", "sleep"; pinctrl-0 =3D <&pinctrl_enet>; diff --git a/arch/arm64/boot/dts/freescale/imx8ulp.dtsi b/arch/arm64/boot/d= ts/freescale/imx8ulp.dtsi index c460afaa76f5..914d61b2275c 100644 --- a/arch/arm64/boot/dts/freescale/imx8ulp.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8ulp.dtsi @@ -1,6 +1,6 @@ // SPDX-License-Identifier: (GPL-2.0+ OR MIT) /* - * Copyright 2021 NXP + * Copyright 2021, 2024 NXP */ =20 #include @@ -152,7 +152,7 @@ sosc: clock-sosc { #clock-cells =3D <0>; }; =20 - sram@2201f000 { + sram0: sram@2201f000 { compatible =3D "mmio-sram"; reg =3D <0x0 0x2201f000 0x0 0x1000>; =20 @@ -167,6 +167,8 @@ scmi_buf: scmi-sram-section@0 { }; =20 firmware { + #address-cells =3D <1>; + #size-cells =3D <0>; scmi { compatible =3D "arm,scmi-smc"; arm,smc-id =3D <0xc20000fe>; @@ -184,6 +186,13 @@ scmi_sensor: protocol@15 { #thermal-sensor-cells =3D <1>; }; }; + + ele_if0: secure-enclave { + compatible =3D "fsl,imx8ulp-se"; + mbox-names =3D "tx", "rx"; + mboxes =3D <&s4muap 0 0>, <&s4muap 1 0>; + sram =3D <&sram0>; + }; }; =20 cm33: remoteproc-cm33 { --=20 2.34.1 From nobody Wed Nov 27 00:38:34 2024 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2060.outbound.protection.outlook.com [40.107.22.60]) (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 D90051D966F; Tue, 15 Oct 2024 09:05:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983156; cv=fail; b=lzZ/v4ac99T2Xn98IqM1/S7+Xg81FM1E6Q7COPvMVbkfWvLj0HLMXzBeGXCsJnmnDMR0IIVVfdFl1eDkeoqw2+jvgpuk24KGeGye+wHRIfzsJUjlINWOlMtEGJOqrvm1vlpTRaFUtOa52STgG+z8fWosSXgd1cC6lXBaXWEERM0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983156; c=relaxed/simple; bh=J9aUs3PFj5BcVPevQWdBUzAZVCO/5jRI6VQnIVzv1es=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=O3HZxfyVl9TnympEcszOpWGlGxIJenP8lfG9LwJthP5GL4C8nmk8jnNnk2zZ0P2CE3DZmhtoFuqSX7mk++Qahl5S/ZAvct1A//+D+t7ix7/iwunnyzG8uRwInzuwAt5LqUfsQ73mrCOY626NieHKcFDhskTqMQta9pacgwFMkhU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=nydefA4O; arc=fail smtp.client-ip=40.107.22.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="nydefA4O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o3JMAiuwiZGG8squHj+l8yA4TvmtdcoA9wmVtjmk6XrvmzJVXX/LA9pxBv5MGsF/3Nw012xQ6WigXHpVB1lzG+z+9SLeUfh3BdUAnmKaI59PPl/YCyXk3/ohwcBnBv8CU6dBJt0c1dIrFDxo95CbyWgrvVgy1uuYBgJICTH1YmfeHk5aSvXTktm9lP/9gZDaiAKvFeR+EjhsPr2db0W8Fh2rG/LUZyHSQgUFIVhowQ2MsfcXEtSyvuQzBl42OKGPxmP7f7/Y7aTFJFjC0Ac62x/KD8Y3JVMlMPmsKu/XEh/Q8Qkqba5W7nDyIlWuqlLK5D4yeCZe/JGB6WlQm9Vlzw== 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=srG1deAGKA0X42kb5lhsKEqIiaqQOwg4yeZdsTPe3iU=; b=XttGFtosHwBvpTPpSMNKNk2U69xwCAm6Jjzj2hij19p97d1I2WoE1VxpKgQcbTFVBWvEtmiGRS2wDof1f+DCz1R0p3xS9/Im074RbPOYXKocwpDsD3SqsyCa0AgbW9K8QFBYFBLg0OpDosbsEsDD/T/Lq6+4L2Jb6IuXPwAVOhonw1FTmwz3yn9MPtlRtdOegdX6NqWJ5iD6w8RPPboEfHO2IrF0Z2SJ4jSeMMgrZz9QLMREhVrcj3KjSz/kPIUTOL4ggQ1l60un/maPqYp/v5xMmuVFunfPcJoQARR2jSywyxUYeKeCrbqceJaIXU1KsJPyctto4o277fdaDjLPXw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=srG1deAGKA0X42kb5lhsKEqIiaqQOwg4yeZdsTPe3iU=; b=nydefA4O2WX7W95a3+Xl5hN/gq5xLTQsVBKwI84UB31icu6eA6sE3BBR8VEwmPcxIJFLyxz6k66POi/MtkR4YbMfIntVSHKHFShJpHmTkCWICdVvn1m4iQsJ0OpHiZDe9Zd7BDS1uka347XqE/YgchzKW4yf6n1XZzLQ7WK3D2WwV4mmW4anCyzSB976ZVIeWELf8x8ayfswJles1qIUNsgFt6fwM3hxavmXK1O/1bRQV1YROoWDyAXigmzR8H1s35uE0F/qace19fcGLZRbON6Sd5gLMWtflmoBwZdI3MTjm6jJ7tWz87NwUlNK6b7zccjpNuIObdgRiwbrWh/w8Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) by PA4PR04MB9223.eurprd04.prod.outlook.com (2603:10a6:102:2a2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Tue, 15 Oct 2024 09:05:48 +0000 Received: from AM9PR04MB8604.eurprd04.prod.outlook.com ([fe80::e751:223e:aa3d:5827]) by AM9PR04MB8604.eurprd04.prod.outlook.com ([fe80::e751:223e:aa3d:5827%5]) with mapi id 15.20.8048.020; Tue, 15 Oct 2024 09:05:48 +0000 From: Pankaj Gupta Date: Tue, 15 Oct 2024 14:31:02 +0530 Subject: [PATCH v8 4/5] firmware: imx: add driver for NXP EdgeLock Enclave Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241015-imx-se-if-v8-4-915438e267d3@nxp.com> References: <20241015-imx-se-if-v8-0-915438e267d3@nxp.com> In-Reply-To: <20241015-imx-se-if-v8-0-915438e267d3@nxp.com> To: Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Pankaj Gupta , Rob Herring Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728982877; l=39339; i=pankaj.gupta@nxp.com; s=20240523; h=from:subject:message-id; bh=J9aUs3PFj5BcVPevQWdBUzAZVCO/5jRI6VQnIVzv1es=; b=6R5ua3JHn/dVEadcy/Nks720kkd1UxHXDYhUl3IKEu9/AyqDIwP6LaVOzqGXZdR9aXDCAmogS IoctcheeZaEB1qYw/f6vnoEIgLmvuSqvzOxr0kntNFFQE3m9DdDurtt X-Developer-Key: i=pankaj.gupta@nxp.com; a=ed25519; pk=OA0pBQoupy5lV0XfKzD8B0OOBVB6tpAoIf+0x1bYGRg= X-ClientProxiedBy: SG2P153CA0019.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::6) To AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8604:EE_|PA4PR04MB9223:EE_ X-MS-Office365-Filtering-Correlation-Id: db3957a5-1aec-4ebf-3409-08dcecf88f44 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|52116014|366016|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?WXAyd0hqRTlwdEFpWHR6YytCQTltN1ZhamFPWTkzSzJicFBtZkgyWEZHMGVR?= =?utf-8?B?NXVWL001NERYWU1URGdJbGZjUVpvTTBleWtxNi9vODlPZFQ0VDMyTGtKMHhx?= =?utf-8?B?M1l4MHl1cFFHc2hTRmdQSWV6OEhpYWU0UGs2Tk5Fb1hCQy9ISU9xM1k0TnA1?= =?utf-8?B?NE84Y2ZZaHpnejZjMGZFR0twZjAyS1FhS0lxZUJqMTlta0xG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nI0SW95alY3UGZhVzFSVmU2Vnlx?= =?utf-8?B?YUNFZXp3aEI4NUNLQVBZQzhrOUkxR282Z09NMElzZjZzSlF3bytmU2dncTE1?= =?utf-8?B?Yi9TcGlTcW9OalZHdnNLK1pVMWo1U2d5dXZVTzJBM2RpMlRKWFE4VTdma2o3?= =?utf-8?B?c21uc1BqcFhPdVdBTE9xRENBVGpjcjZSblJJWmhTazJjZXVwT21peXJ5LzFH?= =?utf-8?B?cmtyZjlpWUkzc1l4d0dlbkRZV1Yra2xYOThsdzFFY0NoWEhMVTh2cnFSSzNX?= =?utf-8?B?Y002dHRBNHQ4NHpaWktoL2VjdWJ0QXNTWE9YMHJwbCs5WFNObW95dXVYQU9U?= =?utf-8?B?TEFUZWNabThvUzM2Z3I1UUtqTnducGFNcjVkUk1NRi93MHBZUjFkdnkxUHll?= =?utf-8?B?bUdiU3dYeEYxTlU5UzF2b1kwenBZa2xtV2h0aEc2aEVjeGl3MUNKazBSWERO?= =?utf-8?B?S3pZcDVud0ZTSnZIaU14cEtRenArTWdIMjJsUzVPdjBsVTlvMVh2MFQ1SlEx?= =?utf-8?B?bFJ4dTVCc2UwMUhhMXlwSzY2RkZxaXdsZG03NXozMERHYWRndTViTm9nQlAy?= =?utf-8?B?SldUMkFBWDVlN2JCTTczSjg1VDgzNUcxd1Q2WjgrV3huZGxpeTNKOTVldmZv?= =?utf-8?B?eVFrMXZ0ZUtIRGRPYkJxdFF2TGhDR00wdXozbFBsK2VaZFZMRFZIU05VZGNM?= =?utf-8?Q?BWRKGLhRoMFl5YOO0BQ0dF3aQuJv3vtKBHgiA=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8604.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(52116014)(366016)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount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UltSnhRcDBR?= =?utf-8?B?NE5jOU9YM2Q1VkNjRHZmWHZabVp1VDFDaTRHWGFDeXMzYi92N05YY3p2RFBQ?= =?utf-8?B?cUNwUEFwQU04VjlrUU0xaWJJWk50WTZzVG05Z3MyTTZzdTg5a00rc3NRRVFl?= =?utf-8?B?QmI5UzJRak9UYkZhelI4Nmo3YXlkcFJrQWl6dFVYcHgwMnJLdjNHQU14WUZE?= =?utf-8?B?cHpRRVZhRlZ6VmxlUFBoVDc1VDc0MVUzVFBvcUoyc2JxaG1hbVBGcDVJWmNh?= =?utf-8?B?ZmxBV2l4R05vWGZveEFSS2Mwc0k1OEsrN0NPMGdhd21NS1UzQnRUMjZQRHdj?= =?utf-8?B?OVlvdDZxS2x4OUQ1Tnl0SUxjSTRuOXVRb3orUDRQQ3FWZW9WUEllQ2dTSDFS?= =?utf-8?Q?DXeeaj9IoS6Lfy6MSyzcbpzQI?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: db3957a5-1aec-4ebf-3409-08dcecf88f44 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8604.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:05:48.0863 (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: WAyenHYF8uaBAN/BFtloVv0U9UYbF4BtlFTjvpxV5xxKYxftjgSm2+K/nWUtQquAXzC34LNmju4wPTeXTQGD6g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB9223 NXP hardware IP(s) for secure-enclaves like Edgelock Enclave(ELE), are embedded in the SoC to support the features like HSM, SHE & V2X, using message based communication interface. The secure enclave FW communicates on a dedicated messaging unit(MU) based interface(s) with application core, where kernel is running. It exists on specific i.MX processors. e.g. i.MX8ULP, i.MX93. This patch adds the driver for communication interface to secure-enclave, for exchanging messages with NXP secure enclave HW IP(s) like EdgeLock Enclave (ELE) from Kernel-space, used by kernel management layers like - DM-Crypt. Signed-off-by: Pankaj Gupta --- drivers/firmware/imx/Kconfig | 13 + drivers/firmware/imx/Makefile | 2 + drivers/firmware/imx/ele_base_msg.c | 279 ++++++++++++++++++ drivers/firmware/imx/ele_base_msg.h | 94 ++++++ drivers/firmware/imx/ele_common.c | 320 +++++++++++++++++++++ drivers/firmware/imx/ele_common.h | 51 ++++ drivers/firmware/imx/se_ctrl.c | 555 ++++++++++++++++++++++++++++++++= ++++ drivers/firmware/imx/se_ctrl.h | 94 ++++++ include/linux/firmware/imx/se_api.h | 14 + 9 files changed, 1422 insertions(+) diff --git a/drivers/firmware/imx/Kconfig b/drivers/firmware/imx/Kconfig index 183613f82a11..d002933bdd89 100644 --- a/drivers/firmware/imx/Kconfig +++ b/drivers/firmware/imx/Kconfig @@ -22,3 +22,16 @@ config IMX_SCU =20 This driver manages the IPC interface between host CPU and the SCU firmware running on M4. + +config IMX_SEC_ENCLAVE + tristate "i.MX Embedded Secure Enclave - EdgeLock Enclave Firmware driver= ." + depends on IMX_MBOX && ARCH_MXC && ARM64 + select FW_LOADER + default m if ARCH_MXC + + help + It is possible to use APIs exposed by the iMX Secure Enclave HW IP call= ed: + - EdgeLock Enclave Firmware (for i.MX8ULP, i.MX93), + like base, HSM, V2X & SHE using the SAB protocol via the shared Messa= ging + Unit. This driver exposes these interfaces via a set of file descript= ors + allowing to configure shared memory, send and receive messages. diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 8f9f04a513a8..aa9033e0e9e3 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -1,3 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_IMX_DSP) +=3D imx-dsp.o obj-$(CONFIG_IMX_SCU) +=3D imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-so= c.o +sec_enclave-objs =3D se_ctrl.o ele_common.o ele_base_msg.o +obj-${CONFIG_IMX_SEC_ENCLAVE} +=3D sec_enclave.o diff --git a/drivers/firmware/imx/ele_base_msg.c b/drivers/firmware/imx/ele= _base_msg.c new file mode 100644 index 000000000000..fb89340c224e --- /dev/null +++ b/drivers/firmware/imx/ele_base_msg.c @@ -0,0 +1,279 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 NXP + */ + +#include + +#include +#include +#include + +#include "ele_base_msg.h" +#include "ele_common.h" + +int ele_get_info(struct se_if_priv *priv, struct ele_dev_info *s_info) +{ + struct se_api_msg *tx_msg __free(kfree) =3D NULL; + struct se_api_msg *rx_msg __free(kfree) =3D NULL; + dma_addr_t get_info_addr =3D 0; + u32 *get_info_data =3D NULL; + int ret =3D 0; + + if (!priv) { + ret =3D -EINVAL; + return ret; + } + + memset(s_info, 0x0, sizeof(*s_info)); + + if (priv->if_defs.mem_pool) + get_info_data =3D gen_pool_dma_alloc(priv->if_defs.mem_pool, + ELE_GET_INFO_BUFF_SZ, + &get_info_addr); + else + get_info_data =3D dma_alloc_coherent(priv->dev, + ELE_GET_INFO_BUFF_SZ, + &get_info_addr, + GFP_KERNEL); + if (!get_info_data) { + ret =3D -ENOMEM; + dev_dbg(priv->dev, + "%s: Failed to allocate get_info_addr.\n", + __func__); + return ret; + } + + tx_msg =3D kzalloc(ELE_GET_INFO_REQ_MSG_SZ, GFP_KERNEL); + if (!tx_msg) { + ret =3D -ENOMEM; + goto exit; + } + + rx_msg =3D kzalloc(ELE_GET_INFO_RSP_MSG_SZ, GFP_KERNEL); + if (!rx_msg) { + ret =3D -ENOMEM; + goto exit; + } + + ret =3D se_fill_cmd_msg_hdr(priv, + (struct se_msg_hdr *)&tx_msg->header, + ELE_GET_INFO_REQ, + ELE_GET_INFO_REQ_MSG_SZ, + true); + if (ret) + goto exit; + + tx_msg->data[0] =3D upper_32_bits(get_info_addr); + tx_msg->data[1] =3D lower_32_bits(get_info_addr); + tx_msg->data[2] =3D sizeof(*s_info); + ret =3D ele_msg_send_rcv(priv, + tx_msg, + ELE_GET_INFO_REQ_MSG_SZ, + rx_msg, + ELE_GET_INFO_RSP_MSG_SZ); + if (ret < 0) + goto exit; + + ret =3D se_val_rsp_hdr_n_status(priv, + rx_msg, + ELE_GET_INFO_REQ, + ELE_GET_INFO_RSP_MSG_SZ, + true); + + memcpy(s_info, get_info_data, sizeof(*s_info)); + +exit: + if (priv->if_defs.mem_pool) + gen_pool_free(priv->if_defs.mem_pool, + (u64) get_info_data, + ELE_GET_INFO_BUFF_SZ); + else + dma_free_coherent(priv->dev, + ELE_GET_INFO_BUFF_SZ, + get_info_data, + get_info_addr); + + return ret; +} + +int ele_fetch_soc_info(struct se_if_priv *priv, u16 *soc_rev, u64 *serial_= num) +{ + struct ele_dev_info s_info =3D {0}; + int err; + + err =3D ele_get_info(priv, &s_info); + if (err < 0) + return err; + + if (soc_rev) + *soc_rev =3D s_info.d_info.soc_rev; + if (serial_num) + *serial_num =3D GET_SERIAL_NUM_FROM_UID(s_info.d_info.uid, MAX_UID_SIZE = >> 2); + + return err; +} + +int ele_ping(struct se_if_priv *priv) +{ + struct se_api_msg *tx_msg __free(kfree) =3D NULL; + struct se_api_msg *rx_msg __free(kfree) =3D NULL; + int ret =3D 0; + + if (!priv) { + ret =3D -EINVAL; + goto exit; + } + + tx_msg =3D kzalloc(ELE_PING_REQ_SZ, GFP_KERNEL); + if (!tx_msg) { + ret =3D -ENOMEM; + goto exit; + } + + rx_msg =3D kzalloc(ELE_PING_RSP_SZ, GFP_KERNEL); + if (!rx_msg) { + ret =3D -ENOMEM; + goto exit; + } + + ret =3D se_fill_cmd_msg_hdr(priv, + (struct se_msg_hdr *)&tx_msg->header, + ELE_PING_REQ, ELE_PING_REQ_SZ, true); + if (ret) { + dev_err(priv->dev, "Error: se_fill_cmd_msg_hdr failed.\n"); + goto exit; + } + + ret =3D ele_msg_send_rcv(priv, + tx_msg, + ELE_PING_REQ_SZ, + rx_msg, + ELE_PING_RSP_SZ); + if (ret < 0) + goto exit; + + ret =3D se_val_rsp_hdr_n_status(priv, + rx_msg, + ELE_PING_REQ, + ELE_PING_RSP_SZ, + true); +exit: + return ret; +} + +int ele_service_swap(struct se_if_priv *priv, + phys_addr_t addr, + u32 addr_size, u16 flag) +{ + struct se_api_msg *tx_msg __free(kfree) =3D NULL; + struct se_api_msg *rx_msg __free(kfree) =3D NULL; + int ret =3D 0; + + if (!priv) { + ret =3D -EINVAL; + goto exit; + } + + tx_msg =3D kzalloc(ELE_SERVICE_SWAP_REQ_MSG_SZ, GFP_KERNEL); + if (!tx_msg) { + ret =3D -ENOMEM; + goto exit; + } + + rx_msg =3D kzalloc(ELE_SERVICE_SWAP_RSP_MSG_SZ, GFP_KERNEL); + if (!rx_msg) { + ret =3D -ENOMEM; + goto exit; + } + + ret =3D se_fill_cmd_msg_hdr(priv, + (struct se_msg_hdr *)&tx_msg->header, + ELE_SERVICE_SWAP_REQ, + ELE_SERVICE_SWAP_REQ_MSG_SZ, true); + if (ret) + goto exit; + + tx_msg->data[0] =3D flag; + tx_msg->data[1] =3D addr_size; + tx_msg->data[2] =3D ELE_NONE_VAL; + tx_msg->data[3] =3D lower_32_bits(addr); + tx_msg->data[4] =3D se_add_msg_crc((uint32_t *)&tx_msg[0], + ELE_SERVICE_SWAP_REQ_MSG_SZ); + ret =3D ele_msg_send_rcv(priv, + tx_msg, + ELE_SERVICE_SWAP_REQ_MSG_SZ, + rx_msg, + ELE_SERVICE_SWAP_RSP_MSG_SZ); + if (ret < 0) + goto exit; + + ret =3D se_val_rsp_hdr_n_status(priv, + rx_msg, + ELE_SERVICE_SWAP_REQ, + ELE_SERVICE_SWAP_RSP_MSG_SZ, + true); + if (ret) + goto exit; + + if (flag =3D=3D ELE_IMEM_EXPORT) + ret =3D rx_msg->data[1]; + else + ret =3D 0; + +exit: + + return ret; +} + +int ele_fw_authenticate(struct se_if_priv *priv, phys_addr_t addr) +{ + struct se_api_msg *tx_msg __free(kfree) =3D NULL; + struct se_api_msg *rx_msg __free(kfree) =3D NULL; + int ret =3D 0; + + if (!priv) { + ret =3D -EINVAL; + goto exit; + } + + tx_msg =3D kzalloc(ELE_FW_AUTH_REQ_SZ, GFP_KERNEL); + if (!tx_msg) { + ret =3D -ENOMEM; + goto exit; + } + + rx_msg =3D kzalloc(ELE_FW_AUTH_RSP_MSG_SZ, GFP_KERNEL); + if (!rx_msg) { + ret =3D -ENOMEM; + goto exit; + } + + ret =3D se_fill_cmd_msg_hdr(priv, + (struct se_msg_hdr *)&tx_msg->header, + ELE_FW_AUTH_REQ, + ELE_FW_AUTH_REQ_SZ, + true); + if (ret) + goto exit; + + tx_msg->data[1] =3D upper_32_bits(addr); + tx_msg->data[0] =3D lower_32_bits(addr); + tx_msg->data[2] =3D addr; + + ret =3D ele_msg_send_rcv(priv, + tx_msg, + ELE_FW_AUTH_REQ_SZ, + rx_msg, + ELE_FW_AUTH_RSP_MSG_SZ); + if (ret < 0) + goto exit; + + ret =3D se_val_rsp_hdr_n_status(priv, + rx_msg, + ELE_FW_AUTH_REQ, + ELE_FW_AUTH_RSP_MSG_SZ, + true); +exit: + return ret; +} diff --git a/drivers/firmware/imx/ele_base_msg.h b/drivers/firmware/imx/ele= _base_msg.h new file mode 100644 index 000000000000..e390d35fc787 --- /dev/null +++ b/drivers/firmware/imx/ele_base_msg.h @@ -0,0 +1,94 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2024 NXP + * + * Header file for the EdgeLock Enclave Base API(s). + */ + +#ifndef ELE_BASE_MSG_H +#define ELE_BASE_MSG_H + +#include +#include + +#include "se_ctrl.h" + +#define ELE_NONE_VAL 0x0 + +#define ELE_GET_INFO_REQ 0xDA +#define ELE_GET_INFO_REQ_MSG_SZ 0x10 +#define ELE_GET_INFO_RSP_MSG_SZ 0x08 + +#define SOC_ID_MASK 0x0000FFFF + +#define MAX_UID_SIZE (16) +#define DEV_GETINFO_ROM_PATCH_SHA_SZ (32) +#define DEV_GETINFO_FW_SHA_SZ (32) +#define DEV_GETINFO_OEM_SRKH_SZ (64) +#define DEV_GETINFO_MIN_VER_MASK 0xFF +#define DEV_GETINFO_MAJ_VER_MASK 0xFF00 +#define ELE_DEV_INFO_EXTRA_SZ 0x60 + +struct dev_info { + uint8_t cmd; + uint8_t ver; + uint16_t length; + uint16_t soc_id; + uint16_t soc_rev; + uint16_t lmda_val; + uint8_t ssm_state; + uint8_t dev_atts_api_ver; + uint8_t uid[MAX_UID_SIZE]; + uint8_t sha_rom_patch[DEV_GETINFO_ROM_PATCH_SHA_SZ]; + uint8_t sha_fw[DEV_GETINFO_FW_SHA_SZ]; +}; + +struct dev_addn_info { + uint8_t oem_srkh[DEV_GETINFO_OEM_SRKH_SZ]; + uint8_t trng_state; + uint8_t csal_state; + uint8_t imem_state; + uint8_t reserved2; +}; + +struct ele_dev_info { + struct dev_info d_info; + struct dev_addn_info d_addn_info; +}; + +#define ELE_GET_INFO_BUFF_SZ (sizeof(struct ele_dev_info) \ + + ELE_DEV_INFO_EXTRA_SZ) + +#define GET_SERIAL_NUM_FROM_UID(x, uid_word_sz) \ + (((u64)(((u32 *)(x))[(uid_word_sz) - 1]) << 32) | ((u32 *)(x))[0]) + +#define ELE_DEBUG_DUMP_REQ 0x21 +#define ELE_DEBUG_DUMP_RSP_SZ 0x14 + +#define ELE_PING_REQ 0x01 +#define ELE_PING_REQ_SZ 0x04 +#define ELE_PING_RSP_SZ 0x08 + +#define ELE_SERVICE_SWAP_REQ 0xDF +#define ELE_SERVICE_SWAP_REQ_MSG_SZ 0x18 +#define ELE_SERVICE_SWAP_RSP_MSG_SZ 0x0C +#define ELE_IMEM_SIZE 0x10000 +#define ELE_IMEM_STATE_OK 0xCA +#define ELE_IMEM_STATE_BAD 0xFE +#define ELE_IMEM_STATE_WORD 0x27 +#define ELE_IMEM_STATE_MASK 0x00ff0000 +#define ELE_IMEM_EXPORT 0x1 +#define ELE_IMEM_IMPORT 0x2 + +#define ELE_FW_AUTH_REQ 0x02 +#define ELE_FW_AUTH_REQ_SZ 0x10 +#define ELE_FW_AUTH_RSP_MSG_SZ 0x08 + +int ele_get_info(struct se_if_priv *priv, struct ele_dev_info *s_info); +int ele_fetch_soc_info(struct se_if_priv *priv, u16 *soc_rev, u64 *serial_= num); +int ele_ping(struct se_if_priv *priv); +int ele_service_swap(struct se_if_priv *priv, + phys_addr_t addr, + u32 addr_size, u16 flag); +int ele_fw_authenticate(struct se_if_priv *priv, phys_addr_t addr); +#endif diff --git a/drivers/firmware/imx/ele_common.c b/drivers/firmware/imx/ele_c= ommon.c new file mode 100644 index 000000000000..1cd76c630bdf --- /dev/null +++ b/drivers/firmware/imx/ele_common.c @@ -0,0 +1,320 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 NXP + */ + +#include "ele_base_msg.h" +#include "ele_common.h" + +u32 se_add_msg_crc(u32 *msg, u32 msg_len) +{ + u32 nb_words =3D msg_len / (u32)sizeof(u32); + u32 crc =3D 0; + u32 i; + + for (i =3D 0; i < nb_words - 1; i++) + crc ^=3D *(msg + i); + + return crc; +} + +int ele_msg_rcv(struct se_if_priv *priv, + struct se_clbk_handle *se_clbk_hdl) +{ + int err =3D 0; + + do { + /* If callback is executed before entrying to wait state, + * it will immediately come out after entering the wait state, + * but completion_done(&se_clbk_hdl->done), will return false + * after exiting the wait state, with err =3D 0. + */ + err =3D wait_for_completion_interruptible(&se_clbk_hdl->done); + if (err =3D=3D -ERESTARTSYS) { + if (priv->waiting_rsp_clbk_hdl.rx_msg) { + priv->waiting_rsp_clbk_hdl.signal_rcvd =3D true; + continue; + } + dev_err(priv->dev, + "Err[0x%x]:Interrupted by signal.\n", + err); + err =3D -EINTR; + break; + } + } while (err !=3D 0); + + return err ? err : se_clbk_hdl->rx_msg_sz; +} + +int ele_msg_send(struct se_if_priv *priv, + void *tx_msg, + int tx_msg_sz) +{ + struct se_msg_hdr *header; + int err; + + header =3D tx_msg; + + /* + * Check that the size passed as argument matches the size + * carried in the message. + */ + if (header->size << 2 !=3D tx_msg_sz) { + err =3D -EINVAL; + dev_err(priv->dev, + "User buf hdr: 0x%x, sz mismatced with input-sz (%d !=3D %d).", + *(u32 *)header, + header->size << 2, tx_msg_sz); + goto exit; + } + + err =3D mbox_send_message(priv->tx_chan, tx_msg); + if (err < 0) { + dev_err(priv->dev, "Error: mbox_send_message failure.\n"); + return err; + } + err =3D tx_msg_sz; + +exit: + return err; +} + +/* API used for send/receive blocking call. */ +int ele_msg_send_rcv(struct se_if_priv *priv, + void *tx_msg, + int tx_msg_sz, + void *rx_msg, + int exp_rx_msg_sz) +{ + int err; + + guard(mutex)(&priv->se_if_cmd_lock); + + priv->waiting_rsp_clbk_hdl.rx_msg_sz =3D exp_rx_msg_sz; + priv->waiting_rsp_clbk_hdl.rx_msg =3D rx_msg; + + err =3D ele_msg_send(priv, tx_msg, tx_msg_sz); + if (err < 0) + goto exit; + + err =3D ele_msg_rcv(priv, &priv->waiting_rsp_clbk_hdl); + + if (priv->waiting_rsp_clbk_hdl.signal_rcvd) { + err =3D -EINTR; + priv->waiting_rsp_clbk_hdl.signal_rcvd =3D false; + } + +exit: + return err; +} + +static bool exception_for_size(struct se_if_priv *priv, + struct se_msg_hdr *header) +{ + /* List of API(s) that can be accepte variable length + * response buffer. + */ + if (header->command =3D=3D ELE_DEBUG_DUMP_REQ && + header->ver =3D=3D priv->if_defs.base_api_ver && + header->size >=3D 0 && + header->size <=3D ELE_DEBUG_DUMP_RSP_SZ) + return true; + + return false; +} + +/* + * Callback called by mailbox FW, when data is received. + */ +void se_if_rx_callback(struct mbox_client *mbox_cl, void *msg) +{ + struct se_clbk_handle *se_clbk_hdl; + struct device *dev =3D mbox_cl->dev; + struct se_msg_hdr *header; + struct se_if_priv *priv; + u32 rx_msg_sz; + + priv =3D dev_get_drvdata(dev); + + /* The function can be called with NULL msg */ + if (!msg) { + dev_err(dev, "Message is invalid\n"); + return; + } + + header =3D msg; + rx_msg_sz =3D header->size << 2; + + /* Incoming command: wake up the receiver if any. */ + if (header->tag =3D=3D priv->if_defs.cmd_tag) { + se_clbk_hdl =3D &priv->cmd_receiver_clbk_hdl; + dev_dbg(dev, + "Selecting cmd receiver for mesg header:0x%x.", + *(u32 *) header); + + /* Pre-allocated buffer of MAX_NVM_MSG_LEN + * as the NVM command are initiated by FW. + * Size is revealed as part of this call function. + */ + if (rx_msg_sz > MAX_NVM_MSG_LEN) { + dev_err(dev, + "CMD-RCVER NVM: hdr(0x%x) with different sz(%d !=3D %d).\n", + *(u32 *) header, + rx_msg_sz, se_clbk_hdl->rx_msg_sz); + + se_clbk_hdl->rx_msg_sz =3D MAX_NVM_MSG_LEN; + } + se_clbk_hdl->rx_msg_sz =3D rx_msg_sz; + + } else if (header->tag =3D=3D priv->if_defs.rsp_tag) { + se_clbk_hdl =3D &priv->waiting_rsp_clbk_hdl; + dev_dbg(dev, + "Selecting resp waiter for mesg header:0x%x.", + *(u32 *) header); + + if (rx_msg_sz !=3D se_clbk_hdl->rx_msg_sz + && !exception_for_size(priv, header)) { + dev_err(dev, + "Rsp to CMD: hdr(0x%x) with different sz(%d !=3D %d).\n", + *(u32 *) header, + rx_msg_sz, se_clbk_hdl->rx_msg_sz); + + se_clbk_hdl->rx_msg_sz =3D min(rx_msg_sz, se_clbk_hdl->rx_msg_sz); + } + } else { + dev_err(dev, "Failed to select a device for message: %.8x\n", + *((u32 *) header)); + return; + } + + memcpy(se_clbk_hdl->rx_msg, msg, se_clbk_hdl->rx_msg_sz); + + /* Allow user to read */ + complete(&se_clbk_hdl->done); +} + +int se_val_rsp_hdr_n_status(struct se_if_priv *priv, + struct se_api_msg *msg, + uint8_t msg_id, + uint8_t sz, + bool is_base_api) +{ + u32 status; + struct se_msg_hdr *header =3D &msg->header; + + if (header->tag !=3D priv->if_defs.rsp_tag) { + dev_err(priv->dev, + "MSG[0x%x] Hdr: Resp tag mismatch. (0x%x !=3D 0x%x)", + msg_id, header->tag, priv->if_defs.rsp_tag); + return -EINVAL; + } + + if (header->command !=3D msg_id) { + dev_err(priv->dev, + "MSG Header: Cmd id mismatch. (0x%x !=3D 0x%x)", + header->command, msg_id); + return -EINVAL; + } + + if (header->size !=3D (sz >> 2)) { + dev_err(priv->dev, + "MSG[0x%x] Hdr: Cmd size mismatch. (0x%x !=3D 0x%x)", + msg_id, header->size, (sz >> 2)); + return -EINVAL; + } + + if (is_base_api && (header->ver !=3D priv->if_defs.base_api_ver)) { + dev_err(priv->dev, + "MSG[0x%x] Hdr: Base API Vers mismatch. (0x%x !=3D 0x%x)", + msg_id, header->ver, priv->if_defs.base_api_ver); + return -EINVAL; + } else if (!is_base_api && header->ver !=3D priv->if_defs.fw_api_ver) { + dev_err(priv->dev, + "MSG[0x%x] Hdr: FW API Vers mismatch. (0x%x !=3D 0x%x)", + msg_id, header->ver, priv->if_defs.fw_api_ver); + return -EINVAL; + } + + status =3D RES_STATUS(msg->data[0]); + if (status !=3D priv->if_defs.success_tag) { + dev_err(priv->dev, "Command Id[%d], Response Failure =3D 0x%x", + header->command, status); + return -EPERM; + } + + return 0; +} + +int se_save_imem_state(struct se_if_priv *priv, struct se_imem_buf *imem) +{ + int ret; + + /* EXPORT command will save encrypted IMEM to given address, + * so later in resume, IMEM can be restored from the given + * address. + * + * Size must be at least 64 kB. + */ + ret =3D ele_service_swap(priv, + imem->phyaddr, + ELE_IMEM_SIZE, + ELE_IMEM_EXPORT); + if (ret < 0) + dev_err(priv->dev, "Failed to export IMEM\n"); + else + dev_info(priv->dev, + "Exported %d bytes of encrypted IMEM\n", + ret); + + return ret; +} + +int se_restore_imem_state(struct se_if_priv *priv, struct se_imem_buf *ime= m) +{ + struct ele_dev_info s_info; + int ret; + + /* get info from ELE */ + ret =3D ele_get_info(priv, &s_info); + if (ret) { + dev_err(priv->dev, "Failed to get info from ELE.\n"); + return ret; + } + imem->state =3D s_info.d_addn_info.imem_state; + + /* Get IMEM state, if 0xFE then import IMEM */ + if (s_info.d_addn_info.imem_state =3D=3D ELE_IMEM_STATE_BAD) { + /* IMPORT command will restore IMEM from the given + * address, here size is the actual size returned by ELE + * during the export operation + */ + ret =3D ele_service_swap(priv, + imem->phyaddr, + imem->size, + ELE_IMEM_IMPORT); + if (ret) { + dev_err(priv->dev, "Failed to import IMEM\n"); + goto exit; + } + } else + goto exit; + + /* After importing IMEM, check if IMEM state is equal to 0xCA + * to ensure IMEM is fully loaded and + * ELE functionality can be used. + */ + ret =3D ele_get_info(priv, &s_info); + if (ret) { + dev_err(priv->dev, "Failed to get info from ELE.\n"); + goto exit; + } + imem->state =3D s_info.d_addn_info.imem_state; + + if (s_info.d_addn_info.imem_state =3D=3D ELE_IMEM_STATE_OK) + dev_info(priv->dev, "Successfully restored IMEM\n"); + else + dev_err(priv->dev, "Failed to restore IMEM\n"); + +exit: + return ret; +} diff --git a/drivers/firmware/imx/ele_common.h b/drivers/firmware/imx/ele_c= ommon.h new file mode 100644 index 000000000000..374f158a85de --- /dev/null +++ b/drivers/firmware/imx/ele_common.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2024 NXP + */ + + +#ifndef __ELE_COMMON_H__ +#define __ELE_COMMON_H__ + +#include "se_ctrl.h" + +#define ELE_SUCCESS_IND 0xD6 + +#define IMX_ELE_FW_DIR "imx/ele/" + +uint32_t se_add_msg_crc(uint32_t *msg, uint32_t msg_len); +int ele_msg_rcv(struct se_if_priv *priv, + struct se_clbk_handle *se_clbk_hdl); +int ele_msg_send(struct se_if_priv *priv, + void *tx_msg, + int tx_msg_sz); +int ele_msg_send_rcv(struct se_if_priv *priv, + void *tx_msg, + int tx_msg_sz, + void *rx_msg, + int exp_rx_msg_sz); +void se_if_rx_callback(struct mbox_client *mbox_cl, void *msg); +int se_val_rsp_hdr_n_status(struct se_if_priv *priv, + struct se_api_msg *msg, + uint8_t msg_id, + uint8_t sz, + bool is_base_api); + +/* Fill a command message header with a given command ID and length in byt= es. */ +static inline int se_fill_cmd_msg_hdr(struct se_if_priv *priv, + struct se_msg_hdr *hdr, + u8 cmd, u32 len, + bool is_base_api) +{ + hdr->tag =3D priv->if_defs.cmd_tag; + hdr->ver =3D (is_base_api) ? priv->if_defs.base_api_ver : priv->if_defs.f= w_api_ver; + hdr->command =3D cmd; + hdr->size =3D len >> 2; + + return 0; +} + +int se_save_imem_state(struct se_if_priv *priv, struct se_imem_buf *imem); +int se_restore_imem_state(struct se_if_priv *priv, struct se_imem_buf *ime= m); + +#endif /*__ELE_COMMON_H__ */ diff --git a/drivers/firmware/imx/se_ctrl.c b/drivers/firmware/imx/se_ctrl.c new file mode 100644 index 000000000000..37693c27042f --- /dev/null +++ b/drivers/firmware/imx/se_ctrl.c @@ -0,0 +1,555 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 NXP + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ele_base_msg.h" +#include "ele_common.h" +#include "se_ctrl.h" + +#define MBOX_TX_NAME "tx" +#define MBOX_RX_NAME "rx" +#define SE_TYPE_HSM "hsm" + +struct se_fw_load_info { + const u8 *prim_fw_nm_in_rfs; + const u8 *seco_fw_nm_in_rfs; + struct mutex se_fw_load; + bool is_fw_loaded; + bool handle_susp_resm; + struct se_imem_buf imem; +}; + +struct se_if_node_info { + u8 se_if_id; + u8 se_if_did; + u8 cmd_tag; + u8 rsp_tag; + u8 success_tag; + u8 base_api_ver; + u8 fw_api_ver; + u8 *se_name; + u8 *pool_name; + bool soc_register; + bool reserved_dma_ranges; + int (*se_fetch_soc_info)(struct se_if_priv *priv, u16 *soc_rev, u64 *seri= al_num); +}; + +struct se_if_node_info_list { + const u8 num_mu; + const u16 soc_id; + struct se_fw_load_info load_hsm_fw; + const struct se_if_node_info info[]; +}; + +static u16 se_soc_rev; +static struct se_if_node_info_list imx8ulp_info =3D { + .num_mu =3D 1, + .soc_id =3D SOC_ID_OF_IMX8ULP, + .load_hsm_fw =3D { + .prim_fw_nm_in_rfs =3D IMX_ELE_FW_DIR + "mx8ulpa2-ahab-container.img", + .seco_fw_nm_in_rfs =3D IMX_ELE_FW_DIR + "mx8ulpa2ext-ahab-container.img", + .is_fw_loaded =3D false, + .handle_susp_resm =3D true, + .imem =3D { + .state =3D ELE_IMEM_STATE_OK, + }, + }, + .info =3D { + { + .se_if_id =3D 0, + .se_if_did =3D 7, + .cmd_tag =3D 0x17, + .rsp_tag =3D 0xe1, + .success_tag =3D ELE_SUCCESS_IND, + .base_api_ver =3D MESSAGING_VERSION_6, + .fw_api_ver =3D MESSAGING_VERSION_7, + .se_name =3D SE_TYPE_HSM"1", + .pool_name =3D "sram", + .soc_register =3D true, + .reserved_dma_ranges =3D true, + .se_fetch_soc_info =3D ele_fetch_soc_info, + }, + }, +}; + +static struct se_if_node_info_list imx93_info =3D { + .num_mu =3D 1, + .soc_id =3D SOC_ID_OF_IMX93, + .load_hsm_fw =3D { + .prim_fw_nm_in_rfs =3D NULL, + .seco_fw_nm_in_rfs =3D NULL, + .is_fw_loaded =3D true, + .handle_susp_resm =3D false, + }, + .info =3D { + { + .se_if_id =3D 2, + .se_if_did =3D 3, + .cmd_tag =3D 0x17, + .rsp_tag =3D 0xe1, + .success_tag =3D ELE_SUCCESS_IND, + .base_api_ver =3D MESSAGING_VERSION_6, + .fw_api_ver =3D MESSAGING_VERSION_7, + .se_name =3D SE_TYPE_HSM"1", + .reserved_dma_ranges =3D true, + .soc_register =3D true, + }, + }, +}; + +static const struct of_device_id se_match[] =3D { + { .compatible =3D "fsl,imx8ulp-se", .data =3D (void *)&imx8ulp_info}, + { .compatible =3D "fsl,imx93-se", .data =3D (void *)&imx93_info}, + {}, +}; + +static const struct se_if_node_info + *get_se_if_node_info(const struct se_if_node_info_list *info_list, + const u32 idx) +{ + return &info_list->info[idx]; +} + +static int se_soc_info(struct se_if_priv *priv) +{ + const struct se_if_node_info *info; + struct se_if_node_info_list *info_list; + struct soc_device_attribute *attr; + struct soc_device *sdev; + u64 serial_num; + int err =3D 0; + + info =3D priv->if_defs.info; + info_list =3D container_of(info, + typeof(*info_list), + info[info->se_if_id]); + + /* This function should be called once. + * Check if the se_soc_rev is zero to continue. + */ + if (se_soc_rev) + return err; + + if (info->se_fetch_soc_info) { + err =3D info->se_fetch_soc_info(priv, &se_soc_rev, &serial_num); + if (err < 0) { + dev_err(priv->dev, "Failed to fetch SoC Info."); + return err; + } + } else { + dev_err(priv->dev, "Failed to fetch SoC revision."); + if (info->soc_register) + dev_err(priv->dev, "Failed to do SoC registration."); + err =3D -EINVAL; + return err; + } + + if (!info->soc_register) + return 0; + + attr =3D devm_kzalloc(priv->dev, sizeof(*attr), GFP_KERNEL); + if (!attr) + return -ENOMEM; + + if (FIELD_GET(DEV_GETINFO_MIN_VER_MASK, se_soc_rev)) + attr->revision =3D devm_kasprintf(priv->dev, GFP_KERNEL, "%x.%x", + FIELD_GET(DEV_GETINFO_MIN_VER_MASK, + se_soc_rev), + FIELD_GET(DEV_GETINFO_MAJ_VER_MASK, + se_soc_rev)); + else + attr->revision =3D devm_kasprintf(priv->dev, GFP_KERNEL, "%x", + FIELD_GET(DEV_GETINFO_MAJ_VER_MASK, + se_soc_rev)); + + switch (info_list->soc_id) { + case SOC_ID_OF_IMX8ULP: + attr->soc_id =3D devm_kasprintf(priv->dev, GFP_KERNEL, + "i.MX8ULP"); + break; + case SOC_ID_OF_IMX93: + attr->soc_id =3D devm_kasprintf(priv->dev, GFP_KERNEL, + "i.MX93"); + break; + } + + err =3D of_property_read_string(of_root, "model", + &attr->machine); + if (err) + return -EINVAL; + + attr->family =3D devm_kasprintf(priv->dev, GFP_KERNEL, "Freescale i.MX"); + + attr->serial_number + =3D devm_kasprintf(priv->dev, GFP_KERNEL, "%016llX", serial_num); + + sdev =3D soc_device_register(attr); + if (IS_ERR(sdev)) + return PTR_ERR(sdev); + + return 0; +} + +static struct se_fw_load_info *get_load_fw_instance(struct se_if_priv *pri= v) +{ + const struct se_if_node_info *info =3D priv->if_defs.info; + struct se_if_node_info_list *info_list; + struct se_fw_load_info *load_fw =3D NULL; + + info_list =3D container_of(info, + typeof(*info_list), + info[info->se_if_id]); + + if (!memcmp(SE_TYPE_HSM, info->se_name, strlen(SE_TYPE_HSM))) + load_fw =3D &info_list->load_hsm_fw; + else + dev_err(priv->dev, "Invalid load fw configuration."); + + return load_fw; +} + +static int se_load_firmware(struct se_if_priv *priv) +{ + struct se_fw_load_info *load_fw =3D get_load_fw_instance(priv); + const struct firmware *fw; + phys_addr_t se_fw_phyaddr; + const u8 *se_img_file_to_load; + u8 *se_fw_buf; + int ret; + + guard(mutex)(&load_fw->se_fw_load); + if (load_fw->is_fw_loaded) + return 0; + + se_img_file_to_load =3D load_fw->seco_fw_nm_in_rfs; + if (load_fw->prim_fw_nm_in_rfs) { + /* allocate buffer where SE store encrypted IMEM */ + load_fw->imem.buf =3D dmam_alloc_coherent(priv->dev, ELE_IMEM_SIZE, + &load_fw->imem.phyaddr, + GFP_KERNEL); + if (!load_fw->imem.buf) { + dev_err(priv->dev, + "dmam-alloc-failed: To store encr-IMEM.\n"); + ret =3D -ENOMEM; + goto exit; + } + if (load_fw->imem.state =3D=3D ELE_IMEM_STATE_BAD) + se_img_file_to_load + =3D load_fw->prim_fw_nm_in_rfs; + } + + do { + ret =3D request_firmware(&fw, se_img_file_to_load, priv->dev); + if (ret) + goto exit; + + dev_info(priv->dev, "loading firmware %s\n", se_img_file_to_load); + + /* allocate buffer to store the SE FW */ + se_fw_buf =3D dma_alloc_coherent(priv->dev, fw->size, + &se_fw_phyaddr, GFP_KERNEL); + if (!se_fw_buf) { + ret =3D -ENOMEM; + goto exit; + } + + memcpy(se_fw_buf, fw->data, fw->size); + ret =3D ele_fw_authenticate(priv, se_fw_phyaddr); + if (ret < 0) { + dev_err(priv->dev, + "Error %pe: Authenticate & load SE firmware %s.\n", + ERR_PTR(ret), + se_img_file_to_load); + ret =3D -EPERM; + } + + dma_free_coherent(priv->dev, + fw->size, + se_fw_buf, + se_fw_phyaddr); + + release_firmware(fw); + + if (!ret && load_fw->imem.state =3D=3D ELE_IMEM_STATE_BAD && + se_img_file_to_load =3D=3D load_fw->prim_fw_nm_in_rfs) + se_img_file_to_load =3D load_fw->seco_fw_nm_in_rfs; + else + se_img_file_to_load =3D NULL; + + } while (se_img_file_to_load); + + if (!ret) + load_fw->is_fw_loaded =3D true; + +exit: + return ret; +} + +/* interface for managed res to free a mailbox channel */ +static void if_mbox_free_channel(void *mbox_chan) +{ + mbox_free_channel(mbox_chan); +} + +static int se_if_request_channel(struct device *dev, + struct mbox_chan **chan, + struct mbox_client *cl, + const char *name) +{ + struct mbox_chan *t_chan; + int ret =3D 0; + + t_chan =3D mbox_request_channel_byname(cl, name); + if (IS_ERR(t_chan)) { + ret =3D PTR_ERR(t_chan); + return dev_err_probe(dev, ret, + "Failed to request %s channel.", name); + } + + ret =3D devm_add_action(dev, if_mbox_free_channel, t_chan); + if (ret) { + dev_err(dev, "failed to add devm removal of mbox %s\n", name); + goto exit; + } + + *chan =3D t_chan; + +exit: + return ret; +} + +static void se_if_probe_cleanup(void *plat_dev) +{ + struct platform_device *pdev =3D plat_dev; + struct device *dev =3D &pdev->dev; + struct se_fw_load_info *load_fw; + struct se_if_priv *priv; + + priv =3D dev_get_drvdata(dev); + load_fw =3D get_load_fw_instance(priv); + + /* In se_if_request_channel(), passed the clean-up functional + * pointer reference as action to devm_add_action(). + * No need to free the mbox channels here. + */ + + /* free the buffer in se remove, previously allocated + * in se probe to store encrypted IMEM + */ + if (!load_fw && load_fw->imem.buf) { + dmam_free_coherent(dev, + ELE_IMEM_SIZE, + load_fw->imem.buf, + load_fw->imem.phyaddr); + load_fw->imem.buf =3D NULL; + } + + /* No need to check, if reserved memory is allocated + * before calling for its release. Or clearing the + * un-set bit. + */ + of_reserved_mem_device_release(dev); +} + +static int se_if_probe(struct platform_device *pdev) +{ + const struct se_if_node_info_list *info_list; + const struct se_if_node_info *info; + struct device *dev =3D &pdev->dev; + struct se_fw_load_info *load_fw; + struct se_if_priv *priv; + u32 idx; + int ret; + + idx =3D GET_IDX_FROM_DEV_NODE_NAME(dev->of_node); + info_list =3D device_get_match_data(dev); + if (idx >=3D info_list->num_mu) { + dev_err(dev, + "Incorrect node name :%s\n", + dev->of_node->full_name); + dev_err(dev, + "%s-, acceptable index range is 0..%d\n", + dev->of_node->name, + info_list->num_mu - 1); + ret =3D -EINVAL; + return ret; + } + + info =3D get_se_if_node_info(info_list, idx); + if (!info) { + ret =3D -EINVAL; + goto exit; + } + + + priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) { + ret =3D -ENOMEM; + goto exit; + } + + priv->dev =3D dev; + priv->if_defs.info =3D info; + dev_set_drvdata(dev, priv); + + ret =3D devm_add_action(dev, se_if_probe_cleanup, pdev); + if (ret) + goto exit; + + + /* Mailbox client configuration */ + priv->se_mb_cl.dev =3D dev; + priv->se_mb_cl.tx_block =3D false; + priv->se_mb_cl.knows_txdone =3D true; + priv->se_mb_cl.rx_callback =3D se_if_rx_callback; + + ret =3D se_if_request_channel(dev, &priv->tx_chan, + &priv->se_mb_cl, MBOX_TX_NAME); + if (ret) + goto exit; + + ret =3D se_if_request_channel(dev, &priv->rx_chan, + &priv->se_mb_cl, MBOX_RX_NAME); + if (ret) + goto exit; + + mutex_init(&priv->se_if_cmd_lock); + + init_completion(&priv->waiting_rsp_clbk_hdl.done); + init_completion(&priv->cmd_receiver_clbk_hdl.done); + + priv->if_defs.cmd_tag =3D info->cmd_tag; + priv->if_defs.rsp_tag =3D info->rsp_tag; + if (info->pool_name) { + priv->if_defs.mem_pool =3D of_gen_pool_get(dev->of_node, + info->pool_name, 0); + if (!priv->if_defs.mem_pool) { + dev_err(dev, + "Unable to get sram pool =3D %s\n", + info->pool_name); + goto exit; + } + } + priv->if_defs.success_tag =3D info->success_tag; + priv->if_defs.base_api_ver =3D info->base_api_ver; + priv->if_defs.fw_api_ver =3D info->fw_api_ver; + + if (info->reserved_dma_ranges) { + ret =3D of_reserved_mem_device_init(dev); + if (ret) { + dev_err(dev, + "failed to init reserved memory region %d\n", + ret); + goto exit; + } + } + + ret =3D se_soc_info(priv); + if (ret) { + dev_err(dev, + "failed[%pe] to fetch SoC Info\n", ERR_PTR(ret)); + goto exit; + } + + load_fw =3D get_load_fw_instance(priv); + /* By default, there is no pending FW to be loaded.*/ + if (load_fw->is_fw_loaded) { + mutex_init(&load_fw->se_fw_load); + ret =3D se_load_firmware(priv); + if (ret) + dev_warn(dev, "Failed to load firmware."); + ret =3D 0; + } + dev_info(dev, "i.MX secure-enclave: %s interface to firmware, configured.= \n", + info->se_name); + return ret; + +exit: + /* if execution control reaches here, if probe fails. + */ + return dev_err_probe(dev, ret, "%s: Probe failed.", __func__); + + return ret; +} + +static int se_if_remove(struct platform_device *pdev) +{ + se_if_probe_cleanup(pdev); + + return 0; +} + +static int se_suspend(struct device *dev) +{ + struct se_if_priv *priv =3D dev_get_drvdata(dev); + struct se_fw_load_info *load_fw; + int ret =3D 0; + + load_fw =3D get_load_fw_instance(priv); + + if (load_fw->handle_susp_resm) { + ret =3D se_save_imem_state(priv, &load_fw->imem); + if (ret < 0) + goto exit; + load_fw->imem.size =3D ret; + } +exit: + return ret; +} + +static int se_resume(struct device *dev) +{ + struct se_if_priv *priv =3D dev_get_drvdata(dev); + struct se_fw_load_info *load_fw; + + load_fw =3D get_load_fw_instance(priv); + + if (load_fw->handle_susp_resm) + se_restore_imem_state(priv, &load_fw->imem); + + return 0; +} + +static const struct dev_pm_ops se_pm =3D { + RUNTIME_PM_OPS(se_suspend, se_resume, NULL) +}; + +static struct platform_driver se_driver =3D { + .driver =3D { + .name =3D "fsl-se-fw", + .of_match_table =3D se_match, + .pm =3D &se_pm, + }, + .probe =3D se_if_probe, + .remove =3D se_if_remove, +}; +MODULE_DEVICE_TABLE(of, se_match); + +module_platform_driver(se_driver); +MODULE_AUTHOR("Pankaj Gupta "); +MODULE_DESCRIPTION("iMX Secure Enclave Driver."); +MODULE_LICENSE("GPL"); diff --git a/drivers/firmware/imx/se_ctrl.h b/drivers/firmware/imx/se_ctrl.h new file mode 100644 index 000000000000..fa2804c5f7e3 --- /dev/null +++ b/drivers/firmware/imx/se_ctrl.h @@ -0,0 +1,94 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2024 NXP + */ + +#ifndef SE_MU_H +#define SE_MU_H + +#include +#include +#include + +#define MAX_FW_LOAD_RETRIES 50 + +#define RES_STATUS(x) FIELD_GET(0x000000ff, x) +#define MAX_NVM_MSG_LEN (256) +#define MESSAGING_VERSION_6 0x6 +#define MESSAGING_VERSION_7 0x7 +#define NODE_NAME "secure-enclave" + +#define GET_ASCII_TO_U8(diff, tens_chr, ones_chr) \ + ((diff > 2) ? (((tens_chr - '0') * 10) + (ones_chr - '0')) :\ + (tens_chr - '0')) + +#define GET_IDX_FROM_DEV_NODE_NAME(dev_of_node) \ + ((strlen(dev_of_node->full_name) > strlen(NODE_NAME)) ?\ + GET_ASCII_TO_U8((strlen(dev_of_node->full_name) - strlen(NODE_NAME)),\ + dev_of_node->full_name[strlen(NODE_NAME) + 1], \ + dev_of_node->full_name[strlen(NODE_NAME) + 2]) : 0) + +struct se_clbk_handle { + struct completion done; + bool signal_rcvd; + atomic_t pending_hdr; + u32 rx_msg_sz; + /* Assignment of the rx_msg buffer to held till the + * received content as part callback function, is copied. + */ + struct se_api_msg *rx_msg; +}; + +struct se_imem_buf { + u8 *buf; + phys_addr_t phyaddr; + u32 size; + u32 state; +}; + +/* Header of the messages exchange with the EdgeLock Enclave */ +struct se_msg_hdr { + u8 ver; + u8 size; + u8 command; + u8 tag; +} __packed; + +#define SE_MU_HDR_SZ 4 + +struct se_api_msg { + struct se_msg_hdr header; + u32 data[]; +}; + +struct se_if_defines { + struct gen_pool *mem_pool; + const void *info; + u8 cmd_tag; + u8 rsp_tag; + u8 success_tag; + u8 base_api_ver; + u8 fw_api_ver; +}; + +struct se_if_priv { + struct device *dev; + + struct se_clbk_handle cmd_receiver_clbk_hdl; + /* Update to the waiting_rsp_dev, to be protected + * under se_if_cmd_lock. + */ + struct se_clbk_handle waiting_rsp_clbk_hdl; + /* + * prevent new command to be sent on the se interface while previous + * command is still processing. (response is awaited) + */ + struct mutex se_if_cmd_lock; + + struct mbox_client se_mb_cl; + struct mbox_chan *tx_chan, *rx_chan; + + struct se_if_defines if_defs; +}; + +#endif diff --git a/include/linux/firmware/imx/se_api.h b/include/linux/firmware/i= mx/se_api.h new file mode 100644 index 000000000000..c47f84906837 --- /dev/null +++ b/include/linux/firmware/imx/se_api.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2024 NXP + */ + +#ifndef __SE_API_H__ +#define __SE_API_H__ + +#include + +#define SOC_ID_OF_IMX8ULP 0x084D +#define SOC_ID_OF_IMX93 0x9300 + +#endif /* __SE_API_H__ */ --=20 2.34.1 From nobody Wed Nov 27 00:38:34 2024 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2042.outbound.protection.outlook.com [40.107.21.42]) (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 096ED1D9A4E; Tue, 15 Oct 2024 09:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983164; cv=fail; b=VEYFi5g65/YG2v27YtWqxPs/3tMcZxzbDxpQuxeJx6y+J8Nrce7LVSYEWzSZQqFqNS8sumhP1LJeseZatYjuXcYCEPQEe+Ru0zgtQA9YO/JsUK+SFE4Uis98dk70Cd5EO2NXp8wpNCKi+PcPcqjmwlKmT4Rh/u9kewepYlK+bbs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983164; c=relaxed/simple; bh=ax172y29fbwMFJtJnw1/wnSI3JvsRz4Spt+X5leqanc=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=ZTc+ZdQS2Wtd2mpfkkxyljVziZn9LZiEyHD2irA4N5m6StyW3Uors1Ft8hWd+TM6RPSG0DoRneygxLiGtmctaAvvcqlbfKbjhxec/LEq8BhjvjjwQIfJH43Vbg2Q7EGBPyoXyJmC5A9ZEXZ7AO54FgsDucMDhQCQnbmYhCuEGkw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=oKvkEyq8; arc=fail smtp.client-ip=40.107.21.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="oKvkEyq8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=v9GP1Gf82tZ0aIFmI/8nwSgjnuxh+awdfET8wGMmVGGbGaViJQe+oIpvpjIFS2HgdIxRCy28UfU/JSSnkrGxGO9HBg7p7+mOM6kt53TgwOB98DmHXCHg9Mt3lfKAVvLS7fQcgZBtdVkifXymCC11khaFd3wCrr6uO9Ow+BCgTmgwczyvUS+KAW1CwUayWwuuY1DfElJaiHBSmWLdZCvBbJLnuhuPG+cHMqkXNiilLGMwnqPOCCn8EUTHAhfZ3BCZxLoRtgFGCkihTX04ixSAQJfO3eUj1vOwdnTiEwPSORyCuESZdprcrkSBKtAaleeUjTXseIxivRsjY/joJMHd3Q== 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=uk92+3FZgT2pxRCdpUZQfLho0vhwZQf8eAn9G9kYcs0=; b=gyZfuzPE53nlS1fjMWq9gGBBAqvDTbXCPts1X29aF1ZHYCIaY+rb5a1Kdc70E38SsJhsFIQQHZX85Ma/qKdyxJo7JdnnN7jDFvWBf6w0/sHx7s8jX1HtAOrHVZL3fBEPs/1oj3xgv/kVvEAhoX8USyJeOL1CGcbQOhby6gFribkIvSp4RDngoI0VIH8woaEckX1OIbqpZalDt4NTiC7vR9EYSntfpdW5t+e8tWCFM8t93wTMWaZSfEL0NnF3PhOZFetXE+CfflgMikfRwZFmw+vEw8CVSgR6CXoB8acWIxlqPJ/4e2h4cP3iAcCCa2cdYPNC7Cqx7NUZjsd2ZKNCxA== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uk92+3FZgT2pxRCdpUZQfLho0vhwZQf8eAn9G9kYcs0=; b=oKvkEyq8Vo8cch4sEnPKjL/JVg9QzxC41CMa3xPzikAvv2XbwUAEv75niErMlN7CdmR2N87lRSkSats7iC8I3pvJYqDV/uzfbz7GBlmqktylLq0oL0vA8XQp622RQcQIqlWO5vMM/NE3FCEnXVIssCjzucm6vdO2rcOmMqjVAUGgLoDYC6wvm9PcW5K6FFdU0t8rNBQp2+drBc3pqTbaOSa2uYxNELSjeQ/ZN8la2wW3kFVAu5RXR4SdwOOrjQxHCJtYgE0TsbydYVBHTrNkVmhsIGvvb5V1+73Ex1FndCcK0v+BLgZSOg9V2hcr36VbWP5vIjnVB0tss+WaKZY7TA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) by PAXPR04MB8223.eurprd04.prod.outlook.com (2603:10a6:102:1c9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 09:05:52 +0000 Received: from AM9PR04MB8604.eurprd04.prod.outlook.com ([fe80::e751:223e:aa3d:5827]) by AM9PR04MB8604.eurprd04.prod.outlook.com ([fe80::e751:223e:aa3d:5827%5]) with mapi id 15.20.8048.020; Tue, 15 Oct 2024 09:05:52 +0000 From: Pankaj Gupta Date: Tue, 15 Oct 2024 14:31:03 +0530 Subject: [PATCH v8 5/5] firmware: imx: adds miscdev Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241015-imx-se-if-v8-5-915438e267d3@nxp.com> References: <20241015-imx-se-if-v8-0-915438e267d3@nxp.com> In-Reply-To: <20241015-imx-se-if-v8-0-915438e267d3@nxp.com> To: Jonathan Corbet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Pankaj Gupta , Rob Herring Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728982877; l=36622; i=pankaj.gupta@nxp.com; s=20240523; h=from:subject:message-id; bh=ax172y29fbwMFJtJnw1/wnSI3JvsRz4Spt+X5leqanc=; b=1f74ZGswKCqxNmyZVPWy9VrOscQ7xMQs4vKsl74xOVKhDBi6dA6dZZbHwwFs3aYg56CVXo+8l M7iL8eiyeaECFOr4VS84xBCA7b2ZwUvn+2tF2j8sGJlljNkiuq/5Rqq X-Developer-Key: i=pankaj.gupta@nxp.com; a=ed25519; pk=OA0pBQoupy5lV0XfKzD8B0OOBVB6tpAoIf+0x1bYGRg= X-ClientProxiedBy: SG2P153CA0019.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::6) To AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8604:EE_|PAXPR04MB8223:EE_ X-MS-Office365-Filtering-Correlation-Id: 80b11af5-6a6a-4ed2-df7a-08dcecf891d4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|52116014|376014|366016|1800799024|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?NVVYZm16YmFtYTZTejBBSTdGRkJJbFdGamoySTQydFZPL2FkTFR1S1IydnZi?= =?utf-8?B?Y1crL0xoMndSaHBzVnl4YnVyTDI3TFpNTjFxTktBaFFqV1p5a2hHNXJMdEg4?= =?utf-8?B?ZEhtWlBCaWJzdm1JaXFoUzBVUHZXVHhLTVVRMm9BdGYxZWZMYkFvVE5ZMWpo?= =?utf-8?B?UkVxQ2ZrRGNSRGdMMUJwMmpSTW96eWw1ZDY0ZTFaNVByNzFYQ3lBQUJCWGMy?= =?utf-8?B?cHNlL0pBMGJBWWIwUjNMaXVta0tOQjNabFZuY2FtUk1tdHJFRHlNbW42QjNG?= =?utf-8?B?bEx0VzRleGlOdHBrQTY1MGhkZkFpc1NYSW5ONnNlaEFIUHIvaDFrVTdnTGJF?= =?utf-8?B?UnFtTGE3a2RybTlXc3Y5OEFCemlSd1NQYVdidWVvaXlrNDR6WkNmRHgrRWZk?= =?utf-8?B?WDYybjk3THpIRktmbmx4a2lMUlV0TjYxYTVhWm1hZnhZWVNWcEF4cGd5N1Ji?= =?utf-8?B?TGRWZ1VjZUF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S?= =?utf-8?B?SzJ3OGpmTnR2WDljSkRORzVsNC9pMnRaeFBFZEVRRk9UMFFaQldsK1lHMTZy?= =?utf-8?B?TG1MUE0zTzRwTnlodHFmNnd6bEdrWkcwWmFHL214NHFPbk9IaHJFam1QSVdF?= =?utf-8?B?anN0ZXZVT0hyckZZalBrZU1jN2h5SDBSZHBmRUQwSVRtOW0xbVJnNVE0K2JS?= =?utf-8?B?SWVHRjdUWDBUSUhVK0tzSmNwNHYxVmRXcC80V0JvSTY5NDdwSXFhc0FJVzdh?= =?utf-8?B?bFJLLzdoT0t4N0tyTGsydm15SWlpdGdPUENtNGh0S0xjd2t1YXNBbDJKTEt5?= =?utf-8?B?VjdFWlQ0Y2NBOHJ1RGpwNUtwckFCRmhWTmlxU3Boc2NzdThLdmo2VWRVbzJu?= =?utf-8?B?eUIwQUZjSldMUnY5R1Via3Q5SzBVajVjUGYvanRUN0RLWW0zdFMxSWFxUlFW?= =?utf-8?Q?Sb/Ea0uJtNhRVrqNykFcBn1G0CFaWrrmS4xqY=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8604.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(52116014)(376014)(366016)(1800799024)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?K0E0QXZPTzdqR1VXU2FFcGV5M1BHQWFvcEhRS2NoTVRlRE1rZE1sVjZMeUt1?= =?utf-8?B?eDdPQmY2Q1RiWnk4UDJiMHNoQnVNMGZ3cUZCRFFKdDFrN2hJZjFPWStyOWpv?= =?utf-8?B?VFRvVnZZZ0JkK1JxWU9lQVhTeDBuU2hCZ1gya3FGTzNWRVgwajZsVVNSM3ZC?= =?utf-8?B?b29xTFRFcGtlcTlMVGdHTFFxcGhkcy90RURHL1lRcX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?B?ak13R2tCNU42TXdPMDFZKzAyQk1pUWpJSUxXV0hHRzJqT3p6NUpPazNYZXds?= =?utf-8?B?c1pPT0RWeUxvWXVneVo4RlRncFFDZHVoRmwxRU05Vk9WR1Q1ZlR5UXJLdTBZ?= =?utf-8?Q?LWeZC84ubdzyX7mAz/nCnsIe/?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 80b11af5-6a6a-4ed2-df7a-08dcecf891d4 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8604.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 09:05:52.4393 (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: 5vJxOC55X4YGqefWVdL6AQSsgjFzeODbq2Q4dg4vC+yvFvpA0eoth8iFKtqNDN70ZKuLBlxe7rB1rkDB3N6FNA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8223 Adds the driver for communication interface to secure-enclave, for exchanging messages with NXP secure enclave HW IP(s) like EdgeLock Enclave from: - User-Space Applications via character driver. ABI documentation for the NXP secure-enclave driver. User-space library using this driver: - i.MX Secure Enclave library: -- URL: https://github.com/nxp-imx/imx-secure-enclave.git, - i.MX Secure Middle-Ware: -- URL: https://github.com/nxp-imx/imx-smw.git Signed-off-by: Pankaj Gupta --- Documentation/ABI/testing/se-cdev | 43 ++ drivers/firmware/imx/ele_base_msg.c | 8 +- drivers/firmware/imx/ele_common.c | 39 +- drivers/firmware/imx/ele_common.h | 6 +- drivers/firmware/imx/se_ctrl.c | 774 ++++++++++++++++++++++++++++++++= ++++ drivers/firmware/imx/se_ctrl.h | 42 +- include/uapi/linux/se_ioctl.h | 94 +++++ 7 files changed, 985 insertions(+), 21 deletions(-) diff --git a/Documentation/ABI/testing/se-cdev b/Documentation/ABI/testing/= se-cdev new file mode 100644 index 000000000000..3451c909ccc4 --- /dev/null +++ b/Documentation/ABI/testing/se-cdev @@ -0,0 +1,43 @@ +What: /dev/_mu[0-9]+_ch[0-9]+ +Date: May 2024 +KernelVersion: 6.8 +Contact: linux-imx@nxp.com, pankaj.gupta@nxp.com +Description: + NXP offers multiple hardware IP(s) for secure enclaves like EdgeLock- + Enclave(ELE), SECO. The character device file descriptors + /dev/_mu*_ch* are the interface between userspace NXP's secure- + enclave shared library and the kernel driver. + + The ioctl(2)-based ABI is defined and documented in + [include]. + ioctl(s) are used primarily for: + - shared memory management + - allocation of I/O buffers + - getting mu info + - setting a dev-ctx as receiver to receive all the commands from FW + - getting SoC info + - send command and receive command response + + The following file operations are supported: + + open(2) + Currently the only useful flags are O_RDWR. + + read(2) + Every read() from the opened character device context is waiting on + wait_event_interruptible, that gets set by the registered mailbox call= back + function, indicating a message received from the firmware on message- + unit. + + write(2) + Every write() to the opened character device context needs to acquire + mailbox_lock before sending message on to the message unit. + + close(2) + Stops and frees up the I/O contexts that were associated + with the file descriptor. + +Users: https://github.com/nxp-imx/imx-secure-enclave.git, + https://github.com/nxp-imx/imx-smw.git + crypto/skcipher, + drivers/nvmem/imx-ocotp-ele.c diff --git a/drivers/firmware/imx/ele_base_msg.c b/drivers/firmware/imx/ele= _base_msg.c index fb89340c224e..346c948e8df0 100644 --- a/drivers/firmware/imx/ele_base_msg.c +++ b/drivers/firmware/imx/ele_base_msg.c @@ -67,7 +67,7 @@ int ele_get_info(struct se_if_priv *priv, struct ele_dev_= info *s_info) tx_msg->data[0] =3D upper_32_bits(get_info_addr); tx_msg->data[1] =3D lower_32_bits(get_info_addr); tx_msg->data[2] =3D sizeof(*s_info); - ret =3D ele_msg_send_rcv(priv, + ret =3D ele_msg_send_rcv(priv->priv_dev_ctx, tx_msg, ELE_GET_INFO_REQ_MSG_SZ, rx_msg, @@ -145,7 +145,7 @@ int ele_ping(struct se_if_priv *priv) goto exit; } =20 - ret =3D ele_msg_send_rcv(priv, + ret =3D ele_msg_send_rcv(priv->priv_dev_ctx, tx_msg, ELE_PING_REQ_SZ, rx_msg, @@ -200,7 +200,7 @@ int ele_service_swap(struct se_if_priv *priv, tx_msg->data[3] =3D lower_32_bits(addr); tx_msg->data[4] =3D se_add_msg_crc((uint32_t *)&tx_msg[0], ELE_SERVICE_SWAP_REQ_MSG_SZ); - ret =3D ele_msg_send_rcv(priv, + ret =3D ele_msg_send_rcv(priv->priv_dev_ctx, tx_msg, ELE_SERVICE_SWAP_REQ_MSG_SZ, rx_msg, @@ -261,7 +261,7 @@ int ele_fw_authenticate(struct se_if_priv *priv, phys_a= ddr_t addr) tx_msg->data[0] =3D lower_32_bits(addr); tx_msg->data[2] =3D addr; =20 - ret =3D ele_msg_send_rcv(priv, + ret =3D ele_msg_send_rcv(priv->priv_dev_ctx, tx_msg, ELE_FW_AUTH_REQ_SZ, rx_msg, diff --git a/drivers/firmware/imx/ele_common.c b/drivers/firmware/imx/ele_c= ommon.c index 1cd76c630bdf..30ebfcc0600c 100644 --- a/drivers/firmware/imx/ele_common.c +++ b/drivers/firmware/imx/ele_common.c @@ -18,9 +18,10 @@ u32 se_add_msg_crc(u32 *msg, u32 msg_len) return crc; } =20 -int ele_msg_rcv(struct se_if_priv *priv, +int ele_msg_rcv(struct se_if_device_ctx *dev_ctx, struct se_clbk_handle *se_clbk_hdl) { + struct se_if_priv *priv =3D dev_ctx->priv; int err =3D 0; =20 do { @@ -31,12 +32,13 @@ int ele_msg_rcv(struct se_if_priv *priv, */ err =3D wait_for_completion_interruptible(&se_clbk_hdl->done); if (err =3D=3D -ERESTARTSYS) { - if (priv->waiting_rsp_clbk_hdl.rx_msg) { + if (priv->waiting_rsp_clbk_hdl.dev_ctx) { priv->waiting_rsp_clbk_hdl.signal_rcvd =3D true; continue; } dev_err(priv->dev, - "Err[0x%x]:Interrupted by signal.\n", + "%s: Err[0x%x]:Interrupted by signal.\n", + se_clbk_hdl->dev_ctx->devname, err); err =3D -EINTR; break; @@ -46,10 +48,11 @@ int ele_msg_rcv(struct se_if_priv *priv, return err ? err : se_clbk_hdl->rx_msg_sz; } =20 -int ele_msg_send(struct se_if_priv *priv, +int ele_msg_send(struct se_if_device_ctx *dev_ctx, void *tx_msg, int tx_msg_sz) { + struct se_if_priv *priv =3D dev_ctx->priv; struct se_msg_hdr *header; int err; =20 @@ -62,7 +65,8 @@ int ele_msg_send(struct se_if_priv *priv, if (header->size << 2 !=3D tx_msg_sz) { err =3D -EINVAL; dev_err(priv->dev, - "User buf hdr: 0x%x, sz mismatced with input-sz (%d !=3D %d).", + "%s: User buf hdr: 0x%x, sz mismatced with input-sz (%d !=3D %d).", + dev_ctx->devname, *(u32 *)header, header->size << 2, tx_msg_sz); goto exit; @@ -70,7 +74,9 @@ int ele_msg_send(struct se_if_priv *priv, =20 err =3D mbox_send_message(priv->tx_chan, tx_msg); if (err < 0) { - dev_err(priv->dev, "Error: mbox_send_message failure.\n"); + dev_err(priv->dev, + "%s: Error: mbox_send_message failure.", + dev_ctx->devname); return err; } err =3D tx_msg_sz; @@ -80,29 +86,32 @@ int ele_msg_send(struct se_if_priv *priv, } =20 /* API used for send/receive blocking call. */ -int ele_msg_send_rcv(struct se_if_priv *priv, +int ele_msg_send_rcv(struct se_if_device_ctx *dev_ctx, void *tx_msg, int tx_msg_sz, void *rx_msg, int exp_rx_msg_sz) { int err; + struct se_if_priv *priv =3D dev_ctx->priv; =20 guard(mutex)(&priv->se_if_cmd_lock); =20 + priv->waiting_rsp_clbk_hdl.dev_ctx =3D dev_ctx; priv->waiting_rsp_clbk_hdl.rx_msg_sz =3D exp_rx_msg_sz; priv->waiting_rsp_clbk_hdl.rx_msg =3D rx_msg; =20 - err =3D ele_msg_send(priv, tx_msg, tx_msg_sz); + err =3D ele_msg_send(dev_ctx, tx_msg, tx_msg_sz); if (err < 0) goto exit; =20 - err =3D ele_msg_rcv(priv, &priv->waiting_rsp_clbk_hdl); + err =3D ele_msg_rcv(dev_ctx, &priv->waiting_rsp_clbk_hdl); =20 if (priv->waiting_rsp_clbk_hdl.signal_rcvd) { err =3D -EINTR; priv->waiting_rsp_clbk_hdl.signal_rcvd =3D false; } + priv->waiting_rsp_clbk_hdl.dev_ctx =3D NULL; =20 exit: return err; @@ -149,7 +158,8 @@ void se_if_rx_callback(struct mbox_client *mbox_cl, voi= d *msg) if (header->tag =3D=3D priv->if_defs.cmd_tag) { se_clbk_hdl =3D &priv->cmd_receiver_clbk_hdl; dev_dbg(dev, - "Selecting cmd receiver for mesg header:0x%x.", + "Selecting cmd receiver:%s for mesg header:0x%x.", + se_clbk_hdl->dev_ctx->devname, *(u32 *) header); =20 /* Pre-allocated buffer of MAX_NVM_MSG_LEN @@ -158,7 +168,8 @@ void se_if_rx_callback(struct mbox_client *mbox_cl, voi= d *msg) */ if (rx_msg_sz > MAX_NVM_MSG_LEN) { dev_err(dev, - "CMD-RCVER NVM: hdr(0x%x) with different sz(%d !=3D %d).\n", + "%s: CMD-RCVER NVM: hdr(0x%x) with different sz(%d !=3D %d).\n", + se_clbk_hdl->dev_ctx->devname, *(u32 *) header, rx_msg_sz, se_clbk_hdl->rx_msg_sz); =20 @@ -169,13 +180,15 @@ void se_if_rx_callback(struct mbox_client *mbox_cl, v= oid *msg) } else if (header->tag =3D=3D priv->if_defs.rsp_tag) { se_clbk_hdl =3D &priv->waiting_rsp_clbk_hdl; dev_dbg(dev, - "Selecting resp waiter for mesg header:0x%x.", + "Selecting resp waiter:%s for mesg header:0x%x.", + se_clbk_hdl->dev_ctx->devname, *(u32 *) header); =20 if (rx_msg_sz !=3D se_clbk_hdl->rx_msg_sz && !exception_for_size(priv, header)) { dev_err(dev, - "Rsp to CMD: hdr(0x%x) with different sz(%d !=3D %d).\n", + "%s: Rsp to CMD: hdr(0x%x) with different sz(%d !=3D %d).\n", + se_clbk_hdl->dev_ctx->devname, *(u32 *) header, rx_msg_sz, se_clbk_hdl->rx_msg_sz); =20 diff --git a/drivers/firmware/imx/ele_common.h b/drivers/firmware/imx/ele_c= ommon.h index 374f158a85de..314b782c413c 100644 --- a/drivers/firmware/imx/ele_common.h +++ b/drivers/firmware/imx/ele_common.h @@ -14,12 +14,12 @@ #define IMX_ELE_FW_DIR "imx/ele/" =20 uint32_t se_add_msg_crc(uint32_t *msg, uint32_t msg_len); -int ele_msg_rcv(struct se_if_priv *priv, +int ele_msg_rcv(struct se_if_device_ctx *dev_ctx, struct se_clbk_handle *se_clbk_hdl); -int ele_msg_send(struct se_if_priv *priv, +int ele_msg_send(struct se_if_device_ctx *dev_ctx, void *tx_msg, int tx_msg_sz); -int ele_msg_send_rcv(struct se_if_priv *priv, +int ele_msg_send_rcv(struct se_if_device_ctx *dev_ctx, void *tx_msg, int tx_msg_sz, void *rx_msg, diff --git a/drivers/firmware/imx/se_ctrl.c b/drivers/firmware/imx/se_ctrl.c index 37693c27042f..b89f195e0d40 100644 --- a/drivers/firmware/imx/se_ctrl.c +++ b/drivers/firmware/imx/se_ctrl.c @@ -23,6 +23,7 @@ #include #include #include +#include =20 #include "ele_base_msg.h" #include "ele_common.h" @@ -309,6 +310,757 @@ static int se_load_firmware(struct se_if_priv *priv) return ret; } =20 +static int init_se_shared_mem(struct se_if_device_ctx *dev_ctx) +{ + struct se_shared_mem_mgmt_info *se_shared_mem_mgmt =3D &dev_ctx->se_share= d_mem_mgmt; + struct se_if_priv *priv =3D dev_ctx->priv; + + INIT_LIST_HEAD(&se_shared_mem_mgmt->pending_out); + INIT_LIST_HEAD(&se_shared_mem_mgmt->pending_in); + + /* + * Allocate some memory for data exchanges with S40x. + * This will be used for data not requiring secure memory. + */ + se_shared_mem_mgmt->non_secure_mem.ptr + =3D dma_alloc_coherent(priv->dev, + MAX_DATA_SIZE_PER_USER, + &se_shared_mem_mgmt->non_secure_mem.dma_addr, + GFP_KERNEL); + if (!se_shared_mem_mgmt->non_secure_mem.ptr) + return -ENOMEM; + + se_shared_mem_mgmt->non_secure_mem.size =3D MAX_DATA_SIZE_PER_USER; + se_shared_mem_mgmt->non_secure_mem.pos =3D 0; + + return 0; +} + +static void cleanup_se_shared_mem(struct se_if_device_ctx *dev_ctx) +{ + struct se_shared_mem_mgmt_info *se_shared_mem_mgmt =3D &dev_ctx->se_share= d_mem_mgmt; + struct se_if_priv *priv =3D dev_ctx->priv; + + /* Unmap secure memory shared buffer. */ + if (se_shared_mem_mgmt->secure_mem.ptr) + devm_iounmap(priv->dev, + se_shared_mem_mgmt->secure_mem.ptr); + + se_shared_mem_mgmt->secure_mem.ptr =3D NULL; + se_shared_mem_mgmt->secure_mem.dma_addr =3D 0; + se_shared_mem_mgmt->secure_mem.size =3D 0; + se_shared_mem_mgmt->secure_mem.pos =3D 0; + + /* Free non-secure shared buffer. */ + dma_free_coherent(priv->dev, MAX_DATA_SIZE_PER_USER, + se_shared_mem_mgmt->non_secure_mem.ptr, + se_shared_mem_mgmt->non_secure_mem.dma_addr); + + se_shared_mem_mgmt->non_secure_mem.ptr =3D NULL; + se_shared_mem_mgmt->non_secure_mem.dma_addr =3D 0; + se_shared_mem_mgmt->non_secure_mem.size =3D 0; + se_shared_mem_mgmt->non_secure_mem.pos =3D 0; +} + +/* Need to copy the output data to user-device context. + */ +static int se_dev_ctx_cpy_out_data(struct se_if_device_ctx *dev_ctx) +{ + struct se_shared_mem_mgmt_info *se_shared_mem_mgmt =3D &dev_ctx->se_share= d_mem_mgmt; + struct se_if_priv *priv =3D dev_ctx->priv; + struct se_buf_desc *b_desc, *temp; + bool do_cpy =3D true; + + list_for_each_entry_safe(b_desc, temp, &se_shared_mem_mgmt->pending_out, = link) { + if (b_desc->usr_buf_ptr && b_desc->shared_buf_ptr && do_cpy) { + + dev_dbg(priv->dev, + "Copying output data to user."); + if (do_cpy && copy_to_user(b_desc->usr_buf_ptr, + b_desc->shared_buf_ptr, + b_desc->size)) { + dev_err(priv->dev, + "Failure copying output data to user."); + do_cpy =3D false; + } + } + + if (b_desc->shared_buf_ptr) + memset(b_desc->shared_buf_ptr, 0, b_desc->size); + + list_del(&b_desc->link); + kfree(b_desc); + } + + return do_cpy ? 0 : -EFAULT; +} + +/* + * Clean the used Shared Memory space, + * whether its Input Data copied from user buffers, or + * Data received from FW. + */ +static void se_dev_ctx_shared_mem_cleanup(struct se_if_device_ctx *dev_ctx) +{ + struct se_shared_mem_mgmt_info *se_shared_mem_mgmt =3D &dev_ctx->se_share= d_mem_mgmt; + struct list_head *pending_lists[] =3D {&se_shared_mem_mgmt->pending_in, + &se_shared_mem_mgmt->pending_out}; + struct se_buf_desc *b_desc, *temp; + int i; + + for (i =3D 0; i < 2; i++) { + list_for_each_entry_safe(b_desc, temp, + pending_lists[i], link) { + + if (b_desc->shared_buf_ptr) + memset(b_desc->shared_buf_ptr, 0, b_desc->size); + + list_del(&b_desc->link); + kfree(b_desc); + } + } + se_shared_mem_mgmt->secure_mem.pos =3D 0; + se_shared_mem_mgmt->non_secure_mem.pos =3D 0; +} + +static int add_b_desc_to_pending_list(void *shared_ptr_with_pos, + struct se_ioctl_setup_iobuf *io, + struct se_if_device_ctx *dev_ctx) +{ + struct se_shared_mem_mgmt_info *se_shared_mem_mgmt =3D &dev_ctx->se_share= d_mem_mgmt; + struct se_buf_desc *b_desc =3D NULL; + + b_desc =3D kzalloc(sizeof(*b_desc), GFP_KERNEL); + if (!b_desc) + return -ENOMEM; + + b_desc->shared_buf_ptr =3D shared_ptr_with_pos; + b_desc->usr_buf_ptr =3D io->user_buf; + b_desc->size =3D io->length; + + if (io->flags & SE_IO_BUF_FLAGS_IS_INPUT) { + /* + * buffer is input: + * add an entry in the "pending input buffers" list so + * that copied data can be cleaned from shared memory + * later. + */ + list_add_tail(&b_desc->link, &se_shared_mem_mgmt->pending_in); + } else { + /* + * buffer is output: + * add an entry in the "pending out buffers" list so data + * can be copied to user space when receiving Secure-Enclave + * response. + */ + list_add_tail(&b_desc->link, &se_shared_mem_mgmt->pending_out); + } + + return 0; +} + +/* interface for managed res to unregister a character device */ +static void if_misc_deregister(void *miscdevice) +{ + misc_deregister(miscdevice); +} + +static int init_device_context(struct se_if_priv *priv, int ch_id, + struct se_if_device_ctx **new_dev_ctx, + const struct file_operations *se_if_fops) +{ + const struct se_if_node_info *info =3D priv->if_defs.info; + struct se_if_device_ctx *dev_ctx; + int ret =3D 0; + + if (ch_id) + dev_ctx =3D kzalloc(sizeof(*dev_ctx), GFP_KERNEL); + else + dev_ctx =3D devm_kzalloc(priv->dev, sizeof(*dev_ctx), GFP_KERNEL); + + if (!dev_ctx) { + ret =3D -ENOMEM; + return ret; + } + + dev_ctx->priv =3D priv; + + if (ch_id) + dev_ctx->devname =3D kasprintf(GFP_KERNEL, "%s_ch%d", + info->se_name, ch_id); + else + dev_ctx->devname =3D devm_kasprintf(priv->dev, + GFP_KERNEL, "%s_ch%d", + info->se_name, ch_id); + if (!dev_ctx->devname) { + ret =3D -ENOMEM; + if (ch_id) + kfree(dev_ctx); + + return ret; + } + + mutex_init(&dev_ctx->fops_lock); + + *new_dev_ctx =3D dev_ctx; + + if (ch_id) { + list_add_tail(&dev_ctx->link, &priv->dev_ctx_list); + priv->active_devctx_count++; + + ret =3D init_se_shared_mem(dev_ctx); + if (ret < 0) { + kfree(dev_ctx->devname); + kfree(dev_ctx); + *new_dev_ctx =3D NULL; + return ret; + } + + return ret; + } + + /* Only for ch_id =3D 0: + * - register the misc device. + * - add action + */ + dev_ctx->miscdev =3D devm_kzalloc(priv->dev, sizeof(*dev_ctx->miscdev), G= FP_KERNEL); + if (!dev_ctx->miscdev) { + ret =3D -ENOMEM; + *new_dev_ctx =3D NULL; + return ret; + } + + dev_ctx->miscdev->name =3D dev_ctx->devname; + dev_ctx->miscdev->minor =3D MISC_DYNAMIC_MINOR; + dev_ctx->miscdev->fops =3D se_if_fops; + dev_ctx->miscdev->parent =3D priv->dev; + ret =3D misc_register(dev_ctx->miscdev); + if (ret) { + dev_err(priv->dev, "failed to register misc device %d\n", + ret); + return ret; + } + + ret =3D devm_add_action(priv->dev, if_misc_deregister, + dev_ctx->miscdev); + if (ret) { + dev_err(priv->dev, + "failed[%d] to add action to the misc-dev\n", + ret); + misc_deregister(dev_ctx->miscdev); + } + + return ret; +} + +static int se_ioctl_cmd_snd_rcv_rsp_handler(struct se_if_device_ctx *dev_c= tx, + u64 arg) +{ + const struct se_if_node_info *info =3D dev_ctx->priv->if_defs.info; + struct se_ioctl_cmd_snd_rcv_rsp_info cmd_snd_rcv_rsp_info; + struct se_if_node_info_list *info_list + =3D container_of(info, + typeof(*info_list), + info[info->se_if_id]); + struct se_if_priv *priv =3D dev_ctx->priv; + struct se_api_msg *tx_msg __free(kfree) =3D NULL; + struct se_api_msg *rx_msg __free(kfree) =3D NULL; + int err =3D 0; + + if (copy_from_user(&cmd_snd_rcv_rsp_info, (u8 *)arg, + sizeof(cmd_snd_rcv_rsp_info))) { + dev_err(priv->dev, + "%s: Failed to copy cmd_snd_rcv_rsp_info from user\n", + dev_ctx->devname); + err =3D -EFAULT; + goto exit; + } + + if (cmd_snd_rcv_rsp_info.tx_buf_sz < SE_MU_HDR_SZ) { + dev_err(priv->dev, + "%s: User buffer too small(%d < %d)\n", + dev_ctx->devname, + cmd_snd_rcv_rsp_info.tx_buf_sz, + SE_MU_HDR_SZ); + err =3D -ENOSPC; + goto exit; + } + + rx_msg =3D kzalloc(cmd_snd_rcv_rsp_info.rx_buf_sz, GFP_KERNEL); + if (!rx_msg) { + err =3D -ENOMEM; + goto exit; + } + + tx_msg =3D memdup_user(cmd_snd_rcv_rsp_info.tx_buf, + cmd_snd_rcv_rsp_info.tx_buf_sz); + if (IS_ERR(tx_msg)) { + err =3D PTR_ERR(tx_msg); + goto exit; + } + + if (tx_msg->header.tag !=3D priv->if_defs.cmd_tag) { + err =3D -EINVAL; + goto exit; + } + + if (tx_msg->header.ver =3D=3D priv->if_defs.fw_api_ver && + !info_list->load_hsm_fw.is_fw_loaded) { + err =3D se_load_firmware(priv); + if (err) { + dev_err(priv->dev, "Could not send the message as FW is not loaded."); + err =3D -EPERM; + goto exit; + } + } + err =3D ele_msg_send_rcv(dev_ctx, + tx_msg, + cmd_snd_rcv_rsp_info.tx_buf_sz, + rx_msg, + cmd_snd_rcv_rsp_info.rx_buf_sz); + if (err < 0) + goto exit; + + dev_dbg(priv->dev, + "%s: %s %s\n", + dev_ctx->devname, + __func__, + "message received, start transmit to user"); + + /* We may need to copy the output data to user before + * delivering the completion message. + */ + err =3D se_dev_ctx_cpy_out_data(dev_ctx); + if (err < 0) + goto exit; + + /* Copy data from the buffer */ + print_hex_dump_debug("to user ", DUMP_PREFIX_OFFSET, 4, 4, + rx_msg, + cmd_snd_rcv_rsp_info.rx_buf_sz, false); + + if (copy_to_user(cmd_snd_rcv_rsp_info.rx_buf, rx_msg, + cmd_snd_rcv_rsp_info.rx_buf_sz)) { + dev_err(priv->dev, + "%s: Failed to copy to user\n", + dev_ctx->devname); + err =3D -EFAULT; + } + +exit: + se_dev_ctx_shared_mem_cleanup(dev_ctx); + + if (copy_to_user((void *)arg, &cmd_snd_rcv_rsp_info, + sizeof(cmd_snd_rcv_rsp_info))) { + dev_err(priv->dev, + "%s: Failed to copy cmd_snd_rcv_rsp_info from user\n", + dev_ctx->devname); + err =3D -EFAULT; + } + + return err; +} + +static int se_ioctl_get_mu_info(struct se_if_device_ctx *dev_ctx, + u64 arg) +{ + struct se_if_priv *priv =3D dev_ctx->priv; + struct se_if_node_info *if_node_info; + struct se_ioctl_get_if_info info; + int err =3D 0; + + if_node_info =3D (struct se_if_node_info *)priv->if_defs.info; + + info.se_if_id =3D if_node_info->se_if_id; + info.interrupt_idx =3D 0; + info.tz =3D 0; + info.did =3D if_node_info->se_if_did; + info.cmd_tag =3D if_node_info->cmd_tag; + info.rsp_tag =3D if_node_info->rsp_tag; + info.success_tag =3D if_node_info->success_tag; + info.base_api_ver =3D if_node_info->base_api_ver; + info.fw_api_ver =3D if_node_info->fw_api_ver; + + dev_dbg(priv->dev, + "%s: info [se_if_id: %d, irq_idx: %d, tz: 0x%x, did: 0x%x]\n", + dev_ctx->devname, + info.se_if_id, info.interrupt_idx, info.tz, info.did); + + if (copy_to_user((u8 *)arg, &info, sizeof(info))) { + dev_err(priv->dev, + "%s: Failed to copy mu info to user\n", + dev_ctx->devname); + err =3D -EFAULT; + goto exit; + } + +exit: + return err; +} + +/* + * Copy a buffer of data to/from the user and return the address to use in + * messages + */ +static int se_ioctl_setup_iobuf_handler(struct se_if_device_ctx *dev_ctx, + u64 arg) +{ + struct se_shared_mem *shared_mem =3D NULL; + struct se_ioctl_setup_iobuf io =3D {0}; + int err =3D 0; + u32 pos; + + if (copy_from_user(&io, (u8 *)arg, sizeof(io))) { + dev_err(dev_ctx->priv->dev, + "%s: Failed copy iobuf config from user\n", + dev_ctx->devname); + err =3D -EFAULT; + goto exit; + } + + dev_dbg(dev_ctx->priv->dev, + "%s: io [buf: %p(%d) flag: %x]\n", + dev_ctx->devname, + io.user_buf, io.length, io.flags); + + if (io.length =3D=3D 0 || !io.user_buf) { + /* + * Accept NULL pointers since some buffers are optional + * in FW commands. In this case we should return 0 as + * pointer to be embedded into the message. + * Skip all data copy part of code below. + */ + io.ele_addr =3D 0; + goto copy; + } + + /* No specific requirement for this buffer. */ + shared_mem =3D &dev_ctx->se_shared_mem_mgmt.non_secure_mem; + + /* Check there is enough space in the shared memory. */ + if (shared_mem->size < shared_mem->pos || + round_up(io.length, 8u) >=3D (shared_mem->size - shared_mem->pos)) { + dev_err(dev_ctx->priv->dev, + "%s: Not enough space in shared memory\n", + dev_ctx->devname); + err =3D -ENOMEM; + goto exit; + } + + /* Allocate space in shared memory. 8 bytes aligned. */ + pos =3D shared_mem->pos; + shared_mem->pos +=3D round_up(io.length, 8u); + io.ele_addr =3D (u64)shared_mem->dma_addr + pos; + + memset(shared_mem->ptr + pos, 0, io.length); + if ((io.flags & SE_IO_BUF_FLAGS_IS_INPUT) || + (io.flags & SE_IO_BUF_FLAGS_IS_IN_OUT)) { + /* + * buffer is input: + * copy data from user space to this allocated buffer. + */ + if (copy_from_user(shared_mem->ptr + pos, io.user_buf, + io.length)) { + dev_err(dev_ctx->priv->dev, + "%s: Failed copy data to shared memory\n", + dev_ctx->devname); + err =3D -EFAULT; + goto exit; + } + } + + err =3D add_b_desc_to_pending_list(shared_mem->ptr + pos, + &io, + dev_ctx); + if (err < 0) + dev_err(dev_ctx->priv->dev, + "%s: Failed to allocate/link b_desc.", + dev_ctx->devname); + +copy: + /* Provide the EdgeLock Enclave address to user space only if success.*/ + if (copy_to_user((u8 *)arg, &io, sizeof(io))) { + dev_err(dev_ctx->priv->dev, + "%s: Failed to copy iobuff setup to user.", + dev_ctx->devname); + err =3D -EFAULT; + goto exit; + } +exit: + return err; +} + +/* IOCTL to provide SoC information */ +static int se_ioctl_get_se_soc_info_handler(struct se_if_device_ctx *dev_c= tx, + u64 arg) +{ + const struct se_if_node_info_list *info_list; + struct se_ioctl_get_soc_info soc_info; + int err =3D -EINVAL; + + info_list =3D device_get_match_data(dev_ctx->priv->dev); + if (!info_list) + goto exit; + + soc_info.soc_id =3D info_list->soc_id; + soc_info.soc_rev =3D se_soc_rev; + + err =3D (int)copy_to_user((u8 *)arg, (u8 *)(&soc_info), sizeof(soc_info)); + if (err) { + dev_err(dev_ctx->priv->dev, + "%s: Failed to copy soc info to user\n", + dev_ctx->devname); + err =3D -EFAULT; + goto exit; + } + +exit: + return err; +} + +/* + * File operations for user-space + */ + +/* Write a message to the MU. */ +static ssize_t se_if_fops_write(struct file *fp, const char __user *buf, + size_t size, loff_t *ppos) +{ + struct se_if_device_ctx *dev_ctx =3D fp->private_data; + struct se_api_msg *tx_msg __free(kfree) =3D NULL; + struct se_if_priv *priv =3D dev_ctx->priv; + int err; + + dev_dbg(priv->dev, + "%s: write from buf (%p)%zu, ppos=3D%lld\n", + dev_ctx->devname, + buf, size, ((ppos) ? *ppos : 0)); + + if (mutex_lock_interruptible(&dev_ctx->fops_lock)) + return -EBUSY; + + if (dev_ctx !=3D priv->cmd_receiver_clbk_hdl.dev_ctx) { + err =3D -EINVAL; + goto exit; + } + + if (size < SE_MU_HDR_SZ) { + dev_err(priv->dev, + "%s: User buffer too small(%zu < %d)\n", + dev_ctx->devname, + size, SE_MU_HDR_SZ); + err =3D -ENOSPC; + goto exit; + } + + tx_msg =3D memdup_user(buf, size); + if (IS_ERR(tx_msg)) { + err =3D PTR_ERR(tx_msg); + goto exit; + } + + print_hex_dump_debug("from user ", DUMP_PREFIX_OFFSET, 4, 4, + tx_msg, size, false); + + err =3D ele_msg_send(dev_ctx, tx_msg, size); + if (err < 0) + goto exit; +exit: + mutex_unlock(&dev_ctx->fops_lock); + return err; +} + +/* + * Read a message from the MU. + * Blocking until a message is available. + */ +static ssize_t se_if_fops_read(struct file *fp, char __user *buf, + size_t size, loff_t *ppos) +{ + struct se_if_device_ctx *dev_ctx =3D fp->private_data; + struct se_if_priv *priv =3D dev_ctx->priv; + int err; + + dev_dbg(priv->dev, + "%s: read to buf %p(%zu), ppos=3D%lld\n", + dev_ctx->devname, + buf, size, ((ppos) ? *ppos : 0)); + + if (mutex_lock_interruptible(&dev_ctx->fops_lock)) + return -EBUSY; + + if (dev_ctx !=3D priv->cmd_receiver_clbk_hdl.dev_ctx) { + err =3D -EINVAL; + goto exit; + } + + err =3D ele_msg_rcv(dev_ctx, &priv->cmd_receiver_clbk_hdl); + if (err < 0) { + dev_err(priv->dev, + "%s: Err[0x%x]:Interrupted by signal.\n", + dev_ctx->devname, err); + dev_dbg(priv->dev, + "Current active dev-ctx count =3D %d.\n", + dev_ctx->priv->active_devctx_count); + goto exit; + } + + /* We may need to copy the output data to user before + * delivering the completion message. + */ + err =3D se_dev_ctx_cpy_out_data(dev_ctx); + if (err < 0) + goto exit; + + /* Copy data from the buffer */ + print_hex_dump_debug("to user ", DUMP_PREFIX_OFFSET, 4, 4, + priv->cmd_receiver_clbk_hdl.rx_msg, + priv->cmd_receiver_clbk_hdl.rx_msg_sz, + false); + + if (copy_to_user(buf, priv->cmd_receiver_clbk_hdl.rx_msg, + priv->cmd_receiver_clbk_hdl.rx_msg_sz)) { + dev_err(priv->dev, + "%s: Failed to copy to user\n", + dev_ctx->devname); + err =3D -EFAULT; + } + err =3D priv->cmd_receiver_clbk_hdl.rx_msg_sz; +exit: + priv->cmd_receiver_clbk_hdl.rx_msg_sz =3D 0; + + se_dev_ctx_shared_mem_cleanup(dev_ctx); + + mutex_unlock(&dev_ctx->fops_lock); + return err; +} + +/* Open a character device. */ +static int se_if_fops_open(struct inode *nd, struct file *fp) +{ + struct miscdevice *miscdev =3D fp->private_data; + struct se_if_priv *priv =3D dev_get_drvdata(miscdev->parent); + struct se_if_device_ctx *misc_dev_ctx =3D priv->priv_dev_ctx; + struct se_if_device_ctx *dev_ctx; + int err =3D 0; + + if (mutex_lock_interruptible(&misc_dev_ctx->fops_lock)) + return -EBUSY; + + priv->dev_ctx_mono_count++; + err =3D init_device_context(priv, + priv->dev_ctx_mono_count ? + priv->dev_ctx_mono_count + : priv->dev_ctx_mono_count++, + &dev_ctx, NULL); + if (err) { + dev_err(priv->dev, + "Failed[0x%x] to create device contexts.\n", + err); + goto exit; + } + + fp->private_data =3D dev_ctx; + +exit: + mutex_unlock(&misc_dev_ctx->fops_lock); + return err; +} + +/* Close a character device. */ +static int se_if_fops_close(struct inode *nd, struct file *fp) +{ + struct se_if_device_ctx *dev_ctx =3D fp->private_data; + struct se_if_priv *priv =3D dev_ctx->priv; + + if (mutex_lock_interruptible(&dev_ctx->fops_lock)) + return -EBUSY; + + /* check if this device was registered as command receiver. */ + if (priv->cmd_receiver_clbk_hdl.dev_ctx =3D=3D dev_ctx) { + priv->cmd_receiver_clbk_hdl.dev_ctx =3D NULL; + kfree(priv->cmd_receiver_clbk_hdl.rx_msg); + priv->cmd_receiver_clbk_hdl.rx_msg =3D NULL; + } + + se_dev_ctx_shared_mem_cleanup(dev_ctx); + cleanup_se_shared_mem(dev_ctx); + + priv->active_devctx_count--; + list_del(&dev_ctx->link); + + mutex_unlock(&dev_ctx->fops_lock); + kfree(dev_ctx->devname); + kfree(dev_ctx); + + return 0; +} + +/* IOCTL entry point of a character device */ +static long se_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) +{ + struct se_if_device_ctx *dev_ctx =3D fp->private_data; + struct se_if_priv *priv =3D dev_ctx->priv; + int err; + + /* Prevent race during change of device context */ + if (mutex_lock_interruptible(&dev_ctx->fops_lock)) + return -EBUSY; + + switch (cmd) { + case SE_IOCTL_ENABLE_CMD_RCV: + if (!priv->cmd_receiver_clbk_hdl.dev_ctx) { + if (!priv->cmd_receiver_clbk_hdl.rx_msg) { + priv->cmd_receiver_clbk_hdl.rx_msg + =3D kzalloc(MAX_NVM_MSG_LEN, + GFP_KERNEL); + if (!priv->cmd_receiver_clbk_hdl.rx_msg) { + err =3D -ENOMEM; + break; + } + } + priv->cmd_receiver_clbk_hdl.rx_msg_sz =3D MAX_NVM_MSG_LEN; + priv->cmd_receiver_clbk_hdl.dev_ctx =3D dev_ctx; + err =3D 0; + } else { + err =3D -EBUSY; + } + break; + case SE_IOCTL_GET_MU_INFO: + err =3D se_ioctl_get_mu_info(dev_ctx, arg); + break; + case SE_IOCTL_SETUP_IOBUF: + err =3D se_ioctl_setup_iobuf_handler(dev_ctx, arg); + break; + case SE_IOCTL_GET_SOC_INFO: + err =3D se_ioctl_get_se_soc_info_handler(dev_ctx, arg); + break; + case SE_IOCTL_CMD_SEND_RCV_RSP: + err =3D se_ioctl_cmd_snd_rcv_rsp_handler(dev_ctx, arg); + break; + default: + err =3D -EINVAL; + dev_dbg(priv->dev, + "%s: IOCTL %.8x not supported\n", + dev_ctx->devname, + cmd); + } + + mutex_unlock(&dev_ctx->fops_lock); + + return (long)err; +} + +/* Char driver setup */ +static const struct file_operations se_if_fops =3D { + .open =3D se_if_fops_open, + .owner =3D THIS_MODULE, + .release =3D se_if_fops_close, + .unlocked_ioctl =3D se_ioctl, + .read =3D se_if_fops_read, + .write =3D se_if_fops_write, +}; + /* interface for managed res to free a mailbox channel */ static void if_mbox_free_channel(void *mbox_chan) { @@ -344,6 +1096,7 @@ static int se_if_request_channel(struct device *dev, =20 static void se_if_probe_cleanup(void *plat_dev) { + struct se_if_device_ctx *dev_ctx, *t_dev_ctx; struct platform_device *pdev =3D plat_dev; struct device *dev =3D &pdev->dev; struct se_fw_load_info *load_fw; @@ -368,6 +1121,18 @@ static void se_if_probe_cleanup(void *plat_dev) load_fw->imem.buf =3D NULL; } =20 + if (priv->dev_ctx_mono_count) { + list_for_each_entry_safe(dev_ctx, t_dev_ctx, &priv->dev_ctx_list, link) { + list_del(&dev_ctx->link); + priv->active_devctx_count--; + } + } + + if (priv->priv_dev_ctx && priv->priv_dev_ctx->miscdev) { + devm_remove_action(dev, if_misc_deregister, &priv->priv_dev_ctx->miscdev= ); + misc_deregister(priv->priv_dev_ctx->miscdev); + } + /* No need to check, if reserved memory is allocated * before calling for its release. Or clearing the * un-set bit. @@ -457,6 +1222,7 @@ static int se_if_probe(struct platform_device *pdev) priv->if_defs.success_tag =3D info->success_tag; priv->if_defs.base_api_ver =3D info->base_api_ver; priv->if_defs.fw_api_ver =3D info->fw_api_ver; + INIT_LIST_HEAD(&priv->dev_ctx_list); =20 if (info->reserved_dma_ranges) { ret =3D of_reserved_mem_device_init(dev); @@ -468,6 +1234,14 @@ static int se_if_probe(struct platform_device *pdev) } } =20 + ret =3D init_device_context(priv, 0, &priv->priv_dev_ctx, &se_if_fops); + if (ret) { + dev_err(dev, + "Failed[0x%x] to create device contexts.\n", + ret); + goto exit; + } + ret =3D se_soc_info(priv); if (ret) { dev_err(dev, diff --git a/drivers/firmware/imx/se_ctrl.h b/drivers/firmware/imx/se_ctrl.h index fa2804c5f7e3..52885990cee2 100644 --- a/drivers/firmware/imx/se_ctrl.h +++ b/drivers/firmware/imx/se_ctrl.h @@ -13,6 +13,7 @@ #define MAX_FW_LOAD_RETRIES 50 =20 #define RES_STATUS(x) FIELD_GET(0x000000ff, x) +#define MAX_DATA_SIZE_PER_USER (65 * 1024) #define MAX_NVM_MSG_LEN (256) #define MESSAGING_VERSION_6 0x6 #define MESSAGING_VERSION_7 0x7 @@ -31,7 +32,7 @@ struct se_clbk_handle { struct completion done; bool signal_rcvd; - atomic_t pending_hdr; + struct se_if_device_ctx *dev_ctx; u32 rx_msg_sz; /* Assignment of the rx_msg buffer to held till the * received content as part callback function, is copied. @@ -46,6 +47,40 @@ struct se_imem_buf { u32 state; }; =20 +struct se_buf_desc { + u8 *shared_buf_ptr; + u8 *usr_buf_ptr; + u32 size; + struct list_head link; +}; + +struct se_shared_mem { + dma_addr_t dma_addr; + u32 size; + u32 pos; + u8 *ptr; +}; + +struct se_shared_mem_mgmt_info { + struct list_head pending_in; + struct list_head pending_out; + + struct se_shared_mem secure_mem; + struct se_shared_mem non_secure_mem; +}; + +/* Private struct for each char device instance. */ +struct se_if_device_ctx { + struct se_if_priv *priv; + struct miscdevice *miscdev; + const char *devname; + + struct mutex fops_lock; + + struct se_shared_mem_mgmt_info se_shared_mem_mgmt; + struct list_head link; +}; + /* Header of the messages exchange with the EdgeLock Enclave */ struct se_msg_hdr { u8 ver; @@ -89,6 +124,11 @@ struct se_if_priv { struct mbox_chan *tx_chan, *rx_chan; =20 struct se_if_defines if_defs; + + struct se_if_device_ctx *priv_dev_ctx; + struct list_head dev_ctx_list; + u32 active_devctx_count; + u32 dev_ctx_mono_count; }; =20 #endif diff --git a/include/uapi/linux/se_ioctl.h b/include/uapi/linux/se_ioctl.h new file mode 100644 index 000000000000..c2d0a92ef626 --- /dev/null +++ b/include/uapi/linux/se_ioctl.h @@ -0,0 +1,94 @@ +/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Cla= use*/ +/* + * Copyright 2024 NXP + */ + +#ifndef SE_IOCTL_H +#define SE_IOCTL_H + +/* IOCTL definitions. */ + +struct se_ioctl_setup_iobuf { + u8 *user_buf; + u32 length; + u32 flags; + u64 ele_addr; +}; + +struct se_ioctl_shared_mem_cfg { + u32 base_offset; + u32 size; +}; + +struct se_ioctl_get_if_info { + u8 se_if_id; + u8 interrupt_idx; + u8 tz; + u8 did; + u8 cmd_tag; + u8 rsp_tag; + u8 success_tag; + u8 base_api_ver; + u8 fw_api_ver; +}; + +struct se_ioctl_cmd_snd_rcv_rsp_info { + u32 *tx_buf; + int tx_buf_sz; + u32 *rx_buf; + int rx_buf_sz; +}; + +struct se_ioctl_get_soc_info { + u16 soc_id; + u16 soc_rev; +}; + +/* IO Buffer Flags */ +#define SE_IO_BUF_FLAGS_IS_OUTPUT (0x00u) +#define SE_IO_BUF_FLAGS_IS_INPUT (0x01u) +#define SE_IO_BUF_FLAGS_USE_SEC_MEM (0x02u) +#define SE_IO_BUF_FLAGS_USE_SHORT_ADDR (0x04u) +#define SE_IO_BUF_FLAGS_IS_IN_OUT (0x10u) + +/* IOCTLS */ +#define SE_IOCTL 0x0A /* like MISC_MAJOR. */ + +/* + * ioctl to designated the current fd as logical-reciever. + * This is ioctl is send when the nvm-daemon, a slave to the + * firmware is started by the user. + */ +#define SE_IOCTL_ENABLE_CMD_RCV _IO(SE_IOCTL, 0x01) + +/* + * ioctl to get the buffer allocated from the memory, which is shared + * between kernel and FW. + * Post allocation, the kernel tagged the allocated memory with: + * Output + * Input + * Input-Output + * Short address + * Secure-memory + */ +#define SE_IOCTL_SETUP_IOBUF _IOWR(SE_IOCTL, 0x03, \ + struct se_ioctl_setup_iobuf) + +/* + * ioctl to get the mu information, that is used to exchange message + * with FW, from user-spaced. + */ +#define SE_IOCTL_GET_MU_INFO _IOR(SE_IOCTL, 0x04, \ + struct se_ioctl_get_if_info) +/* + * ioctl to get SoC Info from user-space. + */ +#define SE_IOCTL_GET_SOC_INFO _IOR(SE_IOCTL, 0x06, \ + struct se_ioctl_get_soc_info) + +/* + * ioctl to send command and receive response from user-space. + */ +#define SE_IOCTL_CMD_SEND_RCV_RSP _IOWR(SE_IOCTL, 0x07, \ + struct se_ioctl_cmd_snd_rcv_rsp_info) +#endif --=20 2.34.1