From: Per Larsen Date: Tue, 13 May 2025 06:28:30 +0000 Subject: [PATCH v3 1/3] KVM: arm64: Restrict FF-A host version renegotiation MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250513-virtio-msg-ffa-v3-1-d66c76ff1b2c@google.com> References: <20250513-virtio-msg-ffa-v3-0-d66c76ff1b2c@google.com> In-Reply-To: <20250513-virtio-msg-ffa-v3-0-d66c76ff1b2c@google.com> To: Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Sudeep Holla Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, sebastianene@google.com, lpieralisi@kernel.org, arve@android.com, qwandor@google.com, kernel-team@android.com, armellel@google.com, perl@immunant.com, jean-philippe@linaro.org, ahomescu@google.com, tabba@google.com, qperret@google.com, james.morse@arm.com, Per Larsen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1747117739; l=1163; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=Prs9vwH1PpI7boVTkM9t7dd2Gj6IXNMISFZbJ9u0HHQ=; b=iD3MoRDcl6vsNTRQcIKy81Aq/kHV0QjJvlLIp932eUrLbxYG5Q8loKlRusWWZDX7lgiC6r6kh mqLFZjkse+hA86wrqJ46kG7NDve/h1wBZyoRavVqXmupHV3UmqOlBhP X-Developer-Key: i=perlarsen@google.com; a=ed25519; pk=jjc/Ta4VmrLRmMoahP6d1mBcKzvWU+nsmdtYe2oS2kQ= X-Endpoint-Received: by B4 Relay for perlarsen@google.com/20250508 with auth_id=402 List-Id: B4 Relay Submissions Prevent the host from re-negotiating a lesser minor version with the hypervisor. Once the hypervisor negotiates a version, that should remain locked in. Fix the current behaviour by returning NOT_SUPPORTED to avoid the FF-A interoperability rules with lesser minor versions that allow the host version to downgrade. Signed-off-by: Per Larsen Signed-off-by: Per Larsen --- arch/arm64/kvm/hyp/nvhe/ffa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 3369dd0c4009f84ad3cf9481c747bdc57a162370..2c199d40811efb5bfae199c4a67d8ae3d9307357 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -712,7 +712,10 @@ static void do_ffa_version(struct arm_smccc_res *res, hyp_spin_lock(&version_lock); if (has_version_negotiated) { - res->a0 = hyp_ffa_version; + if (FFA_MINOR_VERSION(ffa_req_version) < FFA_MINOR_VERSION(hyp_ffa_version)) + res->a0 = FFA_RET_NOT_SUPPORTED; + else + res->a0 = hyp_ffa_version; goto unlock; } -- 2.49.0.1045.g170613ef41-goog