From nobody Mon Aug 24 11:04:30 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1783353528; cv=none; d=zohomail.com; s=zohoarc; b=lpcACQegNXregeBe+y8N7GXvgZuOS9BchKc2Mtnw4k3MHM3xsfT6lET0rPSeY4VF/JPTxt31kJcWdXwQlRlaDXc3cCgZvw5jZ0KYrAgw2Eb6yYDnPE1epFnGMI06GtEz47nDj16FNsFJzGtQ2R3y58cWweRLuMYm4VS7agaGDnk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353528; h=Content-Type: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=sS+W4tqZwutZWWwcjeWai30+FMlUlIOZS6B2+B7csNw=; b=l0+SzijsWf1/oZv5cyKtQzNUMzKS/wM7rete2Gkzc4RFCYQu/yLhfJEBlcyLDN8BYajAFHKIoeRkWxE+3XHN1cI5BAwsYSZtppPciyphLzds/XWOLXFSUBjVAv++dFmkmjfZK9wEYQFcLxp9yy64YW57VnPOM6Oc+M1XNdSrKT8= 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 1783353528594492.84406215122067; Mon, 6 Jul 2026 08:58:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355487.1610293 (Exim 4.92) (envelope-from ) id 1wgliD-00078G-Ty; Mon, 06 Jul 2026 15:58:25 +0000 Received: by outflank-mailman (output) from mailman id 1355487.1610293; Mon, 06 Jul 2026 15:58:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wgliD-000784-Ph; Mon, 06 Jul 2026 15:58:25 +0000 Received: by outflank-mailman (input) for mailman id 1355487; Mon, 06 Jul 2026 15:58:24 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliC-0006vR-9K for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:24 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliB-003COz-Mc for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:23 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd09f-2eae-0a2a0a5409dd-0a2a450ce8e8-6 for ; Mon, 06 Jul 2026 17:58:23 +0200 Received: from [209.85.128.50] (helo=mail-wm1-f50.google.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd09f-f399-0a2a450c0019-d1558032d4fe-3 for ; Mon, 06 Jul 2026 17:58:23 +0200 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-493b691cb44so22993935e9.0 for ; Mon, 06 Jul 2026 08:58:23 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58:21 -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=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783353503; x=1783958303; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=sS+W4tqZwutZWWwcjeWai30+FMlUlIOZS6B2+B7csNw=; b=DrFd63rQ9QYGteiEvhbKFjs6rya25oGiGWy8KWNoaxtxSSmOxWvu/0UuqKKg50xw5A F42z75iNwCRLIm4g3Z0DKXz+8fC/ZYT8H921z4TBWyO+bWRIFmwQTM7AK9u3Tjc7j7h8 3YHBJ/aySiMjb5jZ+iB1/ezryHV5uXBWcbb4Bf63WdUo8ujD2P+atGFFu3p67eidp6bc /X6nZ4E4HpjUD0sJz3MVO2l8cDrHxcbI08Pce3VzKjHIAYlh4Y5060/tV/7nlAhpjcac i8FQhFyjy1jRsDfga76cqMfccRJcUZStunRF+jJz2VAOCx+onnYKs2IMmcrkgbmoPJBq q31Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353503; x=1783958303; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=sS+W4tqZwutZWWwcjeWai30+FMlUlIOZS6B2+B7csNw=; b=QWWBANkkKoYBvIP6nshf+NmeLqZV4jNZFa2Bf2cviY9TOsAk4NA3nLLrkhOui5lUwi zMtZDsYimzL3/lwJj0i419nUzEwkefmpH0ySHGu5/ODlF6/MwMrvryEMO2qLRsVRnE/G LePp2gKgqrppqQk1VCnRQyn5Jr/UZZzSFdGmAdOrZ3b+RrzelZ5s3p6CXEnDbM3uN2/o s19IFSlgQTlJXKaIi+GSJBGJp46jx4CEsidFraURIZIIiQEbfzCKRU1BLEi5KT6PjosK N2APDP9iAm9VqlrsS+oieAiqaFf38+LSLqjUCGEwEUHskqYMaezKslw6SAK/+kTy7x8e FSvg== X-Gm-Message-State: AOJu0YypCgH/BOIZOFO7HYc2AmlA4PvtbaL7TTA8wPHSyal3I6PYm9ib OHa08sQIbvQw2oBd/0hHkg/YWnge1QfBYJ+7pkLXdNaCx85yn9ENBnLjJ0XqYA== X-Gm-Gg: AfdE7ckyA6YVJPXzDiS1hXIkJGj8yW2b+RU+djN92xcKMwxhWQ90ZGCMkBxB7iuymEG fLkJkGgjVzhvzRcJVnVYsJbeDMvJat5XUfwgyXaUS6uVop/uGwlEvCLcO67YyOmtejj85BdPTzA Z9pCEL6K+ko45qy5MY8kdmzmHTQkl7VNRF5bD1xBnDxXzpoZXqCbNa7SbS6TK2aBYL3T4tVoYQ8 707VlQzikoTZRtWdK5GBKa0jlErUSavUDJY5LtXc2BeHbGHzOZmljf5SDOPJPgLGha/oT3/XWxf VbeMIi8t8pHnToJQOP1QcrOqymcQMvLQq1EcfJld4LGBGPUeCgNdJbhb4R4kYyIF9y6TT/GiiSC l6XsSGzgWRP+BCBqGC/pa7DN6JMiQ2dlWRgiYIz+Is9wDFP+ZfIrIJiphCMbbL4v2XGN61giui1 PelqMLvsDXcFr0yDd0Ca4Elz3cGJ+xarOUZZPgvmTvn7Zo6jdpPEqhf4kKLe8/L/Tu21lw X-Received: by 2002:a05:600c:3b05:b0:493:bb45:d54d with SMTP id 5b1f17b1804b1-493df09e3a9mr13736335e9.37.1783353502372; Mon, 06 Jul 2026 08:58:22 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Oleksii Kurochko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Alistair Francis , Connor Davis Subject: [PATCH v5 03/26] xen: arm: update p2m_set_allocation() prototype Date: Mon, 6 Jul 2026 17:57:44 +0200 Message-ID: X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d25034/1783353503-91924D51-EF473D15/10/73395122804 X-purgate-type: spam X-purgate-size: 8891 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353530733158500 p2m_set_allocation() uses a bool *preempted out-argument that overloads two meanings. When non-NULL, the value written back (true) duplicates informati= on already carried by the -ERESTART return code =E2=80=94 pure redundancy, whi= ch the caller-side ASSERT(preempted =3D=3D (rc =3D=3D -ERESTART)) only documents. = Separately, a NULL pointer is an implicit calling convention meaning "preemption is not permitted in this context". Replace the pointer with a plain bool can_preempt that explicitly controls whether the preemption check runs, making the NULL-to-suppress convention type-safe and self-documenting, and rely on the -ERESTART return code alone= to report that preemption occurred. Since p2m_set_allocation() is called by the common dom0less build code, move its declaration from the ARM-specific asm/p2m.h to xen/p2m-common.h. Reported-by: Jan Beulich Signed-off-by: Oleksii Kurochko Reviewed-by: Michal Orzel --- Changes in v5: - Add Reviewed-by: Michal Orzel --- Changes in v4: - Reword commit message: a NULL pointer was a calling convention meaning "preemption not permitted", not pure redundancy. - Annotate the explicit can_preempt arguments at the call sites with /* can_preempt */ comments for readability. - Move the function's doc comment to the prototype in xen/p2m-common.h (dropping the duplicate above the Arm and RISC-V definitions) and clarify that -ERESTART is only returned when can_preempt is true. - Add __must_check to the prototype, since the return code is now the only preemption-status indicator. --- Changes in v3: - Nothing changed. Only rebase. --- Changes in v2: - new patch --- --- xen/arch/arm/include/asm/p2m.h | 1 - xen/arch/arm/mmu/p2m.c | 24 ++++++------------------ xen/arch/riscv/include/asm/paging.h | 2 +- xen/arch/riscv/p2m.c | 9 ++------- xen/arch/riscv/paging.c | 7 ++----- xen/common/device-tree/dom0less-build.c | 2 +- xen/include/xen/p2m-common.h | 8 ++++++++ 7 files changed, 20 insertions(+), 33 deletions(-) diff --git a/xen/arch/arm/include/asm/p2m.h b/xen/arch/arm/include/asm/p2m.h index 4a4913716bdd..737da60dcf58 100644 --- a/xen/arch/arm/include/asm/p2m.h +++ b/xen/arch/arm/include/asm/p2m.h @@ -238,7 +238,6 @@ void p2m_restore_state(struct vcpu *n); /* Print debugging/statistial info about a domain's p2m */ void p2m_dump_info(struct domain *d); =20 -int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preemp= ted); int p2m_teardown_allocation(struct domain *d); =20 static inline void p2m_write_lock(struct p2m_domain *p2m) diff --git a/xen/arch/arm/mmu/p2m.c b/xen/arch/arm/mmu/p2m.c index 51abf3504fcf..2cf35d8a3709 100644 --- a/xen/arch/arm/mmu/p2m.c +++ b/xen/arch/arm/mmu/p2m.c @@ -65,12 +65,7 @@ int arch_get_paging_mempool_size(struct domain *d, uint6= 4_t *size) return 0; } =20 -/* - * Set the pool of pages to the required number of pages. - * Returns 0 for success, non-zero for failure. - * Call with d->arch.paging.lock held. - */ -int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preemp= ted) +int p2m_set_allocation(struct domain *d, unsigned long pages, bool can_pre= empt) { struct page_info *pg; =20 @@ -112,11 +107,8 @@ int p2m_set_allocation(struct domain *d, unsigned long= pages, bool *preempted) break; =20 /* Check to see if we need to yield and try again */ - if ( preempted && general_preempt_check() ) - { - *preempted =3D true; + if ( can_preempt && general_preempt_check() ) return -ERESTART; - } } =20 return 0; @@ -125,7 +117,6 @@ int p2m_set_allocation(struct domain *d, unsigned long = pages, bool *preempted) int arch_set_paging_mempool_size(struct domain *d, uint64_t size) { unsigned long pages =3D size >> PAGE_SHIFT; - bool preempted =3D false; int rc; =20 if ( (size & ~PAGE_MASK) || /* Non page-sized request? */ @@ -133,27 +124,24 @@ int arch_set_paging_mempool_size(struct domain *d, ui= nt64_t size) return -EINVAL; =20 spin_lock(&d->arch.paging.lock); - rc =3D p2m_set_allocation(d, pages, &preempted); + rc =3D p2m_set_allocation(d, pages, /* can_preempt */ true); spin_unlock(&d->arch.paging.lock); =20 - ASSERT(preempted =3D=3D (rc =3D=3D -ERESTART)); - return rc; } =20 int p2m_teardown_allocation(struct domain *d) { int ret =3D 0; - bool preempted =3D false; =20 spin_lock(&d->arch.paging.lock); if ( d->arch.paging.p2m_total_pages !=3D 0 ) { - ret =3D p2m_set_allocation(d, 0, &preempted); - if ( preempted ) + ret =3D p2m_set_allocation(d, 0, /* can_preempt */ true); + if ( ret =3D=3D -ERESTART ) { spin_unlock(&d->arch.paging.lock); - return -ERESTART; + return ret; } ASSERT(d->arch.paging.p2m_total_pages =3D=3D 0); } diff --git a/xen/arch/riscv/include/asm/paging.h b/xen/arch/riscv/include/a= sm/paging.h index e487c89a4ccd..103384723dc5 100644 --- a/xen/arch/riscv/include/asm/paging.h +++ b/xen/arch/riscv/include/asm/paging.h @@ -9,7 +9,7 @@ struct page_info; int paging_domain_init(struct domain *d); =20 int paging_freelist_adjust(struct domain *d, unsigned long pages, - bool *preempted); + bool can_preempt); =20 int paging_ret_to_domheap(struct domain *d, unsigned int nr_pages); int paging_refill_from_domheap(struct domain *d, unsigned int nr_pages); diff --git a/xen/arch/riscv/p2m.c b/xen/arch/riscv/p2m.c index 703b9f4d2540..566266e3e78f 100644 --- a/xen/arch/riscv/p2m.c +++ b/xen/arch/riscv/p2m.c @@ -428,17 +428,12 @@ int p2m_init(struct domain *d, const struct xen_domct= l_createdomain *config) return 0; } =20 -/* - * Set the pool of pages to the required number of pages. - * Returns 0 for success, non-zero for failure. - * Call with d->arch.paging.lock held. - */ -int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preemp= ted) +int p2m_set_allocation(struct domain *d, unsigned long pages, bool can_pre= empt) { struct p2m_domain *p2m =3D p2m_get_hostp2m(d); int rc; =20 - if ( (rc =3D paging_freelist_adjust(d, pages, preempted)) ) + if ( (rc =3D paging_freelist_adjust(d, pages, can_preempt)) ) return rc; =20 /* diff --git a/xen/arch/riscv/paging.c b/xen/arch/riscv/paging.c index 76a203edbb0c..35f572689a7c 100644 --- a/xen/arch/riscv/paging.c +++ b/xen/arch/riscv/paging.c @@ -47,7 +47,7 @@ static int _paging_add_to_freelist(struct domain *d) } =20 int paging_freelist_adjust(struct domain *d, unsigned long pages, - bool *preempted) + bool can_preempt) { ASSERT(spin_is_locked(&d->arch.paging.lock)); =20 @@ -66,11 +66,8 @@ int paging_freelist_adjust(struct domain *d, unsigned lo= ng pages, return rc; =20 /* Check to see if we need to yield and try again */ - if ( preempted && general_preempt_check() ) - { - *preempted =3D true; + if ( can_preempt && general_preempt_check() ) return -ERESTART; - } } =20 return 0; diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tr= ee/dom0less-build.c index eacfd93087ae..6f0b574755c5 100644 --- a/xen/common/device-tree/dom0less-build.c +++ b/xen/common/device-tree/dom0less-build.c @@ -747,7 +747,7 @@ static int __init domain_p2m_set_allocation(struct doma= in *d, uint64_t mem, domain_p2m_pages(mem, d->max_vcpus); =20 spin_lock(&d->arch.paging.lock); - rc =3D p2m_set_allocation(d, p2m_pages, NULL); + rc =3D p2m_set_allocation(d, p2m_pages, /* can_preempt */ false); spin_unlock(&d->arch.paging.lock); =20 return rc; diff --git a/xen/include/xen/p2m-common.h b/xen/include/xen/p2m-common.h index f0bd9a6b9896..0eb061991283 100644 --- a/xen/include/xen/p2m-common.h +++ b/xen/include/xen/p2m-common.h @@ -43,5 +43,13 @@ int __must_check check_get_page_from_gfn(struct domain *= d, gfn_t gfn, bool readonly, p2m_type_t *p2mt_p, struct page_info **page_p); =20 +/* + * Set the pool of pages to the required number of pages. + * Returns 0 for success, -ERESTART if preempted (only when can_preempt is + * true), or a negative error code on failure. + * Call with d->arch.paging.lock held. + */ +int __must_check p2m_set_allocation(struct domain *d, unsigned long pages, + bool can_preempt); =20 #endif /* _XEN_P2M_COMMON_H */ --=20 2.54.0