Re: [PATCH 2/2] KVM: arm64: Support FFA_FN64_MEM_RECLAIM2 in host handler

From: Snehal Koukuntla

Date: Tue Sep 22 2026 - 07:19:29 EST


Hi Vincent,

On Tue, Sep 22, 2026 at 10:07:27AM +0000, Vincent Donnefort wrote:
> > + if (ffa_check_unused_args_sbz(ctxt, 6) || (flags & ~1ULL) || (x4 >> 32)) {
>
> nit: (flags > 1) ?

Ack, will update in v2.

> > + if (offset % desc_size != 0) {
>
> nit:
>
> if (offset % desc_size) is enough

Ack.

> > + if (offset >= (u64)req_desc_cnt * desc_size) {
> > + ffa_to_smccc_res(res, FFA_RET_INVALID_PARAMETERS);
> > + return;
> > + }
>
> Not sure I understand what Sashiko means here offset can not be bigger than the
> number of constituents we have...
>
> > +
> > + hyp_spin_lock(&host_buffers.lock);
> > + if (!host_buffers.tx) {
> > + ret = FFA_RET_INVALID_PARAMETERS;
> > + goto out_unlock;
> > + }
> > +
> > + memcpy(hyp_buffers.tx, host_buffers.tx, (u64)req_desc_cnt * desc_size);
>
> Either I or Sashiko is confused here. The invocation will not do more than
> req_desc_cnt will it?

Agreed. Per [S0039] and [S0047] in the spec, req_desc_cnt is the total
count of constituent descriptors in the TX buffer array starting at
offset 0, and offset indexes into that array so callers can advance
offset on subsequent invocations without repopulating the array.

> > +
> > + range = (void *)hyp_buffers.tx + offset;
> > + if (page_index >= range->pg_cnt) {
> > + ret = FFA_RET_INVALID_PARAMETERS;
> > + goto out_unlock;
> > + }
>
> Should we also verify total_pages here?

Good catch. I will add a check in v2 to verify that the sum of pg_cnt
across the constituent descriptors matches total_pages (without
overflowing) before forwarding the call.

Thanks,
Snehal