Skip to content

Commit b6e43c0

Browse files
James Morsectmarinas
authored andcommitted
arm64: remove __exception annotations
Since commit 7326749 ("arm64: unwind: reference pt_regs via embedded stack frame") arm64 has not used the __exception annotation to dump the pt_regs during stack tracing. in_exception_text() has no callers. This annotation is only used to blacklist kprobes, it means the same as __kprobes. Section annotations like this require the functions to be grouped together between the start/end markers, and placed according to the linker script. For kprobes we also have NOKPROBE_SYMBOL() which logs the symbol address in a section that kprobes parses and blacklists at boot. Using NOKPROBE_SYMBOL() instead lets kprobes publish the list of blacklisted symbols, and saves us from having an arm64 specific spelling of __kprobes. do_debug_exception() already has a NOKPROBE_SYMBOL() annotation. Signed-off-by: James Morse <james.morse@arm.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 4f5cafb commit b6e43c0

6 files changed

Lines changed: 26 additions & 39 deletions

File tree

‎arch/arm64/include/asm/exception.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
#define __ASM_EXCEPTION_H
99

1010
#include <asm/esr.h>
11+
#include <asm/kprobes.h>
1112

1213
#include <linux/interrupt.h>
1314

14-
#define __exception __attribute__((section(".exception.text")))
1515
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
1616
#define __exception_irq_entry __irq_entry
1717
#else
18-
#define __exception_irq_entry __exception
18+
#define __exception_irq_entry __kprobes
1919
#endif
2020

2121
static inline u32 disr_to_esr(u64 disr)

‎arch/arm64/include/asm/traps.h‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ static inline int __in_irqentry_text(unsigned long ptr)
4242
ptr < (unsigned long)&__irqentry_text_end;
4343
}
4444

45-
static inline int in_exception_text(unsigned long ptr)
46-
{
47-
int in;
48-
49-
in = ptr >= (unsigned long)&__exception_text_start &&
50-
ptr < (unsigned long)&__exception_text_end;
51-
52-
return in ? : __in_irqentry_text(ptr);
53-
}
54-
5545
static inline int in_entry_text(unsigned long ptr)
5646
{
5747
return ptr >= (unsigned long)&__entry_text_start &&

‎arch/arm64/kernel/probes/kprobes.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,6 @@ int __init arch_populate_kprobe_blacklist(void)
455455
(unsigned long)__irqentry_text_end);
456456
if (ret)
457457
return ret;
458-
ret = kprobe_add_area_blacklist((unsigned long)__exception_text_start,
459-
(unsigned long)__exception_text_end);
460-
if (ret)
461-
return ret;
462458
ret = kprobe_add_area_blacklist((unsigned long)__idmap_text_start,
463459
(unsigned long)__idmap_text_end);
464460
if (ret)

‎arch/arm64/kernel/traps.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <asm/debug-monitors.h>
3636
#include <asm/esr.h>
3737
#include <asm/insn.h>
38+
#include <asm/kprobes.h>
3839
#include <asm/traps.h>
3940
#include <asm/smp.h>
4041
#include <asm/stack_pointer.h>
@@ -393,7 +394,7 @@ void arm64_notify_segfault(unsigned long addr)
393394
force_signal_inject(SIGSEGV, code, addr);
394395
}
395396

396-
asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
397+
asmlinkage void do_undefinstr(struct pt_regs *regs)
397398
{
398399
/* check for AArch32 breakpoint instructions */
399400
if (!aarch32_break_handler(regs))
@@ -405,6 +406,7 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
405406
BUG_ON(!user_mode(regs));
406407
force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc);
407408
}
409+
NOKPROBE_SYMBOL(do_undefinstr);
408410

409411
#define __user_cache_maint(insn, address, res) \
410412
if (address >= user_addr_max()) { \
@@ -667,7 +669,7 @@ static const struct sys64_hook cp15_64_hooks[] = {
667669
{},
668670
};
669671

670-
asmlinkage void __exception do_cp15instr(unsigned int esr, struct pt_regs *regs)
672+
asmlinkage void do_cp15instr(unsigned int esr, struct pt_regs *regs)
671673
{
672674
const struct sys64_hook *hook, *hook_base;
673675

@@ -705,9 +707,10 @@ asmlinkage void __exception do_cp15instr(unsigned int esr, struct pt_regs *regs)
705707
*/
706708
do_undefinstr(regs);
707709
}
710+
NOKPROBE_SYMBOL(do_cp15instr);
708711
#endif
709712

710-
asmlinkage void __exception do_sysinstr(unsigned int esr, struct pt_regs *regs)
713+
asmlinkage void do_sysinstr(unsigned int esr, struct pt_regs *regs)
711714
{
712715
const struct sys64_hook *hook;
713716

@@ -724,6 +727,7 @@ asmlinkage void __exception do_sysinstr(unsigned int esr, struct pt_regs *regs)
724727
*/
725728
do_undefinstr(regs);
726729
}
730+
NOKPROBE_SYMBOL(do_sysinstr);
727731

728732
static const char *esr_class_str[] = {
729733
[0 ... ESR_ELx_EC_MAX] = "UNRECOGNIZED EC",

‎arch/arm64/kernel/vmlinux.lds.S‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ SECTIONS
111111
}
112112
.text : { /* Real text segment */
113113
_stext = .; /* Text and read-only data */
114-
__exception_text_start = .;
115-
*(.exception.text)
116-
__exception_text_end = .;
117114
IRQENTRY_TEXT
118115
SOFTIRQENTRY_TEXT
119116
ENTRY_TEXT

‎arch/arm64/mm/fault.c‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <asm/debug-monitors.h>
3434
#include <asm/esr.h>
3535
#include <asm/kasan.h>
36+
#include <asm/kprobes.h>
3637
#include <asm/sysreg.h>
3738
#include <asm/system_misc.h>
3839
#include <asm/pgtable.h>
@@ -732,8 +733,8 @@ static const struct fault_info fault_info[] = {
732733
{ do_bad, SIGKILL, SI_KERNEL, "unknown 63" },
733734
};
734735

735-
asmlinkage void __exception do_mem_abort(unsigned long addr, unsigned int esr,
736-
struct pt_regs *regs)
736+
asmlinkage void do_mem_abort(unsigned long addr, unsigned int esr,
737+
struct pt_regs *regs)
737738
{
738739
const struct fault_info *inf = esr_to_fault_info(esr);
739740

@@ -749,16 +750,17 @@ asmlinkage void __exception do_mem_abort(unsigned long addr, unsigned int esr,
749750
arm64_notify_die(inf->name, regs,
750751
inf->sig, inf->code, (void __user *)addr, esr);
751752
}
753+
NOKPROBE_SYMBOL(do_mem_abort);
752754

753-
asmlinkage void __exception do_el0_irq_bp_hardening(void)
755+
asmlinkage void do_el0_irq_bp_hardening(void)
754756
{
755757
/* PC has already been checked in entry.S */
756758
arm64_apply_bp_hardening();
757759
}
760+
NOKPROBE_SYMBOL(do_el0_irq_bp_hardening);
758761

759-
asmlinkage void __exception do_el0_ia_bp_hardening(unsigned long addr,
760-
unsigned int esr,
761-
struct pt_regs *regs)
762+
asmlinkage void do_el0_ia_bp_hardening(unsigned long addr, unsigned int esr,
763+
struct pt_regs *regs)
762764
{
763765
/*
764766
* We've taken an instruction abort from userspace and not yet
@@ -771,11 +773,10 @@ asmlinkage void __exception do_el0_ia_bp_hardening(unsigned long addr,
771773
local_daif_restore(DAIF_PROCCTX);
772774
do_mem_abort(addr, esr, regs);
773775
}
776+
NOKPROBE_SYMBOL(do_el0_ia_bp_hardening);
774777

775-
776-
asmlinkage void __exception do_sp_pc_abort(unsigned long addr,
777-
unsigned int esr,
778-
struct pt_regs *regs)
778+
asmlinkage void do_sp_pc_abort(unsigned long addr, unsigned int esr,
779+
struct pt_regs *regs)
779780
{
780781
if (user_mode(regs)) {
781782
if (!is_ttbr0_addr(instruction_pointer(regs)))
@@ -786,6 +787,7 @@ asmlinkage void __exception do_sp_pc_abort(unsigned long addr,
786787
arm64_notify_die("SP/PC alignment exception", regs,
787788
SIGBUS, BUS_ADRALN, (void __user *)addr, esr);
788789
}
790+
NOKPROBE_SYMBOL(do_sp_pc_abort);
789791

790792
int __init early_brk64(unsigned long addr, unsigned int esr,
791793
struct pt_regs *regs);
@@ -868,8 +870,7 @@ NOKPROBE_SYMBOL(debug_exception_exit);
868870
#ifdef CONFIG_ARM64_ERRATUM_1463225
869871
DECLARE_PER_CPU(int, __in_cortex_a76_erratum_1463225_wa);
870872

871-
static int __exception
872-
cortex_a76_erratum_1463225_debug_handler(struct pt_regs *regs)
873+
static int cortex_a76_erratum_1463225_debug_handler(struct pt_regs *regs)
873874
{
874875
if (user_mode(regs))
875876
return 0;
@@ -888,16 +889,15 @@ cortex_a76_erratum_1463225_debug_handler(struct pt_regs *regs)
888889
return 1;
889890
}
890891
#else
891-
static int __exception
892-
cortex_a76_erratum_1463225_debug_handler(struct pt_regs *regs)
892+
static int cortex_a76_erratum_1463225_debug_handler(struct pt_regs *regs)
893893
{
894894
return 0;
895895
}
896896
#endif /* CONFIG_ARM64_ERRATUM_1463225 */
897+
NOKPROBE_SYMBOL(cortex_a76_erratum_1463225_debug_handler);
897898

898-
asmlinkage void __exception do_debug_exception(unsigned long addr_if_watchpoint,
899-
unsigned int esr,
900-
struct pt_regs *regs)
899+
asmlinkage void do_debug_exception(unsigned long addr_if_watchpoint,
900+
unsigned int esr, struct pt_regs *regs)
901901
{
902902
const struct fault_info *inf = esr_to_debug_fault_info(esr);
903903
unsigned long pc = instruction_pointer(regs);

0 commit comments

Comments
 (0)