KVM/MMU: Simplify __kvm_sync_page() function
authorTianyu Lan <Tianyu.Lan@microsoft.com>
Wed, 18 Jul 2018 06:12:04 +0000 (06:12 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 6 Aug 2018 15:59:03 +0000 (17:59 +0200)
Merge check of "sp->role.cr4_pae != !!is_pae(vcpu))" and "vcpu->
arch.mmu.sync_page(vcpu, sp) == 0". kvm_mmu_prepare_zap_page()
is called under both these conditions.

Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu.c

index 687bfb03b9ca9ed350419e63ed03bc8bd7ff52df..22a7984c68a51e9fbe039884dca3ef3ed9e424a7 100644 (file)
@@ -2136,12 +2136,8 @@ static void kvm_mmu_commit_zap_page(struct kvm *kvm,
 static bool __kvm_sync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
                            struct list_head *invalid_list)
 {
-       if (sp->role.cr4_pae != !!is_pae(vcpu)) {
-               kvm_mmu_prepare_zap_page(vcpu->kvm, sp, invalid_list);
-               return false;
-       }
-
-       if (vcpu->arch.mmu.sync_page(vcpu, sp) == 0) {
+       if (sp->role.cr4_pae != !!is_pae(vcpu)
+           || vcpu->arch.mmu.sync_page(vcpu, sp) == 0) {
                kvm_mmu_prepare_zap_page(vcpu->kvm, sp, invalid_list);
                return false;
        }