mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
UPSTREAM: KVM: arm64: Add hyp_spin_is_locked() for basic locking assertions at EL2
Introduce hyp_spin_is_locked() so that functions can easily assert that
a given lock is held (albeit possibly by another CPU!) without having to
drag full lockdep support up to EL2.
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Quentin Perret <qperret@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210809152448.1810400-2-qperret@google.com
(cherry picked from commit d21292f13f)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 198418208
Change-Id: I17b84239556e48c14ca41fe12c77d3f20763b4c9
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <asm/alternative.h>
|
||||
#include <asm/lse.h>
|
||||
#include <asm/rwonce.h>
|
||||
|
||||
typedef union hyp_spinlock {
|
||||
u32 __val;
|
||||
@@ -89,4 +90,11 @@ static inline void hyp_spin_unlock(hyp_spinlock_t *lock)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
static inline bool hyp_spin_is_locked(hyp_spinlock_t *lock)
|
||||
{
|
||||
hyp_spinlock_t lockval = READ_ONCE(*lock);
|
||||
|
||||
return lockval.owner != lockval.next;
|
||||
}
|
||||
|
||||
#endif /* __ARM64_KVM_NVHE_SPINLOCK_H__ */
|
||||
|
||||
Reference in New Issue
Block a user