diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 292ea11cb826..6899b912d0ea 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -55,21 +55,21 @@ struct kvm_ffa_descriptor_buffer { static struct kvm_ffa_descriptor_buffer ffa_desc_buf; struct kvm_ffa_buffers { - hyp_spinlock_t lock; void *tx; void *rx; }; /* * Note that we don't currently lock these buffers explicitly, instead - * relying on the locking of the host FFA buffers as we only have one - * client. + * relying on the locking of the hyp FFA buffers. */ static struct kvm_ffa_buffers hyp_buffers; static struct kvm_ffa_buffers host_buffers; static u32 hyp_ffa_version; static bool has_version_negotiated; -static hyp_spinlock_t version_lock; + +static DEFINE_HYP_SPINLOCK(version_lock); +static DEFINE_HYP_SPINLOCK(kvm_ffa_hyp_lock); static void ffa_to_smccc_error(struct arm_smccc_res *res, u64 ffa_errno) { @@ -208,7 +208,7 @@ static void do_ffa_rxtx_map(struct arm_smccc_res *res, goto out; } - hyp_spin_lock(&host_buffers.lock); + hyp_spin_lock(&kvm_ffa_hyp_lock); if (host_buffers.tx) { ret = FFA_RET_DENIED; goto out_unlock; @@ -252,7 +252,7 @@ static void do_ffa_rxtx_map(struct arm_smccc_res *res, host_buffers.rx = rx_virt; out_unlock: - hyp_spin_unlock(&host_buffers.lock); + hyp_spin_unlock(&kvm_ffa_hyp_lock); out: ffa_to_smccc_res(res, ret); return; @@ -280,7 +280,7 @@ static void do_ffa_rxtx_unmap(struct arm_smccc_res *res, goto out; } - hyp_spin_lock(&host_buffers.lock); + hyp_spin_lock(&kvm_ffa_hyp_lock); if (!host_buffers.tx) { ret = FFA_RET_INVALID_PARAMETERS; goto out_unlock; @@ -297,7 +297,7 @@ static void do_ffa_rxtx_unmap(struct arm_smccc_res *res, ffa_unmap_hyp_buffers(); out_unlock: - hyp_spin_unlock(&host_buffers.lock); + hyp_spin_unlock(&kvm_ffa_hyp_lock); out: ffa_to_smccc_res(res, ret); } @@ -388,7 +388,7 @@ static void do_ffa_mem_frag_tx(struct arm_smccc_res *res, if (fraglen % sizeof(*buf)) goto out; - hyp_spin_lock(&host_buffers.lock); + hyp_spin_lock(&kvm_ffa_hyp_lock); if (!host_buffers.tx) goto out_unlock; @@ -413,7 +413,7 @@ static void do_ffa_mem_frag_tx(struct arm_smccc_res *res, WARN_ON(ffa_host_unshare_ranges(buf, nr_ranges)); out_unlock: - hyp_spin_unlock(&host_buffers.lock); + hyp_spin_unlock(&kvm_ffa_hyp_lock); out: if (ret) ffa_to_smccc_res(res, ret); @@ -456,7 +456,7 @@ static void __do_ffa_mem_xfer(const u64 func_id, goto out; } - hyp_spin_lock(&host_buffers.lock); + hyp_spin_lock(&kvm_ffa_hyp_lock); if (!host_buffers.tx) { ret = FFA_RET_INVALID_PARAMETERS; goto out_unlock; @@ -507,7 +507,7 @@ static void __do_ffa_mem_xfer(const u64 func_id, } out_unlock: - hyp_spin_unlock(&host_buffers.lock); + hyp_spin_unlock(&kvm_ffa_hyp_lock); out: if (ret) ffa_to_smccc_res(res, ret); @@ -541,7 +541,7 @@ static void do_ffa_mem_reclaim(struct arm_smccc_res *res, handle = PACK_HANDLE(handle_lo, handle_hi); - hyp_spin_lock(&host_buffers.lock); + hyp_spin_lock(&kvm_ffa_hyp_lock); buf = hyp_buffers.tx; *buf = (struct ffa_mem_region) { @@ -603,7 +603,7 @@ static void do_ffa_mem_reclaim(struct arm_smccc_res *res, WARN_ON(ffa_host_unshare_ranges(reg->constituents, reg->addr_range_cnt)); out_unlock: - hyp_spin_unlock(&host_buffers.lock); + hyp_spin_unlock(&kvm_ffa_hyp_lock); if (ret) ffa_to_smccc_res(res, ret); @@ -756,7 +756,7 @@ static void do_ffa_part_get(struct arm_smccc_res *res, DECLARE_REG(u32, flags, ctxt, 5); u32 count, partition_sz, copy_sz; - hyp_spin_lock(&host_buffers.lock); + hyp_spin_lock(&kvm_ffa_hyp_lock); if (!host_buffers.rx) { ffa_to_smccc_res(res, FFA_RET_BUSY); goto out_unlock; @@ -792,7 +792,7 @@ static void do_ffa_part_get(struct arm_smccc_res *res, memcpy(host_buffers.rx, hyp_buffers.rx, copy_sz); out_unlock: - hyp_spin_unlock(&host_buffers.lock); + hyp_spin_unlock(&kvm_ffa_hyp_lock); } bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id) @@ -908,15 +908,10 @@ int hyp_ffa_init(void *pages) }; hyp_buffers = (struct kvm_ffa_buffers) { - .lock = __HYP_SPIN_LOCK_UNLOCKED, .tx = tx, .rx = rx, }; - host_buffers = (struct kvm_ffa_buffers) { - .lock = __HYP_SPIN_LOCK_UNLOCKED, - }; - version_lock = __HYP_SPIN_LOCK_UNLOCKED; return 0; }