From nobody Mon Apr 13 03:29:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1770830191270318.7697840926148; Wed, 11 Feb 2026 09:16:31 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1228001.1534424 (Exim 4.92) (envelope-from ) id 1vqDow-0006TW-Jn; Wed, 11 Feb 2026 17:16:10 +0000 Received: by outflank-mailman (output) from mailman id 1228001.1534424; Wed, 11 Feb 2026 17:16:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqDow-0006T2-Fd; Wed, 11 Feb 2026 17:16:10 +0000 Received: by outflank-mailman (input) for mailman id 1228001; Wed, 11 Feb 2026 17:16:09 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqDov-0004tt-KN for xen-devel@lists.xenproject.org; Wed, 11 Feb 2026 17:16:09 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 5aecf9a9-076d-11f1-b162-2bf370ae4941; Wed, 11 Feb 2026 18:16:08 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 88A52143D; Wed, 11 Feb 2026 09:16:01 -0800 (PST) Received: from C3HXLD123V.arm.com (unknown [10.57.53.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A31B43F63F; Wed, 11 Feb 2026 09:16:06 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5aecf9a9-076d-11f1-b162-2bf370ae4941 From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: Volodymyr Babchuk , Jens Wiklander , Stefano Stabellini , Julien Grall , Michal Orzel Subject: [PATCH v2 08/12] xen/arm: ffa: Fix FFA_FEATURES validation Date: Wed, 11 Feb 2026 18:15:32 +0100 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1770830191868158500 Content-Type: text/plain; charset="utf-8" FFA_FEATURES advertises several ABIs unconditionally, even when firmware support is missing or when the ABI is physical-instance-only. This can mislead guests about what Xen can actually provide and violates FF-A calling conventions. Some SPMCs (Hafnium v2.14 or earlier) also fail to report FFA_RX_ACQUIRE despite supporting it. Update FFA_FEATURES validation to match spec and firmware support: - do no check w2-w7 input registers during FFA_FEATURES as they are flagged Should Be Zero by the FF-A specification or are not used by the calls we support. - reject 64-bit calling conventions from 32-bit guests with NOT_SUPPORTED - return NOT_SUPPORTED for physical-instance-only ABIs (FFA_NOTIFICATION_BITMAP_{CREATE,DESTROY}, FFA_RX_ACQUIRE) - advertise FFA_INTERRUPT as supported - gate message ABIs on firmware support: - FFA_MSG_SEND_DIRECT_REQ_{32,64} - FFA_MSG_SEND_DIRECT_REQ2 (also requires FF-A 1.2 negotiation) - FFA_MSG_SEND2 (or VM-to-VM enabled) - report MEM_SHARE_{32,64} only when FFA_MEM_SHARE_64 is supported - stop advertising FFA_MSG_YIELD (not implemented) Update firmware probing: drop FFA_MEM_SHARE_32 checks (deprecated) and add FFA_RX_ACQUIRE to the probed set. If FFA_MSG_SEND2 is reported but FFA_RX_ACQUIRE is not, assume RX_ACQUIRE support and warn to work around the Hafnium bug. Functional impact: guests now see ABI support that reflects firmware capabilities and Xen implementation status. When SEND2 is present but RX_ACQUIRE is not reported, Xen assumes RX_ACQUIRE support. Signed-off-by: Bertrand Marquis Reviewed-by: Jens Wiklander --- Changes since v1: - remove completely w2-w7 checking as those are SBZ in the spec or unused by xen --- xen/arch/arm/tee/ffa.c | 63 +++++++++++++++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/xen/arch/arm/tee/ffa.c b/xen/arch/arm/tee/ffa.c index 23e1f408485b..cb8cd95fdafa 100644 --- a/xen/arch/arm/tee/ffa.c +++ b/xen/arch/arm/tee/ffa.c @@ -91,10 +91,10 @@ static const struct ffa_fw_abi ffa_fw_abi_needed[] =3D { FW_ABI(FFA_PARTITION_INFO_GET), FW_ABI(FFA_NOTIFICATION_INFO_GET_64), FW_ABI(FFA_NOTIFICATION_GET), + FW_ABI(FFA_RX_ACQUIRE), FW_ABI(FFA_RX_RELEASE), FW_ABI(FFA_RXTX_MAP_64), FW_ABI(FFA_RXTX_UNMAP), - FW_ABI(FFA_MEM_SHARE_32), FW_ABI(FFA_MEM_SHARE_64), FW_ABI(FFA_MEM_RECLAIM), FW_ABI(FFA_MSG_SEND_DIRECT_REQ_32), @@ -238,21 +238,30 @@ static void handle_features(struct cpu_user_regs *reg= s) uint32_t a1 =3D get_user_reg(regs, 1); struct domain *d =3D current->domain; struct ffa_ctx *ctx =3D d->arch.tee; - unsigned int n; =20 - for ( n =3D 2; n <=3D 7; n++ ) + /* + * FFA_FEATURES defines w2 as input properties only for specific + * function IDs and reserves w3-w7 as SBZ. Xen does not currently + * implement any feature that consumes w2, so ignore extra inputs. + */ + if ( !is_64bit_domain(d) && smccc_is_conv_64(a1) ) { - if ( get_user_reg(regs, n) ) - { - ffa_set_regs_error(regs, FFA_RET_NOT_SUPPORTED); - return; - } + /* 32bit guests should only use 32bit convention calls */ + ffa_set_regs_error(regs, FFA_RET_NOT_SUPPORTED); + return; } =20 switch ( a1 ) { + case FFA_NOTIFICATION_BITMAP_CREATE: + case FFA_NOTIFICATION_BITMAP_DESTROY: + case FFA_RX_ACQUIRE: + /* Physical-instance-only ABIs are not exposed to VMs. */ + ffa_set_regs_error(regs, FFA_RET_NOT_SUPPORTED); + break; case FFA_ERROR: case FFA_VERSION: + case FFA_INTERRUPT: case FFA_SUCCESS_32: case FFA_SUCCESS_64: case FFA_FEATURES: @@ -261,16 +270,25 @@ static void handle_features(struct cpu_user_regs *reg= s) case FFA_RXTX_UNMAP: case FFA_MEM_RECLAIM: case FFA_PARTITION_INFO_GET: + ffa_set_regs_success(regs, 0, 0); + break; case FFA_MSG_SEND_DIRECT_REQ_32: case FFA_MSG_SEND_DIRECT_REQ_64: - case FFA_MSG_SEND2: case FFA_RUN: - case FFA_INTERRUPT: - case FFA_MSG_YIELD: - ffa_set_regs_success(regs, 0, 0); + if ( ffa_fw_supports_fid(a1) ) + ffa_set_regs_success(regs, 0, 0); + else + ffa_set_regs_error(regs, FFA_RET_NOT_SUPPORTED); + break; + case FFA_MSG_SEND2: + if ( ffa_fw_supports_fid(a1) || IS_ENABLED(CONFIG_FFA_VM_TO_VM) ) + ffa_set_regs_success(regs, 0, 0); + else + ffa_set_regs_error(regs, FFA_RET_NOT_SUPPORTED); break; case FFA_MSG_SEND_DIRECT_REQ2: - if ( ACCESS_ONCE(ctx->guest_vers) >=3D FFA_VERSION_1_2 ) + if ( ACCESS_ONCE(ctx->guest_vers) >=3D FFA_VERSION_1_2 && + ffa_fw_supports_fid(FFA_MSG_SEND_DIRECT_REQ2) ) { ffa_set_regs_success(regs, 0, 0); } @@ -281,6 +299,11 @@ static void handle_features(struct cpu_user_regs *regs) break; case FFA_MEM_SHARE_64: case FFA_MEM_SHARE_32: + if ( !ffa_fw_supports_fid(FFA_MEM_SHARE_64) ) + { + ffa_set_regs_error(regs, FFA_RET_NOT_SUPPORTED); + break; + } /* * We currently don't support dynamically allocated buffers. Report * that with 0 in bit[0] of w2. @@ -688,6 +711,20 @@ static bool ffa_probe_fw(void) ffa_fw_abi_needed[i].name); } =20 + /* + * Hafnium v2.14 or earlier does not report FFA_RX_ACQUIRE in + * FFA_FEATURES even though it supports it. + */ + if ( !ffa_fw_supports_fid(FFA_RX_ACQUIRE) && + ffa_fw_supports_fid(FFA_MSG_SEND2) ) + { + printk(XENLOG_WARNING + "ARM FF-A Firmware reports FFA_MSG_SEND2 without FFA_RX_ACQ= UIRE\n"); + printk(XENLOG_WARNING + "ffa: assuming RX_ACQUIRE support (workaround)\n"); + set_bit(FFA_ABI_BITNUM(FFA_RX_ACQUIRE), ffa_fw_abi_supported); + } + if ( !ffa_rxtx_spmc_init() ) { printk(XENLOG_ERR "ffa: Error during RXTX buffer init\n"); --=20 2.52.0