Commit bd3cc5c7 authored by Snehal Koukuntla's avatar Snehal Koukuntla
Browse files

UPSTREAM: KVM: arm64: Add memory length checks and remove inline in do_ffa_mem_xfer



When we share memory through FF-A and the description of the buffers
exceeds the size of the mapped buffer, the fragmentation API is used.
The fragmentation API allows specifying chunks of descriptors in subsequent
FF-A fragment calls and no upper limit has been established for this.
The entire memory region transferred is identified by a handle which can be
used to reclaim the transferred memory.
To be able to reclaim the memory, the description of the buffers has to fit
in the ffa_desc_buf.
Add a bounds check on the FF-A sharing path to prevent the memory reclaim
from failing.

Also do_ffa_mem_xfer() does not need __always_inline, except for the
BUILD_BUG_ON() aspect, which gets moved to a macro.

[maz: fixed the BUILD_BUG_ON() breakage with LLVM, thanks to Wei-Lin Chang
 for the timely report]

Fixes: 634d90cf ("KVM: arm64: Handle FFA_MEM_LEND calls from the host")
Cc: stable@vger.kernel.org
Reviewed-by: default avatarSebastian Ene <sebastianene@google.com>
Signed-off-by: default avatarSnehal Koukuntla <snehalreddy@google.com>
Reviewed-by: default avatarOliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20240909180154.3267939-1-snehalreddy@google.com


Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
(cherry picked from commit f26a525b)

Bug: 298514256
Change-Id: If515f5c03db42e7c994f9f82bef6167b104d75e2
Signed-off-by: default avatarSnehal Koukuntla <snehalreddy@google.com>
parent a43e7c2c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment