OSDN Git Service

RISC-V: KVM: Implement VMID allocator
authorAnup Patel <anup.patel@wdc.com>
Mon, 27 Sep 2021 11:40:08 +0000 (17:10 +0530)
committerAnup Patel <anup@brainfault.org>
Mon, 4 Oct 2021 10:31:04 +0000 (16:01 +0530)
commitfd7bb4a251dfc1da3496bf59a4793937c13e8c1f
treee973bf89d33068885ec7d4f4d9c91322a25fe66a
parent5a5d79acd7daebeb813a7c0654ca91c5ea7c228e
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>
arch/riscv/include/asm/kvm_host.h
arch/riscv/kvm/Makefile
arch/riscv/kvm/main.c
arch/riscv/kvm/tlb.S [new file with mode: 0644]
arch/riscv/kvm/vcpu.c
arch/riscv/kvm/vm.c
arch/riscv/kvm/vmid.c [new file with mode: 0644]