Skip to content

Commit 1c80002

Browse files
Fuad TabbaMarc Zyngier
authored andcommitted
KVM: arm64: Add hyp_spinlock_t static initializer
Introduce a static initializer macro for 'hyp_spinlock_t' so that it is straightforward to instantiate global locks at EL2. This will be later utilised for locking the VM table in the hypervisor. Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Tested-by: Vincent Donnefort <[email protected]> Signed-off-by: Fuad Tabba <[email protected]> Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4d968b1 commit 1c80002

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

arch/arm64/kvm/hyp/include/nvhe/spinlock.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ typedef union hyp_spinlock {
2828
};
2929
} hyp_spinlock_t;
3030

31+
#define __HYP_SPIN_LOCK_INITIALIZER \
32+
{ .__val = 0 }
33+
34+
#define __HYP_SPIN_LOCK_UNLOCKED \
35+
((hyp_spinlock_t) __HYP_SPIN_LOCK_INITIALIZER)
36+
37+
#define DEFINE_HYP_SPINLOCK(x) hyp_spinlock_t x = __HYP_SPIN_LOCK_UNLOCKED
38+
3139
#define hyp_spin_lock_init(l) \
3240
do { \
33-
*(l) = (hyp_spinlock_t){ .__val = 0 }; \
41+
*(l) = __HYP_SPIN_LOCK_UNLOCKED; \
3442
} while (0)
3543

3644
static inline void hyp_spin_lock(hyp_spinlock_t *lock)

0 commit comments

Comments
 (0)