From patchwork Thu Jun 23 11:01:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaurav Jain X-Patchwork-Id: 1647041 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector2 header.b=EK4SHrT1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTHQL4Cskz9sGp for ; Thu, 23 Jun 2022 21:02:16 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1546C842E3; Thu, 23 Jun 2022 13:02:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="EK4SHrT1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2CAF8842E0; Thu, 23 Jun 2022 13:02:06 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70043.outbound.protection.outlook.com [40.107.7.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1BF3D842E4 for ; Thu, 23 Jun 2022 13:02:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=gaurav.jain@nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iGDtIKK3XxwmFGxz0mT42xVibf9xQ54voUsKwXtIXRxuugDlb4e1S6Fe8yNU+eUCURELza9lfHe+Ai6JBLOjJH14zPjdpFsAV+Z+rhtKjs6ns5OCTQImoNgIkq5vr/9/83aZa0/aaQ3pyaSvaVDCSq0G+fOeIMUoY8BSI9nwKDp4/FeGES7WzvIv9fshzEJJkhwc40tLnvhr69gKJ+BGRv97Kuxj1tb380Vkv8h6u4GeHR3ZTW0uDrS8F1dzwNVNjZp9MNcMp/0NtK6tNi2w7ZGhNjZc6BNgaA1NqP4D5jPULDUW/h/JIjOHLudHl0TW92lkuxH6kx8FWpG6ujnV4A== 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=02evxdA7YPAcoPTF4Nn3qOHqL+ODuxZBedlbw4vCH9g=; b=bFTFTcinPTzWT6mB5CuQo5lvDHCT/UcBQWyezNv1ktAtERHbaQYTWTVGdfceihHeSsoSh3pXulW0kMVSEPSwApr3Kle1DOF56BlgUOyXiI4AxQThMguqwCeZtkXJ5EA9nrRp40hqdbL2haV+vaJNC82t3Ayz1Ub+4gdCwAeSlLT11TOKaGEBr03Gq/GOURFkRe28vDpuPDzU69uV2764vFqVtEx7AZiRcqrH+O3KAzqVLF5eDxHb+nVrl4qUGGKgaUaZ7613Nyridd0vMh3R/tkBozY+vVZixgTWvZe0aJbq/4JiFFwlsl6lmXG7JQrY6/OGYXl/DCBwet01Kyw/NA== 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=02evxdA7YPAcoPTF4Nn3qOHqL+ODuxZBedlbw4vCH9g=; b=EK4SHrT1QO+f+uEje1MSxzPEfA9rG8kzw4X7RTIsgGlpFfEDfgFeOw+556ROzuZdPO2JZzYCPJUqpsddWRXHHEY8687vdS2PvwDgYjCofQ4o1aiO+/WMCTZSnTnGlfFr77j91z5GTNGpy8goQecJm9sz4REOAIIWcyBtsiKRvZ8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB5334.eurprd04.prod.outlook.com (2603:10a6:209:50::28) by VI1PR04MB6880.eurprd04.prod.outlook.com (2603:10a6:803:130::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.16; Thu, 23 Jun 2022 11:01:59 +0000 Received: from AM6PR04MB5334.eurprd04.prod.outlook.com ([fe80::99e:6ee:d17:e114]) by AM6PR04MB5334.eurprd04.prod.outlook.com ([fe80::99e:6ee:d17:e114%5]) with mapi id 15.20.5373.015; Thu, 23 Jun 2022 11:01:59 +0000 From: Gaurav Jain To: u-boot@lists.denx.de, Stefano Babic Cc: Peng Fan , Fabio Estevam , "NXP i . MX U-Boot Team" , Horia Geanta , Varun Sethi , Ye Li , Alison Wang , Simon Glass , Ovidiu Panait , Kshitiz Varshney , Priyanka Jain , Gaurav Jain Subject: [PATCH] ls1021atwr: caam: Enable Uboot validaion in SPL. Date: Thu, 23 Jun 2022 16:31:35 +0530 Message-Id: <20220623110135.3887916-1-gaurav.jain@nxp.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: SG2PR02CA0024.apcprd02.prod.outlook.com (2603:1096:3:17::36) To AM6PR04MB5334.eurprd04.prod.outlook.com (2603:10a6:209:50::28) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c46683f2-a182-47f2-42f2-08da5507cb21 X-MS-TrafficTypeDiagnostic: VI1PR04MB6880:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UB5t0BBwIwsnJsPIuTLTyzmvu2f0O+M5AdttGnfUPThnM0fxUS8NigPfgDzyDCAkeKCZbitzjuH8e9SI19Y9Hh/TLmqFeTXAAtNG+pzuQTtU0CDyndcSKV3FYpbuLeYZ1DgC/tLD/0Z3fTQV+VTZk1SDlMJpRAypcBY2ovsoL9cYLTB9Xrd0XUBHLZjpQytPxJkC0+jqDBiKgyexcnXwqNPxFVGxbNtVjqejmKxEjmEwakfUSOHDmX/5IYVrtOJSKKL03JazqNI7bJ13jJ52ir8sQmQF3ajunmQ9jkFMHagTC+mq0yv6Wc7v+88cKAZR3ksc/v1CvCOZPGTgI68OqqLM2sQkMeiGTRRn0OTI4X7r5vfye2dH16RFazyQ4bNoMWb+CMGPQhG8MhEHvhDXdtL3Dg39Cg01wk6klJIA9bue4M6ieWKFRy1X1kbugpuLsdfitAJkVZbR1Lw8FQpTazsYLeC+GfC01F60w8JzkNEMsgsGb3U3QKtG4Y+dYBACRLLBRuFcbT53ZzkWVQZsCBg3dcLZhZPtFbryzq8Vl+IhOHj4YVJKfmKOu7dZQmd4eScU9UIeoo9XvS5xbq5I4Ds+I3hE9u5r9WEFVQHvpBW6jvwa3DNXG6eeZaAb6U2AxnV4KSTSSQnuwrM3wuTXyuZYCZtCVJUZzeORgfSabono/YmFnLx+iefuRztsFkUaKkNIkGAXjtz5WCLMvFo2SSEMnB8crqtIR/lKFX9oOdgoWP748axbiWTC2dcgvDO1 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB5334.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(136003)(366004)(39860400002)(346002)(396003)(376002)(38100700002)(38350700002)(2616005)(6512007)(316002)(2906002)(1076003)(26005)(5660300002)(44832011)(86362001)(83380400001)(6506007)(8676002)(4326008)(66556008)(6486002)(478600001)(41300700001)(54906003)(66946007)(66476007)(6666004)(186003)(8936002)(36756003)(6916009)(55236004)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wqnHiE5IivS7bI9FRbbEiQY5XYBkewSrnbxV6AqLITnaPLWPnUb+E5PIAaYlGBUNmwzVKxyZgf5GDgvXmXksp7pvkdYmkNl7eKaPmonEnOXbrca4SZnn/B1PB1V2GWNf30V+BK8pUYq0sF2zjZAxaq38P0Ul0ylUzT/MwPvnKzt5zHq4l9t8YX5YGYwnvwSBhNEiqgwbBW/ChLrVwclYYWPE6Ez+qwfgNsdppdRNfJxsqeY9Ot/sxFZnHtPLIr1E740FP/6otEirV6a7abMJCnyoQu6F3EgyYI3xGwdxOxaaXrI7PkX8RQ0sSQLl0AP0yw33ltEhRpNlITGQeqBbAEUaA7EqmX/HixKdnH0H7Eqxknv08IlJA8KTDnE5o9uZ2u2MnE1mIqArGdZ3XG9YRwTUqaSmHhOCAaD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4Z9zy/aZXQXC1wKrk9Dyz7E01hc0WwtC3V2IXsE+niWwIWH66hI7kJ89I3x5dP/tz/OZTxWHcmF2R0epa3pjXFiN7pmWRVxSV5noZC+cYmjITqvhPu3VSngpG X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c46683f2-a182-47f2-42f2-08da5507cb21 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5334.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2022 11:01:58.9151 (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: eepjzy1TSSSWLjLDPQQk2kwfRxkJc576zcmYfnOpcYgFzTz/xvfbrU6t7ojCJbrnzKHAUWCMU6WIN9/KSpZFhA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6880 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean caam driver model enabled in spl for secure boot. fsl_rsa_mod_exp driver enabled in spl for validating uboot image. Signed-off-by: Gaurav Jain --- MAINTAINERS | 1 + arch/arm/dts/ls1021a-twr-u-boot.dtsi | 29 +++++++++++++++++++++ arch/arm/dts/ls1021a-twr.dtsi | 1 + board/freescale/common/fsl_chain_of_trust.c | 6 +---- board/freescale/common/fsl_validate.c | 10 ++++++- board/freescale/ls1021atwr/ls1021atwr.c | 13 +++++++-- 6 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 arch/arm/dts/ls1021a-twr-u-boot.dtsi diff --git a/MAINTAINERS b/MAINTAINERS index 28e4d38238..d9bfb307ef 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1450,5 +1450,6 @@ F: */ CAAM M: Gaurav Jain S: Maintained +F: arch/arm/dts/ls1021a-twr-u-boot.dtsi F: drivers/crypto/fsl/ F: include/fsl_sec.h diff --git a/arch/arm/dts/ls1021a-twr-u-boot.dtsi b/arch/arm/dts/ls1021a-twr-u-boot.dtsi new file mode 100644 index 0000000000..3711e42419 --- /dev/null +++ b/arch/arm/dts/ls1021a-twr-u-boot.dtsi @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright 2022 NXP + */ + +&{/soc} { + u-boot,dm-spl; + u-boot,dm-pre-reloc; +}; + +&crypto { + u-boot,dm-spl; +}; + +&sec_jr0 { + u-boot,dm-spl; +}; + +&sec_jr1 { + u-boot,dm-spl; +}; + +&sec_jr2 { + u-boot,dm-spl; +}; + +&sec_jr3 { + u-boot,dm-spl; +}; diff --git a/arch/arm/dts/ls1021a-twr.dtsi b/arch/arm/dts/ls1021a-twr.dtsi index bf96af7e36..82df2f11bb 100644 --- a/arch/arm/dts/ls1021a-twr.dtsi +++ b/arch/arm/dts/ls1021a-twr.dtsi @@ -6,6 +6,7 @@ */ #include "ls1021a.dtsi" +#include "ls1021a-twr-u-boot.dtsi" / { model = "LS1021A TWR Board"; diff --git a/board/freescale/common/fsl_chain_of_trust.c b/board/freescale/common/fsl_chain_of_trust.c index 7ffb315bc9..1b9733cf83 100644 --- a/board/freescale/common/fsl_chain_of_trust.c +++ b/board/freescale/common/fsl_chain_of_trust.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Copyright 2015 Freescale Semiconductor, Inc. + * Copyright 2022 NXP */ #include @@ -113,11 +114,6 @@ void spl_validate_uboot(uint32_t hdr_addr, uintptr_t img_addr) fsl_secboot_handle_error(ERROR_ESBC_PAMU_INIT); #endif -#ifdef CONFIG_FSL_CAAM - if (sec_init() < 0) - fsl_secboot_handle_error(ERROR_ESBC_SEC_INIT); -#endif - /* * dm_init_and_scan() is called as part of common SPL framework, so no * need to call it again but in case of powerpc platforms which currently diff --git a/board/freescale/common/fsl_validate.c b/board/freescale/common/fsl_validate.c index 34875d0b8f..569a8c4655 100644 --- a/board/freescale/common/fsl_validate.c +++ b/board/freescale/common/fsl_validate.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Copyright 2015 Freescale Semiconductor, Inc. - * Copyright 2021 NXP + * Copyright 2021-2022 NXP */ #include @@ -20,6 +20,7 @@ #ifdef CONFIG_ARCH_LS1021A #include #endif +#include #define SHA256_BITS 256 #define SHA256_BYTES (256/8) @@ -806,6 +807,13 @@ static int calculate_cmp_img_sig(struct fsl_secboot_img_priv *img) prop.num_bits = key_len * 8; prop.exp_len = key_len; +#if defined(CONFIG_SPL_BUILD) + ret = device_bind_driver(NULL, "fsl_rsa_mod_exp", "fsl_rsa_mod_exp", NULL); + if (ret) { + printf("Couldn't bind fsl_rsa_mod_exp driver (%d)\n", ret); + return -EINVAL; + } +#endif ret = uclass_get_device(UCLASS_MOD_EXP, 0, &mod_exp_dev); if (ret) { printf("RSA: Can't find Modular Exp implementation\n"); diff --git a/board/freescale/ls1021atwr/ls1021atwr.c b/board/freescale/ls1021atwr/ls1021atwr.c index a3aa84deb2..746b35a678 100644 --- a/board/freescale/ls1021atwr/ls1021atwr.c +++ b/board/freescale/ls1021atwr/ls1021atwr.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* * Copyright 2014 Freescale Semiconductor, Inc. - * Copyright 2019, 2021 NXP + * Copyright 2019, 2021-2022 NXP */ #include @@ -34,7 +34,7 @@ #include #endif #include - +#include DECLARE_GLOBAL_DATA_PTR; @@ -530,6 +530,15 @@ int board_init(void) #if defined(CONFIG_SPL_BUILD) void spl_board_init(void) { + if (IS_ENABLED(CONFIG_FSL_CAAM)) { + struct udevice *dev; + int ret; + + ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(caam_jr), &dev); + if (ret) + printf("Failed to initialize caam_jr: %d\n", ret); + } + ls102xa_smmu_stream_id_init(); } #endif