From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95479C433B4 for ; Tue, 4 May 2021 10:25:12 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F314261176 for ; Tue, 4 May 2021 10:25:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F314261176 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=s8OE9n9PZAEByhxYLqNnARM6yCLkjGFej8+3kxZaxJ8=; b=cFcFQvqcrizgjrtAyTlDQXiMG xkM/geHx8UIvdPO8o1doIMPO0DlRgZYxRZHfPz0e54j+klKHFExvNBsdR42fnfyG6mh829mm+Ph2F gHfH13vazgNAM3Q2gfscPPl3tG8lqQeoo+BVOG6oGPLDWP9ei5lw1IFXlLDSDWsU9l2pUek7157gn IL49Dv3o+ltzlwByG7jAWJBLbVPW7VOAmPBQ0wEAPgcVt7/32cDifQ4n0KliSBpJIjj2O08o3Laow aoKj7eIdw5mo5ISSDi+eRm23w8syReRJjTNxkydJwpM+3WtOknaL1MeJYouDttrUkENZ4/SA636rg 82xARZgWw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1ldsD2-00FxOU-K7; Tue, 04 May 2021 10:23:20 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ldsCp-00FxM6-CD for linux-arm-kernel@desiato.infradead.org; Tue, 04 May 2021 10:23:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=lK7ltAR+odXS+1lyHwU2R7vWKUZKsrUOnSZGTMytPwE=; b=f9CKNyRzYRmI3p8Q/RXEFcNS81 /S4NYU7ZCXx4xx7aWMZSiEAK2ZJlABipC8N4OD8EHx+LnPOmRNgijL+TOSzY0DY2HMw2ZpHOApvso aNilDigGU7eWiqczhkBwdNtXrSVAZ89CXv8VYHp6h2uKvBoo5zyOQfjs9JXo1Pg5S6eugVKo2Oxia phzAXjZdvJoILCk2gPZGiK3jft+oZ+4zg70yw963sHQvTL7HoBvX41EF1vE4RR5yJcHp19MsS0J26 89ApBFBWoQCP1Zvv5YrbuNONsnPr+reI6hwsnAmatWLDt7uG87Gg2xEZRcW7XXyPGaNap71t9FzEm VpYx+jUQ==; Received: from mail-mw2nam10on2089.outbound.protection.outlook.com ([40.107.94.89] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ldsCm-003tJ7-It for linux-arm-kernel@lists.infradead.org; Tue, 04 May 2021 10:23:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I+VC2cRYKzQv9oSKNBdGUlrvZ+DM9oNPxNFYoPUwCWExiHtzcmta+eFPbwgm78XJxhqAOQHRGR2Chg62OvVhvLu1Sx4jFmiIUYBY22hi2LMlSQh3dfrZ0OI/MszffV4Er/M5ip8/hzf6JUV1GxZYHHvhSumX4SKElNeN1g1p1X8fRwV1xfjc0maQRfVjFg2KTcievdXZSXgIR9dSFFrbuJ9jLUkfsOTKJrrb0sEscqpIoTFcMP678byA8dblzaE15sHfdkQb+xlV6wBFu9wCTrDehWepDDpOerH1vC/3U616UMqQrWbrlo7b4yslqq52BRBwPMmKlzSfbtHjXE9iLA== 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-SenderADCheck; bh=lK7ltAR+odXS+1lyHwU2R7vWKUZKsrUOnSZGTMytPwE=; b=Q1WfnOLlOADeTavupquEml+VKJ+QoNUW3wm6WlArcWrX6ZuJGsJ2t9VjkUQOXy+w/26UCsQXF0hTbB1HbEEHBGj30LQl/ppaj0TEn1mbt4y78ElvIEj6BUuHPZN0h3yqxmOzoNRv3JNUHHQpU8wcJFAPqOlR09AeXJB7OB4DK7pFy5ZlajvNAKChrAf0APIwKIUMOdHkMLRJ5qlKmgnv+3BopD/rR/kB/igbjl2VaVvWxQDsJ28JR9nZQGEqRGc4+smvk6kACNTQfvopCs2N/4u+uZStTITmxuLaA81H+6xmFVNB4pY7FOnt8rK3wGLY8MrG+RC5PF/stJLDUd8BCQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=kernel.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lK7ltAR+odXS+1lyHwU2R7vWKUZKsrUOnSZGTMytPwE=; b=GpF3FF1H7WtYd3dLyaLZVDIhRhMlkiPEESydBlV1BzRM+H4S0Tja/hmD5ioBcYNJdCfWy+r/JluiM3ONSNV5HOqvP4m550rTLLgdw3EtzjirBs4nFhy8vSpzuyQoBH/E2OZNZs0nfGiEBSrdjswMLaZ9zZnogRNASnyXBnJlf8o= Received: from SN4PR0201CA0020.namprd02.prod.outlook.com (2603:10b6:803:2b::30) by MWHPR02MB2399.namprd02.prod.outlook.com (2603:10b6:300:5c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.38; Tue, 4 May 2021 10:22:59 +0000 Received: from SN1NAM02FT040.eop-nam02.prod.protection.outlook.com (2603:10b6:803:2b:cafe::9e) by SN4PR0201CA0020.outlook.office365.com (2603:10b6:803:2b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.24 via Frontend Transport; Tue, 4 May 2021 10:22:58 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by SN1NAM02FT040.mail.protection.outlook.com (10.152.72.195) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4065.21 via Frontend Transport; Tue, 4 May 2021 10:22:58 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 4 May 2021 03:22:52 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Tue, 4 May 2021 03:22:52 -0700 Received: from [10.140.6.60] (port=35290 helo=xhdnavam40.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1ldsCZ-000192-Ej; Tue, 04 May 2021 03:22:51 -0700 From: Nava kishore Manne To: , , , , , , , , , , , , , , , , , , , , Subject: [RFC PATCH 3/4] drivers: fpga: Add user-key encrypted FPGA Image loading support Date: Tue, 4 May 2021 15:52:26 +0530 Message-ID: <20210504102227.15475-4-nava.manne@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210504102227.15475-1-nava.manne@xilinx.com> References: <20210504102227.15475-1-nava.manne@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c189947-b1e2-4d56-56a5-08d90ee69706 X-MS-TrafficTypeDiagnostic: MWHPR02MB2399: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zTDlbVOat4JjzNMWDt4FZzDHCtB83jaK/AS9IREOxQB7AltmEx4J4YTa9boaNrvQO4LqU3cZIidmHb+E8oFyQtmRnPkyjY28OOtMHuS/34v15cjP6PhyyNBP2LQMO9aLe5lJ3FPX+lil8ax7+lQjT1pXFjAtLVAWyF5EDy+GU/D1Jnd3nu2LXUf+pfo4Yc8U7SU/5xhYxUEvx1xNWHIk0fpckKFE0jDOAHwqoxlH03d5zXHL1+rV7rCFH0QhIQAZIf9F0uxDy/Psy2arbtlrwPMoYyrCU80GHlM52VXmeonSnfuSb1oNjhqFpoAU7vOaUjYW7BaHWYzQm6TVKI2H+MnZh1n/yl+OUz3O7/Px0ntQwuAt0dYnLlJqZjuTe+ADSvCEzNx6INaGuQNiLkreGlitZ0njYwmpZxvbAz2WEMkmrnKWIovDmbu7zNnQ3s2hxBiNvko6W/38v3PRlZe/GaQQUonZ1UVGuN0lcPLQcJLGHUD/p5zaabeUxk8F5xTdo38hAdr6dayC1KYDZAO9rAChUZz3osKMXYUqZovzPiKFYhgDtOLjBp4aVD8mDDPU6txDri0GziQUNvouCImU2FG8tu3s668Wd0hxTXu8F+GtXev3FPZopww05ffSGIJBPUSutiR6HzIoJKjQwP0OubB73Xxjh581P1oKdu2ZVmzCF07zlEUXtGZa/ToKQ3AIxV+QfywBRNNCQyPz5Ka0cyyqQZVhbvx3hlCClTvqsxmxXSDbTWBkfuJCVtwyjkdJ X-Forefront-Antispam-Report: CIP:149.199.62.198; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:xsj-pvapexch01.xlnx.xilinx.com; PTR:unknown-62-198.xilinx.com; CAT:NONE; SFS:(4636009)(39860400002)(396003)(136003)(376002)(346002)(36840700001)(46966006)(7696005)(6666004)(316002)(478600001)(8676002)(82310400003)(8936002)(1076003)(356005)(7416002)(36756003)(110136005)(2616005)(921005)(186003)(2906002)(36906005)(5660300002)(336012)(7636003)(82740400003)(70586007)(83380400001)(47076005)(426003)(26005)(70206006)(36860700001)(9786002)(102446001)(2101003)(83996005); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 10:22:58.7868 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c189947-b1e2-4d56-56a5-08d90ee69706 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.62.198]; Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT040.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR02MB2399 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210504_032304_647489_E89BA9CA X-CRM114-Status: GOOD ( 14.34 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch adds user-key encrypted FPGA Image loading support to the framework. Signed-off-by: Nava kishore Manne --- drivers/fpga/fpga-mgr.c | 15 +++++++++++++++ drivers/fpga/of-fpga-region.c | 13 +++++++++++++ include/linux/fpga/fpga-mgr.h | 7 +++++++ 3 files changed, 35 insertions(+) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index b85bc47c91a9..3e79ab8cc86f 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -325,6 +325,7 @@ static int fpga_mgr_firmware_load(struct fpga_manager *mgr, const char *image_name) { struct device *dev = &mgr->dev; + const struct firmware *enc_fw; const struct firmware *fw; int ret; @@ -339,8 +340,22 @@ static int fpga_mgr_firmware_load(struct fpga_manager *mgr, return ret; } + if (info->encrypted_key_name) { + ret = request_firmware(&enc_fw, info->encrypted_key_name, dev); + if (ret) { + mgr->state = FPGA_MGR_STATE_FIRMWARE_REQ_ERR; + dev_err(dev, "Error requesting firmware %s\n", + info->encrypted_key_name); + return ret; + } + info->enc_key_buf = enc_fw->data; + info->enc_key_buf_size = enc_fw->size; + } + ret = fpga_mgr_buf_load(mgr, info, fw->data, fw->size); + if (info->encrypted_key_name) + release_firmware(enc_fw); release_firmware(fw); return ret; diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c index e405309baadc..19faa463d96e 100644 --- a/drivers/fpga/of-fpga-region.c +++ b/drivers/fpga/of-fpga-region.c @@ -195,6 +195,7 @@ static struct fpga_image_info *of_fpga_region_parse_ov( { struct device *dev = ®ion->dev; struct fpga_image_info *info; + const char *encrypted_key_name; const char *firmware_name; int ret; @@ -228,6 +229,18 @@ static struct fpga_image_info *of_fpga_region_parse_ov( if (of_property_read_bool(overlay, "encrypted-fpga-config")) info->flags |= FPGA_MGR_ENCRYPTED_BITSTREAM; + if (of_property_read_bool(overlay, "encrypted-user-key-fpga-config")) { + if (!of_property_read_string(overlay, "encrypted-key-name", + &encrypted_key_name)) { + info->encrypted_key_name = + devm_kstrdup(dev, encrypted_key_name, GFP_KERNEL); + if (!info->encrypted_key_name) + return ERR_PTR(-ENOMEM); + } + + info->flags |= FPGA_MGR_ENCRYPTED_USER_KEY_BITSTREAM; + } + if (!of_property_read_string(overlay, "firmware-name", &firmware_name)) { info->firmware_name = devm_kstrdup(dev, firmware_name, diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index 2bc3030a69e5..ac86f4398c3c 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h @@ -67,12 +67,15 @@ enum fpga_mgr_states { * %FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first * * %FPGA_MGR_COMPRESSED_BITSTREAM: FPGA bitstream is compressed + * %FPGA_MGR_ENCRYPTED_USER_KEY_BITSTREAM: indicates bitstream is encrypted + * with user-key */ #define FPGA_MGR_PARTIAL_RECONFIG BIT(0) #define FPGA_MGR_EXTERNAL_CONFIG BIT(1) #define FPGA_MGR_ENCRYPTED_BITSTREAM BIT(2) #define FPGA_MGR_BITSTREAM_LSB_FIRST BIT(3) #define FPGA_MGR_COMPRESSED_BITSTREAM BIT(4) +#define FPGA_MGR_ENCRYPTED_USER_KEY_BITSTREAM BIT(5) /** * struct fpga_image_info - information specific to a FPGA image @@ -82,6 +85,7 @@ enum fpga_mgr_states { * @config_complete_timeout_us: maximum time for FPGA to switch to operating * status in the write_complete op. * @firmware_name: name of FPGA image firmware file + * @encrypted_key_name: name of the FPGA image encrypted user-key file * @sgt: scatter/gather table containing FPGA image * @buf: contiguous buffer containing FPGA image * @count: size of buf @@ -95,8 +99,11 @@ struct fpga_image_info { u32 disable_timeout_us; u32 config_complete_timeout_us; char *firmware_name; + char *encrypted_key_name; struct sg_table *sgt; + const char *enc_key_buf; const char *buf; + size_t enc_key_buf_size; size_t count; int region_id; struct device *dev; -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel