• Anup Patel's avatar
    RISC-V: KVM: Add remote HFENCE functions based on VCPU requests · 13acfec2
    Anup Patel authored
    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: default avatarAnup Patel <apatel@ventanamicro.com>
    Reviewed-by: default avatarAtish Patra <atishp@rivosinc.com>
    Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
    13acfec2
vcpu.c 22.5 KB