* [PATCH 1/2] tests/tcg/ppc64le: Added an overflow with OE=1 test
@ 2022-08-17 16:57 Lucas Mateus Castro(alqotel)
2022-08-17 16:57 ` [PATCH 2/2] tests/tcg/ppc64le: Added an underflow with UE=1 test Lucas Mateus Castro(alqotel)
2022-08-18 15:32 ` [PATCH 1/2] tests/tcg/ppc64le: Added an overflow with OE=1 test Richard Henderson
0 siblings, 2 replies; 4+ messages in thread
From: Lucas Mateus Castro(alqotel) @ 2022-08-17 16:57 UTC (permalink / raw)
To: qemu-ppc, qemu-devel
Cc: richard.henderson, danielhb413, Lucas Mateus Castro (alqotel)
From: "Lucas Mateus Castro (alqotel)" <lucas.araujo@eldorado.org.br>
Added a test to see if the adjustment is being made correctly when an
overflow occurs and OE is set.
Signed-off-by: Lucas Mateus Castro (alqotel) <lucas.araujo@eldorado.org.br>
---
The prctl patch is not ready yet, so this patch does as Richard
Henderson suggested and check the fp register in the signal handler
This patch will fail without the overflow with OE set bugfix
Message-Id:<20220805141522.412864-3-lucas.araujo@eldorado.org.br>
---
tests/tcg/ppc64/Makefile.target | 1 +
tests/tcg/ppc64le/Makefile.target | 1 +
tests/tcg/ppc64le/oe_excp.c | 54 +++++++++++++++++++++++++++++++
3 files changed, 56 insertions(+)
create mode 100644 tests/tcg/ppc64le/oe_excp.c
diff --git a/tests/tcg/ppc64/Makefile.target b/tests/tcg/ppc64/Makefile.target
index 331fae628e..43958ad87b 100644
--- a/tests/tcg/ppc64/Makefile.target
+++ b/tests/tcg/ppc64/Makefile.target
@@ -29,5 +29,6 @@ run-plugin-sha512-vector-with-%: QEMU_OPTS+=-cpu POWER10
PPC64_TESTS += signal_save_restore_xer
PPC64_TESTS += xxspltw
+PPC64_TESTS += oe_excp
TESTS += $(PPC64_TESTS)
diff --git a/tests/tcg/ppc64le/Makefile.target b/tests/tcg/ppc64le/Makefile.target
index 6ca3003f02..8d11ac731d 100644
--- a/tests/tcg/ppc64le/Makefile.target
+++ b/tests/tcg/ppc64le/Makefile.target
@@ -27,5 +27,6 @@ PPC64LE_TESTS += mtfsf
PPC64LE_TESTS += mffsce
PPC64LE_TESTS += signal_save_restore_xer
PPC64LE_TESTS += xxspltw
+PPC64LE_TESTS += oe_excp
TESTS += $(PPC64LE_TESTS)
diff --git a/tests/tcg/ppc64le/oe_excp.c b/tests/tcg/ppc64le/oe_excp.c
new file mode 100644
index 0000000000..cfc364f5ed
--- /dev/null
+++ b/tests/tcg/ppc64le/oe_excp.c
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/prctl.h>
+#include <signal.h>
+#include <stdint.h>
+
+#define FP_OE (1ull << 6)
+#define MTFSF(FLM, FRB) asm volatile ("mtfsf %0, %1" :: "i" (FLM), "f" (FRB))
+
+void sigfpe_handler(int sig, siginfo_t *si, void *ucontext)
+{
+ uint64_t t;
+ uint64_t ch = 0x5fcfffe4965a17e0ull;
+ asm (
+ "stfd 2, %0\n\t"
+ : "=m"(t)
+ :
+ : "memory", "fr2"
+ );
+ if (t == ch) {
+ exit(0);
+ }
+ fprintf(stderr, "expected result: %lx\n result: %lx\n", ch, t);
+ exit(1);
+}
+
+int main()
+{
+ uint64_t fpscr;
+ uint64_t a = 0x7fdfffe816d77b00ull;
+ uint64_t b = 0x7fdfffFC7F7FFF00ull;
+
+ struct sigaction sa = {
+ .sa_sigaction = sigfpe_handler,
+ .sa_flags = SA_SIGINFO
+ };
+
+ prctl(PR_SET_FPEXC, PR_FP_EXC_PRECISE);
+ sigaction(SIGFPE, &sa, NULL);
+
+ fpscr = FP_OE;
+ MTFSF(0b11111111, fpscr);
+
+ asm (
+ "lfd 0, %0\n\t"
+ "lfd 1, %1\n\t"
+ "fmul 2, 0, 1\n\t"
+ :
+ : "m"(a), "m"(b)
+ : "memory", "fr0", "fr1", "fr2"
+ );
+
+ return -1;
+}
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] tests/tcg/ppc64le: Added an underflow with UE=1 test
2022-08-17 16:57 [PATCH 1/2] tests/tcg/ppc64le: Added an overflow with OE=1 test Lucas Mateus Castro(alqotel)
@ 2022-08-17 16:57 ` Lucas Mateus Castro(alqotel)
2022-08-18 15:32 ` [PATCH 1/2] tests/tcg/ppc64le: Added an overflow with OE=1 test Richard Henderson
1 sibling, 0 replies; 4+ messages in thread
From: Lucas Mateus Castro(alqotel) @ 2022-08-17 16:57 UTC (permalink / raw)
To: qemu-ppc, qemu-devel
Cc: richard.henderson, danielhb413, Lucas Mateus Castro (alqotel)
From: "Lucas Mateus Castro (alqotel)" <lucas.araujo@eldorado.org.br>
Added a test to see if the adjustment is being made correctly when an
underflow occurs and UE is set.
Signed-off-by: Lucas Mateus Castro (alqotel) <lucas.araujo@eldorado.org.br>
---
This patch will also fail without the underflow with UE set bugfix
Message-Id:<20220805141522.412864-3-lucas.araujo@eldorado.org.br>
---
tests/tcg/ppc64/Makefile.target | 1 +
tests/tcg/ppc64le/Makefile.target | 1 +
tests/tcg/ppc64le/ue_excp.c | 54 +++++++++++++++++++++++++++++++
3 files changed, 56 insertions(+)
create mode 100644 tests/tcg/ppc64le/ue_excp.c
diff --git a/tests/tcg/ppc64/Makefile.target b/tests/tcg/ppc64/Makefile.target
index 43958ad87b..583677031b 100644
--- a/tests/tcg/ppc64/Makefile.target
+++ b/tests/tcg/ppc64/Makefile.target
@@ -30,5 +30,6 @@ run-plugin-sha512-vector-with-%: QEMU_OPTS+=-cpu POWER10
PPC64_TESTS += signal_save_restore_xer
PPC64_TESTS += xxspltw
PPC64_TESTS += oe_excp
+PPC64_TESTS += ue_excp
TESTS += $(PPC64_TESTS)
diff --git a/tests/tcg/ppc64le/Makefile.target b/tests/tcg/ppc64le/Makefile.target
index 8d11ac731d..b9e689c582 100644
--- a/tests/tcg/ppc64le/Makefile.target
+++ b/tests/tcg/ppc64le/Makefile.target
@@ -28,5 +28,6 @@ PPC64LE_TESTS += mffsce
PPC64LE_TESTS += signal_save_restore_xer
PPC64LE_TESTS += xxspltw
PPC64LE_TESTS += oe_excp
+PPC64LE_TESTS += ue_excp
TESTS += $(PPC64LE_TESTS)
diff --git a/tests/tcg/ppc64le/ue_excp.c b/tests/tcg/ppc64le/ue_excp.c
new file mode 100644
index 0000000000..b25ba1f803
--- /dev/null
+++ b/tests/tcg/ppc64le/ue_excp.c
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/prctl.h>
+#include <signal.h>
+#include <stdint.h>
+
+#define FP_UE (1ull << 5)
+#define MTFSF(FLM, FRB) asm volatile ("mtfsf %0, %1" :: "i" (FLM), "f" (FRB))
+
+void sigfpe_handler(int sig, siginfo_t *si, void *ucontext)
+{
+ uint64_t t;
+ uint64_t ch = 0x1b64f1c1b0000000ull;
+ asm (
+ "stfd 2, %0\n\t"
+ : "=m"(t)
+ :
+ : "memory", "fr2"
+ );
+ if (t == ch) {
+ exit(0);
+ }
+ fprintf(stderr, "expected result: %lx\n result: %lx\n", ch, t);
+ exit(1);
+}
+
+int main()
+{
+ uint64_t fpscr;
+ uint64_t a = 0x00005ca8ull;
+ uint64_t b = 0x00001cefull;
+
+ struct sigaction sa = {
+ .sa_sigaction = sigfpe_handler,
+ .sa_flags = SA_SIGINFO
+ };
+
+ prctl(PR_SET_FPEXC, PR_FP_EXC_PRECISE);
+ sigaction(SIGFPE, &sa, NULL);
+
+ fpscr = FP_UE;
+ MTFSF(0b11111111, fpscr);
+
+ asm (
+ "lfd 0, %0\n\t"
+ "lfd 1, %1\n\t"
+ "fmul 2, 0, 1\n\t"
+ :
+ : "m"(a), "m"(b)
+ : "memory", "fr0", "fr1", "fr2"
+ );
+
+ return -1;
+}
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] tests/tcg/ppc64le: Added an overflow with OE=1 test
2022-08-17 16:57 [PATCH 1/2] tests/tcg/ppc64le: Added an overflow with OE=1 test Lucas Mateus Castro(alqotel)
2022-08-17 16:57 ` [PATCH 2/2] tests/tcg/ppc64le: Added an underflow with UE=1 test Lucas Mateus Castro(alqotel)
@ 2022-08-18 15:32 ` Richard Henderson
2022-08-18 16:14 ` Lucas Mateus Martins Araujo e Castro
1 sibling, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2022-08-18 15:32 UTC (permalink / raw)
To: Lucas Mateus Castro(alqotel), qemu-ppc, qemu-devel; +Cc: danielhb413
On 8/17/22 09:57, Lucas Mateus Castro(alqotel) wrote:
> +void sigfpe_handler(int sig, siginfo_t *si, void *ucontext)
> +{
> + uint64_t t;
> + uint64_t ch = 0x5fcfffe4965a17e0ull;
> + asm (
> + "stfd 2, %0\n\t"
> + : "=m"(t)
> + :
> + : "memory", "fr2"
> + );
No, you need to fetch f2 from ucontext. There's no guarantee of any specific values being
present in the signal handler otherwise.
> + return -1;
exit(-1), which return from main equates to, helpful over EXIT_FAILURE.
But here I'd tend to abort(), since it really shouldn't be reachable.
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] tests/tcg/ppc64le: Added an overflow with OE=1 test
2022-08-18 15:32 ` [PATCH 1/2] tests/tcg/ppc64le: Added an overflow with OE=1 test Richard Henderson
@ 2022-08-18 16:14 ` Lucas Mateus Martins Araujo e Castro
0 siblings, 0 replies; 4+ messages in thread
From: Lucas Mateus Martins Araujo e Castro @ 2022-08-18 16:14 UTC (permalink / raw)
To: Richard Henderson, qemu-ppc, qemu-devel; +Cc: danielhb413
[-- Attachment #1: Type: text/plain, Size: 1197 bytes --]
On 18/08/2022 12:32, Richard Henderson wrote:
> On 8/17/22 09:57, Lucas Mateus Castro(alqotel) wrote:
>> +void sigfpe_handler(int sig, siginfo_t *si, void *ucontext)
>> +{
>> + uint64_t t;
>> + uint64_t ch = 0x5fcfffe4965a17e0ull;
>> + asm (
>> + "stfd 2, %0\n\t"
>> + : "=m"(t)
>> + :
>> + : "memory", "fr2"
>> + );
>
> No, you need to fetch f2 from ucontext. There's no guarantee of any
> specific values being
> present in the signal handler otherwise.
Yeah, for some reason I completely forgot about this, my bad. I'll send
a second version fixing this
>
>> + return -1;
>
> exit(-1), which return from main equates to, helpful over EXIT_FAILURE.
> But here I'd tend to abort(), since it really shouldn't be reachable.
Good point, I'll change in v2
>
>
> r~
--
Lucas Mateus M. Araujo e Castro
Instituto de Pesquisas ELDORADO
<https://www.eldorado.org.br/?utm_campaign=assinatura_de_e-mail&utm_medium=email&utm_source=RD+Station>
Departamento Computação Embarcada
Analista de Software Trainee
Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
[-- Attachment #2: Type: text/html, Size: 2367 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-18 16:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-17 16:57 [PATCH 1/2] tests/tcg/ppc64le: Added an overflow with OE=1 test Lucas Mateus Castro(alqotel)
2022-08-17 16:57 ` [PATCH 2/2] tests/tcg/ppc64le: Added an underflow with UE=1 test Lucas Mateus Castro(alqotel)
2022-08-18 15:32 ` [PATCH 1/2] tests/tcg/ppc64le: Added an overflow with OE=1 test Richard Henderson
2022-08-18 16:14 ` Lucas Mateus Martins Araujo e Castro
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).