lkml.org 
[lkml]   [2020]   [Sep]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/9] ARM: traps: use get_kernel_nofault instead of set_fs()
> +static void dump_mem(const char *, const char *, unsigned long, unsigned long, bool kernel_mode);

This adds a pointlessly long line.

And looking at the code I don't see why the argument is even needed.

dump_mem() currently does an unconditional set_fs(KERNEL_DS), so it
should always use get_kernel_nofault.

> +static void dump_instr(const char *lvl, struct pt_regs *regs)
> {
> unsigned long addr = instruction_pointer(regs);
> const int thumb = thumb_mode(regs);
> @@ -173,10 +169,20 @@ static void __dump_instr(const char *lvl, struct pt_regs *regs)
> for (i = -4; i < 1 + !!thumb; i++) {
> unsigned int val, bad;
>
> - if (thumb)
> - bad = get_user(val, &((u16 *)addr)[i]);
> - else
> - bad = get_user(val, &((u32 *)addr)[i]);
> + if (!user_mode(regs)) {
> + if (thumb) {
> + u16 val16;
> + bad = get_kernel_nofault(val16, &((u16 *)addr)[i]);
> + val = val16;
> + } else {
> + bad = get_kernel_nofault(val, &((u32 *)addr)[i]);
> + }
> + } else {
> + if (thumb)
> + bad = get_user(val, &((u16 *)addr)[i]);
> + else
> + bad = get_user(val, &((u32 *)addr)[i]);
> + }

When I looked at this earlier I just added a little helper to make
this a little easier to read. Here is my patch from an old tree:

http://git.infradead.org/users/hch/misc.git/commitdiff/67413030ccb7a64a7eb828e13ff0795f4eadfeb7

\
 
 \ /
  Last update: 2020-09-08 08:16    [W:0.110 / U:0.552 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site