A TVM can only be created upon explicit request from the VMM via the vm type if CoVE SBI extensions must supported by the TSM. Signed-off-by: Atish Patra <atishp@xxxxxxxxxxxx> --- arch/riscv/kvm/vm.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/riscv/kvm/vm.c b/arch/riscv/kvm/vm.c index 1b59a8f..8a1460d 100644 --- a/arch/riscv/kvm/vm.c +++ b/arch/riscv/kvm/vm.c @@ -42,6 +42,19 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) return r; } + if (unlikely(type == KVM_VM_TYPE_RISCV_COVE)) { + if (!kvm_riscv_cove_enabled()) { + kvm_err("Unable to init CoVE VM because cove is not enabled\n"); + return -EPERM; + } + + r = kvm_riscv_cove_vm_init(kvm); + if (r) + return r; + kvm->arch.vm_type = type; + kvm_info("Trusted VM instance init successful\n"); + } + kvm_riscv_aia_init_vm(kvm); kvm_riscv_guest_timer_init(kvm); @@ -54,6 +67,9 @@ void kvm_arch_destroy_vm(struct kvm *kvm) kvm_destroy_vcpus(kvm); kvm_riscv_aia_destroy_vm(kvm); + + if (unlikely(is_cove_vm(kvm))) + kvm_riscv_cove_vm_destroy(kvm); } int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irql, -- 2.25.1