diff options
author | Fuad Tabba <tabba@google.com> | 2022-11-10 20:02:43 +0100 |
---|---|---|
committer | Marc Zyngier <maz@kernel.org> | 2022-11-11 17:40:54 +0100 |
commit | 1c80002e3264552d8b9c0e162e09aa4087403716 (patch) | |
tree | 9eed618e07926be900b15b1c53cbc3e3b6ef4e3e | |
parent | KVM: arm64: Include asm/kvm_mmu.h in nvhe/mem_protect.h (diff) | |
download | linux-1c80002e3264552d8b9c0e162e09aa4087403716.tar.xz linux-1c80002e3264552d8b9c0e162e09aa4087403716.zip |
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é <philmd@linaro.org>
Tested-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Fuad Tabba <tabba@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221110190259.26861-11-will@kernel.org
-rw-r--r-- | arch/arm64/kvm/hyp/include/nvhe/spinlock.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/arch/arm64/kvm/hyp/include/nvhe/spinlock.h b/arch/arm64/kvm/hyp/include/nvhe/spinlock.h index 4652fd04bdbe..7c7ea8c55405 100644 --- a/arch/arm64/kvm/hyp/include/nvhe/spinlock.h +++ b/arch/arm64/kvm/hyp/include/nvhe/spinlock.h @@ -28,9 +28,17 @@ typedef union hyp_spinlock { }; } hyp_spinlock_t; +#define __HYP_SPIN_LOCK_INITIALIZER \ + { .__val = 0 } + +#define __HYP_SPIN_LOCK_UNLOCKED \ + ((hyp_spinlock_t) __HYP_SPIN_LOCK_INITIALIZER) + +#define DEFINE_HYP_SPINLOCK(x) hyp_spinlock_t x = __HYP_SPIN_LOCK_UNLOCKED + #define hyp_spin_lock_init(l) \ do { \ - *(l) = (hyp_spinlock_t){ .__val = 0 }; \ + *(l) = __HYP_SPIN_LOCK_UNLOCKED; \ } while (0) static inline void hyp_spin_lock(hyp_spinlock_t *lock) |