From nobody Sat Dec 13 07:23:09 2025 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 1764931081326969.7872665152936; Fri, 5 Dec 2025 02:38:01 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1178635.1502394 (Exim 4.92) (envelope-from ) id 1vRTC6-0006IR-2M; Fri, 05 Dec 2025 10:37:46 +0000 Received: by outflank-mailman (output) from mailman id 1178635.1502394; Fri, 05 Dec 2025 10:37:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vRTC5-0006IG-V2; Fri, 05 Dec 2025 10:37:45 +0000 Received: by outflank-mailman (input) for mailman id 1178635; Fri, 05 Dec 2025 10:37:44 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vRTC4-0005Ju-A6 for xen-devel@lists.xenproject.org; Fri, 05 Dec 2025 10:37:44 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 6dc0335a-d1c6-11f0-980a-7dc792cee155; Fri, 05 Dec 2025 11:37:42 +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 9F95F1575; Fri, 5 Dec 2025 02:37:34 -0800 (PST) Received: from C3HXLD123V.arm.com (unknown [10.57.45.211]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E79ED3F86F; Fri, 5 Dec 2025 02:37:40 -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: 6dc0335a-d1c6-11f0-980a-7dc792cee155 From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: jens.wiklander@linaro.org, Volodymyr Babchuk , Stefano Stabellini , Julien Grall , Michal Orzel Subject: [PATCH v1 03/12] xen/arm: ffa: Fix is_64bit init Date: Fri, 5 Dec 2025 11:36:36 +0100 Message-ID: <697ab9880767b75c9964ae900a43fd4e065fc502.1764930353.git.bertrand.marquis@arm.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1764931081784019200 Content-Type: text/plain; charset="utf-8" is_64bit_domain(d) is not set during domain_init as the domain field is only set when loading the domain image which is done after executing domain_init. Fix the implementation to set is_64bit when version gets negotiated. is_64bit is only used during partition_info_get once a domain is added in the list of domains having ffa support. It must only be accessed when the rwlock is taken (which is the case). is_64bit must not be used without the rwlock taken and other places in the code needing to test 64bit support of the current domain will have to use calls to is_64bit_domain instead of the field from now on. Fixes: 09a201605f99 ("xen/arm: ffa: Introduce VM to VM support") Signed-off-by: Bertrand Marquis --- Changes in v1: - patch introduced --- xen/arch/arm/tee/ffa.c | 9 ++++++++- xen/arch/arm/tee/ffa_private.h | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/tee/ffa.c b/xen/arch/arm/tee/ffa.c index aadd6c21e7f2..0f6f837378cc 100644 --- a/xen/arch/arm/tee/ffa.c +++ b/xen/arch/arm/tee/ffa.c @@ -180,6 +180,14 @@ static bool ffa_negotiate_version(struct cpu_user_regs= *regs) goto out_handled; } =20 + /* + * We cannot set is_64bit during domain init because the field is = not + * yet initialized. + * This field is only used during partinfo_get with the rwlock tak= en + * so there is no ordering issue with guest_vers. + */ + ctx->is_64bit =3D is_64bit_domain(d); + /* * A successful FFA_VERSION call does not freeze negotiation. Gues= ts * are allowed to issue multiple FFA_VERSION attempts (e.g. probing @@ -433,7 +441,6 @@ static int ffa_domain_init(struct domain *d) =20 ctx->ffa_id =3D ffa_get_vm_id(d); ctx->num_vcpus =3D d->max_vcpus; - ctx->is_64bit =3D is_64bit_domain(d); =20 /* * ffa_domain_teardown() will be called if ffa_domain_init() returns an diff --git a/xen/arch/arm/tee/ffa_private.h b/xen/arch/arm/tee/ffa_private.h index 4e4ac7fd7bc4..2daa4589a930 100644 --- a/xen/arch/arm/tee/ffa_private.h +++ b/xen/arch/arm/tee/ffa_private.h @@ -344,6 +344,11 @@ struct ffa_ctx { /* FF-A Endpoint ID */ uint16_t ffa_id; uint16_t num_vcpus; + /* + * Must only be accessed with the ffa_ctx_list_rwlock taken as it set + * when guest_vers is set and other accesses could see a partially set + * value. + */ bool is_64bit; =20 /* --=20 2.51.2