From e352553e1aed7902fe5d00ddd09b23cc79a2a174 Mon Sep 17 00:00:00 2001 From: "Li, Fei1" Date: Tue, 16 Jul 2019 22:30:44 +0800 Subject: [PATCH] hv: atomic: remove atomic load/store and set/clear In x86 architecture, word/doubleword/quadword aligned read/write on its boundary is atomic, so we may remove atomic load/store. As for atomic set/clear, use bitmap_set/claer seems more reasonable. After replace them all, we could remove them too. Tracked-On: #1842 Signed-off-by: Li, Fei1 --- hypervisor/include/arch/x86/lib/atomic.h | 89 ------------------------ 1 file changed, 89 deletions(-) diff --git a/hypervisor/include/arch/x86/lib/atomic.h b/hypervisor/include/arch/x86/lib/atomic.h index 4104f973c..eca0fcfba 100644 --- a/hypervisor/include/arch/x86/lib/atomic.h +++ b/hypervisor/include/arch/x86/lib/atomic.h @@ -33,32 +33,6 @@ #define BUS_LOCK "lock ; " -#define build_atomic_load(name, size, type) \ -static inline type name(const volatile type *ptr) \ -{ \ - type ret; \ - asm volatile("mov" size " %1,%0" \ - : "=r" (ret) \ - : "m" (*ptr) \ - : "cc", "memory"); \ - return ret; \ -} -build_atomic_load(atomic_load16, "w", uint16_t) -build_atomic_load(atomic_load32, "l", uint32_t) -build_atomic_load(atomic_load64, "q", uint64_t) - -#define build_atomic_store(name, size, type) \ -static inline void name(volatile type *ptr, type v) \ -{ \ - asm volatile("mov" size " %1,%0" \ - : "=m" (*ptr) \ - : "r" (v) \ - : "cc", "memory"); \ -} -build_atomic_store(atomic_store16, "w", uint16_t) -build_atomic_store(atomic_store32, "l", uint32_t) -build_atomic_store(atomic_store64, "q", uint64_t) - #define build_atomic_inc(name, size, type) \ static inline void name(type *ptr) \ { \ @@ -81,69 +55,6 @@ build_atomic_dec(atomic_dec16, "w", uint16_t) build_atomic_dec(atomic_dec32, "l", uint32_t) build_atomic_dec(atomic_dec64, "q", uint64_t) -/** - * #define atomic_set32(P, V) (*(uint32_t *)(P) |= (V)) - * - * Parameters: - * uint32_t* p A pointer to memory area that stores source - * value and setting result; - * uint32_t v The value needs to be set. - */ -static inline void atomic_set32(uint32_t *p, uint32_t v) -{ - __asm __volatile(BUS_LOCK "orl %1,%0" - : "+m" (*p) - : "r" (v) - : "cc", "memory"); -} - -/* - * #define atomic_clear32(P, V) (*(uint32_t *)(P) &= ~(V)) - * Parameters: - * uint32_t* p A pointer to memory area that stores source - * value and clearing result; - * uint32_t v The value needs to be cleared. - */ -static inline void atomic_clear32(uint32_t *p, uint32_t v) -{ - __asm __volatile(BUS_LOCK "andl %1,%0" - : "+m" (*p) - : "r" (~v) - : "cc", "memory"); -} - -/* - * #define atomic_set64(P, V) (*(uint64_t *)(P) |= (V)) - * - * Parameters: - * uint64_t* p A pointer to memory area that stores source - * value and setting result; - * uint64_t v The value needs to be set. - */ -static inline void atomic_set64(uint64_t *p, uint64_t v) -{ - __asm __volatile(BUS_LOCK "orq %1,%0" - : "+m" (*p) - : "r" (v) - : "cc", "memory"); -} - -/* - * #define atomic_clear64(P, V) (*(uint64_t *)(P) &= ~(V)) - * - * Parameters: - * uint64_t* p A pointer to memory area that stores source - * value and clearing result; - * uint64_t v The value needs to be cleared. - */ -static inline void atomic_clear64(uint64_t *p, uint64_t v) -{ - __asm __volatile(BUS_LOCK "andq %1,%0" - : "+m" (*p) - : "r" (~v) - : "cc", "memory"); -} - #define build_atomic_swap(name, size, type) \ static inline type name(type *ptr, type v) \ { \