[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH] target/ppc: fix vector registers access in gdbstub for littl
From: |
matheus . ferst |
Subject: |
[RFC PATCH] target/ppc: fix vector registers access in gdbstub for little-endian |
Date: |
Thu, 12 Aug 2021 16:10:07 -0300 |
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
- [RFC PATCH] target/ppc: fix vector registers access in gdbstub for little-endian,
matheus . ferst <=