From: Andrew Jones <ajones@ventanamicro.com>
To: Chao Du <duchao@eswincomputing.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
pbonzini@redhat.com, alistair23@gmail.com,
bin.meng@windriver.com, liweiwei@iscas.ac.cn,
dbarboza@ventanamicro.com, zhiwei_liu@linux.alibaba.com,
palmer@dabbelt.com, anup@brainfault.org, duchao713@qq.com
Subject: Re: [PATCH v1 3/4] target/riscv/kvm: handle the exit with debug reason
Date: Mon, 27 May 2024 17:48:23 +0200 [thread overview]
Message-ID: <20240527-c55d280af95ef901fb715dc0@orel> (raw)
In-Reply-To: <20240527021916.12953-4-duchao@eswincomputing.com>
On Mon, May 27, 2024 at 02:19:15AM GMT, Chao Du wrote:
> If the breakpoint belongs to the userspace then set the ret value.
>
> Signed-off-by: Chao Du <duchao@eswincomputing.com>
> ---
> target/riscv/kvm/kvm-cpu.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c
> index 0bc3348b91..0c45e520b2 100644
> --- a/target/riscv/kvm/kvm-cpu.c
> +++ b/target/riscv/kvm/kvm-cpu.c
> @@ -1555,6 +1555,21 @@ static int kvm_riscv_handle_csr(CPUState *cs, struct kvm_run *run)
> return ret;
> }
>
> +static bool kvm_riscv_handle_debug(CPUState *cs)
> +{
> + RISCVCPU *cpu = RISCV_CPU(cs);
> + CPURISCVState *env = &cpu->env;
> +
> + /* Ensure PC is synchronised */
> + kvm_cpu_synchronize_state(cs);
> +
> + if (kvm_find_sw_breakpoint(cs, env->pc)) {
> + return true;
> + }
> +
> + return false;
> +}
> +
> int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
> {
> int ret = 0;
> @@ -1565,6 +1580,11 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
> case KVM_EXIT_RISCV_CSR:
> ret = kvm_riscv_handle_csr(cs, run);
> break;
> + case KVM_EXIT_DEBUG:
> + if (kvm_riscv_handle_debug(cs)) {
> + ret = EXCP_DEBUG;
> + }
> + break;
> default:
> qemu_log_mask(LOG_UNIMP, "%s: un-handled exit reason %d\n",
> __func__, run->exit_reason);
> --
> 2.17.1
>
>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
next prev parent reply other threads:[~2024-05-27 15:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 2:19 [PATCH v1 0/4] target/riscv/kvm: QEMU support for KVM Guest Debug on RISC-V Chao Du
2024-05-27 2:19 ` [PATCH v1 1/4] target/riscv/kvm: add software breakpoints support Chao Du
2024-05-27 12:00 ` Daniel Henrique Barboza
2024-05-27 15:41 ` Andrew Jones
2024-05-28 2:43 ` Chao Du
2024-05-27 2:19 ` [PATCH v1 2/4] target/riscv/kvm: implement kvm_arch_update_guest_debug() Chao Du
2024-05-27 12:00 ` Daniel Henrique Barboza
2024-05-27 15:42 ` Andrew Jones
2024-05-27 2:19 ` [PATCH v1 3/4] target/riscv/kvm: handle the exit with debug reason Chao Du
2024-05-27 12:00 ` Daniel Henrique Barboza
2024-05-27 15:48 ` Andrew Jones [this message]
2024-05-27 2:19 ` [PATCH v1 4/4] target/riscv/kvm: define TARGET_KVM_HAVE_GUEST_DEBUG Chao Du
2024-05-27 12:00 ` Daniel Henrique Barboza
2024-05-27 15:50 ` Andrew Jones
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=20240527-c55d280af95ef901fb715dc0@orel \
--to=ajones@ventanamicro.com \
--cc=alistair23@gmail.com \
--cc=anup@brainfault.org \
--cc=bin.meng@windriver.com \
--cc=dbarboza@ventanamicro.com \
--cc=duchao713@qq.com \
--cc=duchao@eswincomputing.com \
--cc=liweiwei@iscas.ac.cn \
--cc=palmer@dabbelt.com \
--cc=pbonzini@redhat.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).