NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-riscv/59304: kernel longjmp(9) fails to make setjmp(9) return 1



>Number:         59304
>Category:       port-riscv
>Synopsis:       kernel longjmp(9) fails to make setjmp(9) return 1
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-riscv-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 17 04:55:00 +0000 2025
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The Risc of the Long Jmp Foundation
>Environment:
>Description:
Kernel longjmp(9) is supposed to make setjmp(9) return 1 -- it doesn't take a second argument for the return value.  But the riscv code does this:

    520 	mv	a0, a1
    521 	ret

https://nxr.netbsd.org/xref/src/sys/arch/riscv/riscv/cpu_switch.S?r=1.6#520

So it returns whatever garbage happens to be in a1.
>How-To-Repeat:
code inspection
mess with ddb, probably
>Fix:
Change

mv a0, a1

to

li a0, 1



Home | Main Index | Thread Index | Old Index