Skip to contentSkip to conversation

boot/image-board.c: boot_get_fpga(): pass compatible flag to fpga_load()

PATCH Applied Peter Korsgaard 2 participants 2 messages Nov 5, 2024 – Nov 8, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 boot/image-board.c: boot_get_fpga(): pass compatible flag to fpga_load()

For E.G. signed FPGA bitstreams, similar to how it is done for the FPGA loading from SPL since commit 71f1a5392aad ("spl: fit: pass real compatible flags to fpga_load()").

---
Changes since v1:
- Reference correct SPL commit

 boot/image-board.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
boot/image-board.c +13 -3
index 1757e5816d8..b726bd6b303 100644
@@ -624,9 +624,10 @@ int boot_get_fpga(struct bootm_headers *images)
 	void *buf;
 	int conf_noffset;
 	int fit_img_result;
-	const char *uname, *name;
+	const char *uname, *name, *compatible;
 	int err;
 	int devnum = 0; /* TODO support multi fpga platforms */
+	int flags = 0;
 
 	if (!IS_ENABLED(CONFIG_FPGA))
 		return -ENOSYS;
@@ -674,20 +675,29 @@ int boot_get_fpga(struct bootm_headers *images)
 			return fit_img_result;
 		}
 
+		conf_noffset = fit_image_get_node(buf, uname);
+		compatible = fdt_getprop(buf, conf_noffset, "compatible", NULL);
+		if (!compatible) {
+			printf("'fpga' image without 'compatible' property\n");
+		} else {
+			if (CONFIG_IS_ENABLED(FPGA_LOAD_SECURE))
+				flags = fpga_compatible2flag(devnum, compatible);
+		}
+
 		if (!fpga_is_partial_data(devnum, img_len)) {
 			name = "full";
 			err = fpga_loadbitstream(devnum, (char *)img_data,
 						 img_len, BIT_FULL);
 			if (err)
 				err = fpga_load(devnum, (const void *)img_data,
-						img_len, BIT_FULL, 0);
+						img_len, BIT_FULL, flags);
 		} else {
 			name = "partial";
 			err = fpga_loadbitstream(devnum, (char *)img_data,
 						 img_len, BIT_PARTIAL);
 			if (err)
 				err = fpga_load(devnum, (const void *)img_data,
-						img_len, BIT_PARTIAL, 0);
+						img_len, BIT_PARTIAL, flags);
 		}
 
 		if (err)
Signature · 1 line
2.39.5
Applied
#1 lore raw
Quoted 50 lines · Peter Korsgaard

For E.G. signed FPGA bitstreams, similar to how it is done for the FPGA loading from SPL since commit 71f1a5392aad ("spl: fit: pass real compatible flags to fpga_load()").

---
Changes since v1:
- Reference correct SPL commit

  boot/image-board.c | 16 +++++++++++++---
  1 file changed, 13 insertions(+), 3 deletions(-)
boot/image-board.c +12 -2
index 1757e5816d8..b726bd6b303 100644
@@ -624,9 +624,10 @@ int boot_get_fpga(struct bootm_headers *images)
  	void *buf;
  	int conf_noffset;
  	int fit_img_result;
-	const char *uname, *name;
+	const char *uname, *name, *compatible;
  	int err;
  	int devnum = 0; /* TODO support multi fpga platforms */
+	int flags = 0;
 
  	if (!IS_ENABLED(CONFIG_FPGA))
  		return -ENOSYS;
@@ -674,20 +675,29 @@ int boot_get_fpga(struct bootm_headers *images)
  			return fit_img_result;
  		}
 
+		conf_noffset = fit_image_get_node(buf, uname);
+		compatible = fdt_getprop(buf, conf_noffset, "compatible", NULL);
+		if (!compatible) {
+			printf("'fpga' image without 'compatible' property\n");
+		} else {
+			if (CONFIG_IS_ENABLED(FPGA_LOAD_SECURE))
+				flags = fpga_compatible2flag(devnum, compatible);
+		}
+
  		if (!fpga_is_partial_data(devnum, img_len)) {
  			name = "full";
  			err = fpga_loadbitstream(devnum, (char *)img_data,
  						 img_len, BIT_FULL);
  			if (err)
  				err = fpga_load(devnum, (const void *)img_data,
-						img_len, BIT_FULL, 0);
+						img_len, BIT_FULL, flags);
  		} else {

boot/image-board.c int boot_get_fpga(struct bootm_headers *images) · line 703

Quoted 10 lines
boot/image-board.c +1 -1
  			name = "partial";
  			err = fpga_loadbitstream(devnum, (char *)img_data,
  						 img_len, BIT_PARTIAL);
  			if (err)
  				err = fpga_load(devnum, (const void *)img_data,
-						img_len, BIT_PARTIAL, 0);
+						img_len, BIT_PARTIAL, flags);
  		}
 
  		if (err)

Applied.
M