Skip to contentSkip to conversation

Extend FPGA manager and region drivers for

PATCH In review [email protected] 4 participants 30 messages Nov 12, 2020 – Nov 19, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Extend FPGA manager and region drivers for

From: Richard Gong <[email protected]>

The customer wants to verify that a FPGA bitstream can be started properly before saving the bitstream to the QSPI flash memory.

The customer sends the bitstream via FPGA framework and overlay, the firmware will authenticate the bitstream but not program the bitstream to device. If the authentication passes, the bitstream will be programmed into QSPI flash and will be expected to boot without issues.

Extend FPGA manager and region drivers to support the bitstream authentication feature.

Richard Gong (4):
fpga: fpga-mgr: add FPGA_MGR_BITSTREM_AUTHENTICATION flag
fpga: of-fpga-region: add authenticate-fpga-config property
dt-bindings: fpga: add authenticate-fpga-config property
fpga: stratix10-soc: entend driver for bitstream authentication

 Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
 drivers/fpga/of-fpga-region.c                          | 3 +++
 drivers/fpga/stratix10-soc.c                           | 5 ++++-
 include/linux/fpga/fpga-mgr.h                          | 3 +++
 4 files changed, 11 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/4 fpga: fpga-mgr: add FPGA_MGR_BITSTREM_AUTHENTICATION flag

From: Richard Gong <[email protected]>

Add FPGA_MGR_BITSTREM_AUTHENTICATION flag for FPGA bitstream authentication.

---
 include/linux/fpga/fpga-mgr.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/fpga/fpga-mgr.h +3 -0
index 2bc3030..1d65814 100644
@@ -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
Signature · 1 line
2.7.4
reviewer
#2 lore raw

Re: [PATCHv1 1/4] fpga: fpga-mgr: add FPGA_MGR_BITSTREM_AUTHENTICATION flag

Quoted 4 lines · On 11/12/20 10:06 AM, [email protected] wrote:

From: Richard Gong <[email protected]>

Add FPGA_MGR_BITSTREM_AUTHENTICATION flag for FPGA bitstream authentication.

Should improve this commit so explain what you mean authentication.

it could mean 'it wrote correctly' or 'it was signed correctly' or something else.

Quoted 13 lines
---
 include/linux/fpga/fpga-mgr.h | 3 +++
 1 file changed, 3 insertions(+)
include/linux/fpga/fpga-mgr.h +0 -0
index 2bc3030..1d65814 100644
@@ -67,12 +67,15 @@ enum fpga_mgr_states {
  * %FPGA_MGR_BITSTREAM_LSB_FIRST: SPI bitstream bit order is LSB first
  *

include/linux/fpga/fpga-mgr.h enum fpga_mgr_states { · line 78

Quoted 10 lines
include/linux/fpga/fpga-mgr.h +3 -0
  * %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)

A whitespace issue, the new BIT(5) should align with the others, so add two spaces to the others.

Tom

Quoted 3 lines
include/linux/fpga/fpga-mgr.h +0 -0
 /**
  * struct fpga_image_info - information specific to a FPGA image
#3 lore raw

Re: [PATCHv1 1/4] fpga: fpga-mgr: add FPGA_MGR_BITSTREM_AUTHENTICATION flag

Hi Tom,

Thanks for review!

Quoted 11 lines · Tom Rix
Quoted 4 lines · On 11/12/20 10:06 AM, [email protected] wrote:

From: Richard Gong <[email protected]>

Add FPGA_MGR_BITSTREM_AUTHENTICATION flag for FPGA bitstream authentication.

Should improve this commit so explain what you mean authentication.

it could mean 'it wrote correctly' or 'it was signed correctly' or something else.

Authentication = make sure a signed bitstream has valid signatures before committing it to QSPI memory. I will update the commit messages in version 2.

Quoted 17 lines
Quoted 17 lines
---
  include/linux/fpga/fpga-mgr.h | 3 +++
  1 file changed, 3 insertions(+)
include/linux/fpga/fpga-mgr.h +2 -0
index 2bc3030..1d65814 100644
@@ -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
   */
Quoted 9 lines

include/linux/fpga/fpga-mgr.h enum fpga_mgr_states { · line 78

Quoted 6 lines
include/linux/fpga/fpga-mgr.h +1 -0
  #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)

A whitespace issue, the new BIT(5) should align with the others, so add two spaces to the others.

There is only one space, also I ran checkpatch with strict option and didn't see any whitespace issue.

In the original patch, BIT(0) to BIT(4) align themselves. I am not sure why we see differently in email.

 #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)

To align BIT(5) with others, I have to use additional tab to BIT(0) to BIT(4). But I don't think I should make such change on them, agree?

Regards,
Richard

Quoted 6 lines

Tom

Quoted 3 lines
include/linux/fpga/fpga-mgr.h +0 -0
  /**
   * struct fpga_image_info - information specific to a FPGA image
reviewer
#4 lore raw

Re: [PATCHv1 1/4] fpga: fpga-mgr: add FPGA_MGR_BITSTREM_AUTHENTICATION flag

Quoted 8 lines · Richard Gong
Quoted 3 lines

A whitespace issue, the new BIT(5) should align with the others, so add two spaces to the others.

There is only one space, also I ran checkpatch with strict option and didn't see any whitespace issue.

In the original patch, BIT(0) to BIT(4) align themselves. I am not sure why we see differently in email.

Quoted 8 lines

 #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)

To align BIT(5) with others, I have to use additional tab to BIT(0) to BIT(4). But I don't think I should make such change on them, agree?

The existing table of #defines has aligned values for BIT(0) to BIT(4)

Your addition of BIT(5) value has an inconsistent alignment with the others BIT(0) to BIT(4)

The alignment of all the values should be consistent.

Tom

Quoted 10 lines

Regards,
Richard

Quoted 5 lines

Tom

Quoted 2 lines

    /**
   * struct fpga_image_info - information specific to a FPGA image

#5 lore raw

Re: [PATCHv1 1/4] fpga: fpga-mgr: add FPGA_MGR_BITSTREM_AUTHENTICATION flag

Hi Tom,

Quoted 17 lines · Tom Rix
Quoted 15 lines · Richard Gong
Quoted 3 lines

A whitespace issue, the new BIT(5) should align with the others, so add two spaces to the others.

There is only one space, also I ran checkpatch with strict option and didn't see any whitespace issue.

In the original patch, BIT(0) to BIT(4) align themselves. I am not sure why we see differently in email.

 #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)

Quoted 8 lines
Quoted 1 line

To align BIT(5) with others, I have to use additional tab to BIT(0) to BIT(4). But I don't think I should make such change on them, agree?

The existing table of #defines has aligned values for BIT(0) to BIT(4)

Your addition of BIT(5) value has an inconsistent alignment with the others BIT(0) to BIT(4)

The alignment of all the values should be consistent.

OK, I will make them all aligned.

Regards,
Richard

Quoted 13 lines

Tom

Quoted 10 lines

Regards,
Richard

Quoted 5 lines

Tom

Quoted 2 lines

    /**
   * struct fpga_image_info - information specific to a FPGA image

#6 lore raw

PATCH 2/4 fpga: of-fpga-region: add authenticate-fpga-config property

In reply to [email protected]

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property to support FPGA bitstream authentication.

---
 drivers/fpga/of-fpga-region.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/fpga/of-fpga-region.c +3 -0
index e405309..c7c6d1c 100644
@@ -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,
Signature · 1 line
2.7.4
reviewer Reviewed-by on v1 2/4
#7 lore raw

Re: [PATCHv1 2/4] fpga: of-fpga-region: add authenticate-fpga-config property

Quoted 15 lines · On 11/12/20 10:06 AM, [email protected] wrote:

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property to support FPGA bitstream authentication.

---
 drivers/fpga/of-fpga-region.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/fpga/of-fpga-region.c +0 -0
index e405309..c7c6d1c 100644

drivers/fpga/of-fpga-region.c static struct fpga_image_info *of_fpga_region_parse_ov( · line 236

Quoted 9 lines
drivers/fpga/of-fpga-region.c +3 -0
@@ -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,

This looks fine.

#8 lore raw

PATCH 3/4 dt-bindings: fpga: add authenticate-fpga-config property

In reply to [email protected]

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property for FPGA bitstream authentication.

---
 Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +1 -0
index e811cf8..7a512bc 100644
@@ -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.
Signature · 1 line
2.7.4
reviewer
#9 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

Quoted 14 lines · On 11/12/20 10:06 AM, [email protected] wrote:

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property for FPGA bitstream authentication.

---
 Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
index e811cf8..7a512bc 100644

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 190

Quoted 4 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +1 -0
@@ -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

The list is mostly in alphabetical order so the new 'authenticate-... ' should go at the top.

Improve what you mean by 'authentication' similar to my comment in the first patch.

Tom

Quoted 3 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
 - region-unfreeze-timeout-us : The maximum time in microseconds to wait for
 	bridges to successfully become enabled after the region has been
 	programmed.
#10 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

Hi Tom,

Quoted 11 lines · Tom Rix
Quoted 9 lines · On 11/12/20 10:06 AM, [email protected] wrote:

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property for FPGA bitstream authentication.

---
  Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
  1 file changed, 1 insertion(+)
Quoted 12 lines

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 190

Quoted 9 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +1 -0
index e811cf8..7a512bc 100644
@@ -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

The list is mostly in alphabetical order so the new 'authenticate-... ' should go at the top.

The original list is not in alphabetical order. The order of partial-fpga-config, external-fpga-config and encrypted-fpga-config here follows the implementation in the of-fpga-region.c file.

So authenticate-fpga-config should follow the way, correct?

Quoted 2 lines

Improve what you mean by 'authentication' similar to my comment in the first patch.

Will do in the version 2 submission.

Regards,
Richard

Quoted 6 lines

Tom

Quoted 3 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
  - region-unfreeze-timeout-us : The maximum time in microseconds to wait for
  	bridges to successfully become enabled after the region has been
  	programmed.
reviewer
#11 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

Quoted 6 lines · Richard Gong

Hi Tom,

Quoted 4 lines
Quoted 3 lines

      prior to OS boot up.
  - encrypted-fpga-config : boolean, set if the bitstream is encrypted +- authenticate-fpga-config : boolean, set if do bitstream authentication

Quoted 7 lines
Quoted 2 lines

The list is mostly in alphabetical order so the new 'authenticate-... ' should go at the top.

The original list is not in alphabetical order. The order of partial-fpga-config, external-fpga-config and encrypted-fpga-config here follows the implementation in the of-fpga-region.c file.

So authenticate-fpga-config should follow the way, correct?

This is why i say 'mostly' ..

In general when listing options for a user to read, you should make it easy for them to find

the option they are looking for.  Ordering them alphabetically is an obvious but not the only

way.  I am not asking for you to fix the whole table, just what you are adding. If there is

a better way to organize them please propose the method.

Tom

Quoted 15 lines
Quoted 2 lines

Improve what you mean by 'authentication' similar to my comment in the first patch.

Will do in the version 2 submission.

Regards,
Richard

Quoted 6 lines

Tom

Quoted 3 lines

  - region-unfreeze-timeout-us : The maximum time in microseconds to wait for bridges to successfully become enabled after the region has been programmed.

#12 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

Hi Tom,

Quoted 17 lines · Tom Rix
Quoted 6 lines · Richard Gong

Hi Tom,

Quoted 4 lines
Quoted 3 lines

      prior to OS boot up.
  - encrypted-fpga-config : boolean, set if the bitstream is encrypted
+- authenticate-fpga-config : boolean, set if do bitstream authentication

Quoted 7 lines
Quoted 2 lines

The list is mostly in alphabetical order so the new 'authenticate-... ' should go at the top.

The original list is not in alphabetical order. The order of partial-fpga-config, external-fpga-config and encrypted-fpga-config here follows the implementation in the of-fpga-region.c file.

So authenticate-fpga-config should follow the way, correct?

This is why i say 'mostly' ..

Quoted 8 lines

In general when listing options for a user to read, you should make it easy for them to find

the option they are looking for.  Ordering them alphabetically is an obvious but not the only

way.  I am not asking for you to fix the whole table, just what you are adding. If there is

a better way to organize them please propose the method.

How about put authenticate-fpga-config above partial-fpga-config? I would like to group all xxx-fpga-config flags together.

Regards,
Richard

Quoted 18 lines

Tom

Quoted 15 lines
Quoted 2 lines

Improve what you mean by 'authentication' similar to my comment in the first patch.

Will do in the version 2 submission.

Regards,
Richard

Quoted 6 lines

Tom

Quoted 3 lines

  - region-unfreeze-timeout-us : The maximum time in microseconds to wait for bridges to successfully become enabled after the region has been programmed.

reviewer
#13 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

Quoted 23 lines · Richard Gong

Hi Tom,

Quoted 19 lines · Tom Rix
Quoted 6 lines · Richard Gong

Hi Tom,

Quoted 4 lines
Quoted 3 lines

       prior to OS boot up.
   - encrypted-fpga-config : boolean, set if the bitstream is encrypted +- authenticate-fpga-config : boolean, set if do bitstream authentication

Quoted 7 lines
Quoted 2 lines

The list is mostly in alphabetical order so the new 'authenticate-... ' should go at the top.

The original list is not in alphabetical order. The order of partial-fpga-config, external-fpga-config and encrypted-fpga-config here follows the implementation in the of-fpga-region.c file.

So authenticate-fpga-config should follow the way, correct?

This is why i say 'mostly' ..

In general when listing options for a user to read, you should make it easy for them to find

Quoted 8 lines
Quoted 6 lines

the option they are looking for.  Ordering them alphabetically is an obvious but not the only

way.  I am not asking for you to fix the whole table, just what you are adding. If there is

a better way to organize them please propose the method.

How about put authenticate-fpga-config above partial-fpga-config? I would like to group all xxx-fpga-config flags together.

Ok that sounds fine.

Tom

Quoted 24 lines

Regards,
Richard

Quoted 18 lines

Tom

Quoted 15 lines
Quoted 2 lines

Improve what you mean by 'authentication' similar to my comment in the first patch.

Will do in the version 2 submission.

Regards,
Richard

Quoted 6 lines

Tom

Quoted 3 lines

   - region-unfreeze-timeout-us : The maximum time in microseconds to wait for bridges to successfully become enabled after the region has been programmed.

maintainer
#14 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

In reply to [email protected]

Hi Richard,

Quoted 14 lines · On Thu, Nov 12, 2020 at 12:06:42PM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property for FPGA bitstream authentication.

---
 Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
index e811cf8..7a512bc 100644

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 190

Quoted 4 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +1 -0
@@ -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

It is unclear to me from the description whether this entails authentication + reconfiguration or just authentication.

If the latter is the case this should probably be described as such.

Quoted 6 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
 - region-unfreeze-timeout-us : The maximum time in microseconds to wait for
 	bridges to successfully become enabled after the region has been
 	programmed.
Signature · 1 line
2.7.4

Thanks

maintainer
#15 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

Quoted 24 lines · Moritz Fischer

Hi Richard,

Quoted 14 lines · On Thu, Nov 12, 2020 at 12:06:42PM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property for FPGA bitstream authentication.

---
 Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
index e811cf8..7a512bc 100644

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 190

Quoted 4 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +1 -0
@@ -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

It is unclear to me from the description whether this entails authentication + reconfiguration or just authentication.

Quoted 1 line

If the latter is the case this should probably be described as such.

If it is just authentication, do we still need to disable bridges in fpga_region_program_fpga?

I'm wondering if the FPGA functionalities could still be working when the authenticating is ongoing, or when the authenticating is failed.

Thanks,
Yilun

Quoted 9 lines
Quoted 7 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
 - region-unfreeze-timeout-us : The maximum time in microseconds to wait for
 	bridges to successfully become enabled after the region has been
 	programmed.
Signature · 1 line
2.7.4

Thanks

#16 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

Hi Yilun,

Quoted 25 lines · Xu Yilun
Quoted 24 lines · Moritz Fischer

Hi Richard,

Quoted 14 lines · On Thu, Nov 12, 2020 at 12:06:42PM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property for FPGA bitstream authentication.

---
  Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
  1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
index e811cf8..7a512bc 100644

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 190

Quoted 4 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +1 -0
@@ -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

It is unclear to me from the description whether this entails authentication + reconfiguration or just authentication.

Quoted 5 lines
Quoted 1 line

If the latter is the case this should probably be described as such.

If it is just authentication, do we still need to disable bridges in fpga_region_program_fpga?

Yes.

Except for the actual configuration of the device, the authentication feature is the same as FPGA configuration.

Regards,
Richard

Quoted 18 lines

I'm wondering if the FPGA functionalities could still be working when the authenticating is ongoing, or when the authenticating is failed.

Thanks,
Yilun

Quoted 9 lines
Quoted 7 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
  - region-unfreeze-timeout-us : The maximum time in microseconds to wait for
  	bridges to successfully become enabled after the region has been
  	programmed.
Signature · 1 line
2.7.4

Thanks

maintainer
#17 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

Quoted 31 lines · Richard Gong

Hi Yilun,

Quoted 27 lines · Xu Yilun
Quoted 25 lines · Moritz Fischer

Hi Richard,

Quoted 14 lines · On Thu, Nov 12, 2020 at 12:06:42PM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property for FPGA bitstream authentication.

---
 Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
index e811cf8..7a512bc 100644

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 190

Quoted 4 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +1 -0
@@ -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

It is unclear to me from the description whether this entails authentication + reconfiguration or just authentication.

If the latter is the case this should probably be described as such.

Quoted 8 lines
Quoted 3 lines

If it is just authentication, do we still need to disable bridges in fpga_region_program_fpga?

Yes.

Except for the actual configuration of the device, the authentication feature is the same as FPGA configuration.

FPGA Bridges gate bus signals between a host and FPGA. So the FPGA region could not be accessed by host when doing configuration. But for this authentication, we are just writing the flash, we don't actually touch the FPGA soft logic. The host should still be able to operate on the old logic before reboot, is it?

Thanks,
Yilun

Quoted 22 lines

Regards,
Richard

Quoted 18 lines

I'm wondering if the FPGA functionalities could still be working when the authenticating is ongoing, or when the authenticating is failed.

Thanks,
Yilun

Quoted 9 lines
Quoted 7 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
 - region-unfreeze-timeout-us : The maximum time in microseconds to wait for
 	bridges to successfully become enabled after the region has been
 	programmed.
Signature · 1 line
2.7.4

Thanks

#18 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

Quoted 38 lines · Xu Yilun
Quoted 37 lines · Richard Gong

Hi Yilun,

Quoted 25 lines · Xu Yilun
Quoted 24 lines · Moritz Fischer

Hi Richard,

Quoted 14 lines · On Thu, Nov 12, 2020 at 12:06:42PM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property for FPGA bitstream authentication.

---
  Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
  1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
index e811cf8..7a512bc 100644

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 190

Quoted 4 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +1 -0
@@ -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

It is unclear to me from the description whether this entails authentication + reconfiguration or just authentication.

Quoted 5 lines
Quoted 1 line

If the latter is the case this should probably be described as such.

If it is just authentication, do we still need to disable bridges in fpga_region_program_fpga?

Yes.

Quoted 9 lines
Quoted 2 lines

Except for the actual configuration of the device, the authentication feature is the same as FPGA configuration.

FPGA Bridges gate bus signals between a host and FPGA. So the FPGA region could not be accessed by host when doing configuration. But for this authentication, we are just writing the flash, we don't actually touch the FPGA soft logic. The host should still be able to operate on the old logic before reboot, is it?

Yes, it's feasible in theory but doesn't make much sense in practice. I prefer to keep fpga_region_program_fpga() unchanged.

Regards,
Richard

Quoted 25 lines

Thanks,
Yilun

Quoted 22 lines

Regards,
Richard

Quoted 18 lines

I'm wondering if the FPGA functionalities could still be working when the authenticating is ongoing, or when the authenticating is failed.

Thanks,
Yilun

Quoted 9 lines
Quoted 7 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
  - region-unfreeze-timeout-us : The maximum time in microseconds to wait for
  	bridges to successfully become enabled after the region has been
  	programmed.
Signature · 1 line
2.7.4

Thanks

maintainer
#19 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

Quoted 44 lines · Richard Gong
Quoted 41 lines · Xu Yilun
Quoted 39 lines · Richard Gong

Hi Yilun,

Quoted 25 lines · Xu Yilun
Quoted 24 lines · Moritz Fischer

Hi Richard,

Quoted 14 lines · On Thu, Nov 12, 2020 at 12:06:42PM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property for FPGA bitstream authentication.

---
 Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
index e811cf8..7a512bc 100644

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 190

Quoted 4 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +1 -0
@@ -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

It is unclear to me from the description whether this entails authentication + reconfiguration or just authentication.

Quoted 5 lines
Quoted 1 line

If the latter is the case this should probably be described as such.

If it is just authentication, do we still need to disable bridges in fpga_region_program_fpga?

Yes.

Except for the actual configuration of the device, the authentication feature is the same as FPGA configuration.

Quoted 8 lines
Quoted 6 lines

FPGA Bridges gate bus signals between a host and FPGA. So the FPGA region could not be accessed by host when doing configuration. But for this authentication, we are just writing the flash, we don't actually touch the FPGA soft logic. The host should still be able to operate on the old logic before reboot, is it?

Yes, it's feasible in theory but doesn't make much sense in practice. I prefer to keep fpga_region_program_fpga() unchanged.

I'm thinking of the case of inband reprograming, that the QSPI flash controller itself is embedded in FPGA soft logic, then maybe host still need to access FPGA on authentication.

Thanks,
Yilun

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

I'm wondering if the FPGA functionalities could still be working when the authenticating is ongoing, or when the authenticating is failed.

Thanks,
Yilun

Quoted 9 lines
Quoted 7 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
 - region-unfreeze-timeout-us : The maximum time in microseconds to wait for
 	bridges to successfully become enabled after the region has been
 	programmed.
Signature · 1 line
2.7.4

Thanks

#20 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

Quoted 51 lines · Xu Yilun
Quoted 50 lines · Richard Gong
Quoted 47 lines · Xu Yilun
Quoted 31 lines · Richard Gong

Hi Yilun,

Quoted 27 lines · Xu Yilun
Quoted 25 lines · Moritz Fischer

Hi Richard,

Quoted 14 lines · On Thu, Nov 12, 2020 at 12:06:42PM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property for FPGA bitstream authentication.

---
  Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
  1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
index e811cf8..7a512bc 100644

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 190

Quoted 4 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +1 -0
@@ -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

It is unclear to me from the description whether this entails authentication + reconfiguration or just authentication.

If the latter is the case this should probably be described as such.

Quoted 8 lines
Quoted 3 lines

If it is just authentication, do we still need to disable bridges in fpga_region_program_fpga?

Yes.

Except for the actual configuration of the device, the authentication feature is the same as FPGA configuration.

FPGA Bridges gate bus signals between a host and FPGA. So the FPGA region could not be accessed by host when doing configuration. But for this authentication, we are just writing the flash, we don't actually touch the FPGA soft logic. The host should still be able to operate on the old logic before reboot, is it?

Quoted 6 lines
Quoted 2 lines

Yes, it's feasible in theory but doesn't make much sense in practice. I prefer to keep fpga_region_program_fpga() unchanged.

I'm thinking of the case of inband reprograming, that the QSPI flash controller itself is embedded in FPGA soft logic, then maybe host still need to access FPGA on authentication.

We can decide whether we should update fpga_region_program_fpga() function when you update for inband reprogramming case.

Regards,
Richard

Quoted 23 lines

Thanks,
Yilun

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

I'm wondering if the FPGA functionalities could still be working when the authenticating is ongoing, or when the authenticating is failed.

Thanks,
Yilun

Quoted 9 lines
Quoted 7 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
  - region-unfreeze-timeout-us : The maximum time in microseconds to wait for
  	bridges to successfully become enabled after the region has been
  	programmed.
Signature · 1 line
2.7.4

Thanks

maintainer
#21 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

Quoted 57 lines · Richard Gong
Quoted 54 lines · Xu Yilun
Quoted 52 lines · Richard Gong
Quoted 38 lines · Xu Yilun
Quoted 37 lines · Richard Gong

Hi Yilun,

Quoted 25 lines · Xu Yilun
Quoted 24 lines · Moritz Fischer

Hi Richard,

Quoted 14 lines · On Thu, Nov 12, 2020 at 12:06:42PM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property for FPGA bitstream authentication.

---
 Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
index e811cf8..7a512bc 100644

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 190

Quoted 4 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +1 -0
@@ -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

It is unclear to me from the description whether this entails authentication + reconfiguration or just authentication.

Quoted 5 lines
Quoted 1 line

If the latter is the case this should probably be described as such.

If it is just authentication, do we still need to disable bridges in fpga_region_program_fpga?

Yes.

Quoted 9 lines
Quoted 2 lines

Except for the actual configuration of the device, the authentication feature is the same as FPGA configuration.

FPGA Bridges gate bus signals between a host and FPGA. So the FPGA region could not be accessed by host when doing configuration. But for this authentication, we are just writing the flash, we don't actually touch the FPGA soft logic. The host should still be able to operate on the old logic before reboot, is it?

Yes, it's feasible in theory but doesn't make much sense in practice. I prefer to keep fpga_region_program_fpga() unchanged.

Quoted 6 lines
Quoted 3 lines

I'm thinking of the case of inband reprograming, that the QSPI flash controller itself is embedded in FPGA soft logic, then maybe host still need to access FPGA on authentication.

We can decide whether we should update fpga_region_program_fpga() function when you update for inband reprogramming case.

Sure, we could think about it later.

Thanks,
Yilun

Quoted 26 lines

Regards,
Richard

Quoted 23 lines

Thanks,
Yilun

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

I'm wondering if the FPGA functionalities could still be working when the authenticating is ongoing, or when the authenticating is failed.

Thanks,
Yilun

Quoted 9 lines
Quoted 7 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
 - region-unfreeze-timeout-us : The maximum time in microseconds to wait for
 	bridges to successfully become enabled after the region has been
 	programmed.
Signature · 1 line
2.7.4

Thanks

#22 lore raw

Re: [PATCHv1 3/4] dt-bindings: fpga: add authenticate-fpga-config property

In reply to Moritz Fischer

Hi Moritz,

Quoted 24 lines · Moritz Fischer

Hi Richard,

Quoted 14 lines · On Thu, Nov 12, 2020 at 12:06:42PM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Add authenticate-fpga-config property for FPGA bitstream authentication.

---
  Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
  1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
index e811cf8..7a512bc 100644

Documentation/devicetree/bindings/fpga/fpga-region.txt Optional properties: · line 190

Quoted 4 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +1 -0
@@ -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

It is unclear to me from the description whether this entails authentication + reconfiguration or just authentication.

Quoted 1 line

If the latter is the case this should probably be described as such.

It is for authentication only, just make the signed bitstream has the valid signatures.

Regards,
Richard

Quoted 10 lines
Quoted 7 lines
Documentation/devicetree/bindings/fpga/fpga-region.txt +0 -0
  - region-unfreeze-timeout-us : The maximum time in microseconds to wait for
  	bridges to successfully become enabled after the region has been
  	programmed.
Signature · 1 line
2.7.4

Thanks

#23 lore raw

PATCH 4/4 fpga: stratix10-soc: entend driver for bitstream authentication

In reply to [email protected]

From: Richard Gong <[email protected]>

Exten FPGA manager driver to support FPGA bitstream authentication on Intel SocFPGA platforms.

---
 drivers/fpga/stratix10-soc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/fpga/stratix10-soc.c +4 -1
index 657a70c..8a59365 100644
@@ -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");
 	}
Signature · 1 line
2.7.4
reviewer
#24 lore raw

Re: [PATCHv1 4/4] fpga: stratix10-soc: entend driver for bitstream authentication

Quoted 15 lines · On 11/12/20 10:06 AM, [email protected] wrote:

From: Richard Gong <[email protected]>

Exten FPGA manager driver to support FPGA bitstream authentication on Intel SocFPGA platforms.

---
 drivers/fpga/stratix10-soc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/fpga/stratix10-soc.c +0 -0
index 657a70c..8a59365 100644

drivers/fpga/stratix10-soc.c static int s10_ops_write_init(struct fpga_manager *mgr, · line 188

Quoted 5 lines
drivers/fpga/stratix10-soc.c +1 -1
@@ -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;

The change does not match the commit log.

Add some comment like..

'Cleanup setting of partial reconfig flag'

to cover the change.

Tom

Quoted 6 lines
drivers/fpga/stratix10-soc.c +3 -0
+	} 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");
 	}
#25 lore raw

Re: [PATCHv1 4/4] fpga: stratix10-soc: entend driver for bitstream authentication

Hi Tom.

Quoted 25 lines · Tom Rix
Quoted 15 lines · On 11/12/20 10:06 AM, [email protected] wrote:

From: Richard Gong <[email protected]>

Exten FPGA manager driver to support FPGA bitstream authentication on Intel SocFPGA platforms.

---
  drivers/fpga/stratix10-soc.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/fpga/stratix10-soc.c +0 -0
index 657a70c..8a59365 100644

drivers/fpga/stratix10-soc.c static int s10_ops_write_init(struct fpga_manager *mgr, · line 188

Quoted 5 lines
drivers/fpga/stratix10-soc.c +1 -1
@@ -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;

The change does not match the commit log.

Quoted 5 lines

Add some comment like..

'Cleanup setting of partial reconfig flag'

to cover the change.

I will make the cleanup change separately in a different patch.

Regards,
Richard

Quoted 10 lines

Tom

Quoted 6 lines
drivers/fpga/stratix10-soc.c +3 -0
+	} 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");
  	}
maintainer
#26 lore raw

Re: [PATCHv1 4/4] fpga: stratix10-soc: entend driver for bitstream authentication

In reply to [email protected]
Quoted 3 lines · On Thu, Nov 12, 2020 at 12:06:43PM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Exten FPGA manager driver to support FPGA bitstream authentication on

Nit: Extend

Quoted 12 lines

Intel SocFPGA platforms.

---
 drivers/fpga/stratix10-soc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/fpga/stratix10-soc.c +0 -0
index 657a70c..8a59365 100644

drivers/fpga/stratix10-soc.c static int s10_ops_write_init(struct fpga_manager *mgr, · line 188

Quoted 5 lines
drivers/fpga/stratix10-soc.c +1 -1
@@ -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;

I think we had this discussion during the original review of the stratix10-soc driver?

Wasn't the point of using the BIT() to not assume alignment of FPGA_MGR flags and firmware structure?

The FPGA_MGR_* bits are kernel internal and can therefore change, it would be unfortunate to end up in a situation where this breaks the FW interface (assuming firmware uses the value in pass-through which it looks like is what is happening).

drivers/fpga/stratix10-soc.c static int s10_ops_write_init(struct fpga_manager *mgr, · line 191

Quoted 3 lines
drivers/fpga/stratix10-soc.c +3 -0
+	} else if (info->flags & FPGA_MGR_BITSTREM_AUTHENTICATION) {
+		dev_dbg(dev, "Requesting bitstream authentication.\n");
+		ctype.flags |= FPGA_MGR_BITSTREM_AUTHENTICATION;

Do you want to change this to BIT(COMMAND_AUTHENTICATE_BITSTREAM) or something like that?

Quoted 6 lines
drivers/fpga/stratix10-soc.c +0 -0
 	} else {
 		dev_dbg(dev, "Requesting full reconfiguration.\n");
 	}
Signature · 1 line
2.7.4

Thanks,
Moritz

#27 lore raw

Re: [PATCHv1 4/4] fpga: stratix10-soc: entend driver for bitstream authentication

Hi Moritz,

Quoted 5 lines · Moritz Fischer
Quoted 3 lines · On Thu, Nov 12, 2020 at 12:06:43PM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

Exten FPGA manager driver to support FPGA bitstream authentication on

Nit: Extend

Sorry, I will fix that in version 2.

Quoted 7 lines
Quoted 7 lines

Intel SocFPGA platforms.

---
  drivers/fpga/stratix10-soc.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
Quoted 12 lines

drivers/fpga/stratix10-soc.c static int s10_ops_write_init(struct fpga_manager *mgr, · line 188

Quoted 10 lines
drivers/fpga/stratix10-soc.c +1 -1
index 657a70c..8a59365 100644
@@ -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;

I think we had this discussion during the original review of the stratix10-soc driver?

Yes, we discussed before.

Quoted 4 lines

Wasn't the point of using the BIT() to not assume alignment of FPGA_MGR flags and firmware structure?

Yes, we should use BIT().

Quoted 4 lines

The FPGA_MGR_* bits are kernel internal and can therefore change, it would be unfortunate to end up in a situation where this breaks the FW interface (assuming firmware uses the value in pass-through which it looks like is what is happening).

In that case, I should use the flag defined in stratix10-soc driver driver.

Quoted 6 lines

drivers/fpga/stratix10-soc.c static int s10_ops_write_init(struct fpga_manager *mgr, · line 191

Quoted 4 lines
drivers/fpga/stratix10-soc.c +3 -0
+	} else if (info->flags & FPGA_MGR_BITSTREM_AUTHENTICATION) {
+		dev_dbg(dev, "Requesting bitstream authentication.\n");
+		ctype.flags |= FPGA_MGR_BITSTREM_AUTHENTICATION;

Do you want to change this to BIT(COMMAND_AUTHENTICATE_BITSTREAM) or something like that?

OK, I will change to BIT(COMMAND_AUTHENTICATE_BITSTREAM).

Regards,
Richard

Quoted 10 lines
Quoted 6 lines
drivers/fpga/stratix10-soc.c +0 -0
  	} else {
  		dev_dbg(dev, "Requesting full reconfiguration.\n");
  	}
Signature · 1 line
2.7.4

Thanks,
Moritz

maintainer
#28 lore raw
In reply to [email protected]
Quoted 9 lines · On Thu, Nov 12, 2020 at 12:06:39PM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

The customer wants to verify that a FPGA bitstream can be started properly before saving the bitstream to the QSPI flash memory.

The customer sends the bitstream via FPGA framework and overlay, the firmware will authenticate the bitstream but not program the bitstream to device. If the authentication passes, the bitstream will be programmed into QSPI flash and will be expected to boot without issues.

So when we have successfully reprogramed region with the FPGA_MGR_BITSTREM_AUTHENTICATION flag, the bitstream in QSPI flash is updated but not activated, we need an FPGA reboot to activate it, is it?

Thanks,
Yilun

Quoted 18 lines

Extend FPGA manager and region drivers to support the bitstream authentication feature.

Richard Gong (4):
fpga: fpga-mgr: add FPGA_MGR_BITSTREM_AUTHENTICATION flag
fpga: of-fpga-region: add authenticate-fpga-config property
dt-bindings: fpga: add authenticate-fpga-config property
fpga: stratix10-soc: entend driver for bitstream authentication

 Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
 drivers/fpga/of-fpga-region.c                          | 3 +++
 drivers/fpga/stratix10-soc.c                           | 5 ++++-
 include/linux/fpga/fpga-mgr.h                          | 3 +++
 4 files changed, 11 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#29 lore raw

Hi Yilun,

Quoted 6 lines · Xu Yilun
Quoted 5 lines · On Thu, Nov 12, 2020 at 12:06:39PM -0600, [email protected] wrote:

From: Richard Gong <[email protected]>

The customer wants to verify that a FPGA bitstream can be started properly before saving the bitstream to the QSPI flash memory.

Quoted 9 lines
Quoted 4 lines

The customer sends the bitstream via FPGA framework and overlay, the firmware will authenticate the bitstream but not program the bitstream to device. If the authentication passes, the bitstream will be programmed into QSPI flash and will be expected to boot without issues.

So when we have successfully reprogramed region with the FPGA_MGR_BITSTREM_AUTHENTICATION flag, the bitstream in QSPI flash is updated but not activated, we need an FPGA reboot to activate it, is it?

Correct. If the authentication passes, the bitstream will be programmed into QSPI flash and will be expected to boot without issues.

Quoted 21 lines

Thanks,
Yilun

Quoted 18 lines

Extend FPGA manager and region drivers to support the bitstream authentication feature.

Richard Gong (4):
fpga: fpga-mgr: add FPGA_MGR_BITSTREM_AUTHENTICATION flag
fpga: of-fpga-region: add authenticate-fpga-config property
dt-bindings: fpga: add authenticate-fpga-config property
fpga: stratix10-soc: entend driver for bitstream authentication

  Documentation/devicetree/bindings/fpga/fpga-region.txt | 1 +
  drivers/fpga/of-fpga-region.c                          | 3 +++
  drivers/fpga/stratix10-soc.c                           | 5 ++++-
  include/linux/fpga/fpga-mgr.h                          | 3 +++
  4 files changed, 11 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4