Skip to contentSkip to conversation

xilinx: zynqmp: Fix AES with a user provided key

PATCH Applied Janne Ylalehto 2 participants 2 messages Aug 16, 2022 – Aug 23, 2022 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xilinx: zynqmp: Fix AES with a user provided key

The user provided key address was not flushed in struct aes because of the flushing location in the function.

---

 board/xilinx/zynqmp/cmds.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
board/xilinx/zynqmp/cmds.c +3 -3
index 2ab9596248..e20030ecda 100644
@@ -142,9 +142,6 @@ static int do_zynqmp_aes(struct cmd_tbl *cmdtp, int flag, int argc,
 	aes->keysrc = hextoul(argv[6], NULL);
 	aes->dstaddr = hextoul(argv[7], NULL);
 
-	flush_dcache_range((ulong)aes, (ulong)(aes) +
-			   roundup(sizeof(struct aes), ARCH_DMA_MINALIGN));
-
 	if (aes->srcaddr && aes->ivaddr && aes->dstaddr) {
 		flush_dcache_range(aes->srcaddr,
 				   (aes->srcaddr +
@@ -169,6 +166,9 @@ static int do_zynqmp_aes(struct cmd_tbl *cmdtp, int flag, int argc,
 						    ARCH_DMA_MINALIGN)));
 	}
 
+	flush_dcache_range((ulong)aes, (ulong)(aes) +
+			   roundup(sizeof(struct aes), ARCH_DMA_MINALIGN));
+
 	ret = xilinx_pm_request(PM_SECURE_AES, upper_32_bits((ulong)aes),
 				lower_32_bits((ulong)aes), 0, 0, ret_payload);
 	if (ret || ret_payload[1])
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 24 lines · Janne Ylalehto

The user provided key address was not flushed in struct aes because of the flushing location in the function.

---

  board/xilinx/zynqmp/cmds.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
board/xilinx/zynqmp/cmds.c +0 -3
index 2ab9596248..e20030ecda 100644
@@ -142,9 +142,6 @@ static int do_zynqmp_aes(struct cmd_tbl *cmdtp, int flag, int argc,
  	aes->keysrc = hextoul(argv[6], NULL);
  	aes->dstaddr = hextoul(argv[7], NULL);
 
-	flush_dcache_range((ulong)aes, (ulong)(aes) +
-			   roundup(sizeof(struct aes), ARCH_DMA_MINALIGN));
-
  	if (aes->srcaddr && aes->ivaddr && aes->dstaddr) {
  		flush_dcache_range(aes->srcaddr,
  				   (aes->srcaddr +

board/xilinx/zynqmp/cmds.c static int do_zynqmp_aes(struct cmd_tbl *cmdtp, int flag, int argc, · line 174

Quoted 9 lines
board/xilinx/zynqmp/cmds.c +3 -0
@@ -169,6 +166,9 @@ static int do_zynqmp_aes(struct cmd_tbl *cmdtp, int flag, int argc,
  						    ARCH_DMA_MINALIGN)));
  	}
 
+	flush_dcache_range((ulong)aes, (ulong)(aes) +
+			   roundup(sizeof(struct aes), ARCH_DMA_MINALIGN));
+
  	ret = xilinx_pm_request(PM_SECURE_AES, upper_32_bits((ulong)aes),
  				lower_32_bits((ulong)aes), 0, 0, ret_payload);
  	if (ret || ret_payload[1])

Applied.
M