From nobody Mon Nov 23 22:39:57 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=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1792762034; cv=none; d=zohomail.com; s=zohoarc; b=T3OKP4Hy2zU8LkOWAvm7lhqvX2ozByHXtzh1eQClQKSdDQQWgYsSevsX4sCpPL2jpn9aBxlPro4NO/feneMkPRSUQJnCQpnJt16bxZub2/Qnbq21d5OIupyELq0PqDGTYx9P9hKPWyfK8gbDmwss451OZEfWwm2jhtoD4d03vUo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792762034; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=re9ZAESsuhqaUOS9sdfxyzW0120b+/xqwVtfLS0UtFg=; b=Z/e/8fw3QXvF7CA37FRRYq95HJy5XlAndPTc1L0TENw9XFZOS+ULMxcCNl3HbrRqzX4P/pw6yD0CwtfE9wac0m4XwnHRKY/A6Oe5iPU/X1TAp9DkmthKEIPYQ6CH6UB0c1niE0wpaFyPgW60RNR3pwf3FfHcmNjKE7fNXazLF60= 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 1792762033929547.884315088201; Fri, 23 Oct 2026 06:27:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1459266.1671257 (Exim 4.92) (envelope-from ) id 1xKFIO-0000Vp-9T; Fri, 23 Oct 2026 13:26:56 +0000 Received: by outflank-mailman (output) from mailman id 1459266.1671257; Fri, 23 Oct 2026 13:26:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xKFIO-0000Vi-6O; Fri, 23 Oct 2026 13:26:56 +0000 Received: by outflank-mailman (input) for mailman id 1459266; Fri, 23 Oct 2026 13:26:54 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xKFIM-0000Vc-QP for xen-devel@lists.xenproject.org; Fri, 23 Oct 2026 13:26:54 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xKFIM-005ljS-3F for xen-devel@lists.xenproject.org; Fri, 23 Oct 2026 15:26:54 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6adb607c-2eae-0a2a0a5409dd-0a2a4505c68c-40 for ; Fri, 23 Oct 2026 15:26:54 +0200 Received: from [185.255.28.35] (helo=prod-mta-13-02.swg-srv.net) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6adb609d-4cb1-0a2a45050019-b9ff1c2399d3-3 for ; Fri, 23 Oct 2026 15:26:53 +0200 Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr) (Authenticated sender: 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e) by prod-mta-13-02.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id 1a168f1512b000f79f.006 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Fri, 23 Oct 2026 13:26:47 +0000 Received: from julian.home (82-67-211-29.subs.proxad.net [82.67.211.29]) (Authenticated sender: julian.vetter@vates.tech) by mail2.vates.fr (Postfix) with ESMTPSA id AEE5480A2A; Fri, 23 Oct 2026 15:26:46 +0200 (CEST) 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=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; q=dns/txt; s=selector1; bh=re9ZAESsuhqaUOS9sdfxyzW0120b+/xqwVtfLS0UtFg=; h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id; b=i9rWkB2YjymCIgcgL+XYZRPxNR2ZRsIoB8UjwFcb1tWHb1+0Xp31xDhQTs23NoycAwP8Rixcx JKd8aSnKkgdtD+48Kc/wMrf33SdmWoZ7lT0iBfBj/i3Zrlg8fGyd8sN6gI4iBZ+0XhkmN//Ho2o 3weaVX2ac2tknuSUeL84zb9azkaREU6zFwYSYCgkWpfHgNhskAvmfHYA3+tVJN9wJUaHCdQ3+Ea lOa7/RlrAJ6/uKcNgjNy9r6VlRMfLmxqV1cohmOtpJKQLxcTIaI54iTNlk9LesxKzBqE09kdLzV P6VrK5lTq7Am1T6ZfRAZuXwcOlfA4KgZgqWL2z9SL//w== X-Zone-Loop: ec95b261c6fa3f38a73a2fe4a982453fc5cff748966b x-campaign-type: default x-transaction-id: 043b4718-86d1-40fa-917f-a3913b4ee4b0 x-swg-uid: 01-ce508661-b39b-40de-a137-8938f36bd21d X-Mailer: Sweego Message-ID: <1792762007.8631fc262581453bbf619ec5b2062170.1a168f1512b000f79f@vates.tech> x-swg-bid: 1792762007.8631fc262581453bbf619ec5b2062170.1a168f1512b000f79f Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Julian Vetter To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Julian Vetter Subject: [PATCH v2 1/1] xen/arm: populate a default P2M pool for new domains Date: Fri, 23 Oct 2026 15:26:41 +0200 In-Reply-To: <1792761821.8631fc262581453bbf619ec5b2062170.1a168ee7993000f79f@vates.tech> References: <1792761821.8631fc262581453bbf619ec5b2062170.1a168ee7993000f79f@vates.tech> MIME-Version: 1.0 X-BM-Disclaimer: Yes Content-Type: multipart/alternative; boundary="-=Part.184.f70550542212459d.1a168f14ed4.f5dadc22baa78df7=-" X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1792762007253 X-purgate-ID: tlsNG-c201ff/1792762014-F6EB12A1-DC48A2DF/0/0 X-purgate-type: clean X-purgate-size: 5473 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1792762035676158500 ---=Part.184.f70550542212459d.1a168f14ed4.f5dadc22baa78df7=- Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" On x86, a domain can be populated directly after the XEN_DOMCTL_createdomain call. Sizing the pool is thus an optional tuning step for the toolstack (libxl: "the Xen minimum is for safety, not performance"). On ARM however, the P2M pool of a non-hardware domain starts empty. So, any toolstack must size the pool before populating the domain's physmap, otherwise no P2M tables can be allocated. This is an ARM specific step, which every toolstack has to know about. Instead, populate a default pool in p2m_init(). Ideally, it would match the formula used by dom0less (domain_p2m_pages()) and libxl (libxl__get_required_paging_memory()), but that depends on the amount of RAM for the given domain, which isn't known at domain creation. So, use the calculation but without depending on the amount of RAM for the domain, i.e., 1MByte per vCPU, plus 512KBytes for the extended regions. Then dom0less and libxl set the full size, as they do today. Skip the hardware domain, which has no dedicated P2M pool. Also skip LLC colored setups, as the domain's colors are only configured after domain creation, so the pool pages would be allocated with the default colors. Signed-off-by: Julian Vetter --- Changes in v2: - Size the default pool based on the exisiting formula - Rewrite commit message to explain why a default pool is desirable --- xen/arch/arm/mmu/p2m.c | 24 ++++++++++++++++++++++++ xen/common/device-tree/dom0less-build.c | 7 +------ xen/include/xen/domain.h | 13 +++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/mmu/p2m.c b/xen/arch/arm/mmu/p2m.c index 2cf35d8a37..d4971ba8d9 100644 --- a/xen/arch/arm/mmu/p2m.c +++ b/xen/arch/arm/mmu/p2m.c @@ -3,7 +3,10 @@ #include #include #include +#include +#include #include +#include #include =20 #include @@ -1541,6 +1544,27 @@ int p2m_init(struct domain *d) if ( rc ) return rc; =20 + /* + * Populate the P2M pages pool here. So, the domain is usable without = the + * pool being sized first, as on x86. The toolstack, or dom0less, still + * sets the full size later. + * + * Skip the hardware domain, which has no dedicated P2M pool, and LLC + * colored setups, as the domain's colors are only configured after do= main + * creation. + */ + if ( !is_hardware_domain(d) && !llc_coloring_enabled ) + { + unsigned long pages =3D + PFN_DOWN(domain_p2m_default_kb(0, d->max_vcpus) * SZ_1K); + + spin_lock(&d->arch.paging.lock); + rc =3D p2m_set_allocation(d, pages, /* can_preempt */ false); + spin_unlock(&d->arch.paging.lock); + if ( rc ) + return rc; + } + return 0; } =20 diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tr= ee/dom0less-build.c index fcb438c50a..21a13f9370 100644 --- a/xen/common/device-tree/dom0less-build.c +++ b/xen/common/device-tree/dom0less-build.c @@ -737,12 +737,7 @@ static void __init domain_vcpu_affinity(struct domain = *d, static unsigned long __init domain_p2m_pages(unsigned long maxmem_kb, unsigned int smp_cpus) { - /* - * Keep in sync with libxl__get_required_paging_memory(). - * 256 pages (1MB) per vcpu, plus 1 page per MiB of RAM for the P2M ma= p, - * plus 128 pages to cover extended regions. - */ - unsigned long memkb =3D 4 * (256 * smp_cpus + (maxmem_kb / 1024) + 128= ); + unsigned long memkb =3D domain_p2m_default_kb(maxmem_kb, smp_cpus); =20 BUILD_BUG_ON(PAGE_SIZE !=3D SZ_4K); =20 diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index aeb8b36ad1..74dee32fb9 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -132,6 +132,19 @@ int default_initialise_vcpu(struct vcpu *v, XEN_GUEST_= HANDLE_PARAM(void) arg); int arch_get_paging_mempool_size(struct domain *d, uint64_t *size /* bytes= */); int arch_set_paging_mempool_size(struct domain *d, uint64_t size /* bytes = */); =20 +/* + * Default size of the P2M pool, in KBytes, for a domain with the given am= ount + * of RAM and number of vCPUs. + * Keep in sync with libxl__get_required_paging_memory(). + * 256 pages (1MB) per vCPU, plus 1 page per MiB of RAM for the P2M map, + * plus 128 pages to cover extended regions. + */ +static inline unsigned long domain_p2m_default_kb(unsigned long maxmem_kb, + unsigned int nr_vcpus) +{ + return 4 * (256 * nr_vcpus + (maxmem_kb / 1024) + 128); +} + #else /* !CONFIG_ARCH_PAGING_MEMPOOL */ =20 static inline int arch_get_paging_mempool_size(struct domain *d, uint64_t = *size) --=20 2.53.0 --=20 Julian Vetter | Vates Hypervisor & Kernel Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech ---=Part.184.f70550542212459d.1a168f14ed4.f5dadc22baa78df7=---