All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Gonda <pgonda@google.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, marcorr@google.com,
	seanjc@google.com, michael.roth@amd.com, thomas.lendacky@amd.com,
	joro@8bytes.org, mizhang@google.com, pbonzini@redhat.com,
	Peter Gonda <pgonda@google.com>
Subject: [RFC V1 07/10] tools: Add atomic_test_and_set_bit()
Date: Fri, 15 Jul 2022 12:29:53 -0700	[thread overview]
Message-ID: <20220715192956.1873315-9-pgonda@google.com> (raw)
In-Reply-To: <20220715192956.1873315-1-pgonda@google.com>

atomic_test_and_set_bit() allows for atomic bitmap usage from KVM
selftests.

Signed-off-by: Peter Gonda <pgonda@google.com>
Suggested-by: Sean Christopherson <seanjc@google.com>

---
 tools/arch/x86/include/asm/atomic.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/arch/x86/include/asm/atomic.h b/tools/arch/x86/include/asm/atomic.h
index 1f5e26aae9fc..45ea15c98957 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, volatile unsigned long *addr)
+{
+	GEN_BINARY_RMWcc(LOCK_PREFIX __ASM_SIZE(bts), *addr, "Ir", nr, "%0", "c");
+
+}
+
 #endif /* _TOOLS_LINUX_ASM_X86_ATOMIC_H */
-- 
2.37.0.170.g444d1eabd0-goog


  parent reply	other threads:[~2022-07-15 19:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-15 19:29 [RFC V1 00/10] *** KVM: selftests: Add simple SEV test Peter Gonda
2022-07-15 19:29 ` [PATCH V2] KVM: selftests: Add simple sev vm testing Peter Gonda
2022-07-15 19:29 ` [RFC V1 01/10] KVM: selftests: move vm_phy_pages_alloc() earlier in file Peter Gonda
2022-07-15 19:29 ` [RFC V1 02/10] KVM: selftests: sparsebit: add const where appropriate Peter Gonda
2022-07-15 19:29 ` [RFC V1 03/10] KVM: selftests: add hooks for managing encrypted guest memory Peter Gonda
2022-07-15 19:29 ` [RFC V1 04/10] KVM: selftests: handle encryption bits in page tables Peter Gonda
2022-07-15 19:29 ` [RFC V1 05/10] KVM: selftests: add support for encrypted vm_vaddr_* allocations Peter Gonda
2022-07-15 19:29 ` [RFC V1 06/10] KVM: selftests: Consolidate boilerplate code in get_ucall() Peter Gonda
2022-07-19 14:42   ` Andrew Jones
2022-07-15 19:29 ` Peter Gonda [this message]
2022-07-15 19:29 ` [RFC V1 08/10] KVM: selftests: Make ucall work with encrypted guests Peter Gonda
2022-07-19 15:43   ` Andrew Jones
2022-07-27 13:38     ` Peter Gonda
2022-07-27 13:56       ` Andrew Jones
2022-07-27 14:07         ` Peter Gonda
2022-07-15 19:29 ` [RFC V1 09/10] KVM: selftests: add library for creating/interacting with SEV guests Peter Gonda
2022-07-15 19:29 ` [RFC V1 10/10] KVM: selftests: Add simple sev vm testing Peter Gonda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220715192956.1873315-9-pgonda@google.com \
    --to=pgonda@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcorr@google.com \
    --cc=michael.roth@amd.com \
    --cc=mizhang@google.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=thomas.lendacky@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.