* Are floating-point exceptions usable on AArch64?
@ 2024-09-04 10:11 Sebastian Huber
2024-09-04 12:18 ` Peter Maydell
2024-09-26 13:52 ` Peter Maydell
0 siblings, 2 replies; 3+ messages in thread
From: Sebastian Huber @ 2024-09-04 10:11 UTC (permalink / raw)
To: qemu-devel
Hello,
I tried to provoke a division-by-zero exception on AArch64 using:
uint64_t value;
__asm__ volatile (
"mrs %0, FPCR\n"
"orr %0, %0, 0x200\n"
"msr FPCR, %0" : "=&r" ( value ) : : "memory"
);
volatile double x = 0x0;
volatile double y = 0x0;
x /= y;
When I look with the debugger at $fpcr it still says 0x0 after the msr. Are floating-point exceptions usable on AArch64 in general?
--
embedded brains GmbH & Co. KG
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Are floating-point exceptions usable on AArch64?
2024-09-04 10:11 Are floating-point exceptions usable on AArch64? Sebastian Huber
@ 2024-09-04 12:18 ` Peter Maydell
2024-09-26 13:52 ` Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2024-09-04 12:18 UTC (permalink / raw)
To: Sebastian Huber; +Cc: qemu-devel
On Wed, 4 Sept 2024 at 11:32, Sebastian Huber
<sebastian.huber@embedded-brains.de> wrote:
> I tried to provoke a division-by-zero exception on AArch64 using:
>
> uint64_t value;
> __asm__ volatile (
> "mrs %0, FPCR\n"
> "orr %0, %0, 0x200\n"
> "msr FPCR, %0" : "=&r" ( value ) : : "memory"
> );
> volatile double x = 0x0;
> volatile double y = 0x0;
> x /= y;
>
> When I look with the debugger at $fpcr it still says 0x0
> after the msr. Are floating-point exceptions usable on
> AArch64 in general?
Floating point exceptions, in the sense of "when the
exception condition happens the cumulative exception bit
in the FPSR is set", work. What you're trying to use here is what
the architecture calls "trapped exception handling", where
you set the DZE etc bits in the FPCR to get a CPU exception
instead of it updating the FPSR bit. Those are architecturally
optional, and QEMU's CPU implementation doesn't implement them.
(Nor do most real hardware implementations AFAIK.)
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Are floating-point exceptions usable on AArch64?
2024-09-04 10:11 Are floating-point exceptions usable on AArch64? Sebastian Huber
2024-09-04 12:18 ` Peter Maydell
@ 2024-09-26 13:52 ` Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2024-09-26 13:52 UTC (permalink / raw)
To: Sebastian Huber; +Cc: qemu-devel
On Wed, 4 Sept 2024 at 11:32, Sebastian Huber
<sebastian.huber@embedded-brains.de> wrote:
>
> Hello,
>
> I tried to provoke a division-by-zero exception on AArch64 using:
>
> uint64_t value;
> __asm__ volatile (
> "mrs %0, FPCR\n"
> "orr %0, %0, 0x200\n"
> "msr FPCR, %0" : "=&r" ( value ) : : "memory"
> );
> volatile double x = 0x0;
> volatile double y = 0x0;
> x /= y;
>
> When I look with the debugger at $fpcr it still says 0x0 after the msr. Are floating-point exceptions usable on AArch64 in general?
Something I just noticed when I was playing around with this
example for other reasons -- it won't trigger an exception
even on a system where trapped floating point exceptions are
implemented. This is because in the FPCR you are setting the
DZE bit to request trapping of division by zero. However the
operation you are doing is 0 / 0, which is defined to
set the InvalidOp floating point exception. If you want
to get a DivideByZero condition you need to divide some
non-zero number by 0.
thanks
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-26 13:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-04 10:11 Are floating-point exceptions usable on AArch64? Sebastian Huber
2024-09-04 12:18 ` Peter Maydell
2024-09-26 13:52 ` Peter Maydell
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).