From: Kris Van Hees Date: Mon, 22 Dec 2014 21:56:13 +0000 (-0500) Subject: dtrace: add support for sparc64 1of3 X-Git-Tag: v4.1.12-92~313^2~29 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=91352d1f425720035944364907ff81ef921bc438;p=users%2Fjedix%2Flinux-maple.git dtrace: add support for sparc64 1of3 This commit is the 1st of 3 commits to add DTrace support to the sparc64 kernel. This particular commit covers the sparc64-specific kernel code changes. - Set ARCH_SUPPORTS_DTRACE for SPARC64. - Add DIE_PAGE_FAULT to be used in the (new) notifier call in the do_kernel_fault() function to allow DTrace to report failed memory accesses from probe recipes as an error rather than causing a kernel OOPS. - Add support for the dtrace_no_pf() functionality to ignore page faults on request when trying to access userspace. - Add support for the waitfd syscall. Orabug: 19005031 Signed-off-by: Kris Van Hees Reviewed-by: Nick Alcock --- diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index e49502acbab40..24d07458c5a77 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -150,6 +150,9 @@ config PGTABLE_LEVELS default 4 if 64BIT default 3 +config ARCH_SUPPORTS_DTRACE + def_bool y if SPARC64 + source "init/Kconfig" source "kernel/Kconfig.freezer" diff --git a/arch/sparc/include/asm/kdebug_64.h b/arch/sparc/include/asm/kdebug_64.h index 04465de8f3b52..d5b482dd1847a 100644 --- a/arch/sparc/include/asm/kdebug_64.h +++ b/arch/sparc/include/asm/kdebug_64.h @@ -16,6 +16,8 @@ enum die_val { DIE_CALL, DIE_NMI, DIE_NMIWATCHDOG, + DIE_GPF, + DIE_PAGE_FAULT, }; #endif diff --git a/arch/sparc/include/uapi/asm/unistd.h b/arch/sparc/include/uapi/asm/unistd.h index 6f35f4df17f28..9149cc8742b03 100644 --- a/arch/sparc/include/uapi/asm/unistd.h +++ b/arch/sparc/include/uapi/asm/unistd.h @@ -416,6 +416,7 @@ #define __NR_memfd_create 348 #define __NR_bpf 349 #define __NR_execveat 350 +#define __NR_waitfd 351 #define NR_syscalls 351 diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S index d72f76ae70eba..8aee6e2d8e56d 100644 --- a/arch/sparc/kernel/systbls_64.S +++ b/arch/sparc/kernel/systbls_64.S @@ -168,4 +168,4 @@ sys_call_table: .word sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev /*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr .word sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf -/*350*/ .word sys64_execveat +/*350*/ .word sys64_execveat, sys_waitfd diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c index 4798232494294..698ad91b10787 100644 --- a/arch/sparc/mm/fault_64.c +++ b/arch/sparc/mm/fault_64.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -264,7 +265,9 @@ static void __kprobes do_kernel_fault(struct pt_regs *regs, int si_code, } cannot_handle: - unhandled_fault (address, current, regs); + if (notify_die(DIE_PAGE_FAULT, "page fault", regs, fault_code, 14, + SIGKILL) != NOTIFY_STOP) + unhandled_fault (address, current, regs); } static void noinline __kprobes bogus_32bit_fault_tpc(struct pt_regs *regs) @@ -326,6 +329,12 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs) } else flags |= FAULT_FLAG_USER; + /* + * DTrace may want the page fault ignored... + */ + if (unlikely(dtrace_no_pf(regs))) + return; + /* * If we're in an interrupt or have no user * context, we must not take the fault..