diff options
author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2022-12-07 04:46:39 +0100 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2022-12-07 04:46:39 +0100 |
commit | 3e2d4756e2e5dd854b36aa947d7b6168f21dc4a1 (patch) | |
tree | d238938ff1d549854745deefae7e39055d9bc39d /arch | |
parent | RISC-V: KVM: Exit run-loop immediately if xfer_to_guest fails (diff) | |
download | linux-3e2d4756e2e5dd854b36aa947d7b6168f21dc4a1.tar.xz linux-3e2d4756e2e5dd854b36aa947d7b6168f21dc4a1.zip |
RISC-V: KVM: Simplify kvm_arch_prepare_memory_region()
In kvm_arch_prepare_memory_region(), if no error occurs, a spin_lock()/
spin_unlock() call can be avoided.
Switch to kvm_riscv_gstage_iounmap() that is the same as the current code,
but with a better semantic.
It also embeds the locking logic. So it is avoided if ret == 0.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/riscv/kvm/mmu.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c index 5942d10c9736..34b57e0be2ef 100644 --- a/arch/riscv/kvm/mmu.c +++ b/arch/riscv/kvm/mmu.c @@ -537,10 +537,8 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, if (change == KVM_MR_FLAGS_ONLY) goto out; - spin_lock(&kvm->mmu_lock); if (ret) - gstage_unmap_range(kvm, base_gpa, size, false); - spin_unlock(&kvm->mmu_lock); + kvm_riscv_gstage_iounmap(kvm, base_gpa, size); out: mmap_read_unlock(current->mm); |