Skip to content

Commit 409d5db

Browse files
committed
arm64: rseq: Implement backend rseq calls and select HAVE_RSEQ
Implement calls to rseq_signal_deliver, rseq_handle_notify_resume and rseq_syscall so that we can select HAVE_RSEQ on arm64. Acked-by: Mathieu Desnoyers <[email protected]> Acked-by: Mark Rutland <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 54501ac commit 409d5db

File tree

6 files changed

+11
-1
lines changed

6 files changed

+11
-1
lines changed

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ config ARM64
138138
select HAVE_PERF_USER_STACK_DUMP
139139
select HAVE_REGS_AND_STACK_ACCESS_API
140140
select HAVE_RCU_TABLE_FREE
141+
select HAVE_RSEQ
141142
select HAVE_STACKPROTECTOR
142143
select HAVE_SYSCALL_TRACEPOINTS
143144
select HAVE_KPROBES

arch/arm64/include/asm/unistd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#define __ARM_NR_compat_cacheflush (__ARM_NR_COMPAT_BASE+2)
4444
#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE+5)
4545

46-
#define __NR_compat_syscalls 398
46+
#define __NR_compat_syscalls 399
4747
#endif
4848

4949
#define __ARCH_WANT_SYS_CLONE

arch/arm64/include/asm/unistd32.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,8 @@ __SYSCALL(__NR_pkey_alloc, sys_pkey_alloc)
817817
__SYSCALL(__NR_pkey_free, sys_pkey_free)
818818
#define __NR_statx 397
819819
__SYSCALL(__NR_statx, sys_statx)
820+
#define __NR_rseq 398
821+
__SYSCALL(__NR_rseq, sys_rseq)
820822

821823
/*
822824
* Please add new compat syscalls above this comment and update

arch/arm64/kernel/entry.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,13 +904,15 @@ ENDPROC(el0_error)
904904
ret_fast_syscall:
905905
disable_daif
906906
str x0, [sp, #S_X0] // returned x0
907+
#ifndef CONFIG_DEBUG_RSEQ
907908
ldr x1, [tsk, #TSK_TI_FLAGS] // re-check for syscall tracing
908909
and x2, x1, #_TIF_SYSCALL_WORK
909910
cbnz x2, ret_fast_syscall_trace
910911
and x2, x1, #_TIF_WORK_MASK
911912
cbnz x2, work_pending
912913
enable_step_tsk x1, x2
913914
kernel_exit 0
915+
#endif
914916
ret_fast_syscall_trace:
915917
enable_daif
916918
b __sys_trace_return_skipped // we already saved x0

arch/arm64/kernel/ptrace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,8 @@ asmlinkage void syscall_trace_exit(struct pt_regs *regs)
16581658

16591659
if (test_thread_flag(TIF_SYSCALL_TRACE))
16601660
tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT);
1661+
1662+
rseq_syscall(regs);
16611663
}
16621664

16631665
/*

arch/arm64/kernel/signal.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,8 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
802802
int usig = ksig->sig;
803803
int ret;
804804

805+
rseq_signal_deliver(ksig, regs);
806+
805807
/*
806808
* Set up the stack frame
807809
*/
@@ -940,6 +942,7 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
940942
if (thread_flags & _TIF_NOTIFY_RESUME) {
941943
clear_thread_flag(TIF_NOTIFY_RESUME);
942944
tracehook_notify_resume(regs);
945+
rseq_handle_notify_resume(NULL, regs);
943946
}
944947

945948
if (thread_flags & _TIF_FOREIGN_FPSTATE)

0 commit comments

Comments
 (0)