From nobody Wed Aug 26 17:03:11 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; dkim=pass; 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=pass(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1776433311; cv=none; d=zohomail.com; s=zohoarc; b=ircj++SwWCOX8qqgKbBVDaDctSRKXjJs14cZu8q94tWuELV5BT/qeKo7VTefq3HlJqZF2ZciRp68pzsDR5Lld9FRD8xFt2izim7A6jM/cxhjxjFi1noHoqoFZcRDQxvyUeMpdrED9/5WbYWcmtCiyVKvPlzy6HPPAuElofJCOOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776433311; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7liEaokosXL/ZPIJG1cA5cVEhgpdkRunIZjEVs3ryvE=; b=FKZxF18Q4fTsCrpp7PQzz9XMWzjB9x4zCEnDxUXkquc4pakDeGpFDjrSv9KbSISYM2idhHEz2u614Y3/bF1tsa/cIZPLLggIEydy1GhFslKRl+/w5FYxa2lIl2qTtEYZM8CdhWJKNnc78NtoCwUVN1LfR6kk8pYZO34F2adVeJE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1776433311721938.0190992430837; Fri, 17 Apr 2026 06:41:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1284302.1566131 (Exim 4.92) (envelope-from ) id 1wDjRs-0005lk-Lj; Fri, 17 Apr 2026 13:41:32 +0000 Received: by outflank-mailman (output) from mailman id 1284302.1566131; Fri, 17 Apr 2026 13:41:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wDjRs-0005ld-J0; Fri, 17 Apr 2026 13:41:32 +0000 Received: by outflank-mailman (input) for mailman id 1284302; Fri, 17 Apr 2026 13:41:31 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wDjRr-0005cp-T0 for xen-devel@lists.xenproject.org; Fri, 17 Apr 2026 13:41:31 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wDjRr-000Ejb-9z for xen-devel@lists.xenproject.org; Fri, 17 Apr 2026 15:41:31 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69e23878-5cb7-0a2a0a5109dd-0a2a450a8746-26 for ; Fri, 17 Apr 2026 15:41:31 +0200 Received: from [217.140.110.172] (helo=foss.arm.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTP (eXpurgate 4.56.1) (envelope-from ) id 69e2388a-56b3-0a2a450a0019-d98c6eacc2a8-1 for ; Fri, 17 Apr 2026 15:41:31 +0200 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 845031516; Fri, 17 Apr 2026 06:41:24 -0700 (PDT) Received: from C3HXLD123V.arm.com (unknown [10.57.89.170]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D5E8A3F7D8; Fri, 17 Apr 2026 06:41:28 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=foss header.d=arm.com header.i="@arm.com" header.h="From:To:Cc:Subject:Date:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1776433290; bh=caqGVxvnjz0bVK6Ez9rNrj5k4WIzyoABx5lWZ62MqVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F/9rK41YnPUbCvUBHCt5U0B3AIRzfayyu4D5MvWYWuc5xGXma+MxvpDDLffQHSAt1 B7Bg4iM3FAywj4XwhUbq14JxtRUZZPfPf8yYJSbdp5KP+U5YjXRuj29S8szj7wmgER JoceslpxERiNOPD+UNgMD4dmFI7ngoNnufOaX6AY= From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: Volodymyr Babchuk , Jens Wiklander , Stefano Stabellini , Julien Grall , Michal Orzel Subject: [PATCH 2/6] xen/arm: ffa: Track hypervisor notifications in a bitmap Date: Fri, 17 Apr 2026 15:40:50 +0200 Message-ID: <7053b8c14bbe50cc855dad0a82cde2bb10153d2b.1776266307.git.bertrand.marquis@arm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1776433291-CEB778B7-F8329588/0/0 X-purgate-type: clean X-purgate-size: 4902 X-ZohoMail-DKIM: pass (identity @arm.com) X-ZM-MESSAGEID: 1776433313286154100 Content-Type: text/plain; charset="utf-8" Hypervisor notifications are currently tracked with a dedicated buff_full_pending boolean. That state only represents a single HYP notification bit and keeps HYP bitmap handling tied to single-purpose bookkeeping. Replace the boolean with a hypervisor notification bitmap protected by notif_lock. INFO_GET reports pending when the bitmap is non-zero, GET returns and clears the HYP bitmap under the lock, and RX-buffer-full sets FFA_NOTIF_RX_BUFFER_FULL in the bitmap instead of updating separate state. Initialize and clear the bitmap during domain lifecycle handling, and use ctx->ffa_id for bitmap create and destroy so the notification state stays tied to the cached FF-A endpoint ID. No functional changes. Signed-off-by: Bertrand Marquis --- xen/arch/arm/tee/ffa_notif.c | 46 ++++++++++++++++++++++++++-------- xen/arch/arm/tee/ffa_private.h | 9 +++++-- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/tee/ffa_notif.c b/xen/arch/arm/tee/ffa_notif.c index 07bc5cb3a430..d15119409a25 100644 --- a/xen/arch/arm/tee/ffa_notif.c +++ b/xen/arch/arm/tee/ffa_notif.c @@ -94,8 +94,15 @@ void ffa_handle_notification_info_get(struct cpu_user_re= gs *regs) =20 notif_pending =3D test_and_clear_bool(ctx->notif.secure_pending); if ( IS_ENABLED(CONFIG_FFA_VM_TO_VM) ) + { notif_pending |=3D test_and_clear_bool(ctx->notif.vm_pending); =20 + spin_lock(&ctx->notif.notif_lock); + if ( ctx->notif.hyp_pending ) + notif_pending =3D true; + spin_unlock(&ctx->notif.notif_lock); + } + if ( notif_pending ) { /* A pending global notification for the guest */ @@ -174,12 +181,17 @@ void ffa_handle_notification_get(struct cpu_user_regs= *regs) w6 =3D resp.a6; } =20 - if ( IS_ENABLED(CONFIG_FFA_VM_TO_VM) && - flags & FFA_NOTIF_FLAG_BITMAP_HYP && - test_and_clear_bool(ctx->notif.buff_full_pending) ) + if ( IS_ENABLED(CONFIG_FFA_VM_TO_VM) ) { - ACCESS_ONCE(ctx->notif.vm_pending) =3D false; - w7 =3D FFA_NOTIF_RX_BUFFER_FULL; + spin_lock(&ctx->notif.notif_lock); + + if ( (flags & FFA_NOTIF_FLAG_BITMAP_HYP) && ctx->notif.hyp_pending= ) + { + w7 =3D ctx->notif.hyp_pending; + ctx->notif.hyp_pending =3D 0; + } + + spin_unlock(&ctx->notif.notif_lock); } =20 ffa_set_regs(regs, FFA_SUCCESS_32, 0, w2, w3, w4, w5, w6, w7); @@ -207,12 +219,17 @@ int32_t ffa_handle_notification_set(struct cpu_user_r= egs *regs) void ffa_raise_rx_buffer_full(struct domain *d) { struct ffa_ctx *ctx =3D d->arch.tee; + uint32_t prev_bitmap; =20 if ( !ctx ) return; =20 - ACCESS_ONCE(ctx->notif.buff_full_pending) =3D true; - if ( !test_and_set_bool(ctx->notif.vm_pending) ) + spin_lock(&ctx->notif.notif_lock); + prev_bitmap =3D ctx->notif.hyp_pending; + ctx->notif.hyp_pending |=3D FFA_NOTIF_RX_BUFFER_FULL; + spin_unlock(&ctx->notif.notif_lock); + + if ( !(prev_bitmap & FFA_NOTIF_RX_BUFFER_FULL) ) inject_notif_pending(d); } #endif @@ -426,12 +443,15 @@ void ffa_notif_init(void) =20 int ffa_notif_domain_init(struct domain *d) { + struct ffa_ctx *ctx =3D d->arch.tee; int32_t res; =20 + spin_lock_init(&ctx->notif.notif_lock); + ctx->notif.hyp_pending =3D 0; + if ( fw_notif_enabled ) { - - res =3D ffa_notification_bitmap_create(ffa_get_vm_id(d), d->max_vc= pus); + res =3D ffa_notification_bitmap_create(ctx->ffa_id, d->max_vcpus); if ( res ) return -ENOMEM; } @@ -441,10 +461,16 @@ int ffa_notif_domain_init(struct domain *d) =20 void ffa_notif_domain_destroy(struct domain *d) { + struct ffa_ctx *ctx =3D d->arch.tee; + + spin_lock(&ctx->notif.notif_lock); + ctx->notif.hyp_pending =3D 0; + spin_unlock(&ctx->notif.notif_lock); + /* * Call bitmap_destroy even if bitmap create failed as the SPMC will * return a DENIED error that we will ignore. */ if ( fw_notif_enabled ) - ffa_notification_bitmap_destroy(ffa_get_vm_id(d)); + ffa_notification_bitmap_destroy(ctx->ffa_id); } diff --git a/xen/arch/arm/tee/ffa_private.h b/xen/arch/arm/tee/ffa_private.h index c291f32b56ff..5693772481ed 100644 --- a/xen/arch/arm/tee/ffa_private.h +++ b/xen/arch/arm/tee/ffa_private.h @@ -340,9 +340,14 @@ struct ffa_ctx_notif { bool vm_pending; =20 /* - * True if domain has buffer full notification pending + * Lock protecting the hypervisor-managed notification state. */ - bool buff_full_pending; + spinlock_t notif_lock; + + /* + * Bitmap of pending hypervisor notifications (for HYP bitmap queries). + */ + uint32_t hyp_pending; }; =20 struct ffa_ctx { --=20 2.53.0