* [PATCH v2] arm64: rename dump_instr as dump_kernel_instr
[not found] <CGME20190620065254epcas1p48539060e94433cc254a1650cdc359ac4@epcas1p4.samsung.com>
@ 2019-06-20 6:52 ` jinho lim
2019-06-24 13:21 ` Will Deacon
0 siblings, 1 reply; 2+ messages in thread
From: jinho lim @ 2019-06-20 6:52 UTC (permalink / raw)
To: will.deacon
Cc: mark.rutland, ebiederm, marc.zyngier, anshuman.khandual,
andreyknvl, linux-arm-kernel, linux-kernel, seroto7, jinho lim
[v2]
dump_kernel_instr does not work for user mode.
rename dump_instr function and remove __dump_instr.
Signed-off-by: jinho lim <jordan.lim@samsung.com>
---
Thanks for review, I rename dump_instr function and merge __dump_instr in it.
arch/arm64/kernel/traps.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index ccc13b45d9b1..7053165cb31a 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -66,11 +66,20 @@ 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);
+ unsigned long addr;
char str[sizeof("00000000 ") * 5 + 2 + 1], *p = str;
int i;
+ mm_segment_t fs;
+
+ if (user_mode(regs))
+ return;
+
+ addr = instruction_pointer(regs);
+
+ fs = get_fs();
+ set_fs(KERNEL_DS);
for (i = -4; i < 1; i++) {
unsigned int val, bad;
@@ -84,19 +93,10 @@ 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);
- }
+ set_fs(fs);
}
void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
@@ -182,8 +182,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;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] arm64: rename dump_instr as dump_kernel_instr
2019-06-20 6:52 ` [PATCH v2] arm64: rename dump_instr as dump_kernel_instr jinho lim
@ 2019-06-24 13:21 ` Will Deacon
0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2019-06-24 13:21 UTC (permalink / raw)
To: jinho lim
Cc: will.deacon, mark.rutland, anshuman.khandual, marc.zyngier,
andreyknvl, linux-kernel, seroto7, ebiederm, linux-arm-kernel
On Thu, Jun 20, 2019 at 03:52:49PM +0900, jinho lim wrote:
> [v2]
The version information is not usually part of the commit message. Please
drop that...
> dump_kernel_instr does not work for user mode.
> rename dump_instr function and remove __dump_instr.
... and rewrite this so it explains the problem that you're solving.
> Signed-off-by: jinho lim <jordan.lim@samsung.com>
> ---
>
> Thanks for review, I rename dump_instr function and merge __dump_instr in it.
>
> arch/arm64/kernel/traps.c | 29 ++++++++++++++---------------
> 1 file changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
> index ccc13b45d9b1..7053165cb31a 100644
> --- a/arch/arm64/kernel/traps.c
> +++ b/arch/arm64/kernel/traps.c
> @@ -66,11 +66,20 @@ 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);
> + unsigned long addr;
> char str[sizeof("00000000 ") * 5 + 2 + 1], *p = str;
> int i;
> + mm_segment_t fs;
> +
> + if (user_mode(regs))
> + return;
> +
> + addr = instruction_pointer(regs);
> +
> + fs = get_fs();
> + set_fs(KERNEL_DS);
Actually, if we use aarch64_insn_read() instead of get_user() then we can
avoid having to mess directly with the fs and we'll also get endianness
correction for free when running a big-endian kernel.
Will
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-24 13:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20190620065254epcas1p48539060e94433cc254a1650cdc359ac4@epcas1p4.samsung.com>
2019-06-20 6:52 ` [PATCH v2] arm64: rename dump_instr as dump_kernel_instr jinho lim
2019-06-24 13:21 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).