lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87pmbcnlpz.fsf@all.your.base.are.belong.to.us>
Date:   Wed, 18 Jan 2023 12:08:56 +0100
From:   Björn Töpel <bjorn@...nel.org>
To:     Geert Uytterhoeven <geert@...ux-m68k.org>
Cc:     Paul Walmsley <paul.walmsley@...ive.com>,
        Palmer Dabbelt <palmer@...belt.com>,
        Albert Ou <aou@...s.berkeley.edu>,
        linux-riscv@...ts.infradead.org,
        Björn Töpel <bjorn@...osinc.com>,
        Andreas Schwab <schwab@...ux-m68k.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/2] riscv: Add instruction dump to RISC-V splats

Geert Uytterhoeven <geert@...ux-m68k.org> writes:

>> +static void dump_kernel_instr(const char *loglvl, struct pt_regs *regs)
>> +{
>> +       char str[sizeof("0000 ") * 12 + 2 + 1], *p = str;
>> +       unsigned long addr = regs->epc;
>
> Given you never use this as an unsigned long, what about
>
>     const u16 *insns = (u16 *)instruction_pointer(regs);
>
> so you no longer need casts below?

Indeed! Good suggestion, thank you! I'll do this change in v3.

>> +       long bad;
>> +       u16 val;
>> +       int i;
>> +
>> +       for (i = -10; i < 2; i++) {
>> +               bad = get_kernel_nofault(val, &((u16 *)addr)[i]);
>> +               if (!bad) {
>> +                       p += sprintf(p, i == 0 ? "(%04hx) " : "%04hx ", val);
>> +               } else {
>> +                       printk("%sCode: Unable to access instruction at 0x%lx.\n",
>
> %px, so you can drop the cast to long below.

Much cleaner. Thanks!


Björn

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ