Commit 2db2f46f authored by Uros Bizjak's avatar Uros Bizjak Committed by Paolo Bonzini

KVM: x86/mmu: Use try_cmpxchg64 in fast_pf_fix_direct_spte

Use try_cmpxchg64 instead of cmpxchg64 (*ptr, old, new) != old in
fast_pf_fix_direct_spte. cmpxchg returns success in ZF flag, so this
change saves a compare after cmpxchg (and related move instruction
in front of cmpxchg).
Signed-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Wanpeng Li <wanpengli@tencent.com>
Cc: Jim Mattson <jmattson@google.com>
Cc: Joerg Roedel <joro@8bytes.org>
Message-Id: <20220520144635.63134-1-ubizjak@gmail.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 0ac304de
...@@ -3093,7 +3093,7 @@ fast_pf_fix_direct_spte(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault, ...@@ -3093,7 +3093,7 @@ fast_pf_fix_direct_spte(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault,
* *
* Compare with set_spte where instead shadow_dirty_mask is set. * Compare with set_spte where instead shadow_dirty_mask is set.
*/ */
if (cmpxchg64(sptep, old_spte, new_spte) != old_spte) if (!try_cmpxchg64(sptep, &old_spte, new_spte))
return false; return false;
if (is_writable_pte(new_spte) && !is_writable_pte(old_spte)) if (is_writable_pte(new_spte) && !is_writable_pte(old_spte))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment