Skip to content

Commit b1e2d95

Browse files
Ada Couprie Diazwilldeacon
authored andcommitted
arm64: refactor aarch32_break_handler()
`aarch32_break_handler()` is called in `do_el0_undef()` when we are trying to handle an exception whose Exception Syndrome is unknown. It checks if the instruction hit might be a 32-bit arm break (be it A32 or T2), and sends a SIGTRAP to userspace if it is so that it can be handled. However, this is badly represented in the naming of the function, and is not consistent with the other functions called with the same logic in `do_el0_undef()`. Rename it `try_handle_aarch32_break()` and change the return value to a boolean to align with the logic of the other tentative handlers in `do_el0_undef()`, the previous error code being ignored anyway. Signed-off-by: Ada Couprie Diaz <[email protected]> Tested-by: Luis Claudio R. Goncalves <[email protected]> Reviewed-by: Anshuman Khandual <[email protected]> Acked-by: Mark Rutland <[email protected]> Reviewed-by: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent ad8b226 commit b1e2d95

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

arch/arm64/include/asm/debug-monitors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static inline int reinstall_suspended_bps(struct pt_regs *regs)
116116
}
117117
#endif
118118

119-
int aarch32_break_handler(struct pt_regs *regs);
119+
bool try_handle_aarch32_break(struct pt_regs *regs);
120120

121121
void debug_traps_init(void);
122122

arch/arm64/kernel/debug-monitors.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,15 @@ static int brk_handler(unsigned long unused, unsigned long esr,
334334
}
335335
NOKPROBE_SYMBOL(brk_handler);
336336

337-
int aarch32_break_handler(struct pt_regs *regs)
337+
bool try_handle_aarch32_break(struct pt_regs *regs)
338338
{
339339
u32 arm_instr;
340340
u16 thumb_instr;
341341
bool bp = false;
342342
void __user *pc = (void __user *)instruction_pointer(regs);
343343

344344
if (!compat_user_mode(regs))
345-
return -EFAULT;
345+
return false;
346346

347347
if (compat_thumb_mode(regs)) {
348348
/* get 16-bit Thumb instruction */
@@ -366,12 +366,12 @@ int aarch32_break_handler(struct pt_regs *regs)
366366
}
367367

368368
if (!bp)
369-
return -EFAULT;
369+
return false;
370370

371371
send_user_sigtrap(TRAP_BRKPT);
372-
return 0;
372+
return true;
373373
}
374-
NOKPROBE_SYMBOL(aarch32_break_handler);
374+
NOKPROBE_SYMBOL(try_handle_aarch32_break);
375375

376376
void __init debug_traps_init(void)
377377
{

arch/arm64/kernel/traps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ void do_el0_undef(struct pt_regs *regs, unsigned long esr)
454454
u32 insn;
455455

456456
/* check for AArch32 breakpoint instructions */
457-
if (!aarch32_break_handler(regs))
457+
if (try_handle_aarch32_break(regs))
458458
return;
459459

460460
if (user_insn_read(regs, &insn))

0 commit comments

Comments
 (0)