Re: [PATCH 0/3] x86/KVM/VMX: Introduce and use try_cmpxchg64()

From: Paolo Bonzini
Date: Mon Jan 18 2021 - 13:30:25 EST


On 15/12/20 19:28, Uros Bizjak wrote:
This patch series introduces try_cmpxchg64() atomic locking function.

try_cmpxchg64() provides the same interface for 64 bit and 32 bit targets,
emits CMPXCHGQ for 64 bit targets and CMPXCHG8B for 32 bit targets,
and provides appropriate fallbacks when CMPXCHG8B is unavailable.

try_cmpxchg64() reuses flags from CMPXCHGQ/CMPXCHG8B instructions and
avoids unneeded CMP for 64 bit targets or XOR/XOR/OR sequence for
32 bit targets.

Cc: Will Deacon <will@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Boqun Feng <boqun.feng@xxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxxxx>
Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
Cc: Sean Christopherson <seanjc@xxxxxxxxxx>
Cc: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
Cc: Wanpeng Li <wanpengli@xxxxxxxxxxx>
Cc: Jim Mattson <jmattson@xxxxxxxxxx>
Cc: Joerg Roedel <joro@xxxxxxxxxx>

Uros Bizjak (3):
asm-generic/atomic: Add try_cmpxchg64() instrumentation
locking/atomic/x86: Introduce arch_try_cmpxchg64()
KVM/VMX: Use try_cmpxchg64() in posted_intr.c

arch/x86/include/asm/cmpxchg_32.h | 62 +++++++++++++++++++----
arch/x86/include/asm/cmpxchg_64.h | 6 +++
arch/x86/kvm/vmx/posted_intr.c | 9 ++--
include/asm-generic/atomic-instrumented.h | 46 ++++++++++++++++-
scripts/atomic/gen-atomic-instrumented.sh | 2 +-
5 files changed, 108 insertions(+), 17 deletions(-)


Queued, thanks.

Paolo