Jiaxun Yang
2022-Nov-11 20:01 UTC
[klibc] [PATCH v2] mips/mips64: Get rid of delay slot hacks
There are some MIPS assembly code trying to take advantage of delay slots. However in MIPS Release 6, assembler (LLVM) will try to relax traditional branch to compat branch, and having noreroder code will block assembler from doing so. Moreover, nowadays assemblers are smart enough to fill delay slots properly. Most of those hacks can actually be archived by assemblers. Signed-off-by: Jiaxun Yang <jiaxun.yang at flygoat.com> --- v2: Rewording commit message to avoid confusion Sorry about lose track of this matter before. --- usr/klibc/arch/mips/syscall.S | 4 ---- usr/klibc/arch/mips/sysstub.ph | 4 +--- usr/klibc/arch/mips/vfork.S | 3 +-- usr/klibc/arch/mips64/sysstub.ph | 4 +--- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/usr/klibc/arch/mips/syscall.S b/usr/klibc/arch/mips/syscall.S index cca0db22..a5cc73de 100644 --- a/usr/klibc/arch/mips/syscall.S +++ b/usr/klibc/arch/mips/syscall.S @@ -1,14 +1,10 @@ #include <machine/asm.h> #include <asm/unistd.h> - .set noreorder LEAF(__syscall_common) syscall beqz a3, 1f - # sw is actually two instructions; the first one goes - # in the branch delay slot - # XXX: Break this up manually; as it is now it generates warnings. sw v0, errno li v0, -1 1: jr ra diff --git a/usr/klibc/arch/mips/sysstub.ph b/usr/klibc/arch/mips/sysstub.ph index 36895291..a3475b70 100644 --- a/usr/klibc/arch/mips/sysstub.ph +++ b/usr/klibc/arch/mips/sysstub.ph @@ -17,11 +17,9 @@ sub make_sysstub($$$$$@) { print OUT "#include <machine/asm.h>\n"; print OUT "#include <asm/unistd.h>\n"; print OUT "\n"; - print OUT "\t.set noreorder\n"; - print OUT "\n"; print OUT "LEAF(${fname})\n"; - print OUT "\tj\t__syscall_${stype}\n"; print OUT "\t li\tv0, __NR_${sname}\n"; + print OUT "\tj\t__syscall_${stype}\n"; print OUT "\tEND(${fname})\n"; close(OUT); } diff --git a/usr/klibc/arch/mips/vfork.S b/usr/klibc/arch/mips/vfork.S index 9aa955ae..ae36d5fd 100644 --- a/usr/klibc/arch/mips/vfork.S +++ b/usr/klibc/arch/mips/vfork.S @@ -5,11 +5,10 @@ #define CLONE_VFORK 0x00004000 #define SIGCHLD 18 - .set noreorder LEAF(vfork) li a0, CLONE_VFORK | CLONE_VM | SIGCHLD li a1, 0 + li v0, __NR_clone j __syscall_common - li v0, __NR_clone END(vfork) diff --git a/usr/klibc/arch/mips64/sysstub.ph b/usr/klibc/arch/mips64/sysstub.ph index e8a02009..57af657f 100644 --- a/usr/klibc/arch/mips64/sysstub.ph +++ b/usr/klibc/arch/mips64/sysstub.ph @@ -17,11 +17,9 @@ sub make_sysstub($$$$$@) { print OUT "#include <machine/asm.h>\n"; print OUT "#include <asm/unistd.h>\n"; print OUT "\n"; - print OUT "\t.set noreorder\n"; - print OUT "\n"; print OUT "LEAF(${fname})\n"; - print OUT "\tj\t__syscall_${stype}\n"; print OUT "\t li\tv0, __NR_${sname}\n"; + print OUT "\tj\t__syscall_${stype}\n"; print OUT "\tEND(${fname})\n"; close(OUT); } -- 2.34.1
Ben Hutchings
2022-Nov-12 00:17 UTC
[klibc] [PATCH v2] mips/mips64: Get rid of delay slot hacks
On Fri, 2022-11-11 at 20:01 +0000, Jiaxun Yang wrote:> There are some MIPS assembly code trying to take advantage of > delay slots. > > However in MIPS Release 6, assembler (LLVM) will try to relax > traditional branch to compat branch, and having noreroder code > will block assembler from doing so. > > Moreover, nowadays assemblers are smart enough to fill delay slots > properly. Most of those hacks can actually be archived by assemblers. > > Signed-off-by: Jiaxun Yang <jiaxun.yang at flygoat.com> > --- > v2: Rewording commit message to avoid confusion > Sorry about lose track of this matter before.[...] Applied, thanks. Ben. -- Ben Hutchings All the simple programs have been written, and all the good names taken -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: This is a digitally signed message part URL: <https://lists.zytor.com/archives/klibc/attachments/20221112/cba7d938/attachment.sig>