]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86/mmu: Use try_cmpxchg64 in tdp_mmu_set_spte_atomic
authorUros Bizjak <ubizjak@gmail.com>
Wed, 18 May 2022 13:51:11 +0000 (15:51 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 15 Jun 2022 12:11:14 +0000 (08:11 -0400)
commit3183f024418770d5ab824e32ac5d6260d0e5dd47
tree79551e55c29d47e91ef351508b21ab314744ce1b
parentae817d559f0fbf6ec6713d7052e3a19bd82bd009
KVM: x86/mmu: Use try_cmpxchg64 in tdp_mmu_set_spte_atomic

Use try_cmpxchg64 instead of cmpxchg64 (*ptr, old, new) != old in
tdp_mmu_set_spte_atomic.  cmpxchg returns success in ZF flag, so this
change saves a compare after cmpxchg (and related move instruction
in front of cmpxchg). Also, remove explicit assignment to iter->old_spte
when cmpxchg fails, this is what try_cmpxchg does implicitly.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Reviewed-by: David Matlack <dmatlack@google.com>
Message-Id: <20220518135111.3535-1-ubizjak@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/tdp_mmu.c