Skip to content

Commit 634d90c

Browse files
willdeaconoupton
authored andcommitted
KVM: arm64: Handle FFA_MEM_LEND calls from the host
Handle FFA_MEM_LEND calls from the host by treating them identically to FFA_MEM_SHARE calls for the purposes of the host stage-2 page-table, but forwarding on the original request to EL3. Signed-off-by: Will Deacon <will@kernel.org> Link: https://lore.kernel.org/r/20230523101828.7328-9-will@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 0e3bcb4 commit 634d90c

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

  • arch/arm64/kvm/hyp/nvhe

arch/arm64/kvm/hyp/nvhe/ffa.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ static int ffa_unmap_hyp_buffers(void)
116116
return res.a0 == FFA_SUCCESS ? FFA_RET_SUCCESS : res.a2;
117117
}
118118

119-
static void ffa_mem_share(struct arm_smccc_res *res, u32 len, u32 fraglen)
119+
static void ffa_mem_xfer(struct arm_smccc_res *res, u64 func_id, u32 len,
120+
u32 fraglen)
120121
{
121-
arm_smccc_1_1_smc(FFA_FN64_MEM_SHARE,
122-
len, fraglen,
122+
arm_smccc_1_1_smc(func_id, len, fraglen,
123123
0, 0, 0, 0, 0,
124124
res);
125125
}
@@ -321,8 +321,9 @@ static int ffa_host_unshare_ranges(struct ffa_mem_region_addr_range *ranges,
321321
return ret;
322322
}
323323

324-
static void do_ffa_mem_share(struct arm_smccc_res *res,
325-
struct kvm_cpu_context *ctxt)
324+
static __always_inline void do_ffa_mem_xfer(const u64 func_id,
325+
struct arm_smccc_res *res,
326+
struct kvm_cpu_context *ctxt)
326327
{
327328
DECLARE_REG(u32, len, ctxt, 1);
328329
DECLARE_REG(u32, fraglen, ctxt, 2);
@@ -333,6 +334,9 @@ static void do_ffa_mem_share(struct arm_smccc_res *res,
333334
int ret = 0;
334335
u32 offset;
335336

337+
BUILD_BUG_ON(func_id != FFA_FN64_MEM_SHARE &&
338+
func_id != FFA_FN64_MEM_LEND);
339+
336340
if (addr_mbz || npages_mbz || fraglen > len ||
337341
fraglen > KVM_FFA_MBOX_NR_PAGES * PAGE_SIZE) {
338342
ret = FFA_RET_INVALID_PARAMETERS;
@@ -382,7 +386,7 @@ static void do_ffa_mem_share(struct arm_smccc_res *res,
382386
if (ret)
383387
goto out_unlock;
384388

385-
ffa_mem_share(res, len, fraglen);
389+
ffa_mem_xfer(res, func_id, len, fraglen);
386390
if (res->a0 != FFA_SUCCESS) {
387391
WARN_ON(ffa_host_unshare_ranges(reg->constituents,
388392
reg->addr_range_cnt));
@@ -519,11 +523,15 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt)
519523
goto out_handled;
520524
case FFA_MEM_SHARE:
521525
case FFA_FN64_MEM_SHARE:
522-
do_ffa_mem_share(&res, host_ctxt);
526+
do_ffa_mem_xfer(FFA_FN64_MEM_SHARE, &res, host_ctxt);
523527
goto out_handled;
524528
case FFA_MEM_RECLAIM:
525529
do_ffa_mem_reclaim(&res, host_ctxt);
526530
goto out_handled;
531+
case FFA_MEM_LEND:
532+
case FFA_FN64_MEM_LEND:
533+
do_ffa_mem_xfer(FFA_FN64_MEM_LEND, &res, host_ctxt);
534+
goto out_handled;
527535
}
528536

529537
if (ffa_call_supported(func_id))

0 commit comments

Comments
 (0)