Skip to contentSkip to conversation

fpga: zynqmppl: fix fpga loads command for unencrypted use case

PATCH Applied Neal Frager 3 participants 3 messages Feb 14, 2023 – Feb 16, 2023

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

PATCH 1/1 fpga: zynqmppl: fix fpga loads command for unencrypted use case

When using the fpga loads command, the driver is passing the AES encryption key address is all cases. However, for the authenticated, but not encrypted use case, there is no AES encryption key, and this value is 0.

When AES encryption is not used on the fpga bitstream, the pmufw assumes that the AES key address is a bitstream size value like what is used by the unsecure fpga load command.

To fix the problem, this patch checks to see if the AES key address is zero. If the AES key address is zero, it means that AES is not being used on the bitstream and the bitstream size should be passed instead. Thus, matching the fpga load functionality.

---
 drivers/fpga/zynqmppl.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/fpga/zynqmppl.c +9 -3
index 6b394869db..718c04b22c 100644
@@ -278,10 +278,16 @@ static int zynqmp_loads(xilinx_desc *desc, const void *buf, size_t bsize,
 	buf_lo = lower_32_bits((ulong)buf);
 	buf_hi = upper_32_bits((ulong)buf);
 
-	ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo,
+	if ((u32)(uintptr_t)fpga_sec_info->userkey_addr)
+		ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo,
 				buf_hi,
-			 (u32)(uintptr_t)fpga_sec_info->userkey_addr,
-			 flag, ret_payload);
+				(u32)(uintptr_t)fpga_sec_info->userkey_addr,
+				flag, ret_payload);
+	else
+		ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo,
+					buf_hi, (u32)bsize, 
+					flag, ret_payload);
+
 	if (ret)
 		puts("PL FPGA LOAD fail\n");
 	else
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw

Thanks,
Ashok

Quoted 57 lines

-----Original Message-----
From: Neal Frager <[email protected]>
Sent: Tuesday, February 14, 2023 6:50 PM
To: [email protected]; git-dev (AMD-Xilinx) <[email protected]>
Cc: Simek, Michal <[email protected]>; Soma, Ashok Reddy <[email protected]>; Manne, Nava kishore <[email protected]>; Erkiaga Elorza, Ibai <ibai.erkiaga- [email protected]>; Frager, Neal <[email protected]>
Subject: [PATCH v1 1/1] fpga: zynqmppl: fix fpga loads command for unencrypted use case

When using the fpga loads command, the driver is passing the AES encryption key address is all cases. However, for the authenticated, but not encrypted use case, there is no AES encryption key, and this value is 0.

When AES encryption is not used on the fpga bitstream, the pmufw assumes that the AES key address is a bitstream size value like what is used by the unsecure fpga load command.

To fix the problem, this patch checks to see if the AES key address is zero. If the AES key address is zero, it means that AES is not being used on the bitstream and the bitstream size should be passed instead. Thus, matching the fpga load functionality.

---
 drivers/fpga/zynqmppl.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/fpga/zynqmppl.c index renamed from drivers/fpga/zynqmppl.c +0 -0

6b394869db..718c04b22c 100644

drivers/fpga/zynqmppl.c +9 -3
@@ -278,10 +278,16 @@ static int zynqmp_loads(xilinx_desc *desc, const
 void *buf, size_t bsize,
 	buf_lo = lower_32_bits((ulong)buf);
 	buf_hi = upper_32_bits((ulong)buf);
 
-	ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo,
+	if ((u32)(uintptr_t)fpga_sec_info->userkey_addr)
+		ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo,
 				buf_hi,
-			 (u32)(uintptr_t)fpga_sec_info->userkey_addr,
-			 flag, ret_payload);
+				(u32)(uintptr_t)fpga_sec_info-
 >userkey_addr,
+				flag, ret_payload);
+	else
+		ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo,
+					buf_hi, (u32)bsize,
+					flag, ret_payload);
+
 	if (ret)
drivers/fpga/zynqmppl.c +0 -1
 		puts("PL FPGA LOAD fail\n");
 	else
--

2.17.1

maintainer Applied
#2 lore raw
In reply to Neal Frager
Quoted 32 lines · Neal Frager

When using the fpga loads command, the driver is passing the AES encryption key address is all cases. However, for the authenticated, but not encrypted use case, there is no AES encryption key, and this value is 0.

When AES encryption is not used on the fpga bitstream, the pmufw assumes that the AES key address is a bitstream size value like what is used by the unsecure fpga load command.

To fix the problem, this patch checks to see if the AES key address is zero. If the AES key address is zero, it means that AES is not being used on the bitstream and the bitstream size should be passed instead. Thus, matching the fpga load functionality.

---
  drivers/fpga/zynqmppl.c | 12 +++++++++---
  1 file changed, 9 insertions(+), 3 deletions(-)
drivers/fpga/zynqmppl.c +2 -3
index 6b394869db..718c04b22c 100644
@@ -278,10 +278,16 @@ static int zynqmp_loads(xilinx_desc *desc, const void *buf, size_t bsize,
  	buf_lo = lower_32_bits((ulong)buf);
  	buf_hi = upper_32_bits((ulong)buf);
 
-	ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo,
+	if ((u32)(uintptr_t)fpga_sec_info->userkey_addr)
+		ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo,
  				buf_hi,
-			 (u32)(uintptr_t)fpga_sec_info->userkey_addr,
-			 flag, ret_payload);

drivers/fpga/zynqmppl.c static int zynqmp_loads(xilinx_desc *desc, const void *buf, size_t bsize, · line 293

Quoted 10 lines
drivers/fpga/zynqmppl.c +7 -0
+				(u32)(uintptr_t)fpga_sec_info->userkey_addr,
+				flag, ret_payload);
+	else
+		ret = xilinx_pm_request(PM_FPGA_LOAD, buf_lo,
+					buf_hi, (u32)bsize,
+					flag, ret_payload);
+
  	if (ret)
  		puts("PL FPGA LOAD fail\n");
  	else

applied.
M