Re: [PATCH] media: mali-c55: Fix unaligned access of AEC histogram zone weights

From: David CARLIER

Date: Thu Jul 09 2026 - 01:01:19 EST


> Does it ?
[...]
> seems to clarify this is a non-issue ?

I think you're right that there's no runtime fault: arm64 has
HAVE_EFFICIENT_UNALIGNED_ACCESS and runs with SCTLR.A off, so the
unaligned load doesn't trap. It's really just a C-level thing - the
(u32 *) cast is UB and -fsanitize=alignment would moan - rather than a
real bug, which is why v2 already dropped Fixes:/stable.

> I still see zone_weights[] at offset 10 which is not 4 bytes aligned.
> What have I missed ?

I don't think you missed anything - the union isn't trying to move the
array, offset 10 has to stay. The idea is just the __packed member: it
makes zone_weights_32[i] an alignment-1 read, so the compiler does the
right thing (a plain LDR on arm64) with no cast, no get_unaligned() and
no memcpy(). Same 240-byte layout, and it also avoids David's KASAN
concern about memcpy().

So if you'd like it cleaned up, in mali-c55-config.h:

union {
__u32 zone_weights_32[56] __attribute__((__packed__));
__u8 zone_weights[MALI_C55_MAX_ZONES];
};

and index zone_weights_32[i] in the driver. And if you'd rather not
carry the uapi churn for something that isn't a fault, I'm equally happy
to just drop it - whichever you prefer.

Cheers