mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] riscv64: fenv.S: Fix fesetenv(FE_DFL_ENV) failure
Date: Sat, 7 Dec 2019 13:00:16 -0500	[thread overview]
Message-ID: <20191207180016.GA1666@brightrain.aerifal.cx> (raw)
In-Reply-To: <20191202110648.GA3068@APC301.andestech.com>

On Mon, Dec 02, 2019 at 07:06:52PM +0800, Ruinland ChuanTzu Tsai wrote:
> Hi all, 
> during testing libc-test on RV64,
> I happended to encounter a segfault on math/fenv.exe .
> 
> When FE_DFL_ENV is passed to fesetenv(),
> the very first instruction : lw t1, 0(a0) 
> will fail since a0 is -1 .
> 
> Here's quick hack - -
> 
> git diff -- src/fenv/riscv64/fenv.S
> diff --git a/src/fenv/riscv64/fenv.S b/src/fenv/riscv64/fenv.S
> index 97f74dd6..06215954 100644
> --- a/src/fenv/riscv64/fenv.S
> +++ b/src/fenv/riscv64/fenv.S
> @@ -45,8 +45,12 @@ fegetenv:
>  .global fesetenv
>  .type fesetenv, %function
>  fesetenv:
> +        li t2, -1
> +        li t1, 0
> +        beq a0, t2, setfpcsr
>          lw t1, 0(a0)
> -        fscsr t0, t1
> +setfpcsr:
> +        fscsr t1
>          li a0, 0
>          ret
> 
> And the test case will pass.

Looks mostly ok. Applying without the label name, 1f/1: instead. I was
a bit confused by the removal of the t0 operand from fscsr but
apparently the one-operand form implicitly uses the zero register as
rd.

Rich


      parent reply	other threads:[~2019-12-07 18:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-02 11:06 Ruinland ChuanTzu Tsai
2019-12-02 16:46 ` Szabolcs Nagy
2019-12-07 18:00 ` Rich Felker [this message]

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=20191207180016.GA1666@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).