aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm64/Makefile2
-rw-r--r--arch/arm64/kernel/crash_dump.c2
-rw-r--r--arch/arm64/kernel/probes/kprobes.c27
3 files changed, 23 insertions, 8 deletions
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index b4e994cd3a42..6cb9fc7e9382 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -134,6 +134,7 @@ vdso_install:
134archclean: 134archclean:
135 $(Q)$(MAKE) $(clean)=$(boot) 135 $(Q)$(MAKE) $(clean)=$(boot)
136 136
137ifeq ($(KBUILD_EXTMOD),)
137# We need to generate vdso-offsets.h before compiling certain files in kernel/. 138# We need to generate vdso-offsets.h before compiling certain files in kernel/.
138# In order to do that, we should use the archprepare target, but we can't since 139# In order to do that, we should use the archprepare target, but we can't since
139# asm-offsets.h is included in some files used to generate vdso-offsets.h, and 140# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
@@ -143,6 +144,7 @@ archclean:
143prepare: vdso_prepare 144prepare: vdso_prepare
144vdso_prepare: prepare0 145vdso_prepare: prepare0
145 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso include/generated/vdso-offsets.h 146 $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso include/generated/vdso-offsets.h
147endif
146 148
147define archhelp 149define archhelp
148 echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)' 150 echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'
diff --git a/arch/arm64/kernel/crash_dump.c b/arch/arm64/kernel/crash_dump.c
index f46d57c31443..6b5037ed15b2 100644
--- a/arch/arm64/kernel/crash_dump.c
+++ b/arch/arm64/kernel/crash_dump.c
@@ -58,7 +58,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
58/** 58/**
59 * elfcorehdr_read - read from ELF core header 59 * elfcorehdr_read - read from ELF core header
60 * @buf: buffer where the data is placed 60 * @buf: buffer where the data is placed
61 * @csize: number of bytes to read 61 * @count: number of bytes to read
62 * @ppos: address in the memory 62 * @ppos: address in the memory
63 * 63 *
64 * This function reads @count bytes from elf core header which exists 64 * This function reads @count bytes from elf core header which exists
diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c
index 9b65132e789a..2a5b338b2542 100644
--- a/arch/arm64/kernel/probes/kprobes.c
+++ b/arch/arm64/kernel/probes/kprobes.c
@@ -23,7 +23,9 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/stop_machine.h> 24#include <linux/stop_machine.h>
25#include <linux/sched/debug.h> 25#include <linux/sched/debug.h>
26#include <linux/set_memory.h>
26#include <linux/stringify.h> 27#include <linux/stringify.h>
28#include <linux/vmalloc.h>
27#include <asm/traps.h> 29#include <asm/traps.h>
28#include <asm/ptrace.h> 30#include <asm/ptrace.h>
29#include <asm/cacheflush.h> 31#include <asm/cacheflush.h>
@@ -42,10 +44,21 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
42static void __kprobes 44static void __kprobes
43post_kprobe_handler(struct kprobe_ctlblk *, struct pt_regs *); 45post_kprobe_handler(struct kprobe_ctlblk *, struct pt_regs *);
44 46
47static int __kprobes patch_text(kprobe_opcode_t *addr, u32 opcode)
48{
49 void *addrs[1];
50 u32 insns[1];
51
52 addrs[0] = addr;
53 insns[0] = opcode;
54
55 return aarch64_insn_patch_text(addrs, insns, 1);
56}
57
45static void __kprobes arch_prepare_ss_slot(struct kprobe *p) 58static void __kprobes arch_prepare_ss_slot(struct kprobe *p)
46{ 59{
47 /* prepare insn slot */ 60 /* prepare insn slot */
48 p->ainsn.api.insn[0] = cpu_to_le32(p->opcode); 61 patch_text(p->ainsn.api.insn, p->opcode);
49 62
50 flush_icache_range((uintptr_t) (p->ainsn.api.insn), 63 flush_icache_range((uintptr_t) (p->ainsn.api.insn),
51 (uintptr_t) (p->ainsn.api.insn) + 64 (uintptr_t) (p->ainsn.api.insn) +
@@ -118,15 +131,15 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
118 return 0; 131 return 0;
119} 132}
120 133
121static int __kprobes patch_text(kprobe_opcode_t *addr, u32 opcode) 134void *alloc_insn_page(void)
122{ 135{
123 void *addrs[1]; 136 void *page;
124 u32 insns[1];
125 137
126 addrs[0] = (void *)addr; 138 page = vmalloc_exec(PAGE_SIZE);
127 insns[0] = (u32)opcode; 139 if (page)
140 set_memory_ro((unsigned long)page, 1);
128 141
129 return aarch64_insn_patch_text(addrs, insns, 1); 142 return page;
130} 143}
131 144
132/* arm kprobe: install breakpoint in text */ 145/* arm kprobe: install breakpoint in text */