summaryrefslogtreecommitdiff
path: root/tools/arch
diff options
context:
space:
mode:
authorPeter Gonda <pgonda@google.com>2022-10-06 00:34:06 +0000
committerSean Christopherson <seanjc@google.com>2022-11-16 16:58:52 -0800
commitcf4694be2b2cf74945e50d39a02ea2307c4495f4 (patch)
tree74389c8ce3d4978a99def91aa5f9a259a61437fb /tools/arch
parentdc88244bf5488b04fb7bbe47d8d9c38ff8f7dbb4 (diff)
tools: Add atomic_test_and_set_bit()
Add x86 and generic implementations of atomic_test_and_set_bit() to allow KVM selftests to atomically manage bitmaps. Note, the generic version is taken from arch_test_and_set_bit() as of commit 415d83249709 ("locking/atomic: Make test_and_*_bit() ordered on failure"). Signed-off-by: Peter Gonda <pgonda@google.com> Co-developed-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20221006003409.649993-5-seanjc@google.com
Diffstat (limited to 'tools/arch')
-rw-r--r--tools/arch/x86/include/asm/atomic.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/arch/x86/include/asm/atomic.h b/tools/arch/x86/include/asm/atomic.h
index 1f5e26aae9fc..01cc27ec4520 100644
--- a/tools/arch/x86/include/asm/atomic.h
+++ b/tools/arch/x86/include/asm/atomic.h
@@ -8,6 +8,7 @@
#define LOCK_PREFIX "\n\tlock; "
+#include <asm/asm.h>
#include <asm/cmpxchg.h>
/*
@@ -70,4 +71,10 @@ static __always_inline int atomic_cmpxchg(atomic_t *v, int old, int new)
return cmpxchg(&v->counter, old, new);
}
+static inline int atomic_test_and_set_bit(long nr, unsigned long *addr)
+{
+ GEN_BINARY_RMWcc(LOCK_PREFIX __ASM_SIZE(bts), *addr, "Ir", nr, "%0", "c");
+
+}
+
#endif /* _TOOLS_LINUX_ASM_X86_ATOMIC_H */