util: Fix the constant length check in the aarch64 mmio_memcpy_x64()
[ Upstream commit b9c03596bafe18d4c311bd41d7f77f8e9a0396bb ]
__builtin_constant_p((bytecount) == 64) is true when the comparison has
a known result, whatever that result is, so the macro writes only 64
bytes for any length the compiler can reason about. A literal 128 is
truncated, and so is a variable after "if (n <= 64) return;".
Take the 64-byte path only when the length is known to be 64. libhns
was the one in-tree caller that relied on the old behaviour, and the
previous patch removes that.
Fixes: 159933c37450 ("libhns: Add support for direct wqe")
Reviewed-by: Junxian Huang <huangjunxian6@hisilicon.com>
Tested-by: Junxian Huang <huangjunxian6@hisilicon.com>
Assisted-by: Claude:claude-opus-5-5 <noreply@anthropic.com>
Signed-off-by: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
Signed-off-by: Nicolas Morey <nmorey@suse.com>
diff --git a/util/mmio.h b/util/mmio.h
index df705de..fa12858 100644
--- a/util/mmio.h
+++ b/util/mmio.h
@@ -258,7 +258,7 @@
#define mmio_memcpy_x64(dest, src, bytecount) \
({ \
- if (__builtin_constant_p((bytecount) == 64)) \
+ if (__builtin_constant_p(bytecount) && (bytecount) == 64) \
_mmio_memcpy_x64_64b((dest), (src)); \
else \
_mmio_memcpy_x64((dest), (src), (bytecount)); \