From nobody Mon Feb 9 16:02:59 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=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1703079878; cv=none; d=zohomail.com; s=zohoarc; b=XqeUut2Wuz7leNMtZcn9MPcPts0h/Z8IA2HfcWsK9XK3aARtv/CJnwi1Ar7M0RVopmcLLGZgbjGONI5bwA3T++UaueK3F4eFNTFOtx35KGNpY0KQlDqesfUotgPe2pmgi/N5sHrUYJlksYQ4iEQRRUTlry3W2Tdb0xyR2tw1J5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703079878; 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=Zpl/pvdAy8I8bWYC4wJLs2ijp/eL3QlGcKk+qyRQerA=; b=KcZ66yeEpHklL7DIMDVku9YVi+N2VlQkwW8kxWANxVL1yTsG+8FdZ+oEXgHA1tgaN8SSISIgfijRBen+3ojvIXzA9IKmHtpt+Zm+/HP385TNsxGsZR/xD+bQ1AsOFJBQ968ldGlji047/R0f7FvnY8gbwxRdAjLgdj4r9XHf17U= 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1703079878088479.46603086464586; Wed, 20 Dec 2023 05:44:38 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.657803.1026911 (Exim 4.92) (envelope-from ) id 1rFws1-0003WF-QT; Wed, 20 Dec 2023 13:44:21 +0000 Received: by outflank-mailman (output) from mailman id 657803.1026911; Wed, 20 Dec 2023 13:44:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFws1-0003W8-Ng; Wed, 20 Dec 2023 13:44:21 +0000 Received: by outflank-mailman (input) for mailman id 657803; Wed, 20 Dec 2023 13:44:20 +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 1rFws0-0003Gg-41 for xen-devel@lists.xenproject.org; Wed, 20 Dec 2023 13:44:20 +0000 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [2a00:1450:4864:20::332]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id dff00579-9f3d-11ee-98eb-6d05b1d4d9a1; Wed, 20 Dec 2023 14:44:19 +0100 (CET) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40c3f68b69aso52860885e9.1 for ; Wed, 20 Dec 2023 05:44:19 -0800 (PST) Received: from localhost ([213.195.127.70]) by smtp.gmail.com with ESMTPSA id j7-20020a05600c190700b0040c31bb66dcsm7358017wmq.20.2023.12.20.05.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:44:18 -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: dff00579-9f3d-11ee-98eb-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1703079859; x=1703684659; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zpl/pvdAy8I8bWYC4wJLs2ijp/eL3QlGcKk+qyRQerA=; b=kDQlau0wZiiBYgVozWyESQ92D6TBhtDU8WSUeJI0QMfPNJEb7IMSN3HUmdwkBwIU+U SkeyR1Jermk4WppxRFWJDESdXbUFUs1jr1qLRaV+xcJ/OKf9c/p4zNGe5gkccZ5nB/Nw hd8JaSnPDtRbnidsPOVAtesmKze87YrXkqeJY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703079859; x=1703684659; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Zpl/pvdAy8I8bWYC4wJLs2ijp/eL3QlGcKk+qyRQerA=; b=n2Ax0z5gvdwBlTjUR8TSu8JIRcwAgnRpkjpy6ywLM8iXZFATOYzmPKuC8kMwi0818w 47PTkVaTd3u18wMvWaZ05T3RUIB4p/i67o1ID4a9xGN59fQtXTYIUlfIv5DlUl147T1u +J1rm3U2M1TLC+1PC0C3/cS0quJLOTvDs9E8o3fzd1dqcHawbRnnUNbrKEdMm09kZ2pG jyD/aSX+n9OWh6pm6bwRVFVAS8avv8CrV3D+XHoz4EnG+3aXb9bKUnBCOYhjxaypbZLH 47KRjlmxkQxhY7vD3e6k+CTOouaPAskXvuZC3DQLqDUwpnrqjmJ7taxC32qbzDOShdpq SfbQ== X-Gm-Message-State: AOJu0YznZtIDAveDsfyzbNCxkpIddksl1bv3UZaOoTPzHVg1Frj06IB9 P9+dAmMTFMR68uPw8N/JFvj2daf8czZGEwVXmno= X-Google-Smtp-Source: AGHT+IGaL4PDOlk862SoqaXg6gAIMGnT4q/dB5L8eKzSmHI0ZJOyu/L0M49PPpwy3+Z2dV1dCBMSHw== X-Received: by 2002:a05:600c:3411:b0:409:79df:7f9c with SMTP id y17-20020a05600c341100b0040979df7f9cmr13537926wmp.36.1703079858702; Wed, 20 Dec 2023 05:44:18 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Wei Liu Subject: [PATCH v4 1/6] x86/p2m: move and rename paging_max_paddr_bits() Date: Wed, 20 Dec 2023 14:43:41 +0100 Message-ID: <20231220134346.22430-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231220134346.22430-1-roger.pau@citrix.com> References: <20231220134346.22430-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1703079879849100003 The function also supports non-paging domains, and hence it being placed in p2m.h and named with the paging_ prefix is misleading. Move to x86 domain.c and rename to domain_max_paddr_bits(). Moving to a different header is non trivial, as the function depends on helpers declare= d in p2m.h. There's no performance reason for the function being inline. Note the function is safe to use against PV or system domains, as it does c= heck whether the domain is using external paging, and if not the returned physic= al address width is the host (native) value. No functional change intended. Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since v3: - Expand changelog. Changes since v2: - New in this version. --- xen/arch/x86/cpu-policy.c | 2 +- xen/arch/x86/domain.c | 21 +++++++++++++++++++++ xen/arch/x86/include/asm/domain.h | 3 +++ xen/arch/x86/include/asm/paging.h | 22 ---------------------- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c index 423932bc13d6..76efb050edf7 100644 --- a/xen/arch/x86/cpu-policy.c +++ b/xen/arch/x86/cpu-policy.c @@ -864,7 +864,7 @@ void recalculate_cpuid_policy(struct domain *d) =20 p->extd.maxphysaddr =3D min(p->extd.maxphysaddr, max->extd.maxphysaddr= ); p->extd.maxphysaddr =3D min_t(uint8_t, p->extd.maxphysaddr, - paging_max_paddr_bits(d)); + domain_max_paddr_bits(d)); p->extd.maxphysaddr =3D max_t(uint8_t, p->extd.maxphysaddr, (p->basic.pae || p->basic.pse36) ? 36 : 32= ); =20 diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 3712e36df930..8a31d18f6967 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -2552,6 +2552,27 @@ static int __init cf_check init_vcpu_kick_softirq(vo= id) } __initcall(init_vcpu_kick_softirq); =20 +unsigned int domain_max_paddr_bits(const struct domain *d) +{ + unsigned int bits =3D paging_mode_hap(d) ? hap_paddr_bits : paddr_bits; + + if ( paging_mode_external(d) ) + { + if ( !IS_ENABLED(CONFIG_BIGMEM) && paging_mode_shadow(d) ) + { + /* Shadowed superpages store GFNs in 32-bit page_info fields. = */ + bits =3D min(bits, 32U + PAGE_SHIFT); + } + else + { + /* Both p2m-ept and p2m-pt only support 4-level page tables. */ + bits =3D min(bits, 48U); + } + } + + return bits; +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/d= omain.h index 4b6b7ceab1ed..622d22bef255 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -777,6 +777,9 @@ static inline void pv_inject_sw_interrupt(unsigned int = vector) struct arch_vcpu_io { }; =20 +/* Maxphysaddr supportable by the paging infrastructure. */ +unsigned int domain_max_paddr_bits(const struct domain *d); + #endif /* __ASM_DOMAIN_H__ */ =20 /* diff --git a/xen/arch/x86/include/asm/paging.h b/xen/arch/x86/include/asm/p= aging.h index 76162a9429ce..8a2a0af40874 100644 --- a/xen/arch/x86/include/asm/paging.h +++ b/xen/arch/x86/include/asm/paging.h @@ -336,28 +336,6 @@ static inline bool gfn_valid(const struct domain *d, g= fn_t gfn) return !(gfn_x(gfn) >> (d->arch.cpuid->extd.maxphysaddr - PAGE_SHIFT)); } =20 -/* Maxphysaddr supportable by the paging infrastructure. */ -static always_inline unsigned int paging_max_paddr_bits(const struct domai= n *d) -{ - unsigned int bits =3D paging_mode_hap(d) ? hap_paddr_bits : paddr_bits; - - if ( paging_mode_external(d) ) - { - if ( !IS_ENABLED(CONFIG_BIGMEM) && paging_mode_shadow(d) ) - { - /* Shadowed superpages store GFNs in 32-bit page_info fields. = */ - bits =3D min(bits, 32U + PAGE_SHIFT); - } - else - { - /* Both p2m-ept and p2m-pt only support 4-level page tables. */ - bits =3D min(bits, 48U); - } - } - - return bits; -} - #endif /* XEN_PAGING_H */ =20 /* --=20 2.43.0