]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
image: fit: Align hash output buffers
authorSean Anderson <sean.anderson@seco.com>
Thu, 24 Mar 2022 15:26:11 +0000 (11:26 -0400)
committerTom Rini <trini@konsulko.com>
Mon, 11 Apr 2022 15:39:19 +0000 (11:39 -0400)
Hardware-accelerated hash functions require that the input and output
buffers be aligned to the minimum DMA alignment. memalign.h helpfully
provides a macro just for this purpose. It doesn't exist on the host,
but we don't need to be aligned there either.

Fixes: 5dfb521386 ("[new uImage] New uImage low-level API")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
boot/image-fit.c
tools/mkimage.h

index f01cafe4e2777dec24ef47087b5ce8a611df7f92..6610035d0ad1338010bac2cba1066df848943dd9 100644 (file)
@@ -24,6 +24,7 @@
 #include <mapmem.h>
 #include <asm/io.h>
 #include <malloc.h>
+#include <memalign.h>
 #include <asm/global_data.h>
 #ifdef CONFIG_DM_HASH
 #include <dm.h>
@@ -1263,7 +1264,8 @@ int calculate_hash(const void *data, int data_len, const char *name,
 static int fit_image_check_hash(const void *fit, int noffset, const void *data,
                                size_t size, char **err_msgp)
 {
-       uint8_t value[FIT_MAX_HASH_LEN];
+       DEFINE_ALIGN_BUFFER(uint8_t, value, FIT_MAX_HASH_LEN,
+                           ARCH_DMA_MINALIGN);
        int value_len;
        const char *algo;
        uint8_t *fit_value;
index 0d3148444c3f878d20e98fab851cccd54cea41d9..7652c8b001c3f335115e6e0ccf7e02d3f97bf50e 100644 (file)
@@ -41,6 +41,9 @@ static inline ulong map_to_sysmem(void *ptr)
        return (ulong)(uintptr_t)ptr;
 }
 
+#define ARCH_DMA_MINALIGN 1
+#define DEFINE_ALIGN_BUFFER(type, name, size, alugn) type name[size]
+
 #define MKIMAGE_TMPFILE_SUFFIX         ".tmp"
 #define MKIMAGE_MAX_TMPFILE_LEN                256
 #define MKIMAGE_DEFAULT_DTC_OPTIONS    "-I dts -O dtb -p 500"