From: Changbin Du <changbin.du@gmail.com>
To: "Alex Bennée" <alex.bennee@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
qemu-riscv@nongnu.org, Bin Meng <bin.meng@windriver.com>,
qemu-devel@nongnu.org, qemu-arm@nongnu.org,
Alistair Francis <alistair.francis@wdc.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Changbin Du <changbin.du@gmail.com>
Subject: [PATCH 3/3] riscv: gdbstub: add support for switchable endianness
Date: Mon, 23 Aug 2021 22:20:04 +0800 [thread overview]
Message-ID: <20210823142004.17935-4-changbin.du@gmail.com> (raw)
In-Reply-To: <20210823142004.17935-1-changbin.du@gmail.com>
Apply new gdbstub interfaces we added previously to support both little
and big endian guest debugging for RISC-V. And enable the
TARGET_SWICHABLE_ENDIANNESS option.
Signed-off-by: Changbin Du <changbin.du@gmail.com>
---
configs/targets/riscv32-softmmu.mak | 1 +
configs/targets/riscv64-softmmu.mak | 1 +
target/riscv/gdbstub.c | 12 ++++++------
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/configs/targets/riscv32-softmmu.mak b/configs/targets/riscv32-softmmu.mak
index d8b71cddcd..7f02e67c72 100644
--- a/configs/targets/riscv32-softmmu.mak
+++ b/configs/targets/riscv32-softmmu.mak
@@ -3,3 +3,4 @@ TARGET_BASE_ARCH=riscv
TARGET_SUPPORTS_MTTCG=y
TARGET_XML_FILES= gdb-xml/riscv-32bit-cpu.xml gdb-xml/riscv-32bit-fpu.xml gdb-xml/riscv-64bit-fpu.xml gdb-xml/riscv-32bit-virtual.xml
TARGET_NEED_FDT=y
+TARGET_SWICHABLE_ENDIANNESS=y
diff --git a/configs/targets/riscv64-softmmu.mak b/configs/targets/riscv64-softmmu.mak
index 7c0e7eeb42..c3e812495c 100644
--- a/configs/targets/riscv64-softmmu.mak
+++ b/configs/targets/riscv64-softmmu.mak
@@ -3,3 +3,4 @@ TARGET_BASE_ARCH=riscv
TARGET_SUPPORTS_MTTCG=y
TARGET_XML_FILES= gdb-xml/riscv-64bit-cpu.xml gdb-xml/riscv-32bit-fpu.xml gdb-xml/riscv-64bit-fpu.xml gdb-xml/riscv-64bit-virtual.xml
TARGET_NEED_FDT=y
+TARGET_SWICHABLE_ENDIANNESS=y
diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c
index a7a9c0b1fe..d639cea859 100644
--- a/target/riscv/gdbstub.c
+++ b/target/riscv/gdbstub.c
@@ -42,10 +42,10 @@ int riscv_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
/* discard writes to x0 */
return sizeof(target_ulong);
} else if (n < 32) {
- env->gpr[n] = ldtul_p(mem_buf);
+ env->gpr[n] = gdb_read_regl(mem_buf);
return sizeof(target_ulong);
} else if (n == 32) {
- env->pc = ldtul_p(mem_buf);
+ env->pc = gdb_read_regl(mem_buf);
return sizeof(target_ulong);
}
return 0;
@@ -81,11 +81,11 @@ static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n)
static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n)
{
if (n < 32) {
- env->fpr[n] = ldq_p(mem_buf); /* always 64-bit */
+ env->fpr[n] = gdb_read_reg64(mem_buf); /* always 64-bit */
return sizeof(uint64_t);
/* there is hole between ft11 and fflags in fpu.xml */
} else if (n < 36 && n > 32) {
- target_ulong val = ldtul_p(mem_buf);
+ target_ulong val = gdb_read_regl(mem_buf);
int result;
/*
* CSR_FFLAGS is at index 1 in csr_register, and gdb says it is FP
@@ -118,7 +118,7 @@ static int riscv_gdb_get_csr(CPURISCVState *env, GByteArray *buf, int n)
static int riscv_gdb_set_csr(CPURISCVState *env, uint8_t *mem_buf, int n)
{
if (n < CSR_TABLE_SIZE) {
- target_ulong val = ldtul_p(mem_buf);
+ target_ulong val = gdb_read_regl(mem_buf);
int result;
result = riscv_csrrw_debug(env, n, NULL, val, -1);
@@ -145,7 +145,7 @@ static int riscv_gdb_set_virtual(CPURISCVState *cs, uint8_t *mem_buf, int n)
{
if (n == 0) {
#ifndef CONFIG_USER_ONLY
- cs->priv = ldtul_p(mem_buf) & 0x3;
+ cs->priv = gdb_read_regl(mem_buf) & 0x3;
if (cs->priv == PRV_H) {
cs->priv = PRV_S;
}
--
2.32.0
next prev parent reply other threads:[~2021-08-23 14:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-23 14:20 [PATCH 0/3] gdbstub: add support for switchable endianness Changbin Du
2021-08-23 14:20 ` [PATCH 1/3] gdbstub: add basic infrastructure to support " Changbin Du
2021-08-23 14:20 ` [PATCH 2/3] arm: gdbstub: add support for " Changbin Du
2021-08-23 14:20 ` Changbin Du [this message]
2021-08-23 15:21 ` [PATCH 0/3] " Philippe Mathieu-Daudé
2021-08-23 15:30 ` Peter Maydell
2021-08-23 15:51 ` Philippe Mathieu-Daudé
2021-08-23 23:05 ` Changbin Du
2021-08-24 9:11 ` Peter Maydell
2021-08-27 14:49 ` Changbin Du
2021-08-28 10:51 ` Peter Maydell
2021-08-23 22:47 ` Changbin Du
2021-08-23 15:23 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210823142004.17935-4-changbin.du@gmail.com \
--to=changbin.du@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=palmer@dabbelt.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).