Skip to content

Commit 12ced09

Browse files
ubizjaksean-jc
authored andcommitted
KVM: x86/mmu: Add comment on try_cmpxchg64 usage in tdp_mmu_set_spte_atomic
Commit aee98a6 ("KVM: x86/mmu: Use try_cmpxchg64 in tdp_mmu_set_spte_atomic") removed the comment that iter->old_spte is updated when different logical CPU modifies the page table entry. Although this is what try_cmpxchg does implicitly, it won't hurt if this fact is explicitly mentioned in a restored comment. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Sean Christopherson <seanjc@google.com> Cc: David Matlack <dmatlack@google.com> Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Link: https://lore.kernel.org/r/20230425113932.3148-1-ubizjak@gmail.com [sean: extend comment above try_cmpxchg64()] Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent b9846a6 commit 12ced09

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/x86/kvm/mmu/tdp_mmu.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,10 @@ static inline int tdp_mmu_set_spte_atomic(struct kvm *kvm,
592592

593593
/*
594594
* Note, fast_pf_fix_direct_spte() can also modify TDP MMU SPTEs and
595-
* does not hold the mmu_lock.
595+
* does not hold the mmu_lock. On failure, i.e. if a different logical
596+
* CPU modified the SPTE, try_cmpxchg64() updates iter->old_spte with
597+
* the current value, so the caller operates on fresh data, e.g. if it
598+
* retries tdp_mmu_set_spte_atomic()
596599
*/
597600
if (!try_cmpxchg64(sptep, &iter->old_spte, new_spte))
598601
return -EBUSY;

0 commit comments

Comments
 (0)