Skip to content

Commit 1984c80

Browse files
Leonardo Brasctmarinas
authored andcommitted
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: Leonardo Bras <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent a743f26 commit 1984c80

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

arch/arm64/include/asm/elf.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,16 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
201201
#define COMPAT_ELF_PLATFORM ("v8l")
202202
#endif
203203

204-
#ifdef CONFIG_COMPAT
205-
206-
/* PIE load location for compat arm. Must match ARM ELF_ET_DYN_BASE. */
207-
#define COMPAT_ELF_ET_DYN_BASE 0x000400000UL
208-
209204
/* AArch32 registers. */
210205
#define COMPAT_ELF_NGREG 18
211206
typedef unsigned int compat_elf_greg_t;
212207
typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG];
213208

209+
#ifdef CONFIG_COMPAT
210+
211+
/* PIE load location for compat arm. Must match ARM ELF_ET_DYN_BASE. */
212+
#define COMPAT_ELF_ET_DYN_BASE 0x000400000UL
213+
214214
/* AArch32 EABI. */
215215
#define EF_ARM_EABI_MASK 0xff000000
216216
int compat_elf_check_arch(const struct elf32_hdr *);

arch/arm64/include/asm/fpsimd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <linux/stddef.h>
2222
#include <linux/types.h>
2323

24-
#ifdef CONFIG_COMPAT
2524
/* Masks for extracting the FPSR and FPCR from the FPSCR */
2625
#define VFP_FPSCR_STAT_MASK 0xf800009f
2726
#define VFP_FPSCR_CTRL_MASK 0x07f79f00
@@ -30,7 +29,6 @@
3029
* control/status register.
3130
*/
3231
#define VFP_STATE_SIZE ((32 * 8) + 4)
33-
#endif
3432

3533
static inline unsigned long cpacr_save_enable_kernel_sve(void)
3634
{

arch/arm64/kernel/ptrace.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ static void ptrace_hbptriggered(struct perf_event *bp,
174174
struct arch_hw_breakpoint *bkpt = counter_arch_bp(bp);
175175
const char *desc = "Hardware breakpoint trap (ptrace)";
176176

177-
#ifdef CONFIG_COMPAT
178177
if (is_compat_task()) {
179178
int si_errno = 0;
180179
int i;
@@ -196,7 +195,7 @@ static void ptrace_hbptriggered(struct perf_event *bp,
196195
desc);
197196
return;
198197
}
199-
#endif
198+
200199
arm64_force_sig_fault(SIGTRAP, TRAP_HWBKPT, bkpt->trigger, desc);
201200
}
202201

@@ -1596,7 +1595,6 @@ static const struct user_regset_view user_aarch64_view = {
15961595
.regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets)
15971596
};
15981597

1599-
#ifdef CONFIG_COMPAT
16001598
enum compat_regset {
16011599
REGSET_COMPAT_GPR,
16021600
REGSET_COMPAT_VFP,
@@ -1853,6 +1851,7 @@ static const struct user_regset_view user_aarch32_ptrace_view = {
18531851
.regsets = aarch32_ptrace_regsets, .n = ARRAY_SIZE(aarch32_ptrace_regsets)
18541852
};
18551853

1854+
#ifdef CONFIG_COMPAT
18561855
static int compat_ptrace_read_user(struct task_struct *tsk, compat_ulong_t off,
18571856
compat_ulong_t __user *ret)
18581857
{
@@ -2114,7 +2113,6 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
21142113

21152114
const struct user_regset_view *task_user_regset_view(struct task_struct *task)
21162115
{
2117-
#ifdef CONFIG_COMPAT
21182116
/*
21192117
* Core dumping of 32-bit tasks or compat ptrace requests must use the
21202118
* 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)
21252123
return &user_aarch32_view;
21262124
else if (is_compat_thread(task_thread_info(task)))
21272125
return &user_aarch32_ptrace_view;
2128-
#endif
2126+
21292127
return &user_aarch64_view;
21302128
}
21312129

arch/arm64/kernel/syscall.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ long sys_ni_syscall(void);
2020

2121
static long do_ni_syscall(struct pt_regs *regs, int scno)
2222
{
23-
#ifdef CONFIG_COMPAT
24-
long ret;
2523
if (is_compat_task()) {
26-
ret = compat_arm_syscall(regs, scno);
24+
long ret = compat_arm_syscall(regs, scno);
2725
if (ret != -ENOSYS)
2826
return ret;
2927
}
30-
#endif
3128

3229
return sys_ni_syscall();
3330
}

0 commit comments

Comments
 (0)