From: Xie Bo <xb@ultrarisc.com>
To: Anup Patel <anup@brainfault.org>,
Atish Patra <atish.patra@linux.dev>,
kvm-riscv@lists.infradead.org
Cc: Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>,
kvm@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, Xie Bo <xb@ultrarisc.com>
Subject: [PATCH] RISC-V: KVM: Add SBI DBTR extension forwarding
Date: Tue, 21 Jul 2026 10:42:36 +0800 [thread overview]
Message-ID: <20260721024236.14761-1-xb@ultrarisc.com> (raw)
The SBI headers define the Debug Triggers extension and its function IDs,
but KVM does not currently allow a VMM to expose DBTR to a guest.
Add DBTR to the KVM SBI extension list and forward its calls to userspace
through the existing KVM_EXIT_RISCV_SBI path. Keep the extension disabled
by default so that userspace must explicitly enable it through the SBI
extension ONE_REG interface before running the VCPU.
Signed-off-by: Xie Bo <xb@ultrarisc.com>
---
arch/riscv/include/asm/kvm_vcpu_sbi.h | 1 +
arch/riscv/include/uapi/asm/kvm.h | 1 +
arch/riscv/kvm/vcpu_sbi.c | 4 ++++
arch/riscv/kvm/vcpu_sbi_forward.c | 7 +++++++
4 files changed, 13 insertions(+)
diff --git a/arch/riscv/include/asm/kvm_vcpu_sbi.h b/arch/riscv/include/asm/kvm_vcpu_sbi.h
index c1a7e3b40..53406b02f 100644
--- a/arch/riscv/include/asm/kvm_vcpu_sbi.h
+++ b/arch/riscv/include/asm/kvm_vcpu_sbi.h
@@ -104,6 +104,7 @@ extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_rfence;
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_srst;
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_hsm;
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_dbcn;
+extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_dbtr;
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_susp;
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_sta;
extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_fwft;
diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include/uapi/asm/kvm.h
index 504e73305..047d82f05 100644
--- a/arch/riscv/include/uapi/asm/kvm.h
+++ b/arch/riscv/include/uapi/asm/kvm.h
@@ -221,6 +221,7 @@ enum KVM_RISCV_SBI_EXT_ID {
KVM_RISCV_SBI_EXT_SUSP,
KVM_RISCV_SBI_EXT_FWFT,
KVM_RISCV_SBI_EXT_MPXY,
+ KVM_RISCV_SBI_EXT_DBTR,
KVM_RISCV_SBI_EXT_MAX,
};
diff --git a/arch/riscv/kvm/vcpu_sbi.c b/arch/riscv/kvm/vcpu_sbi.c
index 46ab7b989..ed21239c5 100644
--- a/arch/riscv/kvm/vcpu_sbi.c
+++ b/arch/riscv/kvm/vcpu_sbi.c
@@ -70,6 +70,10 @@ static const struct kvm_riscv_sbi_extension_entry sbi_ext[] = {
.ext_idx = KVM_RISCV_SBI_EXT_DBCN,
.ext_ptr = &vcpu_sbi_ext_dbcn,
},
+ {
+ .ext_idx = KVM_RISCV_SBI_EXT_DBTR,
+ .ext_ptr = &vcpu_sbi_ext_dbtr,
+ },
{
.ext_idx = KVM_RISCV_SBI_EXT_SUSP,
.ext_ptr = &vcpu_sbi_ext_susp,
diff --git a/arch/riscv/kvm/vcpu_sbi_forward.c b/arch/riscv/kvm/vcpu_sbi_forward.c
index 5a3c75eb2..8ac31b53f 100644
--- a/arch/riscv/kvm/vcpu_sbi_forward.c
+++ b/arch/riscv/kvm/vcpu_sbi_forward.c
@@ -26,6 +26,13 @@ const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_dbcn = {
.handler = kvm_riscv_vcpu_sbi_forward_handler,
};
+const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_dbtr = {
+ .extid_start = SBI_EXT_DBTR,
+ .extid_end = SBI_EXT_DBTR,
+ .default_disabled = true,
+ .handler = kvm_riscv_vcpu_sbi_forward_handler,
+};
+
const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_mpxy = {
.extid_start = SBI_EXT_MPXY,
.extid_end = SBI_EXT_MPXY,
base-commit: b95f03f04d475aa6719d15a636ddf32222d55657
--
2.54.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next reply other threads:[~2026-07-21 2:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 2:42 Xie Bo [this message]
2026-10-02 6:47 ` [PATCH] RISC-V: KVM: Add SBI DBTR extension forwarding Anup Patel
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=20260721024236.14761-1-xb@ultrarisc.com \
--to=xb@ultrarisc.com \
--cc=alex@ghiti.fr \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=atish.patra@linux.dev \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.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