From nobody Sun Dec 14 20:16:28 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 2A5F314AD2D; Sat, 19 Jul 2025 02:11:53 +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=1752891114; cv=none; b=JeMvBRdETJWWsl9UE8jFyHUIIajcXOZ23Y80W0Z9IP/iLfvBZXZ72m6xi48eAXNdLFSQYIy7awg+bgd3pfgTLZXkuN/WJdAexs5mcuHRN1z1cukCwdY/ZLorPM22AC+I9LeikZJ+pyVpki9to0TsLzf4RTuT5kodKZwMEZhAjjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752891114; c=relaxed/simple; bh=coAKO9TLhK8MTIgf77yLemsOevi3hPcTUAqXS91Y2b4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gZc6rJTuZpd0w/C5nggchA7gRTxp1Hk99X4vQW+UwaMVceWDpT028sv7yBV0HtYRa7T9bjWxGYzkLgyAR7rYaPEqNmnUzzD+L4n7GaI/WUR/+O/ZHDsUIK974GUPSUSeJYqOIafOGJQYtlwtqjWeMxFocQ6sZK+xKjUkzYnM5Qs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JNH9a9Kk; 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="JNH9a9Kk" Received: by smtp.kernel.org (Postfix) with ESMTPS id A4129C4CEF4; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752891113; bh=coAKO9TLhK8MTIgf77yLemsOevi3hPcTUAqXS91Y2b4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=JNH9a9KkBf83Hstnxpc0qHWAdgczsuEPME2MsMYzxFGC62UPfbtjrJ8AwBp0J8r3e GWbMu03xTS/rei/BYcLozWhyXGJ8QlPGVQQ9tvyDbMKP25xcPlwV7LWZeg29GK/+Dv YuiUy4nc+5s5TdiGTiqJOO9PIGgBy+vz1yKLSM20j0gY1Qqrx50RMYCU4ZMT0B1eqk nZ1k8gRWikdOwLClk6spvvS9DmwINwC2fmiSh3N0NeSa44elvvwCaej2rPylktugCf z0nydZRuavFm6XvQTyu/Fgcn8Rl5MuKmDVSu5ITARl1a+pduqz7IAHanY1StVfD+j/ yXFBMHJ12NQLw== 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 953E3C83F34; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) From: Per Larsen via B4 Relay Date: Sat, 19 Jul 2025 02:11:23 +0000 Subject: [PATCH v8 1/7] 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: <20250719-virtio-msg-ffa-v8-1-03e8e8dbe856@google.com> References: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@google.com> In-Reply-To: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@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=1752891112; l=1399; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=Dl9KrxrUP4K0W3dgejUfrC3aK93wdcqeauIVLeuo9f0=; b=lJirE4j7wkWB4ZcW5+qaK6CCOsLqrm6DoTu3uQ92cxCsDWf/6HUXasK7WYG+ZO4eEYzhDYFTo bHmnGo6VxdvDx0nd0Fg8/UgHKuIxWg4pBX33eAN6Bx47iuctxSU6aZ5 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.0.727.gbf7dc18ff4-goog From nobody Sun Dec 14 20:16:28 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 40B1C1C32FF; Sat, 19 Jul 2025 02:11:53 +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=1752891114; cv=none; b=WxHaPNw4wy8/7lB5lQ6zhNtssq31BSbRNe73d8dpHeTuushqb9j8iCnfhZiNU1iVpL0cP6pEVP47REzPzkA/9AcKIsgy8tTniqpUFYpQQMsg1d/svKMXhe0rCjfo0EasTwceMpEEhmBLNCWYJKJ0BTCC7S6ovYVmK1VlwlnN/30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752891114; c=relaxed/simple; bh=KVQVAwvTzqE/QnEfsFxGuj0q6gToSmv+sLsoZFV8mJM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WcateT4N/farC07sL7YxuHUIXauUC2hS3BEpY0LA08E6Env5LrmM8iFU/1h6ymSnL3mszdK1c5LMP885JQ7KEGEzQSSUmDKHTROlnO8MPDXA6NwNsTFQ6COVvQ6oZJeXd7KYiJyWKkckSQwiYj3grsEsXqwBivQBzVmLo3BBHnQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GabzZEKh; 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="GabzZEKh" Received: by smtp.kernel.org (Postfix) with ESMTPS id B6ACBC4CEF1; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752891113; bh=KVQVAwvTzqE/QnEfsFxGuj0q6gToSmv+sLsoZFV8mJM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=GabzZEKh71aOf48xj7TwEgAphuznfgIrpkHlsppurFVP8KvJvMnwI2+hgj5jzzlVr ASSkYL5hyC3ea1yq2pLPs584u7ZyqCITYS458lzsEHHIFoajutei/Yx1kevAbH8cml sAOgRyJEj6dEUpXIfgQ/w1Mc3Xs7f3nI18Z+/ic15wyajlh+JgbV92zNoMU+PFhWMX Cf8KqdP2TZcKS9rj54RJ+KVjumr4g7Veea5u6fiB6ypuNAJlJQoeZ5mn0wDgZHVTRx K5GuAVlT0DOMVevLszkHb/fcuXVBBeO5a9+8E3VZ5lq3NTfn9NbNH/57AdzeWwue1c ecRswR9RIsvyw== 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 A32C8C83F3B; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) From: Per Larsen via B4 Relay Date: Sat, 19 Jul 2025 02:11:24 +0000 Subject: [PATCH v8 2/7] 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: <20250719-virtio-msg-ffa-v8-2-03e8e8dbe856@google.com> References: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@google.com> In-Reply-To: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@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=1752891112; l=12373; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=m1/HgRESjtd0MBTbe5flhT/3DvCF84rYT4VVWwmoW3Y=; b=l6KonCDHSwJy+yaj8K5jEOgZ31rhZb0fJpXOiYrXkoMRz51nioHtjrWq1MtrA9hCWcSi/ksOf 7nFLYZCPbAjA1J02ejRtEFUr3x7X9aNP0cNIAKa2YdqIAfEjAgB9UXE 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 | 186 ++++++++++++++++++++++++-----------= ---- 2 files changed, 118 insertions(+), 69 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Mak= efile index a76522d63c3e630795db5972a99abc3d24bc5e26..f859a8fb41a25effea1edd977be= f889423153399 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..52ac3e2689f0c200ebbb57ec564= f71a37b0ddc8f 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -71,36 +71,61 @@ 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. + * + * FF-A 1.2 allows FFA_MSG_WAIT (SMC32) to return a SMC64 reply (e.g. + * FFA_MSG_SEND_DIRECT_REQ2) but that isn't an issue as FFA_MSG_WAIT + * isn't supported by the hypervisor. + */ + 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 +138,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 +302,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 +403,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 +462,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 +556,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 +669,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 +701,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 +739,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 +763,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 +783,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 +799,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 +839,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 +908,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.0.727.gbf7dc18ff4-goog From nobody Sun Dec 14 20:16:28 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 021B7801; Sat, 19 Jul 2025 02:11:53 +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=1752891114; cv=none; b=XJzwK76s6XhLkBZ9iq9zcjuQqPUkldmmuYqBXc49xIaEn7UVoGnlPxJ3NG/TOf+i32yTBIEsg6WWQiwoT5kQnnlzVH+7t9WhQAwabqJNsxFeHTg/vfE/s6nk9n5PM9umKz5Y7QOSTBaRr0BGE/B1XhfdiSEmafAeNqVywT9tORw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752891114; c=relaxed/simple; bh=z9zKqXOSztmepElhFfcFd2r9dFNNAVlWOFmeg8346cA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ee7hFqBeWVCXK5jiroLeNW4psx5qIK3Cdd4NaGpZfIDjnCGd7JVhqwgVcJVMWi98QjFApQWJsi5Q2+qJRe0KO+IC+lCn7Nyfw0tFp35gnAWncW82UT2AxUFGnjy1RwE1BKW0ppfge+5uGvz2WazOZNuzt9IyIZLTVkxg5iAW3sk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FfDonPwy; 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="FfDonPwy" Received: by smtp.kernel.org (Postfix) with ESMTPS id BB13FC4CEF6; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752891113; bh=z9zKqXOSztmepElhFfcFd2r9dFNNAVlWOFmeg8346cA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=FfDonPwyTC2Vyi3OA/+yHSTNM5VcNAmFnRbfzYriv8wyrt/BTZgzYSzuveG6qgiXK JWQbc4FWknlEvm1+Qif9urxFj1yf8JX8pWUb4WHwmEpmHLZgHWhsGdyCNlcIJNyvcl ZyAAF8eBc9W/FQvQinThwYu6IpBxzKHDSa20oXh2NDF7Udm9nvScEnEhEXkESKH/hg +O40X+G7qj6byZBmsOL6R28TtPJ4c9cp1Vi1oZLxlZ5DxJi9nAME3RruzI3NEjqxUN q6cpJIEduMKEjq3tsN/qOm7y8cNMQd4IFMzXdKIpqXBi8ClF7bg777VGGrLr3syTHE tG6cLODrRRFKA== 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 B086AC83F17; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) From: Per Larsen via B4 Relay Date: Sat, 19 Jul 2025 02:11:25 +0000 Subject: [PATCH v8 3/7] 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: <20250719-virtio-msg-ffa-v8-3-03e8e8dbe856@google.com> References: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@google.com> In-Reply-To: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@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=1752891112; l=1008; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=eQvexLnYoTcxsrnl0Pu9EhkGFuUrJCQc4aSj6eFtezc=; b=ApBsC/BlD81Hz0BWfbZYdBl0BwB/z9CBGvXFont7uPFbpjiEcaQFLI26mF0x2FqaERmhWlMst 2ouZvB9XsInANbSCy3Islp4cVzYEtein+r3ifjM3lFZ9DUUuhiBshV3 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 52ac3e2689f0c200ebbb57ec564f71a37b0ddc8f..50ec52bcce4b4443c2f3ffeda45= 5594733f3a5a0 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -663,6 +663,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.0.727.gbf7dc18ff4-goog From nobody Sun Dec 14 20:16:28 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 3F57219D8A2; Sat, 19 Jul 2025 02:11:54 +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=1752891114; cv=none; b=aijxgxcJ40yZTM4GBXbkqoa9zjqpOYYWtBPyUird9iV5FP63vnFQQGqiC+VidbUlzBeTe1Zvr5IUlh5TZ6I1AIHMkKOy5hpGz+rPYIkbQjV6KvGxnr4C7np83O29aoOL2lpSFFftt3qfRfUABI9cPoaP09dK/N9NRVHREkVuDng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752891114; c=relaxed/simple; bh=Mp/jgK6Xt9LoSu/naNECO65nKErgpdesQbN446RlRp0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YGl+Kq5mDf0MOoS8Sk7hjZCX071E6KF983CH2gAIR24z0lnSlFo/wBoR8GkmRu9TKrJH2g/NOrdv89xJhrp3mWhWQS7SeG4XStBydhqebc7p/ndEZCcImbvWrOvwmu44PQer+adfCg020MPm6/KCV0YVq3val2SNlsuqPr55YwA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R/ayT6l7; 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="R/ayT6l7" Received: by smtp.kernel.org (Postfix) with ESMTPS id C743AC4CEF7; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752891113; bh=Mp/jgK6Xt9LoSu/naNECO65nKErgpdesQbN446RlRp0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=R/ayT6l7wFXlgg7aGJK8S37b0YdFH5sFrRyktLemEsrkBxRPWE9G0cFsXPqmhET+j p5xhbLPnzya+vFCgQrfyJrzzGVCR6roN4kOwhMBtMn0r3u/x/UXmPAXrMZnmBo8htB 2lCgcRuOCWRqbXOSlmL0tXdWMlnFkt7YcxAQYGFGI4gABjKkGWRWF5Cbc4bLaXWhsu KNFaOtJ1rbUT9d0V0I/GCX6+b07no3TGFULDUteUt+oLKgQp07f9PgAoDqMYUZuF/B Em0N2/sor7dBnaOoiNx5ogVQqrEEwt+CE4jd+ZEDBLzsMglMkvhtUKWuC6JRHrNU1D uur1MzkYlfXdw== 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 BF2FEC83F3E; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) From: Per Larsen via B4 Relay Date: Sat, 19 Jul 2025 02:11:26 +0000 Subject: [PATCH v8 4/7] 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: <20250719-virtio-msg-ffa-v8-4-03e8e8dbe856@google.com> References: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@google.com> In-Reply-To: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@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=1752891112; l=1289; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=dgBVrMdjAZFSIYAnESFiV+uLEGMo1SRSm+p8aDNjGJQ=; b=IMDnhHhg0FoazYMmOZA5MqsjVPfiAVVoRRaOwqYguuaRhtoI9suue0RLYVCELMYFA2XwFnrmW SiPndnyo+0qDWbM6/aUAyJ88rBrYneqLwdQgpn7XWKjl1F0F3qQYkKZ 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 Update ffa_call_supported to mark FF-A 1.2 interfaces as unsupported lest they get forwarded. FFA_MSG_SEND_DIRECT_REQ2 is not marked as unsupported because a later patch in this series adds support. Also mark FFA_EL3_INTR_HANDLE as unsupported as it is only valid for physical instances. Signed-off-by: Per Larsen --- arch/arm64/kvm/hyp/nvhe/ffa.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index 50ec52bcce4b4443c2f3ffeda455594733f3a5a0..5a173ea481940236356e2bc4248= d094a858a0923 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -671,6 +671,12 @@ 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_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.0.727.gbf7dc18ff4-goog From nobody Sun Dec 14 20:16:28 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 4FE031DC9A3; Sat, 19 Jul 2025 02:11:54 +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=1752891114; cv=none; b=n8pxf87cYl7x6iVO1gRtozXb61JZz55OpHWEyc4JVyvZtEzRJk1J6ejYzh/L4qVD/Q/N870R0sVbiMIlSGnaP3Xt+j6uxRZqm+mmOh077rsThJ7rwB42OVYhm11R4cvrjY2bdCvNTLyZ+gqgVSUBCnLZvf9jfCeK6LTRYzRs8BM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752891114; c=relaxed/simple; bh=Qkay+td2CTF8tiBwafQanjBkZb8hXhQmz0Ko/raVV7c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m+xMKqVdgO946HweuQbYESY/MbmsQw3i2Ne1TXnsLKR4hcOcfjODAAKIni9BpzRG0O6JdoFB2STaeBFfGybqIdil2H+tYbLmCcoAT3fZ/1ymufxlhp0Q4WrbWumnziZE92oTozvUJVd2v5iPp67d1y58IykkQoCR25Dnn9jLwUU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kvzBhPX2; 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="kvzBhPX2" Received: by smtp.kernel.org (Postfix) with ESMTPS id D9659C4CEFF; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752891113; bh=Qkay+td2CTF8tiBwafQanjBkZb8hXhQmz0Ko/raVV7c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=kvzBhPX2As4S9PpPjzujySHMe3jFqms6HMlL0V9wpkpYHlWsxrHjO9A2MEYY2eLbh mEroUHMTA7LOsSDrqNMug+L0vFFnSHdZGYzahA6Vvkl/DHIDo8qMZYSLMmvBHlPltP j7X3xEDLpX5YHb8RfrhHyPyfnoKrCWKomCE68FZk2mPohdZ2el872gDANrEIWpKI5w cKLDKQlTeJAymtOSOmH/wMSwynhrOxQNZ90YfMlVunbB6jzAxYwi+kBX4aXJ6AXPc4 XT9NI+bklB9duXZFpDHsAnWe+3IoZSkWc9RnrL+D1yB1v9KaEgHLMDCPxpMl4l8zUn 0YKzI6KzZbJxw== 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 CB895C83F1A; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) From: Per Larsen via B4 Relay Date: Sat, 19 Jul 2025 02:11:27 +0000 Subject: [PATCH v8 5/7] 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: <20250719-virtio-msg-ffa-v8-5-03e8e8dbe856@google.com> References: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@google.com> In-Reply-To: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@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=1752891112; l=1363; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=55yA/b9WaRmX85NmDdLJkZinkMYQwcAGAdUeGaUKBZ4=; b=sNeyafSSHUrLsmXTiUjqsrcfVjOFuY4rtzvyG/u1PdIsoRhxBd/haBBhQ1GbB2Dt0nX/m0MLl pbxXYv/TMoOA6/Y9FNIxafXa33hJUmsrt3XKiCqhCvmuwtgEaAsL8Mt 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. Signed-off-by: Per Larsen Acked-by: Will Deacon --- 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 5a173ea481940236356e2bc4248d094a858a0923..2cbecc9af5d27a9e7c8497001cf= 9b0987c72bdb4 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -733,7 +733,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.0.727.gbf7dc18ff4-goog From nobody Sun Dec 14 20:16:28 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 4F82B1DB125; Sat, 19 Jul 2025 02:11:54 +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=1752891114; cv=none; b=Fwe2zyYLr6a+XXM3AmG7LhGF4rte8U7eKEv437oyCyTUjbw0AfBb1gmOatj08KtC/H2JpYQfdC6D7ERbWO5wkx/gfGuv0GQCyQAGRXd56RQK4oYYUGEC9Gh0t7Jh4gyV5GUjnd+dES+EOhea+JnTGwJVgFpznLsTDpYIpWUnwkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752891114; c=relaxed/simple; bh=iD6hxJrjXS0zgg4c0EA8e0gUqO8fQd33QdXRgVaGfds=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tdK4rhpQQTTtDdNRyfu9edaFc/iMpc4dbeL8anEhMgeayPbsJMAM9C+yuEB975Ee/7v4adNAPE1jyRY3baqASVKASgCRHp4+4zozveuz+uB+gK9fkCXpORthEgm/L+knDZGndn5Su33eRLw+wgOrC0wbRh9vK21SS8QxBQdxArM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DrWSt6DU; 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="DrWSt6DU" Received: by smtp.kernel.org (Postfix) with ESMTPS id E1F57C113CF; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752891113; bh=iD6hxJrjXS0zgg4c0EA8e0gUqO8fQd33QdXRgVaGfds=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=DrWSt6DUreCWlGuacQiROAKsz7Oced+Lk9MpuCiuYDOy8QXTGG+h8W2oeB2+HXnly VUHjwXXi9jwFtEgNwOWwo9chnFvUvecpa8WZsn/XrFl8TZCcoHaNFIaD4FoHxBcxBI o7FqBbCr1NnFtDQBWYKP3FfIcrnbXfQSZl1zoi0gFjd/tdub4JVUao4DCC9wop/IVd Dc70dKoU+DrmBPLbLVnoy+611VoCYs0lOgI3/CZS+GHoBd0XVyP21vUilF/kprlL7n CFjGp2AY6xRG3bIWhuSRJhYFmIFh8fxYdsFEBkVEPwzH9C6y4vLJ4eUMIcr3e77l+M bCYCwkgP/gZ1w== 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 D7A90C83F34; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) From: Per Larsen via B4 Relay Date: Sat, 19 Jul 2025 02:11:28 +0000 Subject: [PATCH v8 6/7] 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: <20250719-virtio-msg-ffa-v8-6-03e8e8dbe856@google.com> References: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@google.com> In-Reply-To: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@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=1752891112; l=1443; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=txfowO+ukMF1cKRkbyV9oZR3idRq8KAQfVviP632O2Y=; b=NmwH2Kl37jGkp56jhbSbjWyVhPM0UcN4v1fv/oFMEnt32iE+WCcBK521NsQkGB53tMdYwe3+b NYM1hXaTEcXBUsHjEqgsfXeqjbpo/+wdUCh2HaU7CK5szV0s45uKG7y 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. Co-developed-by: Ayrton Munoz Signed-off-by: Ayrton Munoz Signed-off-by: Per Larsen Acked-by: Will Deacon --- 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 2cbecc9af5d27a9e7c8497001cf9b0987c72bdb4..f6d964df53c3e21ba85984f35cc= 7b6859012d1b0 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -930,7 +930,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; @@ -951,10 +951,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.0.727.gbf7dc18ff4-goog From nobody Sun Dec 14 20:16:28 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 88AF81E9B28; Sat, 19 Jul 2025 02:11:54 +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=1752891114; cv=none; b=Igs/zKLvM6jZOURLmsBcCNZD6EkjWCXPb6xem5fcev7784+b75U34jdB9B/07sDuxQdqKPs+9wBS4QwKt8dJUtQLhrMUk32sv7tNO8iaTMKed5xG51XvovdcMTJZR4tSIgDED8/KFQSCOAApps4BIyyOSCNOSMpr2BPfA8MZOW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752891114; c=relaxed/simple; bh=pL2iiryt41F/60ONkgpcLd+A0vFpoBJsL1JAkyL26QQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MF1JY+4x0PtQgnJZ2JbexYvqrTZ34Igv1K2Mta4nVWAkzbHPZEc4TMXZaMWERnhlwDjt7OdPx1ACZenviM3lW7IYJ2Xd2i4WVPnzgdgUvDlhRFI03h10T55WQSFtemhCjiMJdjuUiL/u4gxte4KTs0oqxA+fWEYF4ItkpWNrsrE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jONw8ShQ; 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="jONw8ShQ" Received: by smtp.kernel.org (Postfix) with ESMTPS id ECDF7C113D0; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752891114; bh=pL2iiryt41F/60ONkgpcLd+A0vFpoBJsL1JAkyL26QQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=jONw8ShQFNBkFOyuawi/6n4Bjna8VUgy5C+QgBOUvC0NH5PxU74lrT58uF1cUcU6P Per+e9Ujy6WCwjTvzzRaMK5/10cISSE78d9SJpJiGz2up7GDDaM01kW3JYVIGNN+GI K1FXKhgDFOlcGKSB6qdE2RRYSvwfpr+aeHCbyBElqdY1mRK0azf8DArvaQ3A75yqvu 5zmvMgGB3s3nJxCV77pIbjlaA5/IeSactV/xNvx3zp/4wLvAkxmT4+oOkjeYLbCs05 rA7tWrPP6DL9QsRRz3o5PVwW5UXQZ3BQ323bLviVrotMWCoiv2QIlZA0mFk12cRf74 P5DrPYscAhZaA== 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 E4E0AC83F3E; Sat, 19 Jul 2025 02:11:53 +0000 (UTC) From: Per Larsen via B4 Relay Date: Sat, 19 Jul 2025 02:11:29 +0000 Subject: [PATCH v8 7/7] 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: <20250719-virtio-msg-ffa-v8-7-03e8e8dbe856@google.com> References: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@google.com> In-Reply-To: <20250719-virtio-msg-ffa-v8-0-03e8e8dbe856@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=1752891112; l=1826; i=perlarsen@google.com; s=20250508; h=from:subject:message-id; bh=XKLIrLx+xVZkKFUyrkWFNAg3jN3LAX8G3drs7Zg0LpU=; b=bAFm8MojrTV0HWjRNrhEW7+sivMya8UgN2MnWTQD8h9xbMw8WrO+9bYJ7E6lzG9tF2K5n+Xux wriZLkODV0ZDCFwoyKRat6h5JRoPq6c1NwRiFbJwu04nzWiREVYMTbv 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c index f6d964df53c3e21ba85984f35cc7b6859012d1b0..363374408b354a5d65861b9cf14= 0974d8914ff40 100644 --- a/arch/arm64/kvm/hyp/nvhe/ffa.c +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c @@ -851,6 +851,15 @@ static void do_ffa_part_get(struct arm_smccc_1_2_regs = *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) +{ + struct arm_smccc_1_2_regs *args =3D (void *)&ctxt->regs.regs[0]; + + arm_smccc_1_2_smc(args, regs); +} + bool kvm_host_ffa_handler(struct kvm_cpu_context *host_ctxt, u32 func_id) { struct arm_smccc_1_2_regs res; @@ -909,11 +918,18 @@ bool kvm_host_ffa_handler(struct kvm_cpu_context *hos= t_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(&res, 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); --=20 2.50.0.727.gbf7dc18ff4-goog