Skip to contentSkip to conversation

target/sparc: Fix register selection for the fdtox and fqtox instructions

PATCH Superseded Mikael Szreder 2 participants 4 messages Feb 3, 2025 – Feb 4, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/sparc: Fix register selection for the fdtox and fqtox instructions

A bug was introduced in commit 0bba7572d40d which causes the fdtox and
fqtox instructions to incorrectly select the destination registers.
More information and a test program can be found in issue #2802.

Fixes 0bba7572d40d ("target/sparc: Perform DFPREG/QFPREG in decodetree")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2802

---
 target/sparc/insns.decode | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/sparc/insns.decode +2 -2
index 989c20b44a..694a28d88c 100644
@@ -322,8 +322,8 @@ FNHADDs     10 ..... 110100 ..... 0 0111 0001 .....        @r_r_r
 FNHADDd     10 ..... 110100 ..... 0 0111 0010 .....        @d_d_d
 FNsMULd     10 ..... 110100 ..... 0 0111 1001 .....        @d_r_r
 FsTOx       10 ..... 110100 00000 0 1000 0001 .....        @r_r2
-FdTOx       10 ..... 110100 00000 0 1000 0010 .....        @r_d2
-FqTOx       10 ..... 110100 00000 0 1000 0011 .....        @r_q2
+FdTOx       10 ..... 110100 00000 0 1000 0010 .....        @d_d2
+FqTOx       10 ..... 110100 00000 0 1000 0011 .....        @q_q2
 FxTOs       10 ..... 110100 00000 0 1000 0100 .....        @r_r2
 FxTOd       10 ..... 110100 00000 0 1000 1000 .....        @d_r2
 FxTOq       10 ..... 110100 00000 0 1000 1100 .....        @q_r2
Signature · 1 line
2.48.1
#1 lore raw
Quoted 16 lines · Mikael Szreder

A bug was introduced in commit 0bba7572d40d which causes the fdtox and
fqtox instructions to incorrectly select the destination registers.
More information and a test program can be found in issue #2802.

Fixes 0bba7572d40d ("target/sparc: Perform DFPREG/QFPREG in decodetree")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2802

---
  target/sparc/insns.decode | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
target/sparc/insns.decode +0 -0
index 989c20b44a..694a28d88c 100644

target/sparc/insns.decode FNHADDs 10 ..... 110100 ..... 0 0111 0001 ..... @r_r_r · line 329

Quoted 10 lines
target/sparc/insns.decode +2 -2
@@ -322,8 +322,8 @@ FNHADDs     10 ..... 110100 ..... 0 0111 0001 .....        @r_r_r
  FNHADDd     10 ..... 110100 ..... 0 0111 0010 .....        @d_d_d
  FNsMULd     10 ..... 110100 ..... 0 0111 1001 .....        @d_r_r
  FsTOx       10 ..... 110100 00000 0 1000 0001 .....        @r_r2
-FdTOx       10 ..... 110100 00000 0 1000 0010 .....        @r_d2
-FqTOx       10 ..... 110100 00000 0 1000 0011 .....        @r_q2
+FdTOx       10 ..... 110100 00000 0 1000 0010 .....        @d_d2
+FqTOx       10 ..... 110100 00000 0 1000 0011 .....        @q_q2
  FxTOs       10 ..... 110100 00000 0 1000 0100 .....        @r_r2
  FxTOd       10 ..... 110100 00000 0 1000 1000 .....        @d_r2
  FxTOq       10 ..... 110100 00000 0 1000 1100 .....        @q_r2

Same issue with FsTOx and FxTOs.

r~

author
#2 lore raw
In reply to Mikael Szreder

Thank you Richard for noticing the issue.

I have been able to create tests that show the malfunction of the FsTOx instruction as well. I am however not yet able to prove(through tests) the malfunction of the FxTO{s,d,q} instructions.

Based on the fact that the source registers are 64 bit, a similar pattern should be used.

I also noticed a mistake I made in the patch with the FqTOx instruction, using q_q2, instead of d_q2(since the destination registers are 64 bits).

I will resubmit this patch with corrections once I have managed to write tests which show the issues.

Best regards
Mikael Szreder

Quoted 23 lines · Mikael Szreder

A bug was introduced in commit 0bba7572d40d which causes the fdtox and fqtox instructions to incorrectly select the destination registers. More information and a test program can be found in issue #2802.

Fixes 0bba7572d40d ("target/sparc: Perform DFPREG/QFPREG in decodetree")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2802

---
target/sparc/insns.decode | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
target/sparc/insns.decode +0 -0
index 989c20b44a..694a28d88c 100644
@@ -322,8 +322,8 @@ FNHADDs     10 ..... 110100 ..... 0 0111 0001 .....        @r_r_r
FNHADDd     10 ..... 110100 ..... 0 0111 0010 .....        @d_d_d
FNsMULd     10 ..... 110100 ..... 0 0111 1001 .....        @d_r_r
FsTOx       10 ..... 110100 00000 0 1000 0001 .....        @r_r2
target/sparc/insns.decode +2 -2
-FdTOx       10 ..... 110100 00000 0 1000 0010 .....        @r_d2
-FqTOx       10 ..... 110100 00000 0 1000 0011 .....        @r_q2
+FdTOx       10 ..... 110100 00000 0 1000 0010 .....        @d_d2
+FqTOx       10 ..... 110100 00000 0 1000 0011 .....        @q_q2
Quoted 6 lines
FxTOs       10 ..... 110100 00000 0 1000 0100 .....        @r_r2
FxTOd       10 ..... 110100 00000 0 1000 1000 .....        @d_r2
FxTOq       10 ..... 110100 00000 0 1000 1100 .....        @q_r2
Signature · 1 line
2.48.1

Git

#3 lore raw
Quoted 3 lines · Git

Thank you Richard for noticing the issue.

I have been able to create tests that show the malfunction of the FsTOx instruction as well. I am however not yet able to prove(through tests) the malfunction of the FxTO{s,d,q} instructions.

Destination register 32 should be sufficient there.

r~