OSDN Git Service

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)
commit8c3ce496bd612bd21679e445f75fcabb6be997b2
treef8d6345007c66c77ce957a29a73bdff6a975a15f
parenta44e2c207c30a5780c4ad0cc3579b8715cebf52e
RISC-V: KVM: Don't clear hgatp CSR in kvm_arch_vcpu_put()

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: 34bde9d8b9e6 ("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