From: Sebastian Ene <sebastianene@google.com>
To: Snehal Koukuntla <snehalreddy@google.com>
Cc: Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Sudeep Holla <sudeep.holla@arm.com>,
Vincent Donnefort <vdonnefort@google.com>,
Jean-Philippe Brucker <jean-philippe@linaro.org>,
linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] KVM: arm64: Add memory length checks and remove inline in do_ffa_mem_xfer
Date: Mon, 9 Sep 2024 16:03:07 +0000 [thread overview]
Message-ID: <Zt8cO8aKS64_FW1W@google.com> (raw)
In-Reply-To: <20240909130832.1203849-1-snehalreddy@google.com>
On Mon, Sep 09, 2024 at 01:08:32PM +0000, Snehal Koukuntla wrote:
Hi,
A couple of nits which weren't addressed in the first version.
> Check size during allocation to fix discrepancy in memory reclaim path.
> Currently only happens during memory reclaim, inconsistent with mem_xfer
> Also do_ffa_mem_xfer() does not need __always_inline
>
Please enhance the description in the commit message as Mark suggested
previously. Something like this should work:
"""
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.
Fixes: 43609000177625
Cc: stable@vger.kernel.org
Signed-off-by: Snehal Koukuntla <snehalreddy@google.com>
"""
Otherwise, Reviewed-by: Sebastian Ene <sebastianene@google.com>
> Signed-off-by: Snehal Koukuntla <snehalreddy@google.com>
> ---
> arch/arm64/kvm/hyp/nvhe/ffa.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c
> index e715c157c2c4..637425f63fd1 100644
> --- a/arch/arm64/kvm/hyp/nvhe/ffa.c
> +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c
> @@ -426,7 +426,7 @@ static void do_ffa_mem_frag_tx(struct arm_smccc_res *res,
> return;
> }
>
> -static __always_inline void do_ffa_mem_xfer(const u64 func_id,
> +static void do_ffa_mem_xfer(const u64 func_id,
> struct arm_smccc_res *res,
> struct kvm_cpu_context *ctxt)
> {
> @@ -461,6 +461,11 @@ static __always_inline void do_ffa_mem_xfer(const u64 func_id,
> goto out_unlock;
> }
>
> + if (len > ffa_desc_buf.len) {
> + ret = FFA_RET_NO_MEMORY;
> + goto out_unlock;
> + }
> +
> buf = hyp_buffers.tx;
> memcpy(buf, host_buffers.tx, fraglen);
>
> --
> 2.46.0.469.g59c65b2a67-goog
>
Thanks,
Seb
prev parent reply other threads:[~2024-09-09 16:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-09 13:08 [PATCH v2] KVM: arm64: Add memory length checks and remove inline in do_ffa_mem_xfer Snehal Koukuntla
2024-09-09 16:03 ` Sebastian Ene [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zt8cO8aKS64_FW1W@google.com \
--to=sebastianene@google.com \
--cc=catalin.marinas@arm.com \
--cc=james.morse@arm.com \
--cc=jean-philippe@linaro.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=snehalreddy@google.com \
--cc=sudeep.holla@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=vdonnefort@google.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.