From: Jim Shu <jim.shu@sifive.com>
To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: Jim Shu <jim.shu@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>,
Alistair Francis <alistair.francis@wdc.com>,
Bin Meng <bin.meng@windriver.com>,
Weiwei Li <liweiwei@iscas.ac.cn>,
Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
Liu Zhiwei <zhiwei_liu@linux.alibaba.com>
Subject: [PATCH 2/2] target/riscv: Make the "virt" register writable by GDB
Date: Sun, 5 Mar 2023 09:42:29 +0000 [thread overview]
Message-ID: <20230305094231.1616-2-jim.shu@sifive.com> (raw)
In-Reply-To: <20230305094231.1616-1-jim.shu@sifive.com>
This patch also enables debugger to set current privilege mode to
VU/VS-mode.
Extend previous commit 81d2929c41d32af138f3562f5a7b309f6eac7ca7 to
support H-extension.
Signed-off-by: Jim Shu <jim.shu@sifive.com>
Reviewed-by: Frank Chang <frank.chang@sifive.com>
---
target/riscv/gdbstub.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c
index 1755fd9d51..a7f234beaf 100644
--- a/target/riscv/gdbstub.c
+++ b/target/riscv/gdbstub.c
@@ -203,15 +203,29 @@ static int riscv_gdb_get_virtual(CPURISCVState *cs, GByteArray *buf, int n)
static int riscv_gdb_set_virtual(CPURISCVState *cs, uint8_t *mem_buf, int n)
{
+#ifdef CONFIG_USER_ONLY
+ if (n >= 0 && n <= 1) {
+ return sizeof(target_ulong);
+ }
+#else
+ bool virt;
+
if (n == 0) {
-#ifndef CONFIG_USER_ONLY
cs->priv = ldtul_p(mem_buf) & 0x3;
if (cs->priv == PRV_H) {
cs->priv = PRV_S;
}
-#endif
+ return sizeof(target_ulong);
+ } else if (n == 1) {
+ virt = ldtul_p(mem_buf) & 0x1;
+ if ((cs->priv == PRV_M) && (virt == true)) {
+ /* M-mode only supports V=0. */
+ virt = false;
+ }
+ riscv_cpu_set_virt_enabled(cs, virt);
return sizeof(target_ulong);
}
+#endif
return 0;
}
--
2.17.1
next prev parent reply other threads:[~2023-03-05 9:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-05 9:42 [PATCH 1/2] target/riscv: Expose "virt" register for GDB for reads Jim Shu
2023-03-05 9:42 ` Jim Shu [this message]
2023-03-06 11:26 ` [PATCH 2/2] target/riscv: Make the "virt" register writable by GDB LIU Zhiwei
2023-03-08 11:14 ` Jim Shu
2023-03-09 3:05 ` Jim Shu
2023-03-09 3:21 ` LIU Zhiwei
2023-03-10 3:58 ` Alistair Francis
2023-03-06 11:22 ` [PATCH 1/2] target/riscv: Expose "virt" register for GDB for reads LIU Zhiwei
2023-03-10 0:05 ` Alistair Francis
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=20230305094231.1616-2-jim.shu@sifive.com \
--to=jim.shu@sifive.com \
--cc=alistair.francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=dbarboza@ventanamicro.com \
--cc=liweiwei@iscas.ac.cn \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/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).