All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [Bug 1841442] [NEW] floating point emulation can fail to set FE_INEXACT
@ 2019-08-26 15:00 Paul Clarke
  2019-08-26 15:31 ` [Qemu-devel] [Bug 1841442] " Richard Henderson
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Paul Clarke @ 2019-08-26 15:00 UTC (permalink / raw)
  To: qemu-devel

Public bug reported:

Floating point emulation can fail to set FE_INEXACT in some
circumstances. This shows up quite often in glibc's "math" tests.  A
similar test is attached.

On ppc64le native:
--
$ gcc nextafter.c -o nextafter -lm
$ ./nextafter $(./nextafter)
0x0000000000000001 0.000000
0x0

0xa000000
FE_INEXACT FE_UNDERFLOW
0x0000000000000000 0.000000
--

On x86_64:
--
$ gcc nextafter.c -o nextafter -lm
$ ./nextafter $(./nextafter)
0x0000000000000001 0.000000
0x0

0x30
FE_INEXACT FE_UNDERFLOW 
0x0000000000000000 0.000000
--

Using qemu-system-ppc64
--
$ ./nextafter $(./nextafter)
0x0000000000000001 0.000000
0x0

0x8000000
FE_UNDERFLOW 
0x0000000000000000 0.000000
--

Using qemu-x86_64:
--
$ ./nextafter $(./nextafter)
0x0000000000000001 0.000000
0x0

0x0

0x0000000000000000 0.000000
--

QEMU versions vary, but not too much, and are pretty close to git HEAD:
- 586f3dced9 (HEAD -> master, origin/master, origin/HEAD) Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20190822' into staging
- 864ab31 Update version for v4.1.0-rc4 release

Since the issue happens nearly identically on different targets, I
suspect the issue lies somewhere in fpu/softfloat.c.

** Affects: qemu
     Importance: Undecided
         Status: New

** Attachment added: "testcase reporting exceptions set by nextafter"
   https://bugs.launchpad.net/bugs/1841442/+attachment/5284718/+files/nextafter.c

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1841442

Title:
  floating point emulation can fail to set FE_INEXACT

Status in QEMU:
  New

Bug description:
  Floating point emulation can fail to set FE_INEXACT in some
  circumstances. This shows up quite often in glibc's "math" tests.  A
  similar test is attached.

  On ppc64le native:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0xa000000
  FE_INEXACT FE_UNDERFLOW
  0x0000000000000000 0.000000
  --

  On x86_64:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x30
  FE_INEXACT FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-system-ppc64
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x8000000
  FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-x86_64:
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x0

  0x0000000000000000 0.000000
  --

  QEMU versions vary, but not too much, and are pretty close to git HEAD:
  - 586f3dced9 (HEAD -> master, origin/master, origin/HEAD) Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20190822' into staging
  - 864ab31 Update version for v4.1.0-rc4 release

  Since the issue happens nearly identically on different targets, I
  suspect the issue lies somewhere in fpu/softfloat.c.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1841442/+subscriptions


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [Bug 1841442] Re: floating point emulation can fail to set FE_INEXACT
  2019-08-26 15:00 [Qemu-devel] [Bug 1841442] [NEW] floating point emulation can fail to set FE_INEXACT Paul Clarke
@ 2019-08-26 15:31 ` Richard Henderson
  2019-08-26 16:11     ` Alex Bennée
  2019-08-26 15:57 ` Paul Clarke
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Richard Henderson @ 2019-08-26 15:31 UTC (permalink / raw)
  To: qemu-devel

Well, maybe yes and maybe no.  What you've done is choose two targets
whose floating point emulation have not been well maintained.

If I try this same test on aarch64, it passes:

$ ~/a.out 0x0000000000000001
0x0000000000000001 0.000000
0x0

0x18
FE_INEXACT FE_UNDERFLOW 
0x0000000000000000 0.000000

$ ./aarch64-linux-user/qemu-aarch64 ~/a.out 0x0000000000000001
0x0000000000000001 0.000000
0x0

0x18
FE_INEXACT FE_UNDERFLOW 
0x0000000000000000 0.000000

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1841442

Title:
  floating point emulation can fail to set FE_INEXACT

Status in QEMU:
  New

Bug description:
  Floating point emulation can fail to set FE_INEXACT in some
  circumstances. This shows up quite often in glibc's "math" tests.  A
  similar test is attached.

  On ppc64le native:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0xa000000
  FE_INEXACT FE_UNDERFLOW
  0x0000000000000000 0.000000
  --

  On x86_64:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x30
  FE_INEXACT FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-system-ppc64
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x8000000
  FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-x86_64:
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x0

  0x0000000000000000 0.000000
  --

  QEMU versions vary, but not too much, and are pretty close to git HEAD:
  - 586f3dced9 (HEAD -> master, origin/master, origin/HEAD) Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20190822' into staging
  - 864ab31 Update version for v4.1.0-rc4 release

  Since the issue happens nearly identically on different targets, I
  suspect the issue lies somewhere in fpu/softfloat.c.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1841442/+subscriptions


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [Bug 1841442] Re: floating point emulation can fail to set FE_INEXACT
  2019-08-26 15:00 [Qemu-devel] [Bug 1841442] [NEW] floating point emulation can fail to set FE_INEXACT Paul Clarke
  2019-08-26 15:31 ` [Qemu-devel] [Bug 1841442] " Richard Henderson
@ 2019-08-26 15:57 ` Paul Clarke
  2019-08-26 17:06 ` Richard Henderson
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Paul Clarke @ 2019-08-26 15:57 UTC (permalink / raw)
  To: qemu-devel

Interesting. Did you run qemu-aarch64 on aarch64? If so, it may have
been using "hardfloat".  I ran "qemu-system-ppc64" on x86_64 and "qemu-
x86_64" on ppc64le to ensure I was using "softfloat".

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1841442

Title:
  floating point emulation can fail to set FE_INEXACT

Status in QEMU:
  New

Bug description:
  Floating point emulation can fail to set FE_INEXACT in some
  circumstances. This shows up quite often in glibc's "math" tests.  A
  similar test is attached.

  On ppc64le native:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0xa000000
  FE_INEXACT FE_UNDERFLOW
  0x0000000000000000 0.000000
  --

  On x86_64:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x30
  FE_INEXACT FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-system-ppc64
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x8000000
  FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-x86_64:
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x0

  0x0000000000000000 0.000000
  --

  QEMU versions vary, but not too much, and are pretty close to git HEAD:
  - 586f3dced9 (HEAD -> master, origin/master, origin/HEAD) Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20190822' into staging
  - 864ab31 Update version for v4.1.0-rc4 release

  Since the issue happens nearly identically on different targets, I
  suspect the issue lies somewhere in fpu/softfloat.c.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1841442/+subscriptions


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [Bug 1841442] Re: floating point emulation can fail to set FE_INEXACT
@ 2019-08-26 16:11     ` Alex Bennée
  0 siblings, 0 replies; 8+ messages in thread
From: Alex Bennée @ 2019-08-26 16:11 UTC (permalink / raw)
  To: Bug 1841442; +Cc: qemu-devel


Richard Henderson <rth@twiddle.net> writes:

> Well, maybe yes and maybe no.  What you've done is choose two targets
> whose floating point emulation have not been well maintained.

So this is a failure on the x86_64 and ppc64 frontends to correctly set
the softfloat modes when their appropriate registers are set?

>
> If I try this same test on aarch64, it passes:
>
> $ ~/a.out 0x0000000000000001
> 0x0000000000000001 0.000000
> 0x0
>
> 0x18
> FE_INEXACT FE_UNDERFLOW
> 0x0000000000000000 0.000000
>
> $ ./aarch64-linux-user/qemu-aarch64 ~/a.out 0x0000000000000001
> 0x0000000000000001 0.000000
> 0x0
>
> 0x18
> FE_INEXACT FE_UNDERFLOW
> 0x0000000000000000 0.000000


--
Alex Bennée


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] [Bug 1841442] Re: floating point emulation can fail to set FE_INEXACT
@ 2019-08-26 16:11     ` Alex Bennée
  0 siblings, 0 replies; 8+ messages in thread
From: Alex Bennée @ 2019-08-26 16:11 UTC (permalink / raw)
  To: qemu-devel

Richard Henderson <rth@twiddle.net> writes:

> Well, maybe yes and maybe no.  What you've done is choose two targets
> whose floating point emulation have not been well maintained.

So this is a failure on the x86_64 and ppc64 frontends to correctly set
the softfloat modes when their appropriate registers are set?

>
> If I try this same test on aarch64, it passes:
>
> $ ~/a.out 0x0000000000000001
> 0x0000000000000001 0.000000
> 0x0
>
> 0x18
> FE_INEXACT FE_UNDERFLOW
> 0x0000000000000000 0.000000
>
> $ ./aarch64-linux-user/qemu-aarch64 ~/a.out 0x0000000000000001
> 0x0000000000000001 0.000000
> 0x0
>
> 0x18
> FE_INEXACT FE_UNDERFLOW
> 0x0000000000000000 0.000000


--
Alex Bennée

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1841442

Title:
  floating point emulation can fail to set FE_INEXACT

Status in QEMU:
  New

Bug description:
  Floating point emulation can fail to set FE_INEXACT in some
  circumstances. This shows up quite often in glibc's "math" tests.  A
  similar test is attached.

  On ppc64le native:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0xa000000
  FE_INEXACT FE_UNDERFLOW
  0x0000000000000000 0.000000
  --

  On x86_64:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x30
  FE_INEXACT FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-system-ppc64
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x8000000
  FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-x86_64:
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x0

  0x0000000000000000 0.000000
  --

  QEMU versions vary, but not too much, and are pretty close to git HEAD:
  - 586f3dced9 (HEAD -> master, origin/master, origin/HEAD) Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20190822' into staging
  - 864ab31 Update version for v4.1.0-rc4 release

  Since the issue happens nearly identically on different targets, I
  suspect the issue lies somewhere in fpu/softfloat.c.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1841442/+subscriptions


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [Bug 1841442] Re: floating point emulation can fail to set FE_INEXACT
  2019-08-26 15:00 [Qemu-devel] [Bug 1841442] [NEW] floating point emulation can fail to set FE_INEXACT Paul Clarke
  2019-08-26 15:31 ` [Qemu-devel] [Bug 1841442] " Richard Henderson
  2019-08-26 15:57 ` Paul Clarke
@ 2019-08-26 17:06 ` Richard Henderson
  2019-08-26 17:09 ` Richard Henderson
  2020-03-10  8:47 ` Laurent Vivier
  4 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2019-08-26 17:06 UTC (permalink / raw)
  To: qemu-devel

> Interesting. Did you run qemu-aarch64 on aarch64? If so, it may have been
> using "hardfloat". I ran "qemu-system-ppc64" on x86_64 and "qemu-x86_64"
> on ppc64le to ensure I was using "softfloat".

That's not how that works.  Indeed, the point of the hardfloat path is to
accelerate fpu emulation for a non-native guest.

That said, qemu-system-ppc64 will *never* use hardfloat, because ppc always
need the current and correct result of inexact for emulation of the FI bit,
which requires that we use the softfloat path.

Also, use of the hardfloat path requires normal inputs.  For this test case
we're passing the minimum denormal input: 0x0000_0000_0000_0001.  So we will
always use the softfloat path for this.


** Changed in: qemu
       Status: New => Confirmed

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1841442

Title:
  floating point emulation can fail to set FE_INEXACT

Status in QEMU:
  Confirmed

Bug description:
  Floating point emulation can fail to set FE_INEXACT in some
  circumstances. This shows up quite often in glibc's "math" tests.  A
  similar test is attached.

  On ppc64le native:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0xa000000
  FE_INEXACT FE_UNDERFLOW
  0x0000000000000000 0.000000
  --

  On x86_64:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x30
  FE_INEXACT FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-system-ppc64
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x8000000
  FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-x86_64:
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x0

  0x0000000000000000 0.000000
  --

  QEMU versions vary, but not too much, and are pretty close to git HEAD:
  - 586f3dced9 (HEAD -> master, origin/master, origin/HEAD) Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20190822' into staging
  - 864ab31 Update version for v4.1.0-rc4 release

  Since the issue happens nearly identically on different targets, I
  suspect the issue lies somewhere in fpu/softfloat.c.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1841442/+subscriptions


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [Bug 1841442] Re: floating point emulation can fail to set FE_INEXACT
  2019-08-26 15:00 [Qemu-devel] [Bug 1841442] [NEW] floating point emulation can fail to set FE_INEXACT Paul Clarke
                   ` (2 preceding siblings ...)
  2019-08-26 17:06 ` Richard Henderson
@ 2019-08-26 17:09 ` Richard Henderson
  2020-03-10  8:47 ` Laurent Vivier
  4 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2019-08-26 17:09 UTC (permalink / raw)
  To: qemu-devel

Patch for ppc:
https://lists.gnu.org/archive/html/qemu-devel/2019-08/msg05532.html

Fixing x86_64 is significantly harder, as support for fp exceptions
is completely lacking in the code currently.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1841442

Title:
  floating point emulation can fail to set FE_INEXACT

Status in QEMU:
  Confirmed

Bug description:
  Floating point emulation can fail to set FE_INEXACT in some
  circumstances. This shows up quite often in glibc's "math" tests.  A
  similar test is attached.

  On ppc64le native:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0xa000000
  FE_INEXACT FE_UNDERFLOW
  0x0000000000000000 0.000000
  --

  On x86_64:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x30
  FE_INEXACT FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-system-ppc64
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x8000000
  FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-x86_64:
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x0

  0x0000000000000000 0.000000
  --

  QEMU versions vary, but not too much, and are pretty close to git HEAD:
  - 586f3dced9 (HEAD -> master, origin/master, origin/HEAD) Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20190822' into staging
  - 864ab31 Update version for v4.1.0-rc4 release

  Since the issue happens nearly identically on different targets, I
  suspect the issue lies somewhere in fpu/softfloat.c.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1841442/+subscriptions


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug 1841442] Re: floating point emulation can fail to set FE_INEXACT
  2019-08-26 15:00 [Qemu-devel] [Bug 1841442] [NEW] floating point emulation can fail to set FE_INEXACT Paul Clarke
                   ` (3 preceding siblings ...)
  2019-08-26 17:09 ` Richard Henderson
@ 2020-03-10  8:47 ` Laurent Vivier
  4 siblings, 0 replies; 8+ messages in thread
From: Laurent Vivier @ 2020-03-10  8:47 UTC (permalink / raw)
  To: qemu-devel

Fixed by 16ce2fffa660 ("target/ppc: Fix do_float_check_status vs
inexact")

** Changed in: qemu
       Status: Confirmed => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1841442

Title:
  floating point emulation can fail to set FE_INEXACT

Status in QEMU:
  Fix Released

Bug description:
  Floating point emulation can fail to set FE_INEXACT in some
  circumstances. This shows up quite often in glibc's "math" tests.  A
  similar test is attached.

  On ppc64le native:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0xa000000
  FE_INEXACT FE_UNDERFLOW
  0x0000000000000000 0.000000
  --

  On x86_64:
  --
  $ gcc nextafter.c -o nextafter -lm
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x30
  FE_INEXACT FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-system-ppc64
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x8000000
  FE_UNDERFLOW 
  0x0000000000000000 0.000000
  --

  Using qemu-x86_64:
  --
  $ ./nextafter $(./nextafter)
  0x0000000000000001 0.000000
  0x0

  0x0

  0x0000000000000000 0.000000
  --

  QEMU versions vary, but not too much, and are pretty close to git HEAD:
  - 586f3dced9 (HEAD -> master, origin/master, origin/HEAD) Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20190822' into staging
  - 864ab31 Update version for v4.1.0-rc4 release

  Since the issue happens nearly identically on different targets, I
  suspect the issue lies somewhere in fpu/softfloat.c.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1841442/+subscriptions


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-03-10  8:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-26 15:00 [Qemu-devel] [Bug 1841442] [NEW] floating point emulation can fail to set FE_INEXACT Paul Clarke
2019-08-26 15:31 ` [Qemu-devel] [Bug 1841442] " Richard Henderson
2019-08-26 16:11   ` Alex Bennée
2019-08-26 16:11     ` Alex Bennée
2019-08-26 15:57 ` Paul Clarke
2019-08-26 17:06 ` Richard Henderson
2019-08-26 17:09 ` Richard Henderson
2020-03-10  8:47 ` Laurent Vivier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.