From patchwork Thu Nov 12 18:06:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Gong X-Patchwork-Id: 11900815 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 126B91391 for ; Thu, 12 Nov 2020 17:47:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC9A72085B for ; Thu, 12 Nov 2020 17:47:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726430AbgKLRr1 (ORCPT ); Thu, 12 Nov 2020 12:47:27 -0500 Received: from mga18.intel.com ([134.134.136.126]:5888 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726426AbgKLRr0 (ORCPT ); Thu, 12 Nov 2020 12:47:26 -0500 IronPort-SDR: gxJror6URQOLCCi4zraJc6B+1vRvvVEi4luDbIL3+DCklL0YTnwlq6Bc//c40JLfeuR2dwMJly pp3LGgvG6rWw== X-IronPort-AV: E=McAfee;i="6000,8403,9803"; a="158128461" X-IronPort-AV: E=Sophos;i="5.77,472,1596524400"; d="scan'208";a="158128461" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Nov 2020 09:47:25 -0800 IronPort-SDR: frS8isPJJskiIVBO+3vzhWXH+IVyBu9JlToavkLSf5RxQco4J5pYkZVITYf8aD6g/UxDSrwrFF oCPdeFM1MxIg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,472,1596524400"; d="scan'208";a="328576364" Received: from marshy.an.intel.com ([10.122.105.143]) by orsmga006.jf.intel.com with ESMTP; 12 Nov 2020 09:47:24 -0800 From: richard.gong@linux.intel.com To: mdf@kernel.org, trix@redhat.com, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dinguyen@kernel.org, sridhar.rajagopal@intel.com, richard.gong@linux.intel.com, Richard Gong Subject: [PATCHv1 1/4] fpga: fpga-mgr: add FPGA_MGR_BITSTREM_AUTHENTICATION flag Date: Thu, 12 Nov 2020 12:06:40 -0600 Message-Id: <1605204403-6663-2-git-send-email-richard.gong@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605204403-6663-1-git-send-email-richard.gong@linux.intel.com> References: <1605204403-6663-1-git-send-email-richard.gong@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Richard Gong Add FPGA_MGR_BITSTREM_AUTHENTICATION flag for FPGA bitstream authentication. Signed-off-by: Richard Gong --- include/linux/fpga/fpga-mgr.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index 2bc3030..1d65814 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_BITSTREM_AUTHENTICATION: do FPGA bitstream authentication */ #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_BITSTREM_AUTHENTICATION BIT(5) /** * struct fpga_image_info - information specific to a FPGA image From patchwork Thu Nov 12 18:06:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Gong X-Patchwork-Id: 11900843 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07B7315E6 for ; Thu, 12 Nov 2020 17:47:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D586422250 for ; Thu, 12 Nov 2020 17:47:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726455AbgKLRre (ORCPT ); Thu, 12 Nov 2020 12:47:34 -0500 Received: from mga18.intel.com ([134.134.136.126]:5888 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726394AbgKLRr2 (ORCPT ); Thu, 12 Nov 2020 12:47:28 -0500 IronPort-SDR: gINq8hxpdzFW9nbS8rQ/yqsMlsVUfZYeJWE6GfOkxSZUUD8AWbullly3K06O+0NBun6WMpnCYt V4BimN+eTRKA== X-IronPort-AV: E=McAfee;i="6000,8403,9803"; a="158128468" X-IronPort-AV: E=Sophos;i="5.77,472,1596524400"; d="scan'208";a="158128468" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Nov 2020 09:47:27 -0800 IronPort-SDR: H+MfRLfGlEk0eMJS0l2rm9JZDz1wj3ha2SB0sWXO+ZggY1lZmE3ELNSoXl+t7rG4/eU80EvgX4 Cxx2BLD4vMhA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,472,1596524400"; d="scan'208";a="328576378" Received: from marshy.an.intel.com ([10.122.105.143]) by orsmga006.jf.intel.com with ESMTP; 12 Nov 2020 09:47:26 -0800 From: richard.gong@linux.intel.com To: mdf@kernel.org, trix@redhat.com, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dinguyen@kernel.org, sridhar.rajagopal@intel.com, richard.gong@linux.intel.com, Richard Gong Subject: [PATCHv1 2/4] fpga: of-fpga-region: add authenticate-fpga-config property Date: Thu, 12 Nov 2020 12:06:41 -0600 Message-Id: <1605204403-6663-3-git-send-email-richard.gong@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605204403-6663-1-git-send-email-richard.gong@linux.intel.com> References: <1605204403-6663-1-git-send-email-richard.gong@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Richard Gong Add authenticate-fpga-config property to support FPGA bitstream authentication. Signed-off-by: Richard Gong Reviewed-by: Tom Rix --- drivers/fpga/of-fpga-region.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/fpga/of-fpga-region.c b/drivers/fpga/of-fpga-region.c index e405309..c7c6d1c 100644 --- a/drivers/fpga/of-fpga-region.c +++ b/drivers/fpga/of-fpga-region.c @@ -228,6 +228,9 @@ 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, "authenticate-fpga-config")) + info->flags |= FPGA_MGR_BITSTREM_AUTHENTICATION; + if (!of_property_read_string(overlay, "firmware-name", &firmware_name)) { info->firmware_name = devm_kstrdup(dev, firmware_name, From patchwork Thu Nov 12 18:06:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Gong X-Patchwork-Id: 11900817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BDF441391 for ; Thu, 12 Nov 2020 17:47:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A255C21D91 for ; Thu, 12 Nov 2020 17:47:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726441AbgKLRrc (ORCPT ); Thu, 12 Nov 2020 12:47:32 -0500 Received: from mga18.intel.com ([134.134.136.126]:5888 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726437AbgKLRr3 (ORCPT ); Thu, 12 Nov 2020 12:47:29 -0500 IronPort-SDR: 44Cqq88NUqnawhIlZPlrr4dA3l84Gk8tkYLCXsO0lqQzzO6AhUN2uoIyBhF7e1uMyx/g+68tZL QqMgTCKsYLgw== X-IronPort-AV: E=McAfee;i="6000,8403,9803"; a="158128476" X-IronPort-AV: E=Sophos;i="5.77,472,1596524400"; d="scan'208";a="158128476" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Nov 2020 09:47:29 -0800 IronPort-SDR: 0hhUeegefhlOfHD8NoUPRm8H0jDAx1Gg6Aho3utfqwmckB1aFGgDdGCm4HJiJxXZlTJtKvCpNS JEmOn7AxxQ1g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,472,1596524400"; d="scan'208";a="328576387" Received: from marshy.an.intel.com ([10.122.105.143]) by orsmga006.jf.intel.com with ESMTP; 12 Nov 2020 09:47:28 -0800 From: richard.gong@linux.intel.com To: mdf@kernel.org, trix@redhat.com, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dinguyen@kernel.org, sridhar.rajagopal@intel.com, richard.gong@linux.intel.com, Richard Gong Subject: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property Date: Thu, 12 Nov 2020 12:06:42 -0600 Message-Id: <1605204403-6663-4-git-send-email-richard.gong@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605204403-6663-1-git-send-email-richard.gong@linux.intel.com> References: <1605204403-6663-1-git-send-email-richard.gong@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Richard Gong Add authenticate-fpga-config property for FPGA bitstream authentication. Signed-off-by: Richard Gong --- Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/fpga/fpga-region.txt b/Documentation/devicetree/bindings/fpga/fpga-region.txt index e811cf8..7a512bc 100644 --- a/Documentation/devicetree/bindings/fpga/fpga-region.txt +++ b/Documentation/devicetree/bindings/fpga/fpga-region.txt @@ -187,6 +187,7 @@ Optional properties: - external-fpga-config : boolean, set if the FPGA has already been configured prior to OS boot up. - encrypted-fpga-config : boolean, set if the bitstream is encrypted +- authenticate-fpga-config : boolean, set if do bitstream authentication - region-unfreeze-timeout-us : The maximum time in microseconds to wait for bridges to successfully become enabled after the region has been programmed. From patchwork Thu Nov 12 18:06:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Gong X-Patchwork-Id: 11900845 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDFDD15E6 for ; Thu, 12 Nov 2020 17:47:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B549021D7F for ; Thu, 12 Nov 2020 17:47:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726483AbgKLRrn (ORCPT ); Thu, 12 Nov 2020 12:47:43 -0500 Received: from mga18.intel.com ([134.134.136.126]:5888 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbgKLRrc (ORCPT ); Thu, 12 Nov 2020 12:47:32 -0500 IronPort-SDR: L2Cy4M26uLEx+dd9H2e1J5zKZwO+4rkEX68jWy0Cl+klbFHDjVX6h+Blelfc0ECY00b4J13MDO ScCT2a813TAw== X-IronPort-AV: E=McAfee;i="6000,8403,9803"; a="158128483" X-IronPort-AV: E=Sophos;i="5.77,472,1596524400"; d="scan'208";a="158128483" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Nov 2020 09:47:32 -0800 IronPort-SDR: NbEprrJmNWrSQpq/a12O87/g3d+3K21XcPJd9XyUZkc3zEEI4V6rxP7Nf12yJKTyHVOA/0r18L gar8+Y74G7rA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,472,1596524400"; d="scan'208";a="328576399" Received: from marshy.an.intel.com ([10.122.105.143]) by orsmga006.jf.intel.com with ESMTP; 12 Nov 2020 09:47:31 -0800 From: richard.gong@linux.intel.com To: mdf@kernel.org, trix@redhat.com, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dinguyen@kernel.org, sridhar.rajagopal@intel.com, richard.gong@linux.intel.com, Richard Gong Subject: [PATCHv1 4/4] fpga: stratix10-soc: entend driver for bitstream authentication Date: Thu, 12 Nov 2020 12:06:43 -0600 Message-Id: <1605204403-6663-5-git-send-email-richard.gong@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605204403-6663-1-git-send-email-richard.gong@linux.intel.com> References: <1605204403-6663-1-git-send-email-richard.gong@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Richard Gong Exten FPGA manager driver to support FPGA bitstream authentication on Intel SocFPGA platforms. Signed-off-by: Richard Gong --- drivers/fpga/stratix10-soc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c index 657a70c..8a59365 100644 --- a/drivers/fpga/stratix10-soc.c +++ b/drivers/fpga/stratix10-soc.c @@ -185,7 +185,10 @@ static int s10_ops_write_init(struct fpga_manager *mgr, ctype.flags = 0; if (info->flags & FPGA_MGR_PARTIAL_RECONFIG) { dev_dbg(dev, "Requesting partial reconfiguration.\n"); - ctype.flags |= BIT(COMMAND_RECONFIG_FLAG_PARTIAL); + ctype.flags |= FPGA_MGR_PARTIAL_RECONFIG; + } else if (info->flags & FPGA_MGR_BITSTREM_AUTHENTICATION) { + dev_dbg(dev, "Requesting bitstream authentication.\n"); + ctype.flags |= FPGA_MGR_BITSTREM_AUTHENTICATION; } else { dev_dbg(dev, "Requesting full reconfiguration.\n"); }