linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Heiko Stübner" <heiko@sntech.de>
To: "Guo Ren" <guoren@kernel.org>, "Björn Töpel" <bjorn@kernel.org>
Cc: "Conor Dooley" <conor@kernel.org>,
	palmer@rivosinc.com, linux-riscv@lists.infradead.org,
	"Guo Ren" <guoren@linux.alibaba.com>,
	"Björn Töpel" <bjorn@rivosinc.com>,
	"Yipeng Zou" <zouyipeng@huawei.com>
Subject: Re: [PATCH -next V17 4/7] riscv: entry: Convert to generic entry
Date: Sat, 01 Apr 2023 17:42:28 +0200	[thread overview]
Message-ID: <2173635.1BCLMh4Saa@diego> (raw)
In-Reply-To: <878rfblkee.fsf@all.your.base.are.belong.to.us>

Am Samstag, 1. April 2023, 16:58:01 CEST schrieb Björn Töpel:
> Björn Töpel <bjorn@kernel.org> writes:
> 
> > (Narrowing the Cc list.)
> >
> > Björn Töpel <bjorn@kernel.org> writes:
> >
> >>>> > > > This has unfortunately broken booting my usual NFS rootfs on both my D1
> >>>> > > > and Icicle. It's one of the Fedora images from David, I think this one:
> >>>> > > > http://fedora.riscv.rocks/kojifiles/work/tasks/3933/1313933/
> >>>> > > >
> >>>> > > > It gets pretty far into things, it's once systemd is operational that
> >>>> > > > things go pear shaped:
> >>>> > >
> >>>> > > Shoulda said, can share the full logs if required of course, but they're
> >>>> > > quite verbose cos systemd etc.
> >>>> >
> >>>> > I was just investigating the same thing just now. So that saves me some
> >>>> > tracking down the culprit :-) .
> >>>> >
> >>>> > My main qemu is living as a "board" in my boardfarm (also doing nfsroot)
> >>>> > as well as my d1 nezha with nfsroot was affected.
> >>>> Can you reproduce it with qemu? Could give me some tips and let me
> >>>> reproduce it on qemu?
> >>
> >> FWIW, I'm getting the systemd issue w/o NFS, on a regular 9p virtfs.
> >>
> >> | $ sudo mmdebstrap --architecture=riscv64 lunar rv-rootfs http://ports.ubuntu.com
> >>
> >> and the rootfs qemu config:
> >>  |  -fsdev local,id=root,path=/path/to/rv-rootfs/,security_model=none \
> >>  |  -device virtio-9p-pci,fsdev=root,mount_tag=/dev/root \
> >>  |  -append "root=/dev/root rw rootfstype=9p rootflags=version=9p2000.L,trans=virtio,cache=mmap,access=any security=none earlycon console=tty0 console=ttyS0"
> >
> > I took a couple of different versions of the series for a spin, and for
> > me it stops working between these versions.
> >
> > $ git fetch https://github.com/guoren83/linux.git generic_entry_v12:ge-v12
> > $ git fetch https://github.com/guoren83/linux.git generic_entry_v13:g2-v13
> >
> > v12 is happy with systemd, v13 is not.
> 
> Hmm, this patch seems to resolve the issue for me:
> 
> --8<--
> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
> index       1f4e37be7eb3..8c258b78c925 100644
> --- a/arch/riscv/kernel/traps.c
> +++ b/arch/riscv/kernel/traps.c
> @@ -270,11 +270,11 @@ asmlinkage __visible __trap_section void do_trap_ecall_u(struct pt_regs *regs)
>         if (user_mode(regs)) {
>                 ulong syscall = regs->a7;
>  
> -               syscall = syscall_enter_from_user_mode(regs, syscall);
> -
>                 regs->epc += 4;
>                 regs->orig_a0 = regs->a0;
>  
> +               syscall = syscall_enter_from_user_mode(regs, syscall);
> +
>                 if (syscall < NR_syscalls)
>                         syscall_handler(regs, syscall);
>                 else
> -->8--

Woohoo, thanks for tracking that down. This change makes both my
Qemu and D1-Nezha boot again.

> Seems like syscall_enter_from_user_mode() clobber regs->a0.

With a0 also being the return value in the calling conventions (and being
the syscall value here), I guess that could be somehow expected and thus
as your patch does, the a0 value should be saved first I guess?

An it looks like Loonarch also does save a0 before calling
syscall_enter_from_user_mode() [0]

Reviewed-by: Heiko Stuebner <heiko.stuebner@vrull.eu>
Tested-by: Heiko Stuebner <heiko.stuebner@vrull.eu>

Heiko


[0] https://elixir.bootlin.com/linux/latest/source/arch/loongarch/kernel/syscall.c#L54



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2023-04-01 15:43 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22  3:30 [PATCH -next V17 0/7] riscv: Add GENERIC_ENTRY support guoren
2023-02-22  3:30 ` [PATCH -next V17 1/7] compiler_types.h: Add __noinstr_section() for noinstr guoren
2023-03-22 14:46   ` Björn Töpel
2023-03-24  1:51     ` Guo Ren
2023-03-23  0:43   ` Lai Jiangshan
2023-02-22  3:30 ` [PATCH -next V17 2/7] riscv: ptrace: Remove duplicate operation guoren
2023-02-22  3:30 ` [PATCH -next V17 3/7] riscv: entry: Add noinstr to prevent instrumentation inserted guoren
2023-02-22  3:30 ` [PATCH -next V17 4/7] riscv: entry: Convert to generic entry guoren
2023-03-31 18:34   ` Conor Dooley
2023-03-31 18:41     ` Conor Dooley
2023-03-31 18:46       ` Heiko Stübner
2023-03-31 18:55         ` Conor Dooley
2023-03-31 21:22           ` Palmer Dabbelt
2023-04-01  2:15         ` Guo Ren
2023-04-01 12:10           ` Heiko Stübner
2023-04-01 13:19             ` Björn Töpel
2023-04-01 13:33               ` Björn Töpel
2023-04-01 14:58                 ` Björn Töpel
2023-04-01 15:42                   ` Heiko Stübner [this message]
2023-04-01 18:41                     ` Björn Töpel
2023-04-07  9:13                       ` Guo Ren
2023-04-07  9:18                         ` Conor.Dooley
2023-04-08  4:59                           ` Guo Ren
2023-04-01  1:39     ` Guo Ren
2023-04-01  9:32       ` Conor Dooley
2023-06-29 14:02   ` Daniel Thompson
2023-06-30 11:16     ` Guo Ren
2023-06-30 11:22       ` Guo Ren
2023-06-30 14:50         ` Daniel Thompson
2023-07-01  2:55           ` Guo Ren
2023-07-01  3:08             ` Guo Ren
2023-07-01  4:22               ` Guo Ren
2023-07-03  3:09                 ` Guo Ren
2023-02-22  3:30 ` [PATCH -next V17 5/7] riscv: entry: Remove extra level wrappers of trace_hardirqs_{on,off} guoren
2023-02-22  3:30 ` [PATCH -next V17 6/7] riscv: entry: Consolidate ret_from_kernel_thread into ret_from_fork guoren
2023-02-22  3:30 ` [PATCH -next V17 7/7] riscv: entry: Consolidate general regs saving/restoring guoren
2023-03-24 22:01 ` (subset) [PATCH -next V17 0/7] riscv: Add GENERIC_ENTRY support Palmer Dabbelt
2023-03-24 22:10 ` patchwork-bot+linux-riscv
2023-03-27 23:27 ` Palmer Dabbelt

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=2173635.1BCLMh4Saa@diego \
    --to=heiko@sntech.de \
    --cc=bjorn@kernel.org \
    --cc=bjorn@rivosinc.com \
    --cc=conor@kernel.org \
    --cc=guoren@kernel.org \
    --cc=guoren@linux.alibaba.com \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@rivosinc.com \
    --cc=zouyipeng@huawei.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).