From: "Björn Töpel" <bjorn@kernel.org>
To: yunhui cui <cuiyunhui@bytedance.com>
Cc: paul.walmsley@sifive.com, palmer@dabbelt.com,
aou@eecs.berkeley.edu, guoren@kernel.org, bjorn@rivosinc.com,
conor.dooley@microchip.com, jszhang@kernel.org,
andy.chiu@sifive.com, dave.hansen@linux.intel.com,
elver@google.com, glider@google.com, cyphar@cyphar.com,
kirill.shutemov@linux.intel.com, keescook@chromium.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [External] Re: [PATCH v5] riscv: add userland instruction dump to RISC-V splats
Date: Fri, 08 Sep 2023 20:00:55 +0200 [thread overview]
Message-ID: <87r0n8pmso.fsf@all.your.base.are.belong.to.us> (raw)
In-Reply-To: <CAEEQ3wnDAJOMo2SZAB23aZgOhBKPmZegC9E048YJaFhiXEkA-A@mail.gmail.com>
yunhui cui <cuiyunhui@bytedance.com> writes:
> Hi Björn,
>
> On Fri, Sep 8, 2023 at 2:45 AM Björn Töpel <bjorn@kernel.org> wrote:
>>
>> Yunhui Cui <cuiyunhui@bytedance.com> writes:
>>
>> > Add userland instruction dump and rename dump_kernel_instr()
>> > to dump_instr().
>> >
>> > An example:
>> > [ 0.822439] Freeing unused kernel image (initmem) memory: 6916K
>> > [ 0.823817] Run /init as init process
>> > [ 0.839411] init[1]: unhandled signal 4 code 0x1 at 0x000000000005be18 in bb[10000+5fb000]
>> > [ 0.840751] CPU: 0 PID: 1 Comm: init Not tainted 5.14.0-rc4-00049-gbd644290aa72-dirty #187
>> > [ 0.841373] Hardware name: , BIOS
>> > [ 0.841743] epc : 000000000005be18 ra : 0000000000079e74 sp : 0000003fffcafda0
>> > [ 0.842271] gp : ffffffff816e9dc8 tp : 0000000000000000 t0 : 0000000000000000
>> > [ 0.842947] t1 : 0000003fffc9fdf0 t2 : 0000000000000000 s0 : 0000000000000000
>> > [ 0.843434] s1 : 0000000000000000 a0 : 0000003fffca0190 a1 : 0000003fffcafe18
>> > [ 0.843891] a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000000
>> > [ 0.844357] a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000
>> > [ 0.844803] s2 : 0000000000000000 s3 : 0000000000000000 s4 : 0000000000000000
>> > [ 0.845253] s5 : 0000000000000000 s6 : 0000000000000000 s7 : 0000000000000000
>> > [ 0.845722] s8 : 0000000000000000 s9 : 0000000000000000 s10: 0000000000000000
>> > [ 0.846180] s11: 0000000000d144e0 t3 : 0000000000000000 t4 : 0000000000000000
>> > [ 0.846616] t5 : 0000000000000000 t6 : 0000000000000000
>> > [ 0.847204] status: 0000000200000020 badaddr: 00000000f0028053 cause: 0000000000000002
>> > [ 0.848219] Code: f06f ff5f 3823 fa11 0113 fb01 2e23 0201 0293 0000 (8053) f002
>> > [ 0.851016] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004
>> >
>> > Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
>> > ---
>> > arch/riscv/kernel/traps.c | 19 ++++++++++++++++---
>> > 1 file changed, 16 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
>> > index f798c853bede..923b49c38985 100644
>> > --- a/arch/riscv/kernel/traps.c
>> > +++ b/arch/riscv/kernel/traps.c
>> > @@ -33,7 +33,19 @@ int show_unhandled_signals = 1;
>> >
>> > static DEFINE_SPINLOCK(die_lock);
>> >
>> > -static void dump_kernel_instr(const char *loglvl, struct pt_regs *regs)
>> > +static int copy_code(struct pt_regs *regs, u16 *val, const u16 *insns)
>> > +{
>> > + if (!user_mode(regs))
>> > + return get_kernel_nofault(*val, insns);
>> > +
>> > + /* The user space code from other tasks cannot be accessed. */
>> > + if (regs != task_pt_regs(current))
>> > + return -EPERM;
>> > +
>> > + return copy_from_user_nofault(val, insns, sizeof(*val));
>>
>> Hmm, I think you missed the actual problem in [1]. I'm still getting:
>>
>> | CHECK arch/riscv/kernel/traps.c
>> | arch/riscv/kernel/traps.c:46:44: warning: incorrect type in argument 2 (different address spaces)
>> | arch/riscv/kernel/traps.c:46:44: expected void const [noderef] __user *src
>> | arch/riscv/kernel/traps.c:46:44: got unsigned short const [usertype] *insns
>>
>
> How did the warnings above come about? I don't have one locally. What
> is your risc-v gcc version?
It's from the "sparse" tool. Pass "C=1" to make. Unfortunately RV sparse
needs to be built manually: https://github.com/ConchuOD/sparse
| make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- C=1 W=1 arch/riscv/kernel/traps.o
Thanks!
Björn
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2023-09-08 18:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-01 12:30 [PATCH v5] riscv: add userland instruction dump to RISC-V splats Yunhui Cui
2023-09-07 11:43 ` yunhui cui
2023-09-07 18:45 ` Björn Töpel
2023-09-08 13:15 ` [External] " yunhui cui
2023-09-08 18:00 ` Björn Töpel [this message]
2023-09-12 2:13 ` yunhui cui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r0n8pmso.fsf@all.your.base.are.belong.to.us \
--to=bjorn@kernel.org \
--cc=andy.chiu@sifive.com \
--cc=aou@eecs.berkeley.edu \
--cc=bjorn@rivosinc.com \
--cc=conor.dooley@microchip.com \
--cc=cuiyunhui@bytedance.com \
--cc=cyphar@cyphar.com \
--cc=dave.hansen@linux.intel.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=guoren@kernel.org \
--cc=jszhang@kernel.org \
--cc=keescook@chromium.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).