[klibc] [klibc:master] mips/mips64: Get rid of delay slot hacks

klibc-bot for Jiaxun Yang jiaxun.yang at flygoat.com
Fri Nov 11 16:18:06 PST 2022


Commit-ID:  4a9d3b35a2d40bbf4f821f2eddebc1e1846059cd
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=4a9d3b35a2d40bbf4f821f2eddebc1e1846059cd
Author:     Jiaxun Yang <jiaxun.yang at flygoat.com>
AuthorDate: Fri, 11 Nov 2022 20:01:37 +0000
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Fri, 11 Nov 2022 23:54:04 +0100

[klibc] 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>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

---
 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);
 }


More information about the klibc mailing list