]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: x86/tdp_mmu: Merge prefetch and access checks for spurious faults
authorYan Zhao <yan.y.zhao@intel.com>
Tue, 18 Mar 2025 01:32:10 +0000 (09:32 +0800)
committerSean Christopherson <seanjc@google.com>
Mon, 28 Apr 2025 18:03:06 +0000 (11:03 -0700)
Combine prefetch and is_access_allowed() checks into a unified path to
detect spurious faults, since both cases now share identical logic.

No functional changes.

Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Link: https://lore.kernel.org/r/20250318013210.5701-1-yan.y.zhao@intel.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/mmu/tdp_mmu.c

index f534022572178cc292832ee1d22f86d878f1fb9c..d16e3e6e46a5105e05ee94fcc3a4666da98a7024 100644 (file)
@@ -1153,12 +1153,8 @@ static int tdp_mmu_map_handle_target_level(struct kvm_vcpu *vcpu,
        if (WARN_ON_ONCE(sp->role.level != fault->goal_level))
                return RET_PF_RETRY;
 
-       if (fault->prefetch && is_shadow_present_pte(iter->old_spte) &&
-           is_last_spte(iter->old_spte, iter->level))
-               return RET_PF_SPURIOUS;
-
        if (is_shadow_present_pte(iter->old_spte) &&
-           is_access_allowed(fault, iter->old_spte) &&
+           (fault->prefetch || is_access_allowed(fault, iter->old_spte)) &&
            is_last_spte(iter->old_spte, iter->level))
                return RET_PF_SPURIOUS;