From nobody Sun Oct 5 18:16:45 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 4B9651DDA15; Wed, 30 Jul 2025 21:15:17 +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=1753910117; cv=none; b=jUozOOBHKLe2n+GC68Z+1BcCWob27GCLjsvFCnngbJcBw6zbxGIXuv+VkCMGDNAMUE0s/yX/+EF1LUsTKKqZS/6ZApm8LAat2ahKg9Sd+Ttr64lUs8VJSocbtO29VKdQMhSayps51+rQQ2p3IVYhoIT7xqAOHQYY8iL9ATFc/O0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753910117; c=relaxed/simple; bh=p7eZsxpS3vtI9tDNOoEZiy9hk5CJI4f8gTmOSqmh174=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nLZ5hT39WBW+iF3ZhN4NIzKHGll0ZYfcFDP7F9kBQsDrxHv1JSj8tlXL3Bud36PQSh9DL9AlVIqJ3u9WakwEgu42qxOZFGEnETD7i1zW2I+DAujmLh+5JSeVc0yBc/2e6rezljk4V8M61ApJvNrrkn58pEHVSD7N3IpA+kBfJsM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YmTqUVtx; 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="YmTqUVtx" Received: by smtp.kernel.org (Postfix) with ESMTPS id D6E45C4CEEB; Wed, 30 Jul 2025 21:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753910116; bh=p7eZsxpS3vtI9tDNOoEZiy9hk5CJI4f8gTmOSqmh174=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YmTqUVtxYpaNhdbkPogckhsBnYFGwmR0Vtdaf//I6za5TKQ0VnghxjOVegG/jG2Ny zsRQNR3aRGs4zFphKpbQlySpGdfweQZ+0EbP6RJuy0e/hITMX6Pir8Y3gpAdkbyB+g rxo6xRfN0h47InrLEAReQI2Kr9fTPUh25Zzbzv+w7o7V0CE22LxZhfxLdvD4DH6JcR 0XschW/Zj3zQ/i3tpLe2bc4ZyHWHQgj5BhC07F/Qn2nF7+Tu7eaXE97yTsw+DUe6kT f7SaYYtkDnVoQ3B9sXXxTl42t3bO8TC6wqeZdVuP5IBwZ8OR9wJV4w+HWYmG15Kwoq fEun/NOLKGOdA== 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 C5F76C87FCC; Wed, 30 Jul 2025 21:15:16 +0000 (UTC) From: Per Larsen via B4 Relay Date: Wed, 30 Jul 2025 21:15:04 +0000 Subject: [PATCH v9 1/6] KVM: arm64: Correct return value on host version downgrade attempt 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: <20250730-virtio-msg-ffa-v9-1-7f1b55c8d149@google.com> References: <20250730-virtio-msg-ffa-v9-0-7f1b55c8d149@google.com> In-Reply-To: <20250730-virtio-msg-ffa-v9-0-7f1b55c8d149@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, ahomescu@google.com, armellel@google.com, arve@android.com, ayrton@google.com, qperret@google.com, sebastianene@google.com, qwandor@google.com, Per Larsen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1753910116; l=1399; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=P+lmb3sotGE8m34PBEfN/prSolKXtIpxrlMSQIy5CgE=; b=VKzFYOmcY0g8SQT9dFrjRsgwYo/TQGIlpS1AMrLT5Fz0mUdsn2nlcFi9n9U8XRR0V/4CPVnn1 9X2bF0wPHL4BHihowB+PK5QTAl3dw8KfYS5jViTtx1u6yIQGIVfJnUP 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 Once the hypervisor negotiates the FF-A version with the host, it should remain locked-in. However, it is possible to load FF-A as a module first supporting version 1.1 and then 1.0. Without this patch, the FF-A 1.0 driver will use 1.0 data structures to make calls which the hypervisor will incorrectly interpret as 1.1 data structures. With this patch, negotiation will fail. This patch does not change existing functionality in the case where a FF-A 1.2 driver is loaded after a 1.1 driver; the 1.2 driver will need to use 1.1 in order to proceed. Acked-by: Will Deacon 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..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.50.1.552.g942d659e1b-goog From nobody Sun Oct 5 18:16:45 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 5E3BA1DF244; Wed, 30 Jul 2025 21:15:17 +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=1753910117; cv=none; b=dc2E8ONlW8/TeZqdWNX3EXRu2PeyHo5/K+5er3Y5t11lFG++0MKG/zUhOAdrFBKeOkivbXr1OkcUtZDLYyrI0YM9+Xxd2gIRA6wPxumc8M3SN5FDq1HOn1fDZbVx7J7zAnQUyk8PNjyXVGIJDGgyrfOe52azZU+g8GH0M3od8rw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753910117; c=relaxed/simple; bh=qidCdJTDPdpBtfyyhJefqtU7+TFhUGhLnxwm/t5dsUo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OJDG7qnVKype0Olaz4WGRiXEkQyhePD+4+9ydGxc2jexrysDSgPced8nA4+ZcJa3q4uGj6y0uxYEEav3/eEkEy5iMhRaUkmFeqY0W2/5sjnT3vufob9uUZQ1G+EAaCNQnkeMtNHTDKCeUrZ3NK2rAr11VlFpil/96sO+TicGcTI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tHb15ecW; 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="tHb15ecW" Received: by smtp.kernel.org (Postfix) with ESMTPS id E5294C4CEF8; Wed, 30 Jul 2025 21:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753910117; bh=qidCdJTDPdpBtfyyhJefqtU7+TFhUGhLnxwm/t5dsUo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=tHb15ecW4WhDcqBEtYlSWnthkR+eVRFM6uX+ZgTY6sbt/nubIAlTc8kOmcuPRimsV LKKfu1BzyUh3YLS0oNk2PhoEGy/OXimCnF2WRE7Txot78sQ32MmdvezAtoz57UW/bR EwbR4AFVUryu4d5y+ANHmhmBgGDI5rkLX/2zHHfgb+UwSkeG3KpYQD/6suRrAuggYy pfrmNEgYf0Qnq4fu1lsLzQsOtXd0ciyPF25rZauRSvk6n6QQxCB6bCCxyQXDCMKeMH H1RyhVYuA/2N9g5rDc2ShBcVwqk9zfGuxjtJixW8KW8dTZasOf9Vj/mu3vgyX4YlLj FbeuNU7t9hgpw== 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 D5E46C87FCB; Wed, 30 Jul 2025 21:15:16 +0000 (UTC) From: Per Larsen via B4 Relay Date: Wed, 30 Jul 2025 21:15:05 +0000 Subject: [PATCH v9 2/6] KVM: arm64: Use SMCCC 1.2 for FF-A initialization and 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: <20250730-virtio-msg-ffa-v9-2-7f1b55c8d149@google.com> References: <20250730-virtio-msg-ffa-v9-0-7f1b55c8d149@google.com> In-Reply-To: <20250730-virtio-msg-ffa-v9-0-7f1b55c8d149@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, ahomescu@google.com, armellel@google.com, arve@android.com, ayrton@google.com, qperret@google.com, sebastianene@google.com, qwandor@google.com, Per Larsen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1753910116; l=12636; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=oU1JhrbcLSSWKhLWXNPuMN9Kh7msGJ/A7SDu97b3OiM=; b=8OUy6c4smhA4xDw0Clj2Impz5Zx1BUdwyaHgjD7FiiL23or/FdbPxECwfQ7hmf/BCrL4lC+Z+ J7As+041eeTATGhgHnhpItL4GVjWNMMVh2hKLnBTRBpYyEgDisd1VnP 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 SMCCC 1.1 and prior allows four registers to be sent back as a result of an FF-A interface. SMCCC 1.2 increases the number of results that can be sent back to 8 and 16 for 32-bit and 64-bit SMC/HVCs respectively. FF-A 1.0 references SMCCC 1.2 (reference [4] on page xi) and FF-A 1.2 explicitly requires SMCCC 1.2 so it should be safe to use this version unconditionally. Moreover, it is simpler to implement FF-A features without having to worry about compatibility with SMCCC 1.1 and older. Update the FF-A initialization and host handler code to use SMCCC 1.2. Signed-off-by: Per Larsen --- arch/arm64/kvm/hyp/nvhe/Makefile | 1 + arch/arm64/kvm/hyp/nvhe/ffa.c | 189 +++++++++++++++++++++++++----------= ---- 2 files changed, 121 insertions(+), 69 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Mak= efile index 0b0a68b663d4bd202a7036384bf8a1748cc97ca5..a244ec25f8c5bd0a744f7791102= 265323ecc681c 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 2c199d40811efb5bfae199c4a67d8ae3d9307357..e66149d40c967c14742087d9b45= 970435d3f2c75 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -71,36 +71,64 @@ static u32 hyp_ffa_version; static bool has_version_negotiated; static hyp_spinlock_t version_lock; =20 -static void ffa_to_smccc_error(struct arm_smccc_res *res, u64 ffa_errno) +static void ffa_to_smccc_error(struct arm_smccc_1_2_regs *res, u64 ffa_err= no) { - *res =3D (struct arm_smccc_res) { + *res =3D (struct arm_smccc_1_2_regs) { .a0 =3D FFA_ERROR, .a2 =3D ffa_errno, }; } =20 -static void ffa_to_smccc_res_prop(struct arm_smccc_res *res, int ret, u64 = prop) +static void ffa_to_smccc_res_prop(struct arm_smccc_1_2_regs *res, int ret,= u64 prop) { if (ret =3D=3D FFA_RET_SUCCESS) { - *res =3D (struct arm_smccc_res) { .a0 =3D FFA_SUCCESS, - .a2 =3D prop }; + *res =3D (struct arm_smccc_1_2_regs) { .a0 =3D FFA_SUCCESS, + .a2 =3D prop }; } else { ffa_to_smccc_error(res, ret); } } =20 -static void ffa_to_smccc_res(struct arm_smccc_res *res, int ret) +static void ffa_to_smccc_res(struct arm_smccc_1_2_regs *res, int ret) { ffa_to_smccc_res_prop(res, ret, 0); } =20 static void ffa_set_retval(struct kvm_cpu_context *ctxt, - struct arm_smccc_res *res) + struct arm_smccc_1_2_regs *res) { + DECLARE_REG(u64, func_id, ctxt, 0); cpu_reg(ctxt, 0) =3D res->a0; 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 res->a4; + cpu_reg(ctxt, 5) =3D res->a5; + cpu_reg(ctxt, 6) =3D res->a6; + cpu_reg(ctxt, 7) =3D res->a7; + + /* + * DEN0028C 2.6: SMC32/HVC32 call from aarch64 must preserve x8-x30. + * + * We rely on the function ID sent by the caller. Note that there + * are cases where a 32-bit interface can have a 64-bit response in FF-A + * 1.2 (e.g. FFA_MSG_WAIT or FFA_RUN). This will be addressed in a future + * version of the FF-A spec. Moreover, these corner cases are not relevant + * on this code path (FFA_RUN is passed through [not proxied] by the + * hypervisor and FFA_MSG_WAIT calls are made from the secure partition). + */ + if (ARM_SMCCC_IS_64(func_id)) { + cpu_reg(ctxt, 8) =3D res->a8; + cpu_reg(ctxt, 9) =3D res->a9; + cpu_reg(ctxt, 10) =3D res->a10; + cpu_reg(ctxt, 11) =3D res->a11; + cpu_reg(ctxt, 12) =3D res->a12; + cpu_reg(ctxt, 13) =3D res->a13; + cpu_reg(ctxt, 14) =3D res->a14; + cpu_reg(ctxt, 15) =3D res->a15; + cpu_reg(ctxt, 16) =3D res->a16; + cpu_reg(ctxt, 17) =3D res->a17; + } } =20 static bool is_ffa_call(u64 func_id) @@ -113,82 +141,92 @@ static bool is_ffa_call(u64 func_id) =20 static int ffa_map_hyp_buffers(u64 ffa_page_count) { - struct arm_smccc_res res; + struct arm_smccc_1_2_regs res; =20 - arm_smccc_1_1_smc(FFA_FN64_RXTX_MAP, - hyp_virt_to_phys(hyp_buffers.tx), - hyp_virt_to_phys(hyp_buffers.rx), - ffa_page_count, - 0, 0, 0, 0, - &res); + arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) { + .a0 =3D FFA_FN64_RXTX_MAP, + .a1 =3D hyp_virt_to_phys(hyp_buffers.tx), + .a2 =3D hyp_virt_to_phys(hyp_buffers.rx), + .a3 =3D ffa_page_count, + }, &res); =20 return res.a0 =3D=3D FFA_SUCCESS ? FFA_RET_SUCCESS : res.a2; } =20 static int ffa_unmap_hyp_buffers(void) { - struct arm_smccc_res res; + struct arm_smccc_1_2_regs res; =20 - arm_smccc_1_1_smc(FFA_RXTX_UNMAP, - HOST_FFA_ID, - 0, 0, 0, 0, 0, 0, - &res); + arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) { + .a0 =3D FFA_RXTX_UNMAP, + .a1 =3D HOST_FFA_ID, + }, &res); =20 return res.a0 =3D=3D FFA_SUCCESS ? FFA_RET_SUCCESS : res.a2; } =20 -static void ffa_mem_frag_tx(struct arm_smccc_res *res, u32 handle_lo, +static void ffa_mem_frag_tx(struct arm_smccc_1_2_regs *res, u32 handle_lo, u32 handle_hi, u32 fraglen, u32 endpoint_id) { - arm_smccc_1_1_smc(FFA_MEM_FRAG_TX, - handle_lo, handle_hi, fraglen, endpoint_id, - 0, 0, 0, - res); + arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) { + .a0 =3D FFA_MEM_FRAG_TX, + .a1 =3D handle_lo, + .a2 =3D handle_hi, + .a3 =3D fraglen, + .a4 =3D endpoint_id, + }, res); } =20 -static void ffa_mem_frag_rx(struct arm_smccc_res *res, u32 handle_lo, +static void ffa_mem_frag_rx(struct arm_smccc_1_2_regs *res, u32 handle_lo, u32 handle_hi, u32 fragoff) { - arm_smccc_1_1_smc(FFA_MEM_FRAG_RX, - handle_lo, handle_hi, fragoff, HOST_FFA_ID, - 0, 0, 0, - res); + arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) { + .a0 =3D FFA_MEM_FRAG_RX, + .a1 =3D handle_lo, + .a2 =3D handle_hi, + .a3 =3D fragoff, + .a4 =3D HOST_FFA_ID, + }, res); } =20 -static void ffa_mem_xfer(struct arm_smccc_res *res, u64 func_id, u32 len, +static void ffa_mem_xfer(struct arm_smccc_1_2_regs *res, u64 func_id, u32 = len, u32 fraglen) { - arm_smccc_1_1_smc(func_id, len, fraglen, - 0, 0, 0, 0, 0, - res); + arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) { + .a0 =3D func_id, + .a1 =3D len, + .a2 =3D fraglen, + }, res); } =20 -static void ffa_mem_reclaim(struct arm_smccc_res *res, u32 handle_lo, +static void ffa_mem_reclaim(struct arm_smccc_1_2_regs *res, u32 handle_lo, u32 handle_hi, u32 flags) { - arm_smccc_1_1_smc(FFA_MEM_RECLAIM, - handle_lo, handle_hi, flags, - 0, 0, 0, 0, - res); + arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) { + .a0 =3D FFA_MEM_RECLAIM, + .a1 =3D handle_lo, + .a2 =3D handle_hi, + .a3 =3D flags, + }, res); } =20 -static void ffa_retrieve_req(struct arm_smccc_res *res, u32 len) +static void ffa_retrieve_req(struct arm_smccc_1_2_regs *res, u32 len) { - arm_smccc_1_1_smc(FFA_FN64_MEM_RETRIEVE_REQ, - len, len, - 0, 0, 0, 0, 0, - res); + arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) { + .a0 =3D FFA_FN64_MEM_RETRIEVE_REQ, + .a1 =3D len, + .a2 =3D len, + }, res); } =20 -static void ffa_rx_release(struct arm_smccc_res *res) +static void ffa_rx_release(struct arm_smccc_1_2_regs *res) { - arm_smccc_1_1_smc(FFA_RX_RELEASE, - 0, 0, - 0, 0, 0, 0, 0, - res); + arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) { + .a0 =3D FFA_RX_RELEASE, + }, res); } =20 -static void do_ffa_rxtx_map(struct arm_smccc_res *res, +static void do_ffa_rxtx_map(struct arm_smccc_1_2_regs *res, struct kvm_cpu_context *ctxt) { DECLARE_REG(phys_addr_t, tx, ctxt, 1); @@ -267,7 +305,7 @@ static void do_ffa_rxtx_map(struct arm_smccc_res *res, goto out_unlock; } =20 -static void do_ffa_rxtx_unmap(struct arm_smccc_res *res, +static void do_ffa_rxtx_unmap(struct arm_smccc_1_2_regs *res, struct kvm_cpu_context *ctxt) { DECLARE_REG(u32, id, ctxt, 1); @@ -368,7 +406,7 @@ static int ffa_host_unshare_ranges(struct ffa_mem_regio= n_addr_range *ranges, return ret; } =20 -static void do_ffa_mem_frag_tx(struct arm_smccc_res *res, +static void do_ffa_mem_frag_tx(struct arm_smccc_1_2_regs *res, struct kvm_cpu_context *ctxt) { DECLARE_REG(u32, handle_lo, ctxt, 1); @@ -427,7 +465,7 @@ static void do_ffa_mem_frag_tx(struct arm_smccc_res *re= s, } =20 static void __do_ffa_mem_xfer(const u64 func_id, - struct arm_smccc_res *res, + struct arm_smccc_1_2_regs *res, struct kvm_cpu_context *ctxt) { DECLARE_REG(u32, len, ctxt, 1); @@ -521,7 +559,7 @@ static void __do_ffa_mem_xfer(const u64 func_id, __do_ffa_mem_xfer((fid), (res), (ctxt)); \ } while (0); =20 -static void do_ffa_mem_reclaim(struct arm_smccc_res *res, +static void do_ffa_mem_reclaim(struct arm_smccc_1_2_regs *res, struct kvm_cpu_context *ctxt) { DECLARE_REG(u32, handle_lo, ctxt, 1); @@ -634,7 +672,7 @@ static bool ffa_call_supported(u64 func_id) return true; } =20 -static bool do_ffa_features(struct arm_smccc_res *res, +static bool do_ffa_features(struct arm_smccc_1_2_regs *res, struct kvm_cpu_context *ctxt) { DECLARE_REG(u32, id, ctxt, 1); @@ -666,17 +704,21 @@ static bool do_ffa_features(struct arm_smccc_res *res, static int hyp_ffa_post_init(void) { size_t min_rxtx_sz; - struct arm_smccc_res res; + struct arm_smccc_1_2_regs res; =20 - arm_smccc_1_1_smc(FFA_ID_GET, 0, 0, 0, 0, 0, 0, 0, &res); + arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs){ + .a0 =3D FFA_ID_GET, + }, &res); if (res.a0 !=3D FFA_SUCCESS) return -EOPNOTSUPP; =20 if (res.a2 !=3D HOST_FFA_ID) return -EINVAL; =20 - arm_smccc_1_1_smc(FFA_FEATURES, FFA_FN64_RXTX_MAP, - 0, 0, 0, 0, 0, 0, &res); + arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs){ + .a0 =3D FFA_FEATURES, + .a1 =3D FFA_FN64_RXTX_MAP, + }, &res); if (res.a0 !=3D FFA_SUCCESS) return -EOPNOTSUPP; =20 @@ -700,7 +742,7 @@ static int hyp_ffa_post_init(void) return 0; } =20 -static void do_ffa_version(struct arm_smccc_res *res, +static void do_ffa_version(struct arm_smccc_1_2_regs *res, struct kvm_cpu_context *ctxt) { DECLARE_REG(u32, ffa_req_version, ctxt, 1); @@ -724,9 +766,10 @@ static void do_ffa_version(struct arm_smccc_res *res, * first if TEE supports it. */ if (FFA_MINOR_VERSION(ffa_req_version) < FFA_MINOR_VERSION(hyp_ffa_versio= n)) { - arm_smccc_1_1_smc(FFA_VERSION, ffa_req_version, 0, - 0, 0, 0, 0, 0, - res); + arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) { + .a0 =3D FFA_VERSION, + .a1 =3D ffa_req_version, + }, res); if (res->a0 =3D=3D FFA_RET_NOT_SUPPORTED) goto unlock; =20 @@ -743,7 +786,7 @@ static void do_ffa_version(struct arm_smccc_res *res, hyp_spin_unlock(&version_lock); } =20 -static void do_ffa_part_get(struct arm_smccc_res *res, +static void do_ffa_part_get(struct arm_smccc_1_2_regs *res, struct kvm_cpu_context *ctxt) { DECLARE_REG(u32, uuid0, ctxt, 1); @@ -759,9 +802,14 @@ static void do_ffa_part_get(struct arm_smccc_res *res, goto out_unlock; } =20 - arm_smccc_1_1_smc(FFA_PARTITION_INFO_GET, uuid0, uuid1, - uuid2, uuid3, flags, 0, 0, - res); + arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) { + .a0 =3D FFA_PARTITION_INFO_GET, + .a1 =3D uuid0, + .a2 =3D uuid1, + .a3 =3D uuid2, + .a4 =3D uuid3, + .a5 =3D flags, + }, res); =20 if (res->a0 !=3D FFA_SUCCESS) goto out_unlock; @@ -794,7 +842,7 @@ static void do_ffa_part_get(struct arm_smccc_res *res, =20 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 res; =20 /* * There's no way we can tell what a non-standard SMC call might @@ -863,13 +911,16 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *hos= t_ctxt, u32 func_id) =20 int hyp_ffa_init(void *pages) { - struct arm_smccc_res res; + struct arm_smccc_1_2_regs res; void *tx, *rx; =20 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_2_smc(&(struct arm_smccc_1_2_regs) { + .a0 =3D FFA_VERSION, + .a1 =3D FFA_VERSION_1_1, + }, &res); if (res.a0 =3D=3D FFA_RET_NOT_SUPPORTED) return 0; =20 --=20 2.50.1.552.g942d659e1b-goog From nobody Sun Oct 5 18:16:45 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 5E4201FBC92; Wed, 30 Jul 2025 21:15:17 +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=1753910117; cv=none; b=mLgWTAO9mcTHO8eR/mTzammFChnix59P7aCDWOhe4F4vvze1msuU6I6/TsKLQ+xWT6ihpNCPLSJ94TEyY8udjbO5QUsWtyLXMmfraWv3Lzur+mcg5DLfgy2QuWpUaMJJw6e6IgxqDSVDAcSE5v+jca9dHvmMd5i01Gj5Ch+2HVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753910117; c=relaxed/simple; bh=nR3zHOT/qM6CUnGwkzXLNAPxSF2YXcCdkZcpI7GttFI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kb84zCc4r9ilyIqJKmZ7mhO/NVGcZV3BfoTTAfhSsQWnVe7t4CobplWbzf0TqT8I/2oiopDlzq/nWaSzshp5PjvzxnWS07P+34nOxHkAI5GS73accwEvArdYh/42VBtqXWBOuEukZuh3OQMxrXWP4awqjFRuoEgtjHgM+KA0S1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a7HNXXSw; 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="a7HNXXSw" Received: by smtp.kernel.org (Postfix) with ESMTPS id EDF5BC4CEF9; Wed, 30 Jul 2025 21:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753910117; bh=nR3zHOT/qM6CUnGwkzXLNAPxSF2YXcCdkZcpI7GttFI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=a7HNXXSwQvg3xjqGM8Gso4ihQpmqL0CcqQs1zrq1eaORXpiZXRJImvKcY5bNc8FEZ 9tf6owXYALXBMsFEPlNdbcXLkouZbvt6vEOtBo7VolwjhodtDf+G/V6aA60yEb+uKF G1NL9WdkUSj9AVgMy8NN93g2AluCQCtNkUTKXqneIQfddq2KuQlb1/VnQ68S5LtQtg FIGyAGZo9OzH1AAvFubwJtkymPSNwL7IetgcYWam/mPrJJfxej2Cgu71+NcP/chGqg XdKf81lR8Bu6vvrAUm7bg2BSMFMOlW49Tj9q25BG734Fjwki8DBnPMOBHLy8uHPbi6 tkIKN/4RSZgWQ== 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 E412AC87FD3; Wed, 30 Jul 2025 21:15:16 +0000 (UTC) From: Per Larsen via B4 Relay Date: Wed, 30 Jul 2025 21:15:06 +0000 Subject: [PATCH v9 3/6] 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: <20250730-virtio-msg-ffa-v9-3-7f1b55c8d149@google.com> References: <20250730-virtio-msg-ffa-v9-0-7f1b55c8d149@google.com> In-Reply-To: <20250730-virtio-msg-ffa-v9-0-7f1b55c8d149@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, ahomescu@google.com, armellel@google.com, arve@android.com, ayrton@google.com, qperret@google.com, sebastianene@google.com, qwandor@google.com, Per Larsen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1753910116; l=1008; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=dUX2vyR3ZYQTFCHxhGWOxmpso/rDJ5XMeBkqofPaNOY=; b=9/jRFuS4Y3XNatuiRkzXiXqpRC+uPigr09Vqyv18VORTYqnGJQpijGtTKZuhxX7hDvnOHoECE /x4THJF+hHTC7QrEN1MAs/d37ORpJ45CP15iBecf4sUh0q2q5GWTjgb 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. Acked-by: Will Deacon Signed-off-by: Per Larsen --- 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 e66149d40c967c14742087d9b45970435d3f2c75..48183fa78014e420372c4fb5e48= 9519bc652bf53 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -666,6 +666,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.50.1.552.g942d659e1b-goog From nobody Sun Oct 5 18:16:45 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 609601FDA8E; Wed, 30 Jul 2025 21:15:17 +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=1753910117; cv=none; b=MiGhaW4xtKG7ksKq+UO5P1JdSMYL5xwBkaR1JTxxjTnIici2k9UVarWCTb6hOd5jkz+BypGcwYLEbwGsxkSx+c9D27FON267R44iHqvDYquqPiYhMogHzd7mP6Oc6LQMY8itLSz2BA0DpbpflwCNRLvBeWCVlcqnE8rW9TbsaHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753910117; c=relaxed/simple; bh=hh98tLlJXCvRgiyG81K7JCiTYqxoYUgJDKnikV3MUPI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c+yrfHZKwNheVpRBJ59QyVSAsFv9MeJIstAantVFL4Hph3vuKMa1NKJOHJIvCzf+1zh6COYhW6AWnjCqhADFDf0vwm7JbaWgVrGboNUtiTRV4Bhtiu6xkexFyVlw4LTtu7ZjKdFVUTrspGqaLM/lpwMmOx81dd9oPRXVoLMbqtA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JiU80DVr; 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="JiU80DVr" Received: by smtp.kernel.org (Postfix) with ESMTPS id 140DAC4AF09; Wed, 30 Jul 2025 21:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753910117; bh=hh98tLlJXCvRgiyG81K7JCiTYqxoYUgJDKnikV3MUPI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=JiU80DVrnhKarGT98QOx797L8u1EqeYqSj2HwYDQVy/a7rTmONWpYjAQNCb49j8zD zk4I3hdwRZ6AX5JpqJgG9D0rklk1/sDoI6cu9+Y0rMOuWGPBBB2HqIayoUJDFTRVSP qNIYiF2pAe2eI3TdjVYTtvfPaTbnA7deQZVDp32WbBJkLNUAbCPqQwFlcCaKNIfHJV 8DzqazuGUg8kXF+dPvGs0udZPzcFwCEk7HE6jvYMOotgPqj+a1ORBznoE6klT7AUOY uY0p/OTDZqtVb475fl4I42quUbhBBFmbMFwHhNhvU6SWxmoGp5IXV6kx3vfCxPHBwx paopgyEyLemOw== 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 06924C87FD2; Wed, 30 Jul 2025 21:15:17 +0000 (UTC) From: Per Larsen via B4 Relay Date: Wed, 30 Jul 2025 21:15:07 +0000 Subject: [PATCH v9 4/6] KVM: arm64: Mark optional FF-A 1.2 interfaces 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: <20250730-virtio-msg-ffa-v9-4-7f1b55c8d149@google.com> References: <20250730-virtio-msg-ffa-v9-0-7f1b55c8d149@google.com> In-Reply-To: <20250730-virtio-msg-ffa-v9-0-7f1b55c8d149@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, ahomescu@google.com, armellel@google.com, arve@android.com, ayrton@google.com, qperret@google.com, sebastianene@google.com, qwandor@google.com, Per Larsen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1753910116; l=1210; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=vsxUjiUKITemxut7aihGZIJXjAQ850iOOIHve4ASG3E=; b=gKWwH6ozG59iqR56sr71aowlsg5jb48PB7dhsPM3n2+nBl+wpjlo4dJv8qRVxTZz7bvHNPEDt uDKRggaQq+mD4c4yB9+43JIcp2dm573jv1UsAVQbkMgyDHO60vkhUyg 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 Mark FF-A 1.2 interfaces as unsupported lest they get proxied. Also mark FFA_EL3_INTR_HANDLE as unsupported as it is only valid for physical instances. Signed-off-by: Per Larsen Acked-by: Will Deacon --- arch/arm64/kvm/hyp/nvhe/ffa.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 48183fa78014e420372c4fb5e489519bc652bf53..7fe96fe626d630a9009551e8dec= 1683617acafbd 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -674,6 +674,13 @@ static bool ffa_call_supported(u64 func_id) case FFA_NOTIFICATION_SET: case FFA_NOTIFICATION_GET: case FFA_NOTIFICATION_INFO_GET: + /* Optional interfaces added in FF-A 1.2 */ + case FFA_MSG_SEND_DIRECT_REQ2: /* Optional per 7.5.1 */ + case FFA_MSG_SEND_DIRECT_RESP2: /* Optional per 7.5.1 */ + case FFA_CONSOLE_LOG: /* Optional per 13.1: not in Table 13.1 */ + case FFA_PARTITION_INFO_GET_REGS: /* Optional for virtual instances per 1= 3.1 */ + /* Unsupported interfaces added in FF-A 1.2 */ + case FFA_EL3_INTR_HANDLE: /* Only valid for secure physical instances */ return false; } =20 --=20 2.50.1.552.g942d659e1b-goog From nobody Sun Oct 5 18:16:45 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 931E4221F0A; Wed, 30 Jul 2025 21:15:17 +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=1753910117; cv=none; b=Yq4DP7QEBQDLraappzZ2clvg1sS8hP0S522aZW8pIB4iyZU+aORchELbTOgY4Fajwgent9zqqJjqijs/4gGWtt/QJcMANWVSEndJ9PHfgPD8TOVO949cBZtN+MEFG5kKvoBTk5XwNZltYp/fsfWMUpG3z810BFJPhZyHKld4YeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753910117; c=relaxed/simple; bh=ehvmTG9QreVlMg6OcuHCCXf3VqnfwjHcKBdR0xt8aDc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Slt/FK3WdOutrnoGnlhFnXHRgGY2zDgil0BQ+HAdwnCDsbUvexuhpocolqDd1J2AgAkAE737lJVJTFJLfASuu8Pt/Ji/JaZUXjssvmkbxbaPh+BQbtCEW0TdF0M3L1XJEeizWd1XOjcLwzV+9jvAuwvXr7zDDFCFLQoTQSak+Tg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dBqQimjo; 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="dBqQimjo" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1F211C4AF0D; Wed, 30 Jul 2025 21:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753910117; bh=ehvmTG9QreVlMg6OcuHCCXf3VqnfwjHcKBdR0xt8aDc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=dBqQimjon9cc9FuTYW+n1MgKyLnBz2rq/EnCOZGPRXbmlJzwEa2EtQz5ee4IQbo4t a/oYOE2p77bxIzjMxX339tI0AJ2T2YCoBconffQYqlxSYWGCVY2O0exH9KZ7oguL0v gNY8Rgpe0HhXTGVsBrqSlFZdbQDYMDasWQQiS8Fzrrq65SChw1ceGX2ohWLSWtm74K 8LH8yI4Pmrs9m32hlT1xqC+UXsCa7EjHZ5s7OILwnSKM0zsbKAGfn3u9W4gSgVvwli RcpeELnrGsZDjm6RiAW9aymeU1BVBeX7mVmw/pcZEUE8OeNfMaQp67a8Vv5rbFFqnA rYnbIk0hOkvzQ== 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 162C4C87FC9; Wed, 30 Jul 2025 21:15:17 +0000 (UTC) From: Per Larsen via B4 Relay Date: Wed, 30 Jul 2025 21:15:08 +0000 Subject: [PATCH v9 5/6] KVM: arm64: Mask response to FFA_FEATURE call 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: <20250730-virtio-msg-ffa-v9-5-7f1b55c8d149@google.com> References: <20250730-virtio-msg-ffa-v9-0-7f1b55c8d149@google.com> In-Reply-To: <20250730-virtio-msg-ffa-v9-0-7f1b55c8d149@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, ahomescu@google.com, armellel@google.com, arve@android.com, ayrton@google.com, qperret@google.com, sebastianene@google.com, qwandor@google.com, Per Larsen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1753910116; l=1404; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=dmZ1vWZl/Z8DB9SSRWT99aiqcW400QLvm9waNv1o6lM=; b=sRoCHIfQXsIH2vwYvzb57woXK8E/mk/95HlK7n8HCQXbVfmha00ufq2QGwvnBeuZDY+siyh6W BliUlx3XlYvAVWOk3fx7g0CEYqej7aqLgCnp+PGIOOxfI3WlJFAhr1l 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 The minimum size and alignment boundary for FFA_RXTX_MAP is returned in bit[1:0]. Mask off any other bits in w2 when reading the minimum buffer size in hyp_ffa_post_init. Acked-by: Will Deacon Signed-off-by: Per Larsen --- arch/arm64/kvm/hyp/nvhe/ffa.c | 2 +- include/linux/arm_ffa.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 7fe96fe626d630a9009551e8dec1683617acafbd..6afc7e97a1e1e5e23ccf9cc1155= 3b3fdaf8a51e7 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -737,7 +737,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; diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index e1634897e159cdc208931938649eb0fb04d5a070..cd7ee4df9045dceca1c4e0dca2d= 533b770b1b056 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 GENMASK(1, 0) =20 /* FFA Bus/Device/Driver related */ struct ffa_device { --=20 2.50.1.552.g942d659e1b-goog From nobody Sun Oct 5 18:16:45 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 93262221FB1; Wed, 30 Jul 2025 21:15:17 +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=1753910117; cv=none; b=mcmiHthMswdhKPgHDIFEF9W2bEymhLu2j9fjKLfy7ru3SoHXe2ftHZezkNfzwU+oJDyI5j7WrTOO/zxiB15Wk1wQCYzhuUKiXjq9ULUadNdg79vNZa8wjko0ASalZ0A39Mz31T4crAG9fVMY46PqJ9L1FvV0G1Mqao0IBZytvWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753910117; c=relaxed/simple; bh=L/ffZHLHLfmDPG6MLYu7UcnDeKt5iIqxg63GGjIOWzE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qrG1iSYoa62s0h9mdahAJzn4R2KqGymr49eARnSagi5GSKtqYLeNBfruAQgfkUJhFpT+measDjupeet4GNUH5jleVoA02z0tZoNhtx0DLE/ANPVSbf/JTKwZlolwnY4tASj30MLcXjZeDRcNBrYf/gU6mnGFcXaCdGLPpN7C1AI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jdc1F7v2; 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="jdc1F7v2" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2FBC0C4CEF5; Wed, 30 Jul 2025 21:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753910117; bh=L/ffZHLHLfmDPG6MLYu7UcnDeKt5iIqxg63GGjIOWzE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=jdc1F7v2NWukEnwf+M7tC1HidW+aEouvj5muF7VS1WLjRdmtWLuCKV5MbsXHZJ8Vm UAJlcIj6L4ro6noyReyPpfGxvadHZfQmgs2sY0tygJ6irn8G3R2dnqioGNwyxXdk/M sDEedd+UqJMqLRhsEpLobpc8TxmEbmYc0kTTC4i5B/uaS3CRmjO5yT+uIgmAkzTx6g DE1WLRraz6UvqsL/gkcajjqzBAUE8QkRk7zs/XCe2r1OhT+ElCOVAwSUN+qCLHb9uB a88jcoYAbDE8aVhMZWIsblJiq6uAlmphDDkKLkRPUuhdufiIaKCdtQxJuGyimmX7PG TslBqMrBAdAOw== 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 256A3C87FCC; Wed, 30 Jul 2025 21:15:17 +0000 (UTC) From: Per Larsen via B4 Relay Date: Wed, 30 Jul 2025 21:15:09 +0000 Subject: [PATCH v9 6/6] 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: <20250730-virtio-msg-ffa-v9-6-7f1b55c8d149@google.com> References: <20250730-virtio-msg-ffa-v9-0-7f1b55c8d149@google.com> In-Reply-To: <20250730-virtio-msg-ffa-v9-0-7f1b55c8d149@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, ahomescu@google.com, armellel@google.com, arve@android.com, ayrton@google.com, qperret@google.com, sebastianene@google.com, qwandor@google.com, Per Larsen X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1753910116; l=1481; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=P0vUAR0qDySqTxDDflFhrWZ3pm+eWYd6FxsAvZfn6qs=; b=Uz8YatvRCoyf30WVMnYmDCyh1423xGoL0y2Mwx58zD9islDa5g4SWpNsHFCY/S29KYqX8+/88 Yoo+MJNcEIwDDHcyk8gV0e4EDyTQZ6SjKfdACko6GpOSGmTNztCz2sC 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 to enable implementation of the 1.2-only FFA_MSG_SEND_DIRECT_REQ2 and FFA_MSG_SEND_RESP2 messaging interfaces. Co-developed-by: Ayrton Munoz Signed-off-by: Ayrton Munoz Acked-by: Will Deacon Signed-off-by: Per Larsen --- arch/arm64/kvm/hyp/nvhe/ffa.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 6afc7e97a1e1e5e23ccf9cc11553b3fdaf8a51e7..a9d827ec5a11743c86ba3f36bf3= 671cbecd4f3c1 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -934,7 +934,7 @@ int hyp_ffa_init(void *pages) =20 arm_smccc_1_2_smc(&(struct arm_smccc_1_2_regs) { .a0 =3D FFA_VERSION, - .a1 =3D FFA_VERSION_1_1, + .a1 =3D FFA_VERSION_1_2, }, &res); if (res.a0 =3D=3D FFA_RET_NOT_SUPPORTED) return 0; @@ -955,10 +955,10 @@ 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)) + 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; --=20 2.50.1.552.g942d659e1b-goog