From nobody Mon Apr 13 04:01:09 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 177083026557591.64607039074667; Wed, 11 Feb 2026 09:17:45 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1228066.1534456 (Exim 4.92) (envelope-from ) id 1vqDqD-0001hZ-0C; Wed, 11 Feb 2026 17:17:29 +0000 Received: by outflank-mailman (output) from mailman id 1228066.1534456; Wed, 11 Feb 2026 17:17:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqDqC-0001hS-SP; Wed, 11 Feb 2026 17:17:28 +0000 Received: by outflank-mailman (input) for mailman id 1228066; Wed, 11 Feb 2026 17:17:27 +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 1vqDp1-0004tt-Lr for xen-devel@lists.xenproject.org; Wed, 11 Feb 2026 17:16:15 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 5d6d71a8-076d-11f1-b162-2bf370ae4941; Wed, 11 Feb 2026 18:16:12 +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 BA4F0339; Wed, 11 Feb 2026 09:16:05 -0800 (PST) Received: from C3HXLD123V.arm.com (unknown [10.57.53.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 12D563F63F; Wed, 11 Feb 2026 09:16:10 -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: 5d6d71a8-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 11/12] xen/arm: ffa: Add MEM_SHARE page diagnostics Date: Wed, 11 Feb 2026 18:15:35 +0100 Message-ID: <4fa6736cbe35b060cf34b2978bbf9b3481d9266a.1770826406.git.bertrand.marquis@arm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1770830266267158500 Content-Type: text/plain; charset="utf-8" MEM_SHARE failures in get_shm_pages() are silent, which makes malformed ranges and page mapping failures hard to diagnose. Add debug logging for page validation failures: - descriptor validation failures (unaligned, range short/overflow) - per-page mapping failures (unmapped GFN, wrong p2m type) - address overflow detection in range walks Ratelimit temporary reclaim failures and log permanent reclaim failures as errors. No functional changes. Signed-off-by: Bertrand Marquis --- Changes since v1: - use one print per error case instead of the previous system using variables to classify and a single print site. --- xen/arch/arm/tee/ffa_shm.c | 39 +++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/tee/ffa_shm.c b/xen/arch/arm/tee/ffa_shm.c index 070babce9627..3d61caaeba78 100644 --- a/xen/arch/arm/tee/ffa_shm.c +++ b/xen/arch/arm/tee/ffa_shm.c @@ -161,32 +161,62 @@ static int32_t get_shm_pages(struct domain *d, struct= ffa_shm_mem *shm, addr =3D ACCESS_ONCE(range[n].address); =20 if ( !IS_ALIGNED(addr, FFA_PAGE_SIZE) ) + { + gdprintk(XENLOG_DEBUG, + "ffa: mem share pages invalid: unaligned range %u add= ress %#lx\n", + n, (unsigned long)addr); return FFA_RET_INVALID_PARAMETERS; + } =20 for ( m =3D 0; m < page_count; m++ ) { if ( pg_idx >=3D shm->page_count ) + { + gdprintk(XENLOG_DEBUG, + "ffa: mem share pages invalid: range overflow rg = %u pg %u\n", + n, m); return FFA_RET_INVALID_PARAMETERS; + } =20 if ( !ffa_safe_addr_add(addr, m) ) + { + gdprintk(XENLOG_DEBUG, + "ffa: mem share pages invalid: addr overflow rg %= u pg %u base %#lx\n", + n, m, (unsigned long)addr); return FFA_RET_INVALID_PARAMETERS; + } =20 gaddr =3D addr + m * FFA_PAGE_SIZE; gfn =3D gaddr_to_gfn(gaddr); shm->pages[pg_idx] =3D get_page_from_gfn(d, gfn_x(gfn), &t, P2M_ALLOC); if ( !shm->pages[pg_idx] ) + { + gdprintk(XENLOG_DEBUG, + "ffa: mem share pages invalid: gfn unmapped rg %u= pg %u addr %#lx\n", + n, m, (unsigned long)gaddr); return FFA_RET_DENIED; + } /* Only normal RW RAM for now */ if ( t !=3D p2m_ram_rw ) + { + gdprintk(XENLOG_DEBUG, + "ffa: mem share pages invalid: p2m type %u rg %u = pg %u addr %#lx\n", + t, n, m, (unsigned long)gaddr); return FFA_RET_DENIED; + } pg_idx++; } } =20 /* The ranges must add up */ if ( pg_idx < shm->page_count ) + { + gdprintk(XENLOG_DEBUG, + "ffa: mem share pages invalid: range short pg %u\n", + pg_idx); return FFA_RET_INVALID_PARAMETERS; + } =20 return FFA_RET_OK; } @@ -741,8 +771,10 @@ bool ffa_shm_domain_destroy(struct domain *d) * A temporary error that may get resolved a bit later, it's * worth retrying. */ - printk(XENLOG_G_INFO "%pd: ffa: Failed to reclaim handle %#lx = : %d\n", - d, shm->handle, res); + if ( printk_ratelimit() ) + printk(XENLOG_G_WARNING + "%pd: ffa: Failed to reclaim handle %#lx : %d\n", + d, shm->handle, res); break; /* We will retry later */ default: /* @@ -754,7 +786,8 @@ bool ffa_shm_domain_destroy(struct domain *d) * FFA_RET_NO_MEMORY might be a temporary error as it it could * succeed if retried later, but treat it as permanent for now. */ - printk(XENLOG_G_INFO "%pd: ffa: Permanent failure to reclaim h= andle %#lx : %d\n", + printk(XENLOG_G_ERR + "%pd: ffa: Permanent failure to reclaim handle %#lx : %= d\n", d, shm->handle, res); =20 /* --=20 2.52.0