[PATCH -next V17 4/7] riscv: entry: Convert to generic entry
Björn Töpel
bjorn at kernel.org
Sat Apr 1 11:41:27 PDT 2023
Heiko Stübner <heiko at sntech.de> writes:
> Am Samstag, 1. April 2023, 16:58:01 CEST schrieb Björn Töpel:
>> Björn Töpel <bjorn at kernel.org> writes:
>>
>> > (Narrowing the Cc list.)
>> >
>> > Björn Töpel <bjorn at 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 at vrull.eu>
> Tested-by: Heiko Stuebner <heiko.stuebner at vrull.eu>
Cool, and thanks for testing/verifying! I'll cook a proper patch on
Monday.
Björn
More information about the linux-riscv
mailing list