summaryrefslogtreecommitdiffstats
path: root/arch/riscv/kvm/vcpu_sbi_base.c
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2021-11-26 10:48:41 +0530
committerAnup Patel <anup@brainfault.org>2022-01-06 15:14:33 +0530
commitef8949a986f0e325b1d535389101541849d611d3 (patch)
treed34e6610bebe7b4869604cf06f81012dec427cfc /arch/riscv/kvm/vcpu_sbi_base.c
parent637ad6551b2801cdf9c76046cffc1abe1f5c2243 (diff)
downloadlinux-ef8949a986f0e325b1d535389101541849d611d3.tar.bz2
RISC-V: KVM: Forward SBI experimental and vendor extensions
The SBI experimental extension space is for temporary (or experimental) stuff whereas SBI vendor extension space is for hardware vendor specific stuff. Both these SBI extension spaces won't be standardized by the SBI specification so let's blindly forward such SBI calls to the userspace. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-and-tested-by: Atish Patra <atishp@rivosinc.com>
Diffstat (limited to 'arch/riscv/kvm/vcpu_sbi_base.c')
-rw-r--r--arch/riscv/kvm/vcpu_sbi_base.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/riscv/kvm/vcpu_sbi_base.c b/arch/riscv/kvm/vcpu_sbi_base.c
index d1ec08fe7289..4ecf377f483b 100644
--- a/arch/riscv/kvm/vcpu_sbi_base.c
+++ b/arch/riscv/kvm/vcpu_sbi_base.c
@@ -70,3 +70,30 @@ const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_base = {
.extid_end = SBI_EXT_BASE,
.handler = kvm_sbi_ext_base_handler,
};
+
+static int kvm_sbi_ext_forward_handler(struct kvm_vcpu *vcpu,
+ struct kvm_run *run,
+ unsigned long *out_val,
+ struct kvm_cpu_trap *utrap,
+ bool *exit)
+{
+ /*
+ * Both SBI experimental and vendor extensions are
+ * unconditionally forwarded to userspace.
+ */
+ kvm_riscv_vcpu_sbi_forward(vcpu, run);
+ *exit = true;
+ return 0;
+}
+
+const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_experimental = {
+ .extid_start = SBI_EXT_EXPERIMENTAL_START,
+ .extid_end = SBI_EXT_EXPERIMENTAL_END,
+ .handler = kvm_sbi_ext_forward_handler,
+};
+
+const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_vendor = {
+ .extid_start = SBI_EXT_VENDOR_START,
+ .extid_end = SBI_EXT_VENDOR_END,
+ .handler = kvm_sbi_ext_forward_handler,
+};