aboutsummaryrefslogtreecommitdiff
path: root/arch/powerpc/include/asm/syscalls.h
diff options
context:
space:
mode:
authorRohan McLure <[email protected]>2022-09-21 16:55:48 +1000
committerMichael Ellerman <[email protected]>2022-09-26 23:00:15 +1000
commit016ff72bd2090903715c0f9422a44afbb966f4ee (patch)
treed0cb41079d4fc1b109957920bd3e6fcedd559a49 /arch/powerpc/include/asm/syscalls.h
parent620f5c59c8617d623428c03414a022fca4e9eea2 (diff)
powerpc: Fix fallocate and fadvise64_64 compat parameter combination
As reported[1] by Arnd, the arch-specific fadvise64_64 and fallocate compatibility handlers assume parameters are passed with 32-bit big-endian ABI. This affects the assignment of odd-even parameter pairs to the high or low words of a 64-bit syscall parameter. Fix fadvise64_64 fallocate compat handlers to correctly swap upper/lower 32 bits conditioned on endianness. A future patch will replace the arch-specific compat fallocate with an asm-generic implementation. This patch is intended for ease of back-port. [1]: https://lore.kernel.org/all/[email protected]/ Fixes: 57f48b4b74e7 ("powerpc/compat_sys: swap hi/lo parts of 64-bit syscall args in LE mode") Reported-by: Arnd Bergmann <[email protected]> Signed-off-by: Rohan McLure <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Reviewed-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'arch/powerpc/include/asm/syscalls.h')
-rw-r--r--arch/powerpc/include/asm/syscalls.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/syscalls.h b/arch/powerpc/include/asm/syscalls.h
index 21c2faaa2957..ae7ca59f6267 100644
--- a/arch/powerpc/include/asm/syscalls.h
+++ b/arch/powerpc/include/asm/syscalls.h
@@ -8,6 +8,18 @@
#include <linux/types.h>
#include <linux/compat.h>
+/*
+ * long long munging:
+ * The 32 bit ABI passes long longs in an odd even register pair.
+ * High and low parts are swapped depending on endian mode,
+ * so define a macro (similar to mips linux32) to handle that.
+ */
+#ifdef __LITTLE_ENDIAN__
+#define merge_64(low, high) (((u64)high << 32) | low)
+#else
+#define merge_64(high, low) (((u64)high << 32) | low)
+#endif
+
struct rtas_args;
long sys_mmap(unsigned long addr, size_t len,