Skip to contentSkip to conversation

arm64: rename dump_instr as dump_kernel_instr

PATCH Applied jinho lim 3 participants 3 messages Jun 26, 2019 1 message not in the archive arm64

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20190626115016epcas1p455530417de86ea2e72ce1b389ae57a75@epcas1p4.samsung.com

jinho lim

author
#1 lore raw

PATCH v3 1/1 arm64: rename dump_instr as dump_kernel_instr

In traps.c, only __die calls dump_instr. However, this function has sub-function as __dump_instr.

dump_kernel_instr can replace those functions.
By using aarch64_insn_read, it does not have to change fs to KERNEL_DS.

---
 arch/arm64/kernel/traps.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)
arch/arm64/kernel/traps.c +7 -16
index ccc13b45d9b1..7e69454fd250 100644
@@ -66,16 +66,19 @@ static void dump_backtrace_entry(unsigned long where)
 	printk(" %pS\n", (void *)where);
 }
 
-static void __dump_instr(const char *lvl, struct pt_regs *regs)
+static void dump_kernel_instr(const char *lvl, struct pt_regs *regs)
 {
 	unsigned long addr = instruction_pointer(regs);
 	char str[sizeof("00000000 ") * 5 + 2 + 1], *p = str;
 	int i;
 
+	if (user_mode(regs))
+		return;
+
 	for (i = -4; i < 1; i++) {
 		unsigned int val, bad;
 
-		bad = get_user(val, &((u32 *)addr)[i]);
+		bad = aarch64_insn_read(&((u32 *)addr)[i], &val);
 
 		if (!bad)
 			p += sprintf(p, i == 0 ? "(%08x) " : "%08x ", val);
@@ -84,19 +87,8 @@ static void __dump_instr(const char *lvl, struct pt_regs *regs)
 			break;
 		}
 	}
-	printk("%sCode: %s\n", lvl, str);
-}
 
-static void dump_instr(const char *lvl, struct pt_regs *regs)
-{
-	if (!user_mode(regs)) {
-		mm_segment_t fs = get_fs();
-		set_fs(KERNEL_DS);
-		__dump_instr(lvl, regs);
-		set_fs(fs);
-	} else {
-		__dump_instr(lvl, regs);
-	}
+	printk("%sCode: %s\n", lvl, str);
 }
 
 void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
@@ -182,8 +174,7 @@ static int __die(const char *str, int err, struct pt_regs *regs)
 	print_modules();
 	show_regs(regs);
 
-	if (!user_mode(regs))
-		dump_instr(KERN_EMERG, regs);
+	dump_kernel_instr(KERN_EMERG, regs);
 
 	return ret;
 }
Signature · 1 line
2.17.1
maintainer Acked-by on v3 1/1
#2 lore raw
Quoted 10 lines · jinho lim

In traps.c, only __die calls dump_instr. However, this function has sub-function as __dump_instr.

dump_kernel_instr can replace those functions.
By using aarch64_insn_read, it does not have to change fs to KERNEL_DS.

---
 arch/arm64/kernel/traps.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

Thanks, this looks good to me now:

Catalin can pick this up for 5.3.

Will

maintainer Applied
#3 lore raw
In reply to jinho lim
Quoted 7 lines · jinho lim

In traps.c, only __die calls dump_instr. However, this function has sub-function as __dump_instr.

dump_kernel_instr can replace those functions.
By using aarch64_insn_read, it does not have to change fs to KERNEL_DS.

Queued for 5.3. Thanks.

Signature · 1 line
Catalin