diff options
author | Anup Patel <anup.patel@wdc.com> | 2021-09-27 17:10:08 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2021-10-04 16:01:04 +0530 |
commit | fd7bb4a251dfc1da3496bf59a4793937c13e8c1f (patch) | |
tree | e973bf89d33068885ec7d4f4d9c91322a25fe66a /arch/riscv/kvm/vm.c | |
parent | 5a5d79acd7daebeb813a7c0654ca91c5ea7c228e (diff) | |
download | linux-stable-fd7bb4a251dfc1da3496bf59a4793937c13e8c1f.tar.gz linux-stable-fd7bb4a251dfc1da3496bf59a4793937c13e8c1f.tar.bz2 linux-stable-fd7bb4a251dfc1da3496bf59a4793937c13e8c1f.zip |
RISC-V: KVM: Implement VMID allocator
We implement a simple VMID allocator for Guests/VMs which:
1. Detects number of VMID bits at boot-time
2. Uses atomic number to track VMID version and increments
VMID version whenever we run-out of VMIDs
3. Flushes Guest TLBs on all host CPUs whenever we run-out
of VMIDs
4. Force updates HW Stage2 VMID for each Guest VCPU whenever
VMID changes using VCPU request KVM_REQ_UPDATE_HGATP
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Alexander Graf <graf@amazon.com>
Acked-by: Palmer Dabbelt <palmerdabbelt@google.com>
Diffstat (limited to 'arch/riscv/kvm/vm.c')
-rw-r--r-- | arch/riscv/kvm/vm.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/riscv/kvm/vm.c b/arch/riscv/kvm/vm.c index ad38c575c0bd..42e75dc8ab06 100644 --- a/arch/riscv/kvm/vm.c +++ b/arch/riscv/kvm/vm.c @@ -41,6 +41,12 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) if (r) return r; + r = kvm_riscv_stage2_vmid_init(kvm); + if (r) { + kvm_riscv_stage2_free_pgd(kvm); + return r; + } + return 0; } |