qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] target/ppc: fix vector registers access in gdbstub for little-endian
@ 2021-08-12 19:10 matheus.ferst
  2021-08-12 20:05 ` Richard Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: matheus.ferst @ 2021-08-12 19:10 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc; +Cc: Matheus Ferst, groug, david

From: Matheus Ferst <matheus.ferst@eldorado.org.br>

It seems that access to elements of ppc_avr_t should only depend on
msr_le when !CONFIG_USER_ONLY.

Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
---
To reproduce the problem, build the following program for ppc64le:

int main(void)
{
    __uint128_t a = 0x1122334455667788llu;
    a <<= 64;
    a |= 0xAABBCCDDEEFFAABBllu;
    asm volatile ("xxlor 4, %x0, %x0\n\t"
                  "xxlor 34, %x0, %x0\n\t"
                  :: "wa" (a) : "vs4", "vs34");
    return 0;
}

Run it with qemu-ppc64le, attach gdb, place a breakpoint after the
second xxlor and print vs4 and vs34:
Breakpoint 1, 0x0000000010000d88 in main ()
(gdb) p/x $vs4
$1 = {uint128 = 0x1122334455667788aabbccddeeffaabb, v2_double = {0x0,
    0x0}, v4_float = {0x0, 0x0, 0x78800000, 0x0}, v4_int32 = {
    0xeeffaabb, 0xaabbccdd, 0x55667788, 0x11223344}, v8_int16 = {
    0xaabb, 0xeeff, 0xccdd, 0xaabb, 0x7788, 0x5566, 0x3344, 0x1122},
  v16_int8 = {0xbb, 0xaa, 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x88,
    0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11}}
(gdb) p/x $vs34
$2 = {uint128 = 0xaabbccddeeffaabb1122334455667788, v2_double = {0x0,
    0x0}, v4_float = {0x78800000, 0x0, 0x0, 0x0}, v4_int32 = {
    0x55667788, 0x11223344, 0xeeffaabb, 0xaabbccdd}, v8_int16 = {
    0x7788, 0x5566, 0x3344, 0x1122, 0xaabb, 0xeeff, 0xccdd, 0xaabb},
  v16_int8 = {0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0xbb,
    0xaa, 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa}}

RFC because I'm not quite sure about the fix.
---
 target/ppc/gdbstub.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c
index 09ff1328d4..779e4a4e3f 100644
--- a/target/ppc/gdbstub.c
+++ b/target/ppc/gdbstub.c
@@ -391,10 +391,16 @@ const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name)
 
 static bool avr_need_swap(CPUPPCState *env)
 {
+    bool le;
+#if defined(CONFIG_USER_ONLY)
+    le = false;
+#else
+    le = msr_le;
+#endif
 #ifdef HOST_WORDS_BIGENDIAN
-    return msr_le;
+    return le;
 #else
-    return !msr_le;
+    return !le;
 #endif
 }
 
-- 
2.25.1



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

end of thread, other threads:[~2021-08-16 12:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-12 19:10 [RFC PATCH] target/ppc: fix vector registers access in gdbstub for little-endian matheus.ferst
2021-08-12 20:05 ` Richard Henderson
2021-08-13  9:17   ` Peter Maydell
2021-08-16 12:17     ` Matheus K. Ferst

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).