target/ppc: fix vector registers access in gdbstub for little-endian
As vector registers are stored in host endianness, we shouldn't swap its 64-bit elements in user mode. Add a 16-byte case in ppc_maybe_bswap_register to handle the reordering of elements in softmmu and remove avr_need_swap which is now unused. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br> Message-Id: <20210826145656.2507213-3-matheus.ferst@eldorado.org.br> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
2484cd9c77
commit
0ff16b6b78
@ -101,6 +101,8 @@ void ppc_maybe_bswap_register(CPUPPCState *env, uint8_t *mem_buf, int len)
|
||||
bswap32s((uint32_t *)mem_buf);
|
||||
} else if (len == 8) {
|
||||
bswap64s((uint64_t *)mem_buf);
|
||||
} else if (len == 16) {
|
||||
bswap128s((Int128 *)mem_buf);
|
||||
} else {
|
||||
g_assert_not_reached();
|
||||
}
|
||||
@ -389,15 +391,6 @@ const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name)
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool avr_need_swap(CPUPPCState *env)
|
||||
{
|
||||
#ifdef HOST_WORDS_BIGENDIAN
|
||||
return msr_le;
|
||||
#else
|
||||
return !msr_le;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_USER_ONLY)
|
||||
static int gdb_find_spr_idx(CPUPPCState *env, int n)
|
||||
{
|
||||
@ -486,14 +479,9 @@ static int gdb_get_avr_reg(CPUPPCState *env, GByteArray *buf, int n)
|
||||
|
||||
if (n < 32) {
|
||||
ppc_avr_t *avr = cpu_avr_ptr(env, n);
|
||||
if (!avr_need_swap(env)) {
|
||||
gdb_get_reg128(buf, avr->u64[0] , avr->u64[1]);
|
||||
} else {
|
||||
gdb_get_reg128(buf, avr->u64[1] , avr->u64[0]);
|
||||
}
|
||||
gdb_get_reg128(buf, avr->VsrD(0), avr->VsrD(1));
|
||||
mem_buf = gdb_get_reg_ptr(buf, 16);
|
||||
ppc_maybe_bswap_register(env, mem_buf, 8);
|
||||
ppc_maybe_bswap_register(env, mem_buf + 8, 8);
|
||||
ppc_maybe_bswap_register(env, mem_buf, 16);
|
||||
return 16;
|
||||
}
|
||||
if (n == 32) {
|
||||
@ -515,15 +503,9 @@ static int gdb_set_avr_reg(CPUPPCState *env, uint8_t *mem_buf, int n)
|
||||
{
|
||||
if (n < 32) {
|
||||
ppc_avr_t *avr = cpu_avr_ptr(env, n);
|
||||
ppc_maybe_bswap_register(env, mem_buf, 8);
|
||||
ppc_maybe_bswap_register(env, mem_buf + 8, 8);
|
||||
if (!avr_need_swap(env)) {
|
||||
avr->u64[0] = ldq_p(mem_buf);
|
||||
avr->u64[1] = ldq_p(mem_buf + 8);
|
||||
} else {
|
||||
avr->u64[1] = ldq_p(mem_buf);
|
||||
avr->u64[0] = ldq_p(mem_buf + 8);
|
||||
}
|
||||
ppc_maybe_bswap_register(env, mem_buf, 16);
|
||||
avr->VsrD(0) = ldq_p(mem_buf);
|
||||
avr->VsrD(1) = ldq_p(mem_buf + 8);
|
||||
return 16;
|
||||
}
|
||||
if (n == 32) {
|
||||
|
Loading…
Reference in New Issue
Block a user