Skip to contentSkip to conversation

target/i386: fix byte swap issue with XMM register access

RFC PATCH In review Alex Bennée 2 participants 2 messages Apr 12, 2022

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 target/i386: fix byte swap issue with XMM register access

During the conversion to the gdb_get_reg128 helpers the high and low parts of the XMM register where inadvertently swapped. This causes reads of the register to report the incorrect value to gdb.

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

Fixes b7b8756a9c (target/i386: use gdb_get_reg helpers)
---
 target/i386/gdbstub.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/i386/gdbstub.c +2 -2
index 098a2ad15a..c3a2cf6f28 100644
@@ -129,8 +129,8 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
         n -= IDX_XMM_REGS;
         if (n < CPU_NB_REGS32 || TARGET_LONG_BITS == 64) {
             return gdb_get_reg128(mem_buf,
-                                  env->xmm_regs[n].ZMM_Q(0),
-                                  env->xmm_regs[n].ZMM_Q(1));
+                                  env->xmm_regs[n].ZMM_Q(1),
+                                  env->xmm_regs[n].ZMM_Q(0));
         }
     } else {
         switch (n) {
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Alex Bennée

During the conversion to the gdb_get_reg128 helpers the high and low parts of the XMM register where inadvertently swapped. This causes reads of the register to report the incorrect value to gdb.

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

Fixes b7b8756a9c (target/i386: use gdb_get_reg helpers)
---
  target/i386/gdbstub.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

r~

Quoted 16 lines
target/i386/gdbstub.c +2 -2
index 098a2ad15a..c3a2cf6f28 100644
@@ -129,8 +129,8 @@ int x86_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)
          n -= IDX_XMM_REGS;
          if (n < CPU_NB_REGS32 || TARGET_LONG_BITS == 64) {
              return gdb_get_reg128(mem_buf,
-                                  env->xmm_regs[n].ZMM_Q(0),
-                                  env->xmm_regs[n].ZMM_Q(1));
+                                  env->xmm_regs[n].ZMM_Q(1),
+                                  env->xmm_regs[n].ZMM_Q(0));
          }
      } else {
          switch (n) {