From patchwork Wed Sep 27 17:53:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 13400712 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 09F3CE810D9 for ; Wed, 27 Sep 2023 12:27:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zrsei7ke8WLHeo36hc55Qu6LqHWjr/yDyLxY6oTc6YQ=; b=gguC+yqKRvAHXh e1y8BB5QEOCQiMG+n126yUmfWEdmEv0EH/ACqE2G3r7J1zfXjpF8GqDjZ37K+U0EhIS6s/M9QcWD7 BIHtKPq+uZpQqHywq7Iu3m634Vq9PGVyVf7cHxBNv0J5og5YJZ7HMjfHo3spiWz9SlyASXQMV4mO/ 2c5XVhSSQjjeUqMoM1WmNkWOa7ptn8eUzMjycgzYT1hMiSwIcyYwM60TW2DtMtE9EwW/t+l38frPK gSPgn7VICQoJaa+ztjcagfynxCpU9NPIRPWrKc8z1a9yRbBGbzlZ2eaB2+B40PnPzf75q6N1A1xC9 G1Ijqc/ThXiSJnu6G3Lw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlTck-000t6x-27; Wed, 27 Sep 2023 12:26:38 +0000 Received: from mail-vi1eur04on061e.outbound.protection.outlook.com ([2a01:111:f400:fe0e::61e] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlTch-000t5K-25 for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 12:26:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V+KG+O7RrcU10hE/8LXJXJXdJJiGC8g4Iy34+vz0zkLq8qEEv3eVg1qUBlhj5HzyTnj79a+YZtTr0x919y+mPSDkiyitQMUZh/SQCahNZGRSyO0cIAib9sXGIPYbZpa+9cXNF4jb74I49/T3JQ1SW9nCh3ZYPqchG/Zg2N21SFSWigRW9SCP2NmQXKlRjvvEmqVKPmMoIKU7k+uhg0t2bnfrcnu1yNuAJXOFpKrx+lYXGiSumY73sM3pk9YvjrAslTr2eFBmmSwq37x7cS3ebt0QjzDO1uoUmwQN1JOMi4W5kBDOIqrZ5GnR3EAkTokf8J9vHzxR0goFSevCNA3VTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9jkjTZzXfGW/gQ8bE8PkKRfnxqXYGPBNT0oVC0GmzZQ=; b=EzzDmfkZfQxcWztDpIts1x0diOLPg9QI1VRewIks/Fhhtjvvc3x4jC10Fz1Eid3MYqddJ1yxM0u7VvMNV33XaKIojCMBGCJW+kBVnePivyAmE/npCn8F8dWwL4DJex2Zl5Hm0zTHnAb3E65BM/NtosYUd44vNAmy3BdIRmQaGzRHt5Rm326YnxIcIwBCwgTo7MVH422WxOMNkkBd75ZeblegBS5jappx7SCd2/YnGHb3e2p4ORwM8RTxe6KL/7c9jPiZ1ijrInhollIXoQHOrpylDEeA2W4xv1mYJzaAfHcYbP1NIOdArYm31uA0R3XSvHeMfEZlCiVHl3hObtyiOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9jkjTZzXfGW/gQ8bE8PkKRfnxqXYGPBNT0oVC0GmzZQ=; b=OougMJCnpdFXnQmc+uI/9JovPU8Oc2FUaocq3zjxKHlZB/7GE7IJ98OLFwc+3ekmIzbrNvLNZkV2F1rNw+0vZMSqOTn8z6hurCfLanLRd/e8jPParJSYd1agzBUPN1uyryDN5meZsjXsmXZVi0C2yX/tmUiX66StK903RfINpCQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) by AS8PR04MB7704.eurprd04.prod.outlook.com (2603:10a6:20b:296::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.27; Wed, 27 Sep 2023 12:26:27 +0000 Received: from DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e]) by DU2PR04MB8630.eurprd04.prod.outlook.com ([fe80::dbc:99b7:7808:f82e%7]) with mapi id 15.20.6838.016; Wed, 27 Sep 2023 12:26:27 +0000 From: Pankaj Gupta To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, clin@suse.com, conor+dt@kernel.org, pierre.gondois@arm.com, festevam@gmail.com, linux-imx@nxp.com, davem@davemloft.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, gaurav.jain@nxp.com, alexander.stein@ew.tq-group.com, V.Sethi@nxp.com Cc: Pankaj Gupta Subject: [PATCH v6 00/11] firmware: imx: NXP Secure-Enclave FW Driver Date: Wed, 27 Sep 2023 23:23:50 +0530 Message-Id: <20230927175401.1962733-1-pankaj.gupta@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SG2PR02CA0128.apcprd02.prod.outlook.com (2603:1096:4:188::20) To DU2PR04MB8630.eurprd04.prod.outlook.com (2603:10a6:10:2dd::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8630:EE_|AS8PR04MB7704:EE_ X-MS-Office365-Filtering-Correlation-Id: fcc37925-da7b-4c19-bcd0-08dbbf54f85a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V9QAdXbWvBBT03p7orH3VUHGfLx5ZB2NTTjAxbVsqy0PAGg9UaWWfvhTr8DZwhkhhq4jGW6YE3vc1CT8z13Qv4g1kfXAZdaaSSfbvZrPfwby+x7Wna4DHj7ME8Fl6hZr1oC30k0VGEr1HGTyuudL2HahZBfFNPIhPtwzPaE3NbFQ0FgL1MjVPRlOkHSEI2SZrcjzUOUb2LhAcTAkP1N58CV3f2jFTAHmUir9tyjUnxaDoaF4AbxVDY5qQuV2EjmtnqzOvpVmg/oz1TIupjyqTxkEpXGUF58OgHsU0NPbiDipDrkMz5XhCYAZTotDrKN4p6KBNPx65TG5XKj24ft4otFnx5ztNuApAZuv32BYxYR273cN2W/DBY/vkh4G/CcZTBSKHCxDAUiM5RVNvTZ3O0DAQ2E+eb/8GacX8bSbO21qBDMqQzciImc5LvTm8d1GT3p45THGtnhKKeF8wYl0CBHiyhCAhmkSVgofnBjUTe2uOfAZT+YEhm0ai+LI3YeJgjiD55v87ep6VnWN+dozhz1GAzc+1+2BLIQH4NjBWCJqkU237U4GlZcv/NndrIec9Je+TmWRQkXojZvIldxIMHDkOt0kbfzhgxOb1YbUSpe51Qlb52xOfJyT0Jp4jSLX X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8630.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(366004)(136003)(39860400002)(396003)(376002)(230922051799003)(1800799009)(186009)(451199024)(1076003)(2616005)(6506007)(52116002)(6512007)(44832011)(26005)(8936002)(478600001)(921005)(5660300002)(6666004)(36756003)(4326008)(2906002)(316002)(6636002)(86362001)(66556008)(66946007)(8676002)(41300700001)(38100700002)(38350700002)(66476007)(6486002)(7416002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PHTbdS3ky+EBz3HwI0CL3QsMGd3Sd7SdG7O0LzI7z0Yiu3G1ftIbFS9uRijUw+R2zgU8/+realC3ndvibfG1YSAd5OPk0ey6vKdpAUZKp2+oKMASNyhGY/7oWdRCmW+xXip4SmVXhkO+w0BbYQnHiIg6ald9qOdKoVtn6CsFOTED3fV4JREPsK+je5OubL5WxbuWehwb/P8igKgBA8yANRF7c3Zf8H3yaj0z4hFmTnj2FdcTfVnXPWosnDIvvj3ZS4rY6HK8GdHpGl+cAawAS/cDrv3p+h7XsMB4J7CCeJBL0BLUxz8ICoPOgjiok7XnqsYCZGxCVvau2Pu4a+IMYZPV73e/aPsenU1Vp6kwxr8y2SPS6PIiRX9gSgPQNTrorbrlYEw9U1QyU5pCd2JvdQHMQbxMFf8fEL2K70l0AOGlN/XyUF+lc0u1tjsexPX7gqWlw4sh2BVtYLtF2GzpLNeoZht6rHv95ms0RrX7IUL/yUwgld5yyIMInF8kPH7nsmHVIP0Awu0Ae78bcIPYZZZCJD1JnMYUID5oYGibRttZmYuWWN5A37b4Kufv59Y/2Q/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cc37925-da7b-4c19-bcd0-08dbbf54f85a X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8630.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2023 12:26:26.9832 (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: gLG09VjRZrPQFKC9GEWAFqFOolypHlMcUm2xN9MLbKFMZtL4wruhRmWo3o3lJUOwfqaghNVSICsCozvAyS0LxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7704 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230927_052635_709159_0F671AFC X-CRM114-Status: GOOD ( 19.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org V6 Changes: - 1/11 (New): Kernel doc: "Documentation/driver-api/firmware/other_interfaces.rst" is added. - 2/11 DT Binding: Disposed off comments from .yaml -- replaced the "sram-pool" property, with standard property "fsl,sram". -- removed the additional details from the description. - 3,4,5,6/11: DTSI changes: -- Validated using the following commands: --- make dt_binding_check DT_SCHEMA_FILES=freescale --- make CHECK_DTBS=y freescale/imx8ulp-evk.dtb; make CHECK_DTBS=y freescale/imx93-11x11-evk.dtb - 7/11 firmware: imx: add driver for NXP EdgeLock Enclave: -- Removed: Reported-by: kernel test robot Closes:https://lore.kernel.org/oe-kbuild-all/202304120902.bP52A56z-lkp@intel.com -- pr_info is removed. -- macro "devctx_info", "devctx_dbg" & "devctx_err" is removed. -- Updated ABI: --- Users: user-space SE-LIB, crypto-api, imx-ocotp-ele driver , smw --- IOCTLS: Updated the ioctl --- read/write: -- Correct message header validation. --- segregated handling of the error, while msg header parsing. -- removed TX and RX messages static allocation in state container. -- ran coccicheck: make C=1 CHECK=scripts/coccicheck drivers/firmware/imx/*.* W=1 --- ran on all the patches. - 8/11 firmware: imx: init-fw api exchange on imx93 -- removed TX and RX messages static allocation in state container. -- moved the header file ele_fw_api.h, to driver/firmware/imx/ -- segregated handling of the error, while msg header parsing. - 9/11 firmware: imx: enable trng -- macro "devctx_info", "devctx_dbg" & "devctx_err" is removed. -- will remove this patch, will send this patch later, including RNG and crypto-maintainers. - 10/11 firmware: imx: enclave-fw: add handling for save/restore IMEM region -- Linux comment style fixed. - 10/11(old)(Removed) firmware: imx: enclave api to read-common-fuses -- This API will be used by imx-ocotp-ele.c. -- This patch can be sent later, when the changes to imx-ocotp-ele.c will be sent. -- "Documentation/driver-api/firmware/other_interfaces.rst" will be update for the exported symbols: - read_common_fuses() - get_se_dev() v5 Changes: - 1/7 DT Binding: Disposed off comments from .yaml -- to use "-", instead of "_". -- to use generic name, concatinated with soc-id. -- removed mu-did. -- renamed the ele-mu to se-fw -- moved the file from .../arm/freescale/ to .../firmware/ - 2/7 Changed the .dtsi, as per the comments. -- removed mu-did -- renamed the ele_mu to se-fw. -- updated the compatible string. -- tested the DTB. - 4/7 Changed the .dtsi, as per the comments. -- removed mu-did -- renamed the ele_mu to se-fw. -- updated the compatible string. -- tested the DTB. - 6/7 Changes in driver code: -- replace pr_err with dev_err -- removed export symbols, except one, which will be used in other driver. -- Each API, send-recived based on device reference. -- Divided the commits into smaller commits. - Base Driver -- Added ABI file. - 7/11 (new) firmware: imx: init-fw api exchange on imx93 - 8/11 (new) firmware: imx: enable trng - 9/11 (new) firmware: imx: enclave-fw: add handling for save/restore IMEM region - 10/11 (new) firmware: imx: enclave api to read-common-fuses v4 Changes: - Post internal review, changed the name from "ele-mu" to "se-fw". - Disposed-off comments in the dt-binding file. - Removed the non-hw related dt-bindings from the driver code. - Corrected the File MAINTAINERS for correct name of yaml file. v3 Changes: - update the commit message for documentation. - Fixed dt-binding checking error for file- fsl,ele_mu.yaml - Coverity fixes in the ele_mu.c v2 Changes: - Fixed Kernel Test Bot issues. - Removed ".../devicetree/bindings/mailbox/fsl,muap.txt" The NXP's i.MX EdgeLock Enclave, a HW IP creating an embedded secure enclave within the SoC boundary to enable features like - HSM - SHE - V2X Communicates via message unit with linux kernel. This driver is 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 can communicate on single MU. It exists on some i.MX processors. e.g. i.MX8ULP, i.MX93 etc. Pankaj Gupta (11): Documentation/firmware: added imx/se-fw to other_interfaces dt-bindings: arm: fsl: add imx-se-fw binding doc arm64: dts: imx8ulp-evk: added nxp secure enclave firmware arm64: dts: imx8ulp-evk: reserved mem-ranges to constrain ele_fw dma-range arm64: dts: imx93-11x11-evk: added nxp secure enclave fw arm64: dts: imx93-11x11-evk: reserved mem-ranges firmware: imx: add driver for NXP EdgeLock Enclave firmware: imx: init-fw api exchange on imx93 firmware: imx: enable trng firmware: imx: enclave-fw: add handling for save/restore IMEM region MAINTAINERS: Added maintainer details Documentation/ABI/testing/se-cdev | 41 + .../bindings/firmware/fsl,imx-se-fw.yaml | 73 + .../driver-api/firmware/other_interfaces.rst | 67 + MAINTAINERS | 10 + arch/arm64/boot/dts/freescale/imx8ulp-evk.dts | 15 + arch/arm64/boot/dts/freescale/imx8ulp.dtsi | 12 +- .../boot/dts/freescale/imx93-11x11-evk.dts | 15 + arch/arm64/boot/dts/freescale/imx93.dtsi | 10 +- drivers/firmware/imx/Kconfig | 21 + drivers/firmware/imx/Makefile | 3 + drivers/firmware/imx/ele_base_msg.c | 271 ++++ drivers/firmware/imx/ele_common.c | 294 ++++ drivers/firmware/imx/ele_common.h | 40 + drivers/firmware/imx/ele_fw_api.c | 118 ++ drivers/firmware/imx/ele_fw_api.h | 26 + drivers/firmware/imx/ele_trng.c | 47 + drivers/firmware/imx/se_fw.c | 1372 +++++++++++++++++ drivers/firmware/imx/se_fw.h | 152 ++ include/linux/firmware/imx/ele_base_msg.h | 67 + include/linux/firmware/imx/ele_mu_ioctl.h | 73 + 20 files changed, 2725 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/se-cdev create mode 100644 Documentation/devicetree/bindings/firmware/fsl,imx-se-fw.yaml create mode 100644 drivers/firmware/imx/ele_base_msg.c create mode 100644 drivers/firmware/imx/ele_common.c create mode 100644 drivers/firmware/imx/ele_common.h create mode 100644 drivers/firmware/imx/ele_fw_api.c create mode 100644 drivers/firmware/imx/ele_fw_api.h create mode 100644 drivers/firmware/imx/ele_trng.c create mode 100644 drivers/firmware/imx/se_fw.c create mode 100644 drivers/firmware/imx/se_fw.h create mode 100644 include/linux/firmware/imx/ele_base_msg.h create mode 100644 include/linux/firmware/imx/ele_mu_ioctl.h