From nobody Fri Dec 19 20:15:27 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7990238159; Fri, 16 May 2025 12:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747397651; cv=none; b=hzvUnw/qrHr6ElrCfxNK79I9XwmXdiX1/gxZ/Xc+DqQLYRyD7fv7H8BlwvLrIMnoXlc35gE8emPsdLefhj/3rwYUMVaOT9WdFvke2Dq7+CVgdPsekxHG37+lvez7qKrTnaK2L2GLyf4TRGC37663/qwQIKOU9Bl3SQjckvDtZ/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747397651; c=relaxed/simple; bh=/lGfEK9zU2R6gaBuqIOJeoWF1339hPhixjeue3QgP5o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=P7kJIusgfCBonaugu6iQigdvY/0s61iC4gb4NE7fKOQrYQHap32vy11/mpeXtSk+EmrNTFGuxqSY79WnJ+CfKkqBKNebeEOoqXqKPJd38tUetwbr7ReyHPNQXuFYKItykGYLRGEkX1Cpgp9/xKpY1pXCtjBqnFMQgYY2nb0DWaU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dbMC5gGK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dbMC5gGK" Received: by smtp.kernel.org (Postfix) with ESMTPS id B8C78C4CEEB; Fri, 16 May 2025 12:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747397650; bh=/lGfEK9zU2R6gaBuqIOJeoWF1339hPhixjeue3QgP5o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=dbMC5gGKFmMSORqwk1vfo9RNP992blX2U+MtZhiFH0ZBTH4MwmBnf3smKSjRzdNbo nujshAmCrXxBQcWrow3owAlU854/VsrBKy9vvhAHlecQZogET+TaMMpRbt+FVYyj76 er5nodp0v8i/Tq+3/EYIGZV2+3b9Cq5D6+39xg6+QP3I8b5zEthRzd/omD9lMuVqdd vy5I7Szstaok1mMmuU3wrMOlMe5AjzVlivc54oZesUbuey9/nk0DNmcju5xyTgyDGX 1PScCs8ufZFbYT6pGdDvuNHRnecFd5sxFu8rWE04hcSeqAMAy9LDZtRwlWHM01/oYR yttLZu/itLtPA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4C67C3ABD8; Fri, 16 May 2025 12:14:10 +0000 (UTC) From: Per Larsen via B4 Relay Date: Fri, 16 May 2025 12:14:00 +0000 Subject: [PATCH v4 1/5] KVM: arm64: Restrict FF-A host version renegotiation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250516-virtio-msg-ffa-v4-1-580ee70e5081@google.com> References: <20250516-virtio-msg-ffa-v4-0-580ee70e5081@google.com> In-Reply-To: <20250516-virtio-msg-ffa-v4-0-580ee70e5081@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, qperret@google.com, qwandor@google.com, arve@android.com, perl@immunant.com, lpieralisi@kernel.org, kernel-team@android.com, tabba@google.com, james.morse@arm.com, armellel@google.com, jean-philippe@linaro.org, ahomescu@google.com, Per Larsen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1747397650; l=1116; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=KE0l+d+r+QSm1fqDkNHRHhbIpv9VyyzBoa1V1b9tCZk=; b=LpJQ30mDqqHwDjaicF57PfEsiV7MpwOBSa0ddOhXxE84Qd3wunEL4UivPaPq6LT+HD2GHuv3p j+jb5zbBL7OCb+5b7E/fOyA9HFK3/8f8HvTAypL/tv+h04OrdDwtmbL 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 X-Original-From: Per Larsen Reply-To: perlarsen@google.com From: Per Larsen 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 Acked-by: Will Deacon --- 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..2c199d40811efb5bfae199c4a67= d8ae3d9307357 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, =20 hyp_spin_lock(&version_lock); if (has_version_negotiated) { - res->a0 =3D hyp_ffa_version; + if (FFA_MINOR_VERSION(ffa_req_version) < FFA_MINOR_VERSION(hyp_ffa_versi= on)) + res->a0 =3D FFA_RET_NOT_SUPPORTED; + else + res->a0 =3D hyp_ffa_version; goto unlock; } =20 --=20 2.49.0.1101.gccaa498523-goog From nobody Fri Dec 19 20:15:27 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F03FE238176; Fri, 16 May 2025 12:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747397651; cv=none; b=u+cuuq4W8aUdc2YcInjl3prH9P4ctLOg7z9QwZcil0NSrrgjntfV4xqM2FzTKPR+AcwLOM8QvX8Y8ndz9yis8XSlovrJiyrNNRyhaSanmUlDP1JHhtxpt/IP2Jq2NveP1dyFZSIIOd/AwxsEYYgwO/sgCR310DZTCwgSc+nzPF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747397651; c=relaxed/simple; bh=J6h7ILB6u2p92bToPEUMc7SmKaX4SeQ7fwuvz6UJhcs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h1YV92xB3VY+YpcJBEGE6KtkT2Jjq122jPnKGbJxEHmGTrt+CtshiL8u70YgMGWsQiWlqHq17pcBNXTonYL1eoCyR0uds7TXceC9DLrHsO/G9gJMMMx7wJnXsup0Ugx3QRD4a8Eel8tNfmFZ9sUQafukJfmCgdtkyUmyIYckQFg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pnWfOWd7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pnWfOWd7" Received: by smtp.kernel.org (Postfix) with ESMTPS id C455DC4CEEF; Fri, 16 May 2025 12:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747397650; bh=J6h7ILB6u2p92bToPEUMc7SmKaX4SeQ7fwuvz6UJhcs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=pnWfOWd7x8ZqLFiLqji8GuMFYGRlkL44Gmp95jUD+8eMD3NQ85TPQOzIMJ+AT6o9P ey5w4/CL/MPwHVdoUNau8Nt3NLemauCaoUXNz36ztZTtByAwdQnfNEpz7C962QOj8o Zz6XHfh3NqZT23ql2Of7V4TYJNlV93uVz0CsbZjtEzQmyuS55PhLpEoiMtefEpmp0p YltinF5AAAPPj/5emS9I2BcUEmFaRq97oEbmYk8arufAyIKMfMCtfBhywGaO3exwfY qu8B+SlnBuB1bf5aNzbR8LglrHSq8OhSr5MKP+mc8Hw2Ksbk2tStqj3ShjyLI8akPZ 77LyswhUI9MgQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B42EEC3DA6D; Fri, 16 May 2025 12:14:10 +0000 (UTC) From: Per Larsen via B4 Relay Date: Fri, 16 May 2025 12:14:01 +0000 Subject: [PATCH v4 2/5] KVM: arm64: Zero x4-x7 in ffa_set_retval Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250516-virtio-msg-ffa-v4-2-580ee70e5081@google.com> References: <20250516-virtio-msg-ffa-v4-0-580ee70e5081@google.com> In-Reply-To: <20250516-virtio-msg-ffa-v4-0-580ee70e5081@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, qperret@google.com, qwandor@google.com, arve@android.com, perl@immunant.com, lpieralisi@kernel.org, kernel-team@android.com, tabba@google.com, james.morse@arm.com, armellel@google.com, jean-philippe@linaro.org, ahomescu@google.com, Per Larsen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1747397650; l=1625; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=LMpReGw/k7MiHAdq22ZI2li2EKc28upqB6Z9WwV7U10=; b=N184+8YrogmptYxdr3tgUwyC5QKpJKyFjClV6vICc1bfnlLMzk27GqfoI0om0EZaAnwByKu4P H0Cwk+3GMLaDSotY4mVB+EHKJ30m2U4cLwAJkAqPXCg2hkFuJbi8xcA 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 X-Original-From: Per Larsen Reply-To: perlarsen@google.com From: Per Larsen FF-A 1.0 references SMCCC 1.2 (reference [4] on page xi). The results of an SMC32/HVC32 are returned in W1-W7 in SMCCC 1.2. However, W4-W7 must be preserved unless they contain results according to the function definition. ffa_set_retval is commonly used to report FFA_SUCCESS or FFA_ERROR back to the caller. FFA_SUCCESS requires that x2-x7 must be zero (MBZ) unless a register is explicitly used in the function response. FFA_ERROR requires x3-x7 MBZ. ffa_set_retval is also used to return results of: - FFA_VERSION which requires x1-x7 MBZ - FFA_MEM_FRAG_TX which returns FFA_MEM_FRAG_RX or FFA_ERROR. FFA_MEM_FRAG_RAX always requires that x5-x7 MBZ and x4 MBZ at any virtual FF-A instance (applies to kvm). Messaging interfaces such as FFA_MSG_SEND_DIRECT_{REQ,REQ2}, will not use ffa_set_retval. Given the above, it is safe to zero x4-x7 in ffa_set_retval. Signed-off-by: Per Larsen --- arch/arm64/kvm/hyp/nvhe/ffa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 2c199d40811efb5bfae199c4a67d8ae3d9307357..b3d016bee404ce3f8c72cc57bef= b4ef4e6c1657f 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -101,6 +101,10 @@ static void ffa_set_retval(struct kvm_cpu_context *ctx= t, cpu_reg(ctxt, 1) =3D res->a1; cpu_reg(ctxt, 2) =3D res->a2; cpu_reg(ctxt, 3) =3D res->a3; + cpu_reg(ctxt, 4) =3D 0; + cpu_reg(ctxt, 5) =3D 0; + cpu_reg(ctxt, 6) =3D 0; + cpu_reg(ctxt, 7) =3D 0; } =20 static bool is_ffa_call(u64 func_id) --=20 2.49.0.1101.gccaa498523-goog From nobody Fri Dec 19 20:15:27 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B10C23C8A1; Fri, 16 May 2025 12:14:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747397651; cv=none; b=fT9Ap3RHfj/YnHvWeSuTeo89ynQkAiotrpn5r7Q/v0bIPe1Y6d7DQiQSd/oKq10Elm4yBb8jv91EKWTSPwc6sy21hoV0k2GoEyM/TtSaVn4jeynBUh93Bn2t0wV1alFv4ZPxNhzDfCedfLCnICM2U086UzokgMPktHeYTiKiWQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747397651; c=relaxed/simple; bh=9U/85KTSy2soaOEUs61BjUU0CpktmnMb+qsPkLo0B5o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=r/AxVz/i9gWA0lkXAyq60wgis5FnsL9K4LswBg3/AdVoAsmpaaJUUfziXui6SNktjOKjAAdNEVSyccwK0tV1LL8ODjXmA3nIK3SpF2TWXLX08Uze0QphJKuwHmY2/0ClHkhTnM5M8FB8u3wOkEZFMIUdBnfIujLhoOrBtPOl11Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WJ4FtaOg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WJ4FtaOg" Received: by smtp.kernel.org (Postfix) with ESMTPS id CEA5FC4CEF2; Fri, 16 May 2025 12:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747397650; bh=9U/85KTSy2soaOEUs61BjUU0CpktmnMb+qsPkLo0B5o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=WJ4FtaOgH+39q/9UjmhBnMooZm5KoX+Lc6xfPXvNDMNsfCAUl1pWOMLWya5iMBnLU wQHuSLJspVLnn4hZ+7Wrs6EHUyfiEcN/uxOz+R2KXldLh6DTJYyiHxhBmln8LXzWok 7ectKHLZB0vpmDVhMnBdDfTzVVRZbku0PUpce2wSurbzrXTxDycqtBywlvLJT61q8K MBsDGJeSnouqRehj/aQ/ijXR3VoX2bK68XluFlyhvQqwle27WmbGw6KWo+2WDBFxsy sOax37hTqGWCACMP9df94JZGvlK03PflBQsWi8oaj2vZD2xKSx0D7gVX3pO2LyFUPH JRO3lU3n7EHZA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2C7CC54756; Fri, 16 May 2025 12:14:10 +0000 (UTC) From: Per Larsen via B4 Relay Date: Fri, 16 May 2025 12:14:02 +0000 Subject: [PATCH v4 3/5] KVM: arm64: Mark FFA_NOTIFICATION_* calls as unsupported Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250516-virtio-msg-ffa-v4-3-580ee70e5081@google.com> References: <20250516-virtio-msg-ffa-v4-0-580ee70e5081@google.com> In-Reply-To: <20250516-virtio-msg-ffa-v4-0-580ee70e5081@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, qperret@google.com, qwandor@google.com, arve@android.com, perl@immunant.com, lpieralisi@kernel.org, kernel-team@android.com, tabba@google.com, james.morse@arm.com, armellel@google.com, jean-philippe@linaro.org, ahomescu@google.com, Per Larsen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1747397650; l=968; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=tJ9HD4wjZlLzjCNPRFEt/uGpoSjzet6nmsUHE2M2Jd8=; b=7xqRt3arz28xQfkhqfvJ+B+4UnOt54PAFFfiTGYmU2Bp36rkep1XJN9kBTDpFAIJFbkYVqlts V8tkLlIw+XJDtVSOeWXU/FptsGDEfrLiQLuC1y1FcBgYG2ZSPS91GWU 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 X-Original-From: Per Larsen Reply-To: perlarsen@google.com From: Per Larsen Prevent FFA_NOTIFICATION_* interfaces from being passed through to TZ. Signed-off-by: Per Larsen Acked-by: Will Deacon --- arch/arm64/kvm/hyp/nvhe/ffa.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index b3d016bee404ce3f8c72cc57befb4ef4e6c1657f..a545d25002c85b79a8d28173947= 9dab7838a7cd3 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -632,6 +632,14 @@ static bool ffa_call_supported(u64 func_id) case FFA_RXTX_MAP: case FFA_MEM_DONATE: case FFA_MEM_RETRIEVE_REQ: + /* Optional notification interfaces added in FF-A 1.1 */ + case FFA_NOTIFICATION_BITMAP_CREATE: + case FFA_NOTIFICATION_BITMAP_DESTROY: + case FFA_NOTIFICATION_BIND: + case FFA_NOTIFICATION_UNBIND: + case FFA_NOTIFICATION_SET: + case FFA_NOTIFICATION_GET: + case FFA_NOTIFICATION_INFO_GET: return false; } =20 --=20 2.49.0.1101.gccaa498523-goog From nobody Fri Dec 19 20:15:27 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B06823C8A0; Fri, 16 May 2025 12:14:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747397651; cv=none; b=bh8/7ZddxjoRiCRjipwsi9JIrz7nkSdQs/pNr5fV9k7MdDb3SYB2suS5std3udtLaGFP9GL+ZY5HeS72LVVn5YrnIfCLFZQgNoB6EMEY2l/7T6CyadZVjc0ZYGnz54twysyj6ntl8G4Wv1F3bw2a8NjwYlakmI3RoDvjCt0vMxQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747397651; c=relaxed/simple; bh=AbTOZo2bIHYa+AuZXgK7wBfGLHVL/DsMiueumhxEIwI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OH53AFU2gDXNhVFxu1HtKtahsQQDIMEk8DXlWrV8omp+GbYW69XwFSCdbRmhLl6LeUn+S74w9R1x8QfjUijycmmdpD1ozCr71QduKaLIWnQGqOJnWwyTFB6ehJAQoNH7gK+tQubDdSBaNpmk8emlBady7PDCTgS+VKbN5tHAbXc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ozuVXQL9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ozuVXQL9" Received: by smtp.kernel.org (Postfix) with ESMTPS id DDD8FC4CEF4; Fri, 16 May 2025 12:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747397650; bh=AbTOZo2bIHYa+AuZXgK7wBfGLHVL/DsMiueumhxEIwI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ozuVXQL9pso3mx6vj2sKLbWCP2SVEwtcSjwdfJZBf3ZKM/qlaYB7yf/S5tOHzqaSI uAZOEJt4Sb6EMqujqKzB08x1gxx9rCJF2khiBlJ3NBzM6fAAyIJVMOwAkm4ntfLple PU2kYFTHJeGqDQ/Iko8/tvMquLLoZEFLxj7swdUJRTn88kBJSaS9RMR6opO2g+zvtM 1R5YybYN8sLr1eEYqIPlynWoZ/mDvkfcycO+yifMJjpm116YZV/TFwG4k0bITVw5GN 2oW5BtwVRJsM2bzXKWu0Q6dddGaf+9q0nrIWbf5onGRHsek3KZ3Eykf1sbq8SCKNT+ JQb+i2Urn84Yw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1E1EC54755; Fri, 16 May 2025 12:14:10 +0000 (UTC) From: Per Larsen via B4 Relay Date: Fri, 16 May 2025 12:14:03 +0000 Subject: [PATCH v4 4/5] KVM: arm64: Bump the supported version of FF-A to 1.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250516-virtio-msg-ffa-v4-4-580ee70e5081@google.com> References: <20250516-virtio-msg-ffa-v4-0-580ee70e5081@google.com> In-Reply-To: <20250516-virtio-msg-ffa-v4-0-580ee70e5081@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, qperret@google.com, qwandor@google.com, arve@android.com, perl@immunant.com, lpieralisi@kernel.org, kernel-team@android.com, tabba@google.com, james.morse@arm.com, armellel@google.com, jean-philippe@linaro.org, ahomescu@google.com, Ayrton Munoz , Per Larsen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1747397650; l=6027; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=CRuCyLKNFxMaf56e9Y4I4+VaRj1h0S9SBtIGcRCH7Y8=; b=LXvUXDce7fu7RCfcKhj2RihIzanwXdYDk53LfDW/aC5vxWH+lOcb0BKUEie3ZMvMBmKKGHBNh pzWxOwfuYQZAlgWXTgUhrRH5mblPsS2RiWEdqhkvVTJ65xUpgC/WZ9K 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 X-Original-From: Per Larsen Reply-To: perlarsen@google.com From: Per Larsen FF-A version 1.2 introduces the DIRECT_REQ2 ABI. Bump the FF-A version preferred by the hypervisor as a precursor to implementing the 1.2-only FFA_MSG_SEND_DIRECT_REQ2 and FFA_MSG_SEND_RESP2 messaging interfaces. We must also use SMCCC 1.2 for 64-bit SMCs if hypervisor negotiated FF-A 1.2, so ffa_set_retval is updated and a new function to call 64-bit smcs using SMCCC 1.2 with fallback to SMCCC 1.1 is introduced. Update ffa_call_supported to mark FF-A 1.2 interfaces as unsupported lest they get forwarded. Co-developed-by: Ayrton Munoz Signed-off-by: Ayrton Munoz Signed-off-by: Per Larsen --- arch/arm64/kvm/hyp/nvhe/Makefile | 1 + arch/arm64/kvm/hyp/nvhe/ffa.c | 61 ++++++++++++++++++++++++++++++++++++= ---- include/linux/arm_ffa.h | 1 + 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Mak= efile index b43426a493df5a388caa920e259cc8c54d118a1b..95404ff16dac0389f45a3ee2c13= a93b3ebebaf6d 100644 --- a/arch/arm64/kvm/hyp/nvhe/Makefile +++ b/arch/arm64/kvm/hyp/nvhe/Makefile @@ -27,6 +27,7 @@ hyp-obj-y :=3D timer-sr.o sysreg-sr.o debug-sr.o switch.o= tlb.o hyp-init.o host.o cache.o setup.o mm.o mem_protect.o sys_regs.o pkvm.o stacktrace.o ffa.o hyp-obj-y +=3D ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../en= try.o \ ../fpsimd.o ../hyp-entry.o ../exception.o ../pgtable.o +hyp-obj-y +=3D ../../../kernel/smccc-call.o hyp-obj-$(CONFIG_LIST_HARDENED) +=3D list_debug.o hyp-obj-y +=3D $(lib-objs) =20 diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index a545d25002c85b79a8d281739479dab7838a7cd3..0b952ace29f6847b4e941262c4c= 1b05a5bc13e5a 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -105,6 +105,48 @@ static void ffa_set_retval(struct kvm_cpu_context *ctx= t, cpu_reg(ctxt, 5) =3D 0; cpu_reg(ctxt, 6) =3D 0; cpu_reg(ctxt, 7) =3D 0; + + /* + * Per DEN0077A v1.2 11.2, the caller is expected to write zeroes to + * unused parameter registers. + */ + if (ARM_SMCCC_IS_64(res->a0)) { + /* Prevent race with CPU performing version negotiation */ + if (smp_load_acquire(&has_version_negotiated) && + hyp_ffa_version >=3D FFA_VERSION_1_2) { + cpu_reg(ctxt, 8) =3D 0; + cpu_reg(ctxt, 9) =3D 0; + cpu_reg(ctxt, 10) =3D 0; + cpu_reg(ctxt, 11) =3D 0; + cpu_reg(ctxt, 12) =3D 0; + cpu_reg(ctxt, 13) =3D 0; + cpu_reg(ctxt, 14) =3D 0; + cpu_reg(ctxt, 15) =3D 0; + cpu_reg(ctxt, 16) =3D 0; + cpu_reg(ctxt, 17) =3D 0; + } + } +} + +/* Call SMC64 using SMCCC 1.2 if hyp negotiated FF-A 1.2 falling back to 1= .1 */ +static void arm_smccc_1_x_smc(u64 func_id, u64 a1, u64 a2, u64 a3, + u64 a4, u64 a5, u64 a6, u64 a7, + struct arm_smccc_res *res) +{ + struct arm_smccc_1_2_regs args, regs =3D {0}; + + /* SMC64 only as SMC32 must preserve x8-x30 per DEN0028 1.6G Sec 2.6 */ + if (ARM_SMCCC_IS_64(func_id) && + hyp_ffa_version >=3D FFA_VERSION_1_2) { + args =3D (struct arm_smccc_1_2_regs) { func_id, a1, a2, a3, a4, + a5, a6, a7 }; + arm_smccc_1_2_smc(&args, ®s); + *res =3D (struct arm_smccc_res) { .a0 =3D regs.a0, .a1 =3D regs.a1, + .a2 =3D regs.a2, .a3 =3D regs.a3 }; + return; + } + + arm_smccc_1_1_smc(func_id, a1, a2, a3, a4, a5, a6, a7, res); } =20 static bool is_ffa_call(u64 func_id) @@ -119,7 +161,7 @@ static int ffa_map_hyp_buffers(u64 ffa_page_count) { struct arm_smccc_res res; =20 - arm_smccc_1_1_smc(FFA_FN64_RXTX_MAP, + arm_smccc_1_x_smc(FFA_FN64_RXTX_MAP, hyp_virt_to_phys(hyp_buffers.tx), hyp_virt_to_phys(hyp_buffers.rx), ffa_page_count, @@ -178,7 +220,7 @@ static void ffa_mem_reclaim(struct arm_smccc_res *res, = u32 handle_lo, =20 static void ffa_retrieve_req(struct arm_smccc_res *res, u32 len) { - arm_smccc_1_1_smc(FFA_FN64_MEM_RETRIEVE_REQ, + arm_smccc_1_x_smc(FFA_FN64_MEM_RETRIEVE_REQ, len, len, 0, 0, 0, 0, 0, res); @@ -640,6 +682,12 @@ static bool ffa_call_supported(u64 func_id) case FFA_NOTIFICATION_SET: case FFA_NOTIFICATION_GET: case FFA_NOTIFICATION_INFO_GET: + /* Unimplemented interfaces added in FF-A 1.2 */ + case FFA_MSG_SEND_DIRECT_REQ2: + case FFA_MSG_SEND_DIRECT_RESP2: + case FFA_CONSOLE_LOG: + case FFA_PARTITION_INFO_GET_REGS: + case FFA_EL3_INTR_HANDLE: return false; } =20 @@ -692,7 +740,7 @@ static int hyp_ffa_post_init(void) if (res.a0 !=3D FFA_SUCCESS) return -EOPNOTSUPP; =20 - switch (res.a2) { + switch (res.a2 & FFA_FEAT_RXTX_MIN_SZ_MASK) { case FFA_FEAT_RXTX_MIN_SZ_4K: min_rxtx_sz =3D SZ_4K; break; @@ -881,7 +929,7 @@ int hyp_ffa_init(void *pages) if (kvm_host_psci_config.smccc_version < ARM_SMCCC_VERSION_1_2) return 0; =20 - arm_smccc_1_1_smc(FFA_VERSION, FFA_VERSION_1_1, 0, 0, 0, 0, 0, 0, &res); + arm_smccc_1_1_smc(FFA_VERSION, FFA_VERSION_1_2, 0, 0, 0, 0, 0, 0, &res); if (res.a0 =3D=3D FFA_RET_NOT_SUPPORTED) return 0; =20 @@ -901,10 +949,11 @@ int hyp_ffa_init(void *pages) if (FFA_MAJOR_VERSION(res.a0) !=3D 1) return -EOPNOTSUPP; =20 - if (FFA_MINOR_VERSION(res.a0) < FFA_MINOR_VERSION(FFA_VERSION_1_1)) + /* See do_ffa_guest_version before bumping maximum supported version. */ + if (FFA_MINOR_VERSION(res.a0) < FFA_MINOR_VERSION(FFA_VERSION_1_2)) hyp_ffa_version =3D res.a0; else - hyp_ffa_version =3D FFA_VERSION_1_1; + hyp_ffa_version =3D FFA_VERSION_1_2; =20 tx =3D pages; pages +=3D KVM_FFA_MBOX_NR_PAGES * PAGE_SIZE; diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 5bded24dc24fea8cdcbe42bf79c7c025c3fa5f4b..c0dd6183d956043192114a522b7= eef465e7078ac 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -128,6 +128,7 @@ #define FFA_FEAT_RXTX_MIN_SZ_4K 0 #define FFA_FEAT_RXTX_MIN_SZ_64K 1 #define FFA_FEAT_RXTX_MIN_SZ_16K 2 +#define FFA_FEAT_RXTX_MIN_SZ_MASK 3 =20 /* FFA Bus/Device/Driver related */ struct ffa_device { --=20 2.49.0.1101.gccaa498523-goog From nobody Fri Dec 19 20:15:27 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79B4923C8DB; Fri, 16 May 2025 12:14:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747397651; cv=none; b=WzIZDpZ6H7Eb1oLASHafiyyDBcMFX7LeWdqgzqYFimP0RIstR+e4hkJaVeU6k2BeXWryuq0t7mJNgt8qCPKn3j7VMGY8H99nPbDJot9CJytHBM6XVOiDG/P3EPhs3/rksnAA6YAtYwRb/U2HVYgwzj88dNIrUv1NQ57JHdOoH/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747397651; c=relaxed/simple; bh=RXexCK8Qdt/LRm9vYunDp7LKFYd3x/0zE98ns8Tksyo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EFKudbzCDvG962JNQMSQI+moi4ly8+wZIezi9fsHNIuqTR+3KitZZbQpQXAJLfOJn3Owkow1EyBLg+d+yfdJ/FK4nQo856J04wku2Ox6RZDbpBDDPxWnWgS4Hiewcx0V1UlGEnrOw63spVq3R0jQY/MmBnq7BrK0J13B4oWSxE4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qYdyOhmJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qYdyOhmJ" Received: by smtp.kernel.org (Postfix) with ESMTPS id F11BCC4CEFA; Fri, 16 May 2025 12:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747397651; bh=RXexCK8Qdt/LRm9vYunDp7LKFYd3x/0zE98ns8Tksyo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=qYdyOhmJClToEWPcyFZ9I6K8ccYMWstaLbbI/B8EJc7ZRSq/IcOSmB9O6zlLlpxMq 6uPDgljGZ4WOBncFIbY2W1SFIPc9kkL1HQvwrqvNIXvmTVjWZKUIsphHSCbxqUaqIx wQPauvLBH2Iy39RtpQSVe6VuPAdMI56CVm11FyJjlXPRoGdjbi9VoyUfEPzBwkw8D+ jbCpHSBCPbi9Vgs0sUP6ludNPCLl4K4lsJliRRGT8i8Yy8dTySFvi22rlfIVfE7Sxv j5TyN7fYmh2gE958dV2u/Rx3BVHTMuvotIRmt3OPNw+DSspz89rc695yFA+iO/lWHn MNndziDeSiqYQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3DE1C3ABC9; Fri, 16 May 2025 12:14:10 +0000 (UTC) From: Per Larsen via B4 Relay Date: Fri, 16 May 2025 12:14:04 +0000 Subject: [PATCH v4 5/5] KVM: arm64: Support FFA_MSG_SEND_DIRECT_REQ2 in host handler Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250516-virtio-msg-ffa-v4-5-580ee70e5081@google.com> References: <20250516-virtio-msg-ffa-v4-0-580ee70e5081@google.com> In-Reply-To: <20250516-virtio-msg-ffa-v4-0-580ee70e5081@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, qperret@google.com, qwandor@google.com, arve@android.com, perl@immunant.com, lpieralisi@kernel.org, kernel-team@android.com, tabba@google.com, james.morse@arm.com, armellel@google.com, jean-philippe@linaro.org, ahomescu@google.com, Per Larsen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1747397650; l=6287; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=hU7p4PRxZqf05XqHITft3GvP1fgJbAOODTG2NRdcdeA=; b=iqh8j3zsh8Sg9ZxHsL1pNDrvJXbbRkE3cDt2V0ruu86Mope78hrZsh3HSQqO2P3NgAOp8kAQh RF/+ph1MMUwAjs0uFLWFuzPlOTSVvtlp6zZHrE/fuiO9HC+glkCgb9R 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 X-Original-From: Per Larsen Reply-To: perlarsen@google.com From: Per Larsen FF-A 1.2 adds the DIRECT_REQ2 messaging interface which is similar to the existing FFA_MSG_SEND_DIRECT_{REQ,RESP} functions except that it uses the SMC calling convention v1.2 which allows calls to use x4-x17 as argument and return registers. Add support for FFA_MSG_SEND_DIRECT_REQ2 in the host ffa handler. Signed-off-by: Per Larsen --- arch/arm64/kvm/hyp/nvhe/ffa.c | 110 ++++++++++++++++++++++++++++++++++++++= +++- include/linux/arm_ffa.h | 2 + 2 files changed, 110 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 0b952ace29f6847b4e941262c4c1b05a5bc13e5a..cd75f98bffdb75abd41f9ddc944= b8426b93056e4 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -79,6 +79,14 @@ static void ffa_to_smccc_error(struct arm_smccc_res *res= , u64 ffa_errno) }; } =20 +static void ffa_to_smccc_1_2_error(struct arm_smccc_1_2_regs *regs, u64 ff= a_errno) +{ + *regs =3D (struct arm_smccc_1_2_regs) { + .a0 =3D FFA_ERROR, + .a2 =3D ffa_errno, + }; +} + static void ffa_to_smccc_res_prop(struct arm_smccc_res *res, int ret, u64 = prop) { if (ret =3D=3D FFA_RET_SUCCESS) { @@ -94,6 +102,12 @@ static void ffa_to_smccc_res(struct arm_smccc_res *res,= int ret) ffa_to_smccc_res_prop(res, ret, 0); } =20 +static u32 ffa_get_func_id(struct kvm_cpu_context *ctxt) +{ + DECLARE_REG(u32, func_id, ctxt, 0); + return func_id; +} + static void ffa_set_retval(struct kvm_cpu_context *ctxt, struct arm_smccc_res *res) { @@ -128,6 +142,54 @@ static void ffa_set_retval(struct kvm_cpu_context *ctx= t, } } =20 +static void ffa_set_retval_smccc_1_2(struct kvm_cpu_context *ctxt, + struct arm_smccc_1_2_regs *regs) +{ + cpu_reg(ctxt, 0) =3D regs->a0; + cpu_reg(ctxt, 1) =3D regs->a1; + cpu_reg(ctxt, 2) =3D regs->a2; + cpu_reg(ctxt, 3) =3D regs->a3; + cpu_reg(ctxt, 4) =3D regs->a4; + cpu_reg(ctxt, 5) =3D regs->a5; + cpu_reg(ctxt, 6) =3D regs->a6; + cpu_reg(ctxt, 7) =3D regs->a7; + cpu_reg(ctxt, 8) =3D regs->a8; + cpu_reg(ctxt, 9) =3D regs->a9; + cpu_reg(ctxt, 10) =3D regs->a10; + cpu_reg(ctxt, 11) =3D regs->a11; + cpu_reg(ctxt, 12) =3D regs->a12; + cpu_reg(ctxt, 13) =3D regs->a13; + cpu_reg(ctxt, 14) =3D regs->a14; + cpu_reg(ctxt, 15) =3D regs->a15; + cpu_reg(ctxt, 16) =3D regs->a16; + cpu_reg(ctxt, 17) =3D regs->a17; +} + +/* + * Must a given FFA function use the SMC calling convention v1.2? + */ +static bool ffa_call_needs_smccc_1_2(u64 func_id) +{ + switch (func_id) { + case FFA_MSG_SEND_DIRECT_REQ2: + case FFA_MSG_SEND_DIRECT_RESP2: + case FFA_PARTITION_INFO_GET_REGS: + return true; + } + + return false; +} + +static void ffa_set_retval_smccc_1_x(struct kvm_cpu_context *ctxt, + struct arm_smccc_res *res, + struct arm_smccc_1_2_regs *regs) +{ + if (ffa_call_needs_smccc_1_2(ffa_get_func_id(ctxt))) + ffa_set_retval_smccc_1_2(ctxt, regs); + else + ffa_set_retval(ctxt, res); +} + /* Call SMC64 using SMCCC 1.2 if hyp negotiated FF-A 1.2 falling back to 1= .1 */ static void arm_smccc_1_x_smc(u64 func_id, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6, u64 a7, @@ -683,7 +745,6 @@ static bool ffa_call_supported(u64 func_id) case FFA_NOTIFICATION_GET: case FFA_NOTIFICATION_INFO_GET: /* Unimplemented interfaces added in FF-A 1.2 */ - case FFA_MSG_SEND_DIRECT_REQ2: case FFA_MSG_SEND_DIRECT_RESP2: case FFA_CONSOLE_LOG: case FFA_PARTITION_INFO_GET_REGS: @@ -852,9 +913,47 @@ static void do_ffa_part_get(struct arm_smccc_res *res, hyp_spin_unlock(&host_buffers.lock); } =20 +static void do_ffa_direct_msg2(struct arm_smccc_1_2_regs *regs, + struct kvm_cpu_context *ctxt, + u64 vm_handle) +{ + DECLARE_REG(u32, func_id, ctxt, 0); + DECLARE_REG(u32, endp, ctxt, 1); + DECLARE_REG(u64, uuid_lo, ctxt, 2); + DECLARE_REG(u64, uuid_hi, ctxt, 3); + DECLARE_REG(u64, x4, ctxt, 4); + DECLARE_REG(u64, x5, ctxt, 5); + DECLARE_REG(u64, x6, ctxt, 6); + DECLARE_REG(u64, x7, ctxt, 7); + DECLARE_REG(u64, x8, ctxt, 8); + DECLARE_REG(u64, x9, ctxt, 9); + DECLARE_REG(u64, x10, ctxt, 10); + DECLARE_REG(u64, x11, ctxt, 11); + DECLARE_REG(u64, x12, ctxt, 12); + DECLARE_REG(u64, x13, ctxt, 13); + DECLARE_REG(u64, x14, ctxt, 14); + DECLARE_REG(u64, x15, ctxt, 15); + DECLARE_REG(u64, x16, ctxt, 16); + DECLARE_REG(u64, x17, ctxt, 17); + + if (FIELD_GET(FFA_SRC_ENDPOINT_MASK, endp) !=3D vm_handle) { + ffa_to_smccc_1_2_error(regs, FFA_RET_INVALID_PARAMETERS); + return; + } + + struct arm_smccc_1_2_regs args =3D { + func_id, endp, uuid_lo, uuid_hi, + x4, x5, x6, x7, x8, x9, x10, + x11, x12, x13, x14, x15, x16, x17 + }; + + arm_smccc_1_2_smc(&args, regs); +} + bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id) { struct arm_smccc_res res; + struct arm_smccc_1_2_regs regs; =20 /* * There's no way we can tell what a non-standard SMC call might @@ -910,14 +1009,21 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *ho= st_ctxt, u32 func_id) case FFA_PARTITION_INFO_GET: do_ffa_part_get(&res, host_ctxt); goto out_handled; + case FFA_MSG_SEND_DIRECT_REQ2: + if (hyp_ffa_version >=3D FFA_VERSION_1_2) { + do_ffa_direct_msg2(®s, host_ctxt, HOST_FFA_ID); + goto out_handled; + } + goto out_not_supported; } =20 if (ffa_call_supported(func_id)) return false; /* Pass through */ =20 +out_not_supported: ffa_to_smccc_error(&res, FFA_RET_NOT_SUPPORTED); out_handled: - ffa_set_retval(host_ctxt, &res); + ffa_set_retval_smccc_1_x(host_ctxt, &res, ®s); return true; } =20 diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index c0dd6183d956043192114a522b7eef465e7078ac..82a35a3b22de426f7e9a8894e76= fdf1e933b3d6b 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -269,6 +269,8 @@ bool ffa_partition_check_property(struct ffa_device *de= v, u32 property) (ffa_partition_check_property(dev, FFA_PARTITION_DIRECT_REQ2_RECV) && \ !dev->mode_32bit) =20 +#define FFA_SRC_ENDPOINT_MASK GENMASK(31, 16) + /* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registe= rs */ struct ffa_send_direct_data { unsigned long data0; /* w3/x3 */ --=20 2.49.0.1101.gccaa498523-goog