From: Quentin Perret <qperret@google.com>
To: Sebastian Ene <sebastianene@google.com>
Cc: catalin.marinas@arm.com, joey.gouly@arm.com, maz@kernel.org,
oliver.upton@linux.dev, snehalreddy@google.com,
sudeep.holla@arm.com, suzuki.poulose@arm.com,
vdonnefort@google.com, will@kernel.org, yuzenghui@huawei.com,
kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kernel-team@android.com,
Andrei Homescu <ahomescu@google.com>
Subject: Re: [PATCH v4 3/3] KVM: arm64: Release the ownership of the hyp rx buffer to Trustzone
Date: Wed, 26 Mar 2025 16:48:33 +0000 [thread overview]
Message-ID: <Z-Qv4b0vgVql2yOb@google.com> (raw)
In-Reply-To: <20250326113901.3308804-4-sebastianene@google.com>
On Wednesday 26 Mar 2025 at 11:39:01 (+0000), Sebastian Ene wrote:
> Introduce the release FF-A call to notify Trustzone that the hypervisor
> has finished copying the data from the buffer shared with Trustzone to
> the non-secure partition.
>
> Reported-by: Andrei Homescu <ahomescu@google.com>
> Signed-off-by: Sebastian Ene <sebastianene@google.com>
> ---
> arch/arm64/kvm/hyp/nvhe/ffa.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c
> index 6df6131f1107..ac898ea6274a 100644
> --- a/arch/arm64/kvm/hyp/nvhe/ffa.c
> +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c
> @@ -749,6 +749,7 @@ static void do_ffa_part_get(struct arm_smccc_res *res,
> DECLARE_REG(u32, uuid3, ctxt, 4);
> DECLARE_REG(u32, flags, ctxt, 5);
> u32 count, partition_sz, copy_sz;
> + struct arm_smccc_res _res;
>
> hyp_spin_lock(&host_buffers.lock);
> if (!host_buffers.rx) {
> @@ -765,11 +766,11 @@ static void do_ffa_part_get(struct arm_smccc_res *res,
>
> count = res->a2;
> if (!count)
> - goto out_unlock;
> + goto release_rx;
>
> if (hyp_ffa_version > FFA_VERSION_1_0) {
> /* Get the number of partitions deployed in the system */
> - if (flags & 0x1)
> + if (flags & PARTITION_INFO_GET_RETURN_COUNT_ONLY)
> goto out_unlock;
>
> partition_sz = res->a3;
> @@ -781,10 +782,12 @@ static void do_ffa_part_get(struct arm_smccc_res *res,
> copy_sz = partition_sz * count;
> if (copy_sz > KVM_FFA_MBOX_NR_PAGES * PAGE_SIZE) {
> ffa_to_smccc_res(res, FFA_RET_ABORTED);
> - goto out_unlock;
> + goto release_rx;
> }
>
> memcpy(host_buffers.rx, hyp_buffers.rx, copy_sz);
> +release_rx:
> + ffa_rx_release(&_res);
I'm a bit confused about this release call here. In the pKVM FF-A proxy
model, the hypervisor is essentially 'transparent', so do we not expect
EL1 to issue that instead? How is EL1 supposed to know that the
hypervisor has already sent the release call? And isn't EL1 going to be
confused if the content of the buffer is overridden before is has issued
the release call itself? What would otherwise prevent that from
happening?
Thanks,
Quentin
> out_unlock:
> hyp_spin_unlock(&host_buffers.lock);
> }
> --
> 2.49.0.395.g12beb8f557-goog
>
next prev parent reply other threads:[~2025-03-26 16:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 11:38 [PATCH v4 0/3] KVM: arm64: Separate the hyp FF-A buffers init from the host Sebastian Ene
2025-03-26 11:38 ` [PATCH v4 1/3] KVM: arm64: Use the static initializer for the version lock Sebastian Ene
2025-03-26 16:44 ` Quentin Perret
2025-03-26 11:39 ` [PATCH v4 2/3] firmware: arm_ffa: Move the ffa_to_linux definition to the ffa header Sebastian Ene
2025-03-26 16:44 ` Quentin Perret
2025-03-26 11:39 ` [PATCH v4 3/3] KVM: arm64: Release the ownership of the hyp rx buffer to Trustzone Sebastian Ene
2025-03-26 16:48 ` Quentin Perret [this message]
2025-03-27 9:37 ` Sebastian Ene
2025-03-27 9:48 ` Sudeep Holla
2025-03-28 11:39 ` Quentin Perret
2025-03-28 14:18 ` Sebastian Ene
2025-04-01 12:00 ` Quentin Perret
2025-04-01 12:55 ` Sudeep Holla
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=Z-Qv4b0vgVql2yOb@google.com \
--to=qperret@google.com \
--cc=ahomescu@google.com \
--cc=catalin.marinas@arm.com \
--cc=joey.gouly@arm.com \
--cc=kernel-team@android.com \
--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=sebastianene@google.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).