Skip to content

Commit b583348

Browse files
sean-anderson-secotrini
authored andcommitted
image: fit: Align hash output buffers
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: 5dfb521 ("[new uImage] New uImage low-level API") Signed-off-by: Sean Anderson <[email protected]> Reviewed-by: Simon Glass <[email protected]>
1 parent e6fe02a commit b583348

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

boot/image-fit.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <mapmem.h>
2525
#include <asm/io.h>
2626
#include <malloc.h>
27+
#include <memalign.h>
2728
#include <asm/global_data.h>
2829
#ifdef CONFIG_DM_HASH
2930
#include <dm.h>
@@ -1263,7 +1264,8 @@ int calculate_hash(const void *data, int data_len, const char *name,
12631264
static int fit_image_check_hash(const void *fit, int noffset, const void *data,
12641265
size_t size, char **err_msgp)
12651266
{
1266-
uint8_t value[FIT_MAX_HASH_LEN];
1267+
DEFINE_ALIGN_BUFFER(uint8_t, value, FIT_MAX_HASH_LEN,
1268+
ARCH_DMA_MINALIGN);
12671269
int value_len;
12681270
const char *algo;
12691271
uint8_t *fit_value;

tools/mkimage.h

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ static inline ulong map_to_sysmem(void *ptr)
4141
return (ulong)(uintptr_t)ptr;
4242
}
4343

44+
#define ARCH_DMA_MINALIGN 1
45+
#define DEFINE_ALIGN_BUFFER(type, name, size, alugn) type name[size]
46+
4447
#define MKIMAGE_TMPFILE_SUFFIX ".tmp"
4548
#define MKIMAGE_MAX_TMPFILE_LEN 256
4649
#define MKIMAGE_DEFAULT_DTC_OPTIONS "-I dts -O dtb -p 500"

0 commit comments

Comments
 (0)