@@ -7056,7 +7056,11 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
void kvm_arch_flush_shadow_all(struct kvm *kvm)
{
+ int idx;
+
+ idx = srcu_read_lock(&kvm->srcu);
kvm_mmu_zap_all(kvm);
+ srcu_read_unlock(&kvm->srcu, idx);
}
void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
@@ -418,11 +418,8 @@ static void kvm_mmu_notifier_release(struct mmu_notifier *mn,
struct mm_struct *mm)
{
struct kvm *kvm = mmu_notifier_to_kvm(mn);
- int idx;
- idx = srcu_read_lock(&kvm->srcu);
kvm_arch_flush_shadow_all(kvm);
- srcu_read_unlock(&kvm->srcu, idx);
}
static const struct mmu_notifier_ops kvm_mmu_notifier_ops = {
Move srcu_read_lock/srcu_read_unlock in kvm_mmu_notifier_release to kvm_arch_flush_shadow_all since we will hold slot-lock instead of srcu Only ARM, POWERPC and x86 are using mmu-notify and kvm_arch_flush_shadow_all on ARM and POWERPC does nothing, so we only need to modify the code on x86 Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> --- arch/x86/kvm/x86.c | 4 ++++ virt/kvm/kvm_main.c | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-)