From: Yeoreum Yun <yeoreum.yun@arm.com>
To: maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com,
suzuki.poulose@arm.com, yuzenghui@huawei.com,
catalin.marinas@arm.com, will@kernel.org, perlarsen@google.com,
ayrton@google.com
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org, Yeoreum Yun <yeoreum.yun@arm.com>
Subject: [PATCH 1/2] KVM: arm64: fix FF-A call failure when ff-a driver is built-in
Date: Mon, 27 Oct 2025 19:17:28 +0000 [thread overview]
Message-ID: <20251027191729.1704744-2-yeoreum.yun@arm.com> (raw)
In-Reply-To: <20251027191729.1704744-1-yeoreum.yun@arm.com>
Until has_version_negotiated is set to true,
all FF-A function calls fail except FFA_VERSION.
The has_version_negotiated flag is set to true when
the first FFA_VERSION call is made after init_hyp_mode().
This works fine when the FF-A driver is built as a module,
since ffa_init() is invoked after kvm_arm_init(), allowing do_ffa_version()
to set has_version_negotiated to true.
However, when the FF-A driver is built-in (CONFIG_ARM_FFA_TRANSPORT=y),
all FF-A calls fail. This happens because ffa_init() runs before
kvm_arm_init() — the init level of ffa_init() is rootfs_initcall.
As a result, the hypervisor cannot set has_version_negotiated,
since the FFA_VERSION call made in ffa_init() does not trap to the hypervisor
(HCR_EL2.TSC is cleared before kvm_arm_init()).
Consequently, this causes failures when using EFI variable services
with secure partitions that rely on FFA_SEND_DIRECT_MSG.
To fix this, call hyp_ffa_post_init() and set has_version_negotiated
during hyp_ffa_init() when the FF-A driver is built-in (CONFIG_ARM_FFA_TRANSPORT=y).
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
---
arch/arm64/kvm/hyp/nvhe/ffa.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c
index 4e16f9b96f63..0ae87ff61758 100644
--- a/arch/arm64/kvm/hyp/nvhe/ffa.c
+++ b/arch/arm64/kvm/hyp/nvhe/ffa.c
@@ -984,5 +984,17 @@ int hyp_ffa_init(void *pages)
};
version_lock = __HYP_SPIN_LOCK_UNLOCKED;
+
+ if (IS_BUILTIN(CONFIG_ARM_FFA_TRANSPORT)) {
+ hyp_spin_lock(&version_lock);
+ if (hyp_ffa_post_init()) {
+ hyp_spin_unlock(&version_lock);
+ return -EOPNOTSUPP;
+ }
+
+ smp_store_release(&has_version_negotiated, true);
+ hyp_spin_unlock(&version_lock);
+ }
+
return 0;
}
--
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}
next prev parent reply other threads:[~2025-10-27 19:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 19:17 [PATCH 0/2] use TPM device with CRB over FF-A when kernel boot with pkvm Yeoreum Yun
2025-10-27 19:17 ` Yeoreum Yun [this message]
2025-10-31 8:09 ` [PATCH 1/2] KVM: arm64: fix FF-A call failure when ff-a driver is built-in Sebastian Ene
2025-10-31 10:08 ` Yeoreum Yun
2025-10-31 10:27 ` Marc Zyngier
2025-10-31 11:11 ` Yeoreum Yun
2025-10-27 19:17 ` [PATCH 2/2] KVM: arm64: support optional calls of FF-A v1.2 Yeoreum Yun
2025-10-28 10:26 ` Ben Horgan
2025-10-28 21:06 ` Yeoreum Yun
2025-10-29 9:49 ` Ben Horgan
2025-10-29 13:36 ` Yeoreum Yun
2025-10-30 13:29 ` Per Larsen
2025-10-30 13:43 ` Yeoreum Yun
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=20251027191729.1704744-2-yeoreum.yun@arm.com \
--to=yeoreum.yun@arm.com \
--cc=ayrton@google.com \
--cc=catalin.marinas@arm.com \
--cc=joey.gouly@arm.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=perlarsen@google.com \
--cc=suzuki.poulose@arm.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
all inboxes | Powered by JetHome®