From nobody Thu Dec 18 09:46:01 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 1765824102222315.77935173205015; Mon, 15 Dec 2025 10:41:42 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1187131.1508569 (Exim 4.92) (envelope-from ) id 1vV9tj-0003tm-GC; Mon, 15 Dec 2025 14:50:03 +0000 Received: by outflank-mailman (output) from mailman id 1187131.1508569; Mon, 15 Dec 2025 14:50:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vV9tj-0003tE-A4; Mon, 15 Dec 2025 14:50:03 +0000 Received: by outflank-mailman (input) for mailman id 1187131; Mon, 15 Dec 2025 14:50:02 +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 1vV9th-0003Ov-Uo for xen-devel@lists.xenproject.org; Mon, 15 Dec 2025 14:50:01 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 555d1f67-d9c5-11f0-b15b-2bf370ae4941; Mon, 15 Dec 2025 15:50:01 +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 B94041655; Mon, 15 Dec 2025 06:49:53 -0800 (PST) Received: from C3HXLD123V.arm.com (unknown [10.57.46.206]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D7B503F694; Mon, 15 Dec 2025 06:49:59 -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: 555d1f67-d9c5-11f0-b15b-2bf370ae4941 From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: jens.wiklander@linaro.org, Volodymyr Babchuk , Stefano Stabellini , Julien Grall , Michal Orzel Subject: [PATCH v2 03/12] xen/arm: ffa: Fix is_64bit init Date: Mon, 15 Dec 2025 15:49:20 +0100 Message-ID: <983cdb4effeaa0d72ff02f3a7b561f1570646ea0.1765807707.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: 1765824104111154100 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 Reviewed-by: Jens Wiklander --- Changes in v2: - add Jens R-b 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 8ef214344711..96794ecebe4b 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