Linux 5.11 removed the TIF_IA32 thread flag with commit:
x86: Reclaim TIF_IA32 and TIF_X32 (
8d71d2bf6efec)
The flag TIF_IA32 was being used by openafs to determine if the task was
handling a syscall request from a 32 bit process. Building against a
Linux 5.11 kernel results in a build failure as TIF_IA32 is undefined.
The function 'in_compat_syscall' was introduced in Linux 4.6 as
the preferred method to determine if a syscall needed to handle a
compatible call (e.g. 32bit application).
To resolve the build problem, use 'in_compat_syscall' if present (Linux
4.6 and later) to determine if the syscall needs to handle a
compatibility mode call.
Add autoconf check for in_compat_syscall.
Notes about in_compat_syscall:
In Linux 4.6 'in_compat_syscall' was defined for all architectures with
a generic return of 'is_compat_task', but allows architecture specific
overriding implementations (x86 and sparc).
At 4.6 (and later), the function 'is_compat_task' is defined only for
the following architectures to return:
Arch Returns
======= ==============================
arm64 test_thread_flag(TIF_32BIT);
mips test_thread_flag(TIF_32BIT_ADDR)
parisc test_ti_thread_flag(task_thread_info(t), TIF_32BIT)
powerpc is_32bit_task()
s390 test_thread_flag(TIF_31BIT)
sparc test_thread_flag(TIF_32BIT)
If the Linux kernel is not built with compat mode, is_compat_task and
in_compat_syscall is set to always return 0
Linux commit that introduced in_compat_syscall:
compat: add in_compat_syscall to ask whether we're in a compat syscall
(
5180e3e24fd3e8e7)
Change-Id: I59deebfe5d8cddaf845b15ef69e65a684a961280
Reviewed-on: https://gerrit.openafs.org/14499
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
static inline int
afs_in_compat_syscall(void)
{
-# if defined(AFS_SPARC64_LINUX26_ENV)
+# if defined(HAVE_LINUX_IN_COMPAT_SYSCALL)
+ return in_compat_syscall();
+# elif defined(AFS_SPARC64_LINUX26_ENV)
return test_thread_flag(TIF_32BIT);
# elif defined(AFS_SPARC64_LINUX24_ENV)
return (current->thread.flags & SPARC_FLAG_32BIT) != 0;
[#include <linux/swap.h>],
[lru_cache_add_file(NULL);])
+dnl Linux 4.6 introduced in_compat_syscall as replacement for is_compat_task
+dnl for certain platforms.
+AC_CHECK_LINUX_FUNC([in_compat_syscall],
+ [#include <linux/compat.h>],
+ [in_compat_syscall();])
+
dnl lru_cache_add exported in Linux 5.8
dnl replaces lru_cache_add_file
AC_CHECK_LINUX_FUNC([lru_cache_add],