Message ID | 20231122054404.3764288-2-nava.kishore.manne@amd.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | fpga: Add encrypted Bitstream loading support | expand |
On Wed, Nov 22, 2023 at 11:14:02AM +0530, Nava kishore Manne wrote: > Adds ‘encrypted-key-name’ property to support user-key encrypted > bitstream loading use case. > > Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com> > --- > .../devicetree/bindings/fpga/fpga-region.txt | 32 +++++++++++++++++++ Is there a reason that this has not yet been converted to yaml? > 1 file changed, 32 insertions(+) > > diff --git a/Documentation/devicetree/bindings/fpga/fpga-region.txt b/Documentation/devicetree/bindings/fpga/fpga-region.txt > index 528df8a0e6d8..309334558b3f 100644 > --- a/Documentation/devicetree/bindings/fpga/fpga-region.txt > +++ b/Documentation/devicetree/bindings/fpga/fpga-region.txt > @@ -177,6 +177,9 @@ Optional properties: > it indicates that the FPGA has already been programmed with this image. > If this property is in an overlay targeting an FPGA region, it is a > request to program the FPGA with that image. > +- encrypted-key-name : should contain the name of an encrypted key file located > + on the firmware search path. It will be used to decrypt the FPGA image > + file with user-key. I might be misreading things, but your driver code seems to assume that this is an aes key. Nothing here seems to document that this is supposed to be a key of a particular type. Cheers, Conor. > - fpga-bridges : should contain a list of phandles to FPGA Bridges that must be > controlled during FPGA programming along with the parent FPGA bridge. > This property is optional if the FPGA Manager handles the bridges. > @@ -459,6 +462,35 @@ programming is the FPGA based bridge of fpga_region1. > }; > }; > > +Device Tree Example: Configure/Reconfigure Encrypted Image With User Key > +======================================================================== > + > +Users can encrypt FPGA configuration Images with their own key. While decrypting > +the configuration Image the user needs to provide the same key. > +"encrypted-key-name" Specifies the name of the FPGA image encrypted key file on > +the firmware search path. The search path is described in the firmware class > +documentation. > + > +/dts-v1/; > +/plugin/; > + > +&fpga_region0 { > + #address-cells = <1>; > + #size-cells = <1>; > + > + firmware-name = "soc_image2.rbf"; > + encrypted-key-name = "key.nky"; > + > + gpio@10040 { > + compatible = "altr,pio-1.0"; > + reg = <0x10040 0x20>; > + clocks = <0x2>; > + altr,ngpio = <0x4>; > + #gpio-cells = <0x2>; > + gpio-controller; > + }; > +}; > + > Constraints > =========== > > -- > 2.25.1 >
Hi Conor, Thanks for providing the review comments. Please find my response inline. > -----Original Message----- > From: Conor Dooley <conor@kernel.org> > Sent: Wednesday, November 22, 2023 10:21 PM > To: Manne, Nava kishore <nava.kishore.manne@amd.com> > Cc: mdf@kernel.org; hao.wu@intel.com; yilun.xu@intel.com; > trix@redhat.com; robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; > conor+dt@kernel.org; Simek, Michal <michal.simek@amd.com>; > mathieu.poirier@linaro.org; Levinsky, Ben <ben.levinsky@amd.com>; > Potthuri, Sai Krishna <sai.krishna.potthuri@amd.com>; Shah, Tanmay > <tanmay.shah@amd.com>; dhaval.r.shah@amd.com; arnd@arndb.de; > Datta, Shubhrajyoti <shubhrajyoti.datta@amd.com>; linux- > fpga@vger.kernel.org; devicetree@vger.kernel.org; linux- > kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org > Subject: Re: [RFC PATCH 1/3] dt-bindings: fpga: Add support for user-key > encrypted bitstream loading > > On Wed, Nov 22, 2023 at 11:14:02AM +0530, Nava kishore Manne wrote: > > Adds ‘encrypted-key-name’ property to support user-key encrypted > > bitstream loading use case. > > > > Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com> > > --- > > .../devicetree/bindings/fpga/fpga-region.txt | 32 > > +++++++++++++++++++ > > Is there a reason that this has not yet been converted to yaml? > I am not sure about the complication involved here why it's not converted to yaml format. Due to time constraints, I couldn’t spend much time so I have used this existing legacy format to add my changes. > > 1 file changed, 32 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/fpga/fpga-region.txt > > b/Documentation/devicetree/bindings/fpga/fpga-region.txt > > index 528df8a0e6d8..309334558b3f 100644 > > --- a/Documentation/devicetree/bindings/fpga/fpga-region.txt > > +++ b/Documentation/devicetree/bindings/fpga/fpga-region.txt > > @@ -177,6 +177,9 @@ Optional properties: > > it indicates that the FPGA has already been programmed with this > image. > > If this property is in an overlay targeting an FPGA region, it is a > > request to program the FPGA with that image. > > +- encrypted-key-name : should contain the name of an encrypted key file > located > > + on the firmware search path. It will be used to decrypt the FPGA > image > > + file with user-key. > > I might be misreading things, but your driver code seems to assume that this > is an aes key. Nothing here seems to document that this is supposed to be a > key of a particular type. > Yes, these changes are intended to add the support for Aes user-key encrypted bitstream loading use case. Will fix it in v2, something like below. aes-key-file-name : Should contain the AES key file name on the firmware search path. The key file contains the AES key and it will be used to decrypt the FPGA image. Regards, Navakishore.
On Fri, Nov 24, 2023 at 06:35:19AM +0000, Manne, Nava kishore wrote: > Hi Conor, > > Thanks for providing the review comments. > Please find my response inline. > > > -----Original Message----- > > From: Conor Dooley <conor@kernel.org> > > Sent: Wednesday, November 22, 2023 10:21 PM > > To: Manne, Nava kishore <nava.kishore.manne@amd.com> > > Cc: mdf@kernel.org; hao.wu@intel.com; yilun.xu@intel.com; > > trix@redhat.com; robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; > > conor+dt@kernel.org; Simek, Michal <michal.simek@amd.com>; > > mathieu.poirier@linaro.org; Levinsky, Ben <ben.levinsky@amd.com>; > > Potthuri, Sai Krishna <sai.krishna.potthuri@amd.com>; Shah, Tanmay > > <tanmay.shah@amd.com>; dhaval.r.shah@amd.com; arnd@arndb.de; > > Datta, Shubhrajyoti <shubhrajyoti.datta@amd.com>; linux- > > fpga@vger.kernel.org; devicetree@vger.kernel.org; linux- > > kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org > > Subject: Re: [RFC PATCH 1/3] dt-bindings: fpga: Add support for user-key > > encrypted bitstream loading > > > > On Wed, Nov 22, 2023 at 11:14:02AM +0530, Nava kishore Manne wrote: > > > Adds ‘encrypted-key-name’ property to support user-key encrypted > > > bitstream loading use case. > > > > > > Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com> > > > --- > > > .../devicetree/bindings/fpga/fpga-region.txt | 32 > > > +++++++++++++++++++ > > > > Is there a reason that this has not yet been converted to yaml? > > > I am not sure about the complication involved here why it's not converted to yaml format. > Due to time constraints, I couldn’t spend much time so I have used this existing legacy format > to add my changes. > > > > 1 file changed, 32 insertions(+) > > > > > > diff --git a/Documentation/devicetree/bindings/fpga/fpga-region.txt > > > b/Documentation/devicetree/bindings/fpga/fpga-region.txt > > > index 528df8a0e6d8..309334558b3f 100644 > > > --- a/Documentation/devicetree/bindings/fpga/fpga-region.txt > > > +++ b/Documentation/devicetree/bindings/fpga/fpga-region.txt > > > @@ -177,6 +177,9 @@ Optional properties: > > > it indicates that the FPGA has already been programmed with this > > image. > > > If this property is in an overlay targeting an FPGA region, it is a > > > request to program the FPGA with that image. > > > +- encrypted-key-name : should contain the name of an encrypted key file > > located > > > + on the firmware search path. It will be used to decrypt the FPGA > > image > > > + file with user-key. > > > > I might be misreading things, but your driver code seems to assume that this > > is an aes key. Nothing here seems to document that this is supposed to be a > > key of a particular type. > > > > Yes, these changes are intended to add the support for Aes user-key encrypted bitstream loading use case. > Will fix it in v2, something like below. > aes-key-file-name : Should contain the AES key file name on the firmware search path. > The key file contains the AES key and it will be used to decrypt the FPGA image. Then when someone comes along looking for a different type of encryption we will end up with national-pride-foo-file-name etc. I think I'd rather have a second property that notes what type of cipher is being used and if that property is not present default to AES.
On 24/11/2023 13:48, Conor Dooley wrote: > On Fri, Nov 24, 2023 at 06:35:19AM +0000, Manne, Nava kishore wrote: >> Hi Conor, >> >> Thanks for providing the review comments. >> Please find my response inline. >> >>> -----Original Message----- >>> From: Conor Dooley <conor@kernel.org> >>> Sent: Wednesday, November 22, 2023 10:21 PM >>> To: Manne, Nava kishore <nava.kishore.manne@amd.com> >>> Cc: mdf@kernel.org; hao.wu@intel.com; yilun.xu@intel.com; >>> trix@redhat.com; robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; >>> conor+dt@kernel.org; Simek, Michal <michal.simek@amd.com>; >>> mathieu.poirier@linaro.org; Levinsky, Ben <ben.levinsky@amd.com>; >>> Potthuri, Sai Krishna <sai.krishna.potthuri@amd.com>; Shah, Tanmay >>> <tanmay.shah@amd.com>; dhaval.r.shah@amd.com; arnd@arndb.de; >>> Datta, Shubhrajyoti <shubhrajyoti.datta@amd.com>; linux- >>> fpga@vger.kernel.org; devicetree@vger.kernel.org; linux- >>> kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org >>> Subject: Re: [RFC PATCH 1/3] dt-bindings: fpga: Add support for user-key >>> encrypted bitstream loading >>> >>> On Wed, Nov 22, 2023 at 11:14:02AM +0530, Nava kishore Manne wrote: >>>> Adds ‘encrypted-key-name’ property to support user-key encrypted >>>> bitstream loading use case. >>>> >>>> Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com> >>>> --- >>>> .../devicetree/bindings/fpga/fpga-region.txt | 32 >>>> +++++++++++++++++++ >>> >>> Is there a reason that this has not yet been converted to yaml? >>> >> I am not sure about the complication involved here why it's not converted to yaml format. >> Due to time constraints, I couldn’t spend much time so I have used this existing legacy format >> to add my changes. >> >>>> 1 file changed, 32 insertions(+) >>>> >>>> diff --git a/Documentation/devicetree/bindings/fpga/fpga-region.txt >>>> b/Documentation/devicetree/bindings/fpga/fpga-region.txt >>>> index 528df8a0e6d8..309334558b3f 100644 >>>> --- a/Documentation/devicetree/bindings/fpga/fpga-region.txt >>>> +++ b/Documentation/devicetree/bindings/fpga/fpga-region.txt >>>> @@ -177,6 +177,9 @@ Optional properties: >>>> it indicates that the FPGA has already been programmed with this >>> image. >>>> If this property is in an overlay targeting an FPGA region, it is a >>>> request to program the FPGA with that image. >>>> +- encrypted-key-name : should contain the name of an encrypted key file >>> located >>>> + on the firmware search path. It will be used to decrypt the FPGA >>> image >>>> + file with user-key. >>> >>> I might be misreading things, but your driver code seems to assume that this >>> is an aes key. Nothing here seems to document that this is supposed to be a >>> key of a particular type. >>> >> >> Yes, these changes are intended to add the support for Aes user-key encrypted bitstream loading use case. >> Will fix it in v2, something like below. >> aes-key-file-name : Should contain the AES key file name on the firmware search path. >> The key file contains the AES key and it will be used to decrypt the FPGA image. > > Then when someone comes along looking for a different type of encryption > we will end up with national-pride-foo-file-name etc. I think I'd rather > have a second property that notes what type of cipher is being used and > if that property is not present default to AES. I wonder why does it need to be in DT in the first place? Why it cannot be appended to the FPGA binary image itself? Which also points to dubious security aspect of this approach... Shipping FPGA encrypted image with its decryption key sounds like marvelous idea. Even if this is suitable, why not using more arguments of firmware-name? This would scale even for multiple FPGA firmwares with different keys (although such need seems unlikely). Best regards, Krzysztof
On Fri, Nov 24, 2023 at 04:46:06PM +0100, Krzysztof Kozlowski wrote: > On 24/11/2023 13:48, Conor Dooley wrote: > > On Fri, Nov 24, 2023 at 06:35:19AM +0000, Manne, Nava kishore wrote: > >> Hi Conor, > >> > >> Thanks for providing the review comments. > >> Please find my response inline. > >> > >>> -----Original Message----- > >>> From: Conor Dooley <conor@kernel.org> > >>> Sent: Wednesday, November 22, 2023 10:21 PM > >>> To: Manne, Nava kishore <nava.kishore.manne@amd.com> > >>> Cc: mdf@kernel.org; hao.wu@intel.com; yilun.xu@intel.com; > >>> trix@redhat.com; robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; > >>> conor+dt@kernel.org; Simek, Michal <michal.simek@amd.com>; > >>> mathieu.poirier@linaro.org; Levinsky, Ben <ben.levinsky@amd.com>; > >>> Potthuri, Sai Krishna <sai.krishna.potthuri@amd.com>; Shah, Tanmay > >>> <tanmay.shah@amd.com>; dhaval.r.shah@amd.com; arnd@arndb.de; > >>> Datta, Shubhrajyoti <shubhrajyoti.datta@amd.com>; linux- > >>> fpga@vger.kernel.org; devicetree@vger.kernel.org; linux- > >>> kernel@vger.kernel.org; linux-arm-kernel@lists.infradead.org > >>> Subject: Re: [RFC PATCH 1/3] dt-bindings: fpga: Add support for user-key > >>> encrypted bitstream loading > >>> > >>> On Wed, Nov 22, 2023 at 11:14:02AM +0530, Nava kishore Manne wrote: > >>>> Adds ‘encrypted-key-name’ property to support user-key encrypted > >>>> bitstream loading use case. > >>>> > >>>> Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com> > >>>> --- > >>>> .../devicetree/bindings/fpga/fpga-region.txt | 32 > >>>> +++++++++++++++++++ > >>> > >>> Is there a reason that this has not yet been converted to yaml? > >>> > >> I am not sure about the complication involved here why it's not converted to yaml format. > >> Due to time constraints, I couldn’t spend much time so I have used this existing legacy format > >> to add my changes. > >> > >>>> 1 file changed, 32 insertions(+) > >>>> > >>>> diff --git a/Documentation/devicetree/bindings/fpga/fpga-region.txt > >>>> b/Documentation/devicetree/bindings/fpga/fpga-region.txt > >>>> index 528df8a0e6d8..309334558b3f 100644 > >>>> --- a/Documentation/devicetree/bindings/fpga/fpga-region.txt > >>>> +++ b/Documentation/devicetree/bindings/fpga/fpga-region.txt > >>>> @@ -177,6 +177,9 @@ Optional properties: > >>>> it indicates that the FPGA has already been programmed with this > >>> image. > >>>> If this property is in an overlay targeting an FPGA region, it is a > >>>> request to program the FPGA with that image. > >>>> +- encrypted-key-name : should contain the name of an encrypted key file > >>> located > >>>> + on the firmware search path. It will be used to decrypt the FPGA > >>> image > >>>> + file with user-key. > >>> > >>> I might be misreading things, but your driver code seems to assume that this > >>> is an aes key. Nothing here seems to document that this is supposed to be a > >>> key of a particular type. > >>> > >> > >> Yes, these changes are intended to add the support for Aes user-key encrypted bitstream loading use case. > >> Will fix it in v2, something like below. > >> aes-key-file-name : Should contain the AES key file name on the firmware search path. > >> The key file contains the AES key and it will be used to decrypt the FPGA image. > > > > Then when someone comes along looking for a different type of encryption > > we will end up with national-pride-foo-file-name etc. I think I'd rather > > have a second property that notes what type of cipher is being used and > > if that property is not present default to AES. > > I wonder why does it need to be in DT in the first place? Why it cannot > be appended to the FPGA binary image itself? Which also points to > dubious security aspect of this approach... Shipping FPGA encrypted > image with its decryption key sounds like marvelous idea. > > Even if this is suitable, why not using more arguments of firmware-name? > This would scale even for multiple FPGA firmwares with different keys > (although such need seems unlikely). In case it is not clear (given the month's delay here), this question is for the submitter of the series to answer, not me. Cheers, Conor.
diff --git a/Documentation/devicetree/bindings/fpga/fpga-region.txt b/Documentation/devicetree/bindings/fpga/fpga-region.txt index 528df8a0e6d8..309334558b3f 100644 --- a/Documentation/devicetree/bindings/fpga/fpga-region.txt +++ b/Documentation/devicetree/bindings/fpga/fpga-region.txt @@ -177,6 +177,9 @@ Optional properties: it indicates that the FPGA has already been programmed with this image. If this property is in an overlay targeting an FPGA region, it is a request to program the FPGA with that image. +- encrypted-key-name : should contain the name of an encrypted key file located + on the firmware search path. It will be used to decrypt the FPGA image + file with user-key. - fpga-bridges : should contain a list of phandles to FPGA Bridges that must be controlled during FPGA programming along with the parent FPGA bridge. This property is optional if the FPGA Manager handles the bridges. @@ -459,6 +462,35 @@ programming is the FPGA based bridge of fpga_region1. }; }; +Device Tree Example: Configure/Reconfigure Encrypted Image With User Key +======================================================================== + +Users can encrypt FPGA configuration Images with their own key. While decrypting +the configuration Image the user needs to provide the same key. +"encrypted-key-name" Specifies the name of the FPGA image encrypted key file on +the firmware search path. The search path is described in the firmware class +documentation. + +/dts-v1/; +/plugin/; + +&fpga_region0 { + #address-cells = <1>; + #size-cells = <1>; + + firmware-name = "soc_image2.rbf"; + encrypted-key-name = "key.nky"; + + gpio@10040 { + compatible = "altr,pio-1.0"; + reg = <0x10040 0x20>; + clocks = <0x2>; + altr,ngpio = <0x4>; + #gpio-cells = <0x2>; + gpio-controller; + }; +}; + Constraints ===========
Adds ‘encrypted-key-name’ property to support user-key encrypted bitstream loading use case. Signed-off-by: Nava kishore Manne <nava.kishore.manne@amd.com> --- .../devicetree/bindings/fpga/fpga-region.txt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+)