mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: mips fp32/fpxx/fp64 issues, r6 sjlj broken
Date: Thu, 26 Sep 2019 19:23:50 -0400	[thread overview]
Message-ID: <20190926232350.GD9017@brightrain.aerifal.cx> (raw)
In-Reply-To: <20190926224520.GC9017@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 1328 bytes --]

On Thu, Sep 26, 2019 at 06:45:21PM -0400, Rich Felker wrote:
> Also, mipsr6 (the new mips-family ISA that's not compatible with
> previous mips) always uses the 64-bit register mode. We presently do
> not have setjmp/longjmp code that works with this case at all
> (existing code will wrongly save low 32-bits of 2 registers instead of
> single whole double register); somehow nobody has noticed that this is
> broken. Making this conditional on __mips_isa_rev >= 6 should not be
> hard.

Attached patch should work, but maybe isn't the best thing to do. I
think using sdc1/ldc1 and just even indices like on r6 would also be
valid for pre-r6 mips using fp32 or fpxx abi; with FR=0, it would
save/restore the pair of 32-bit registers, and with FR=1, fp32 code
could not be running anyway, and fpxx code should work fine. However,
mips I lacks the ldc1/stc1 instructions, so at the very least we'd
need to leave the old form in place for mips I. Or maybe use the s.d
and l.d mnemonics that automatically assemble to the right choice
based on the isa level...

BTW, the document I linked in the previous email mentions stuff about
setjmp having to align float args section at runtime, but that does
not seem relevant since the jmp_buf has always been 64-bit aligned, so
I didn't do anything like that. glibc doesn't either.

Rich

[-- Attachment #2: mips-sjlj.diff --]
[-- Type: text/plain, Size: 1216 bytes --]

diff --git a/src/setjmp/mips/longjmp.S b/src/setjmp/mips/longjmp.S
index fdb6c95d..162646b6 100644
--- a/src/setjmp/mips/longjmp.S
+++ b/src/setjmp/mips/longjmp.S
@@ -12,6 +12,14 @@ longjmp:
 	addu    $2, $2, 1
 1:
 #ifndef __mips_soft_float
+#if __mips_isa_rev >= 6
+	ldc1	$20, 56($4)
+	ldc1	$22, 64($4)
+	ldc1	$24, 72($4)
+	ldc1	$26, 80($4)
+	ldc1	$28, 88($4)
+	ldc1	$30, 96($4)
+#else
 	lwc1    $20, 56($4)
 	lwc1    $21, 60($4)
 	lwc1    $22, 64($4)
@@ -24,6 +32,7 @@ longjmp:
 	lwc1    $29, 92($4)
 	lwc1    $30, 96($4)
 	lwc1    $31, 100($4)
+#endif
 #endif
 	lw      $ra,  0($4)
 	lw      $sp,  4($4)
diff --git a/src/setjmp/mips/setjmp.S b/src/setjmp/mips/setjmp.S
index 501d5264..c2700bcb 100644
--- a/src/setjmp/mips/setjmp.S
+++ b/src/setjmp/mips/setjmp.S
@@ -22,6 +22,14 @@ setjmp:
 	sw      $30, 40($4)
 	sw      $28, 44($4)
 #ifndef __mips_soft_float
+#if __mips_isa_rev >= 6
+	sdc1	$20, 56($4)
+	sdc1	$22, 64($4)
+	sdc1	$24, 72($4)
+	sdc1	$26, 80($4)
+	sdc1	$28, 88($4)
+	sdc1	$30, 96($4)
+#else
 	swc1    $20, 56($4)
 	swc1    $21, 60($4)
 	swc1    $22, 64($4)
@@ -34,6 +42,7 @@ setjmp:
 	swc1    $29, 92($4)
 	swc1    $30, 96($4)
 	swc1    $31, 100($4)
+#endif
 #endif
 	jr      $ra
 	li      $2, 0

  reply	other threads:[~2019-09-26 23:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-26 22:45 Rich Felker
2019-09-26 23:23 ` Rich Felker [this message]
2019-09-27  0:38   ` Rich Felker
2019-09-27 11:10     ` Szabolcs Nagy
2019-09-27 11:52       ` Rich Felker
2019-09-27 11:55         ` Szabolcs Nagy
2019-09-27 14:44           ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190926232350.GD9017@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).