Skip to content

Commit 3e2d475

Browse files
tititiou36avpatel
authored andcommitted
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 <[email protected]> Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Anup Patel <[email protected]>
1 parent af93443 commit 3e2d475

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

arch/riscv/kvm/mmu.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,8 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
537537
if (change == KVM_MR_FLAGS_ONLY)
538538
goto out;
539539

540-
spin_lock(&kvm->mmu_lock);
541540
if (ret)
542-
gstage_unmap_range(kvm, base_gpa, size, false);
543-
spin_unlock(&kvm->mmu_lock);
541+
kvm_riscv_gstage_iounmap(kvm, base_gpa, size);
544542

545543
out:
546544
mmap_read_unlock(current->mm);

0 commit comments

Comments
 (0)