[PATCH] KVM: arm64: Drop BUILD_BUG_ON() from do_ffa_mem_xfer()

From: Oliver Upton
Date: Tue Sep 10 2024 - 12:45:30 EST


__always_inline was recently discarded from do_ffa_mem_xfer() since it
appeared to be unnecessary. Of course, this was ~immediately proven
wrong, as the compile-time check against @func_id depends on inlining
for the value to be known.

Just downgrade to a WARN_ON() instead of putting the old mess back in
place. Fix the wrapping/indentation of the function parameters while at
it.

Fixes: 39dacbeeee70 ("KVM: arm64: Add memory length checks and remove inline in do_ffa_mem_xfer")
Reported-by: Wei-Lin Chang <r09922117@xxxxxxxxxxxxxxx>
Signed-off-by: Oliver Upton <oliver.upton@xxxxxxxxx>
---
arch/arm64/kvm/hyp/nvhe/ffa.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c
index 637425f63fd1..316d269341f3 100644
--- a/arch/arm64/kvm/hyp/nvhe/ffa.c
+++ b/arch/arm64/kvm/hyp/nvhe/ffa.c
@@ -426,9 +426,8 @@ static void do_ffa_mem_frag_tx(struct arm_smccc_res *res,
return;
}

-static void do_ffa_mem_xfer(const u64 func_id,
- struct arm_smccc_res *res,
- struct kvm_cpu_context *ctxt)
+static void do_ffa_mem_xfer(const u64 func_id, struct arm_smccc_res *res,
+ struct kvm_cpu_context *ctxt)
{
DECLARE_REG(u32, len, ctxt, 1);
DECLARE_REG(u32, fraglen, ctxt, 2);
@@ -440,8 +439,10 @@ static void do_ffa_mem_xfer(const u64 func_id,
u32 offset, nr_ranges;
int ret = 0;

- BUILD_BUG_ON(func_id != FFA_FN64_MEM_SHARE &&
- func_id != FFA_FN64_MEM_LEND);
+ if (WARN_ON(func_id != FFA_FN64_MEM_SHARE && func_id != FFA_FN64_MEM_LEND)) {
+ ret = SMCCC_RET_NOT_SUPPORTED;
+ goto out;
+ }

if (addr_mbz || npages_mbz || fraglen > len ||
fraglen > KVM_FFA_MBOX_NR_PAGES * PAGE_SIZE) {
--
2.46.0.598.g6f2099f65c-goog


--
Thanks,
Oliver