]> git.baikalelectronics.ru Git - kernel.git/commitdiff
RISC-V: KVM: Don't clear hgatp CSR in kvm_arch_vcpu_put()
authorAnup Patel <apatel@ventanamicro.com>
Sat, 9 Apr 2022 03:45:33 +0000 (09:15 +0530)
committerAnup Patel <anup@brainfault.org>
Sat, 9 Apr 2022 03:45:33 +0000 (09:15 +0530)
We might have RISC-V systems (such as QEMU) where VMID is not part
of the TLB entry tag so these systems will have to flush all TLB
entries upon any change in hgatp.VMID.

Currently, we zero-out hgatp CSR in kvm_arch_vcpu_put() and we
re-program hgatp CSR in kvm_arch_vcpu_load(). For above described
systems, this will flush all TLB entries whenever VCPU exits to
user-space hence reducing performance.

This patch fixes above described performance issue by not clearing
hgatp CSR in kvm_arch_vcpu_put().

Fixes: c5536e067939 ("RISC-V: KVM: Implement VCPU world-switch")
Cc: stable@vger.kernel.org
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/kvm/vcpu.c

index 624166004e36c637fb5fbd8966f3412f72a84294..6785aef4cbd46e4d8bfd90c65fe2ea43c2cc1a5f 100644 (file)
@@ -653,8 +653,6 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
                                     vcpu->arch.isa);
        kvm_riscv_vcpu_host_fp_restore(&vcpu->arch.host_context);
 
-       csr_write(CSR_HGATP, 0);
-
        csr->vsstatus = csr_read(CSR_VSSTATUS);
        csr->vsie = csr_read(CSR_VSIE);
        csr->vstvec = csr_read(CSR_VSTVEC);