diff mbox

[kvm-unit-tests,1/9] x86: lib: Introduce utils for btr/bts

Message ID 1529711980-32764-2-git-send-email-liran.alon@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Liran Alon June 22, 2018, 11:59 p.m. UTC
Signed-off-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Jim Mattson <jmattson@google.com>
---
 lib/x86/processor.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox

Patch

diff --git a/lib/x86/processor.h b/lib/x86/processor.h
index e850029173ab..89ee528a2e36 100644
--- a/lib/x86/processor.h
+++ b/lib/x86/processor.h
@@ -443,4 +443,16 @@  static inline bool is_canonical(u64 addr)
 	return (s64)(addr << 16) >> 16 == addr;
 }
 
+static inline void clear_bit(int bit, u8 *addr)
+{
+	__asm__ __volatile__("btr %1, %0"
+			     : "+m" (*addr) : "Ir" (bit) : "cc", "memory");
+}
+
+static inline void set_bit(int bit, u8 *addr)
+{
+	__asm__ __volatile__("bts %1, %0"
+			     : "+m" (*addr) : "Ir" (bit) : "cc", "memory");
+}
+
 #endif