xilinx: zynqmp: Fix AES with a user provided key
authorJanne Ylalehto <ylalehto@gmail.com>
Tue, 16 Aug 2022 12:45:25 +0000 (15:45 +0300)
committerMichal Simek <michal.simek@amd.com>
Mon, 12 Sep 2022 10:03:17 +0000 (12:03 +0200)
The user provided key address was not flushed in struct aes because of
the flushing location in the function.

Signed-off-by: Janne Ylalehto <ylalehto@gmail.com>
Link: https://lore.kernel.org/r/20220816124525.19671-1-ylalehto@gmail.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
board/xilinx/zynqmp/cmds.c

index 2ab9596248c04d71388396b02cf93e5da50da696..e20030ecda790297f05184db7ae80918c0f24eb8 100644 (file)
@@ -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])