On Mon, Mar 21, 2022 at 08:03:40PM +0000, Miod Vallat wrote:
> Unlike userland, the OpenBSD kernel longjmp() function does not take a
> return value for setjmp as second argument, but is guaranteed to return
> nonzero.
>
> The following diff makes sure the code matches this expectation.
>
> Completely untested, yadda yadda.
powerpc64 also needs a change for this
ok jsg@ for both
Index: locore.S
===================================================================
RCS file: /cvs/src/sys/arch/powerpc64/powerpc64/locore.S,v
retrieving revision 1.43
diff -u -p -r1.43 locore.S
--- locore.S 23 Jan 2021 12:10:08 -0000 1.43
+++ locore.S 22 Mar 2022 00:34:40 -0000
@@ -562,7 +562,7 @@ longjmp:
ld %r29, 0x98(%r3)
ld %r30, 0xa0(%r3)
ld %r31, 0xa8(%r3)
- mr %r4, %r3 /* return val */
+ li %r3, 1 /* return non-zero */
RETGUARD_CHECK(longjmp, %r11)
blr
#endif
>
> Index: support.S
> ===================================================================
> RCS file: /OpenBSD/src/sys/arch/riscv64/riscv64/support.S,v
> retrieving revision 1.2
> diff -u -p -r1.2 support.S
> --- support.S 12 May 2021 01:20:52 -0000 1.2
> +++ support.S 21 Mar 2022 20:02:03 -0000
> @@ -58,7 +58,7 @@ ENTRY(setjmp)
> sd s11, (11 * 8)(a0)
> sd ra, (12 * 8)(a0)
>
> - /* Return value */
> + /* Return zero */
> li a0, 0
> ret
> END(setjmp)
> @@ -83,7 +83,7 @@ ENTRY(longjmp)
> ld s11, (11 * 8)(a0)
> ld ra, (12 * 8)(a0)
>
> - /* Load the return value */
> - mv a0, a1
> + /* Return nonzero */
> + li a0, 1
> ret
> END(longjmp)
>
>