diff options
author | Tony Lindgren <tony@atomide.com> | 2018-11-08 18:32:24 +0100 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2018-11-08 18:32:24 +0100 |
commit | 91e43395820baad80248987608216c35da9df65b (patch) | |
tree | 29d41d1a036eb1abd6a60f16ad37aa578acd8159 /arch/arm64/kernel/probes/kprobes.c | |
parent | ARM: OMAP2+: prm44xx: Fix section annotation on omap44xx_prm_enable_io_wakeup (diff) | |
parent | ARM: OMAP1: ams-delta: Fix possible use of uninitialized field (diff) | |
download | linux-91e43395820baad80248987608216c35da9df65b.tar.xz linux-91e43395820baad80248987608216c35da9df65b.zip |
Merge branch 'fixes-dts' into omap-for-v4.20/fixes
Diffstat (limited to 'arch/arm64/kernel/probes/kprobes.c')
-rw-r--r-- | arch/arm64/kernel/probes/kprobes.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c index e78c3ef04d95..2a5b338b2542 100644 --- a/arch/arm64/kernel/probes/kprobes.c +++ b/arch/arm64/kernel/probes/kprobes.c @@ -23,7 +23,9 @@ #include <linux/slab.h> #include <linux/stop_machine.h> #include <linux/sched/debug.h> +#include <linux/set_memory.h> #include <linux/stringify.h> +#include <linux/vmalloc.h> #include <asm/traps.h> #include <asm/ptrace.h> #include <asm/cacheflush.h> @@ -42,10 +44,21 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); static void __kprobes post_kprobe_handler(struct kprobe_ctlblk *, struct pt_regs *); +static int __kprobes patch_text(kprobe_opcode_t *addr, u32 opcode) +{ + void *addrs[1]; + u32 insns[1]; + + addrs[0] = addr; + insns[0] = opcode; + + return aarch64_insn_patch_text(addrs, insns, 1); +} + static void __kprobes arch_prepare_ss_slot(struct kprobe *p) { /* prepare insn slot */ - p->ainsn.api.insn[0] = cpu_to_le32(p->opcode); + patch_text(p->ainsn.api.insn, p->opcode); flush_icache_range((uintptr_t) (p->ainsn.api.insn), (uintptr_t) (p->ainsn.api.insn) + @@ -107,7 +120,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) if (!p->ainsn.api.insn) return -ENOMEM; break; - }; + } /* prepare the instruction */ if (p->ainsn.api.insn) @@ -118,15 +131,15 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) return 0; } -static int __kprobes patch_text(kprobe_opcode_t *addr, u32 opcode) +void *alloc_insn_page(void) { - void *addrs[1]; - u32 insns[1]; + void *page; - addrs[0] = (void *)addr; - insns[0] = (u32)opcode; + page = vmalloc_exec(PAGE_SIZE); + if (page) + set_memory_ro((unsigned long)page, 1); - return aarch64_insn_patch_text(addrs, insns, 1); + return page; } /* arm kprobe: install breakpoint in text */ |