NetBSD-Bugs archive

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

port-mips/59342: compat_setjmp.S is confused about delay slots



>Number:         59342
>Category:       port-mips
>Synopsis:       compat_setjmp.S is confused about delay slots
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-mips-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 23 01:55:00 +0000 2025
>Originator:     Taylor R Campbell
>Release:        current, 10, 9, 8, 7, 6, ...
>Organization:
The Foundation MipsBSD--no, wait, is that a delay slot or not?
>Environment:
>Description:
compat_setjmp.S tries to set the return value to zero through a delay slot:

    143 	j	ra
    144 	move	v0, zero

https://nxr.netbsd.org/xref/src/lib/libc/compat/arch/mips/gen/compat_setjmp.S?r=1.5#143

Unfortunately, this file is built without `.set noreorder', so the Mips Magical Mystery Assembler fills this with a nop and the move never happens and the compat13 setjmp() function returns garbage:

   85fcc:       03e00008        jr      ra
   85fd0:       00000000        nop
   85fd4:       00001025        move    v0,zero

This was broken in rev. 1.1.34.1 on the matt-nb5-mips64 branch.  The modern __setjmp14 function was later fixed on the branch and in HEAD, but the fix was not applied to the compat13 setjmp function.
>How-To-Repeat:
run a binary that uses compat13 setjmp and longjmp
>Fix:
reorder the j/move instructions -- not sure what other havoc using `.set noreorder' would cause on this file so let's not even try



Home | Main Index | Thread Index | Old Index