Commit 1984c805 authored by Leonardo Bras's avatar Leonardo Bras Committed by Catalin Marinas

arm64: remove unnecessary ifdefs around is_compat_task()

Currently some parts of the codebase will test for CONFIG_COMPAT before
testing is_compat_task().

is_compat_task() is a inlined function only present on CONFIG_COMPAT.
On the other hand, for !CONFIG_COMPAT, we have in linux/compat.h:

 #define is_compat_task() (0)

Since we have this define available in every usage of is_compat_task() for
!CONFIG_COMPAT, it's unnecessary to keep the ifdefs, since the compiler is
smart enough to optimize-out those snippets on CONFIG_COMPAT=n

This requires some regset code as well as a few other defines to be made
available on !CONFIG_COMPAT, so some symbols can get resolved before
getting optimized-out.
Signed-off-by: default avatarLeonardo Bras <leobras@redhat.com>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20240109034651.478462-2-leobras@redhat.comSigned-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent a743f26d
...@@ -201,16 +201,16 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, ...@@ -201,16 +201,16 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
#define COMPAT_ELF_PLATFORM ("v8l") #define COMPAT_ELF_PLATFORM ("v8l")
#endif #endif
#ifdef CONFIG_COMPAT
/* PIE load location for compat arm. Must match ARM ELF_ET_DYN_BASE. */
#define COMPAT_ELF_ET_DYN_BASE 0x000400000UL
/* AArch32 registers. */ /* AArch32 registers. */
#define COMPAT_ELF_NGREG 18 #define COMPAT_ELF_NGREG 18
typedef unsigned int compat_elf_greg_t; typedef unsigned int compat_elf_greg_t;
typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
#ifdef CONFIG_COMPAT
/* PIE load location for compat arm. Must match ARM ELF_ET_DYN_BASE. */
#define COMPAT_ELF_ET_DYN_BASE 0x000400000UL
/* AArch32 EABI. */ /* AArch32 EABI. */
#define EF_ARM_EABI_MASK 0xff000000 #define EF_ARM_EABI_MASK 0xff000000
int compat_elf_check_arch(const struct elf32_hdr *); int compat_elf_check_arch(const struct elf32_hdr *);
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/types.h> #include <linux/types.h>
#ifdef CONFIG_COMPAT
/* Masks for extracting the FPSR and FPCR from the FPSCR */ /* Masks for extracting the FPSR and FPCR from the FPSCR */
#define VFP_FPSCR_STAT_MASK 0xf800009f #define VFP_FPSCR_STAT_MASK 0xf800009f
#define VFP_FPSCR_CTRL_MASK 0x07f79f00 #define VFP_FPSCR_CTRL_MASK 0x07f79f00
...@@ -30,7 +29,6 @@ ...@@ -30,7 +29,6 @@
* control/status register. * control/status register.
*/ */
#define VFP_STATE_SIZE ((32 * 8) + 4) #define VFP_STATE_SIZE ((32 * 8) + 4)
#endif
static inline unsigned long cpacr_save_enable_kernel_sve(void) static inline unsigned long cpacr_save_enable_kernel_sve(void)
{ {
......
...@@ -174,7 +174,6 @@ static void ptrace_hbptriggered(struct perf_event *bp, ...@@ -174,7 +174,6 @@ static void ptrace_hbptriggered(struct perf_event *bp,
struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp); struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp);
const char *desc = "Hardware breakpoint trap (ptrace)"; const char *desc = "Hardware breakpoint trap (ptrace)";
#ifdef CONFIG_COMPAT
if (is_compat_task()) { if (is_compat_task()) {
int si_errno = 0; int si_errno = 0;
int i; int i;
...@@ -196,7 +195,7 @@ static void ptrace_hbptriggered(struct perf_event *bp, ...@@ -196,7 +195,7 @@ static void ptrace_hbptriggered(struct perf_event *bp,
desc); desc);
return; return;
} }
#endif
arm64_force_sig_fault(SIGTRAP, TRAP_HWBKPT, bkpt->trigger, desc); arm64_force_sig_fault(SIGTRAP, TRAP_HWBKPT, bkpt->trigger, desc);
} }
...@@ -1596,7 +1595,6 @@ static const struct user_regset_view user_aarch64_view = { ...@@ -1596,7 +1595,6 @@ static const struct user_regset_view user_aarch64_view = {
.regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets) .regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets)
}; };
#ifdef CONFIG_COMPAT
enum compat_regset { enum compat_regset {
REGSET_COMPAT_GPR, REGSET_COMPAT_GPR,
REGSET_COMPAT_VFP, REGSET_COMPAT_VFP,
...@@ -1853,6 +1851,7 @@ static const struct user_regset_view user_aarch32_ptrace_view = { ...@@ -1853,6 +1851,7 @@ static const struct user_regset_view user_aarch32_ptrace_view = {
.regsets = aarch32_ptrace_regsets, .n = ARRAY_SIZE(aarch32_ptrace_regsets) .regsets = aarch32_ptrace_regsets, .n = ARRAY_SIZE(aarch32_ptrace_regsets)
}; };
#ifdef CONFIG_COMPAT
static int compat_ptrace_read_user(struct task_struct *tsk, compat_ulong_t off, static int compat_ptrace_read_user(struct task_struct *tsk, compat_ulong_t off,
compat_ulong_t __user *ret) compat_ulong_t __user *ret)
{ {
...@@ -2114,7 +2113,6 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, ...@@ -2114,7 +2113,6 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
const struct user_regset_view *task_user_regset_view(struct task_struct *task) const struct user_regset_view *task_user_regset_view(struct task_struct *task)
{ {
#ifdef CONFIG_COMPAT
/* /*
* Core dumping of 32-bit tasks or compat ptrace requests must use the * Core dumping of 32-bit tasks or compat ptrace requests must use the
* user_aarch32_view compatible with arm32. Native ptrace requests on * user_aarch32_view compatible with arm32. Native ptrace requests on
...@@ -2125,7 +2123,7 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task) ...@@ -2125,7 +2123,7 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
return &user_aarch32_view; return &user_aarch32_view;
else if (is_compat_thread(task_thread_info(task))) else if (is_compat_thread(task_thread_info(task)))
return &user_aarch32_ptrace_view; return &user_aarch32_ptrace_view;
#endif
return &user_aarch64_view; return &user_aarch64_view;
} }
......
...@@ -20,14 +20,11 @@ long sys_ni_syscall(void); ...@@ -20,14 +20,11 @@ long sys_ni_syscall(void);
static long do_ni_syscall(struct pt_regs *regs, int scno) static long do_ni_syscall(struct pt_regs *regs, int scno)
{ {
#ifdef CONFIG_COMPAT
long ret;
if (is_compat_task()) { if (is_compat_task()) {
ret = compat_arm_syscall(regs, scno); long ret = compat_arm_syscall(regs, scno);
if (ret != -ENOSYS) if (ret != -ENOSYS)
return ret; return ret;
} }
#endif
return sys_ni_syscall(); return sys_ni_syscall();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment