RISC-V: KVM: Add remote HFENCE functions based on VCPU requests
authorAnup Patel <apatel@ventanamicro.com>
Mon, 9 May 2022 05:14:05 +0000 (10:44 +0530)
committerAnup Patel <anup@brainfault.org>
Fri, 20 May 2022 03:39:15 +0000 (09:09 +0530)
commit13acfec2dbccfafff3331a3810cd7dde2fb16891
tree961a009272dbc57463373abe49439abc7c22694b
parent486a38429498eef5acac90aeab68a1c3fa653a21
RISC-V: KVM: Add remote HFENCE functions based on VCPU requests

The generic KVM has support for VCPU requests which can be used
to do arch-specific work in the run-loop. We introduce remote
HFENCE functions which will internally use VCPU requests instead
of host SBI calls.

Advantages of doing remote HFENCEs as VCPU requests are:
1) Multiple VCPUs of a Guest may be running on different Host CPUs
   so it is not always possible to determine the Host CPU mask for
   doing Host SBI call. For example, when VCPU X wants to do HFENCE
   on VCPU Y, it is possible that VCPU Y is blocked or in user-space
   (i.e. vcpu->cpu < 0).
2) To support nested virtualization, we will be having a separate
   shadow G-stage for each VCPU and a common host G-stage for the
   entire Guest/VM. The VCPU requests based remote HFENCEs helps
   us easily synchronize the common host G-stage and shadow G-stage
   of each VCPU without any additional IPI calls.

This is also a preparatory patch for upcoming nested virtualization
support where we will be having a shadow G-stage page table for
each Guest VCPU.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/include/asm/kvm_host.h
arch/riscv/kvm/mmu.c
arch/riscv/kvm/tlb.c
arch/riscv/kvm/vcpu.c
arch/riscv/kvm/vcpu_sbi_replace.c
arch/riscv/kvm/vcpu_sbi_v01.c
arch/riscv/kvm/vmid.c