The current alignment of 4 bytes is too low. Access to 64-bit data via ldrd/strd requires at least an eight byte alignment: | Prior to ARMv6, if the memory address is not 64-bit aligned, the | data read from memory is UNPREDICTABLE. Alignment checking (taking | a data abort), and support for a big-endian (BE-32) data format are | implementation options. We already have at least an 8 byte alignment for dlmalloc, so have TLSF follow suit. Reported-by: Enrico Scholz <enrico.scholz@xxxxxxxxxxxxxxxxx> Link: https://lore.barebox.org/barebox/ly7d1z1qvs.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/ Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- common/tlsf.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/common/tlsf.c b/common/tlsf.c index 16682435e492..561635dfd3f3 100644 --- a/common/tlsf.c +++ b/common/tlsf.c @@ -35,13 +35,8 @@ enum tlsf_public /* Private constants: do not modify. */ enum tlsf_private { -#if defined (TLSF_64BIT) /* All allocation sizes and addresses are aligned to 8 bytes. */ ALIGN_SIZE_LOG2 = 3, -#else - /* All allocation sizes and addresses are aligned to 4 bytes. */ - ALIGN_SIZE_LOG2 = 2, -#endif ALIGN_SIZE = (1 << ALIGN_SIZE_LOG2), /* @@ -95,7 +90,7 @@ enum tlsf_private #define tlsf_static_assert(exp) \ typedef char _tlsf_glue(static_assert, __LINE__) [(exp) ? 1 : -1] -typedef size_t tlsf_size_t; +typedef uint64_t tlsf_size_t; /* This code has been tested on 32- and 64-bit (LP/LLP) architectures. */ tlsf_static_assert(sizeof(int) * CHAR_BIT == 32); -- 2.30.2