Commit 6ee337a7 authored by Uros Bizjak's avatar Uros Bizjak Committed by Yu Zhang
Browse files

KVM: x86/mmu: Add comment on try_cmpxchg64 usage in tdp_mmu_set_spte_atomic

mainline inclusion
from mainline-v6.5-rc1
commit 12ced095
category: feature
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I9HH9U
CVE: N/A
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=12ced095956a517dc0c8c8f9264e29fd67124302



-------------------------------------

Commit aee98a68 ("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: default avatarUros 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: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarYu Zhang <yu.c.zhang@linux.intel.com>
parent bbdd2f77
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -590,7 +590,10 @@ static inline int tdp_mmu_set_spte_atomic(struct kvm *kvm,

	/*
	 * Note, fast_pf_fix_direct_spte() can also modify TDP MMU SPTEs and
	 * does not hold the mmu_lock.
	 * does not hold the mmu_lock.  On failure, i.e. if a different logical
	 * CPU modified the SPTE, try_cmpxchg64() updates iter->old_spte with
	 * the current value, so the caller operates on fresh data, e.g. if it
	 * retries tdp_mmu_set_spte_atomic()
	 */
	old_spte = cmpxchg64(sptep, iter->old_spte, new_spte);
	if (old_spte != iter->old_spte) {