compat: add a compat_need_64bit_alignment_fixup() helper
authorChristoph Hellwig <hch@lst.de>
Thu, 17 Sep 2020 07:41:58 +0000 (09:41 +0200)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 17 Sep 2020 17:00:46 +0000 (13:00 -0400)
Add a helper to check if the calling syscall needs a fixup for
non-natural 64-bit type alignment in the compat ABI.  This will only
return true for i386 syscalls on x86_64.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/x86/include/asm/compat.h
include/linux/compat.h

index bf547701f41f878a4a7d380975787f219a26bcf6..0e327a01f50fbbff551727d38ee51fe351011254 100644 (file)
@@ -209,6 +209,7 @@ static inline bool in_compat_syscall(void)
        return in_32bit_syscall();
 }
 #define in_compat_syscall in_compat_syscall    /* override the generic impl */
+#define compat_need_64bit_alignment_fixup in_ia32_syscall
 #endif
 
 struct compat_siginfo;
index d38c4d7e83bd32391dc99df671f88a1bc068cc30..f0026a344482b7ad3f8ee75c85643ae5a2ea2024 100644 (file)
@@ -932,6 +932,15 @@ static inline bool in_compat_syscall(void) { return false; }
 
 #endif /* CONFIG_COMPAT */
 
+/*
+ * Some legacy ABIs like the i386 one use less than natural alignment for 64-bit
+ * types, and will need special compat treatment for that.  Most architectures
+ * don't need that special handling even for compat syscalls.
+ */
+#ifndef compat_need_64bit_alignment_fixup
+#define compat_need_64bit_alignment_fixup()            false
+#endif
+
 /*
  * A pointer passed in from user mode. This should not
  * be used for syscall parameters, just declare them