summaryrefslogtreecommitdiff
path: root/arch/riscv/include/asm/kvm_vcpu_insn.h
diff options
context:
space:
mode:
authorAnup Patel <apatel@ventanamicro.com>2022-07-29 14:44:53 +0300
committerAnup Patel <anup@brainfault.org>2022-07-29 14:44:53 +0300
commit8a061562e2f2b32bfb5bff5bf3afc64e37d95a27 (patch)
treeca9fef5fb33c95fe9580daf738f3c033e5c92270 /arch/riscv/include/asm/kvm_vcpu_insn.h
parent1222b55cee2396a1a286e924d9f6abb6d7a04f55 (diff)
downloadlinux-8a061562e2f2b32bfb5bff5bf3afc64e37d95a27.tar.xz
RISC-V: KVM: Add extensible CSR emulation framework
We add an extensible CSR emulation framework which is based upon the existing system instruction emulation. This will be useful to upcoming AIA, PMU, Nested and other virtualization features. The CSR emulation framework also has provision to emulate CSR in user space but this will be used only in very specific cases such as AIA IMSIC CSR emulation in user space or vendor specific CSR emulation in user space. By default, all CSRs not handled by KVM RISC-V will be redirected back to Guest VCPU as illegal instruction trap. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'arch/riscv/include/asm/kvm_vcpu_insn.h')
-rw-r--r--arch/riscv/include/asm/kvm_vcpu_insn.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/riscv/include/asm/kvm_vcpu_insn.h b/arch/riscv/include/asm/kvm_vcpu_insn.h
index 3351eb61a251..350011c83581 100644
--- a/arch/riscv/include/asm/kvm_vcpu_insn.h
+++ b/arch/riscv/include/asm/kvm_vcpu_insn.h
@@ -18,6 +18,11 @@ struct kvm_mmio_decode {
int return_handled;
};
+struct kvm_csr_decode {
+ unsigned long insn;
+ int return_handled;
+};
+
/* Return values used by function emulating a particular instruction */
enum kvm_insn_return {
KVM_INSN_EXIT_TO_USER_SPACE = 0,
@@ -28,6 +33,7 @@ enum kvm_insn_return {
};
void kvm_riscv_vcpu_wfi(struct kvm_vcpu *vcpu);
+int kvm_riscv_vcpu_csr_return(struct kvm_vcpu *vcpu, struct kvm_run *run);
int kvm_riscv_vcpu_virtual_insn(struct kvm_vcpu *vcpu, struct kvm_run *run,
struct kvm_cpu_trap *trap);