From nobody Fri Oct 31 23:24:43 2025 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 header.i=dpsmith@apertussolutions.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; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) ARC-Seal: i=2; a=rsa-sha256; t=1745101311; cv=pass; d=zohomail.com; s=zohoarc; b=YHdHPUmfM4A6eeFdHT2KAq/AFP3w4JFYamVeWkNI0keKYcbOvHbsweitxCIzpSUGeiD3uvfmWutKG447DSEGygLDk4rHkHDiw7wpClUjvQddmieHj7Ae88B+yayVsp8duhWBsb1vpnYPzFjs0ksqjjFXPzkET47Axo0xYisA46s= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745101311; 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=oYA+q2bu6uUk9qzE25f2Pzdoh1C0vsI/Nr7Od6zvzCs=; b=Si3jvFkgvyfADOTZy3pwEwoUup4x7SbqskI+/3JD/ntBMfPfQuc4NpD/chzdUURfUnn2B5dVjFNRtG09SMPT2KCHCNtJgeaz8L3HYuVzk/ioycLMx0j8E9wJt9Fv5/6vWvF0WMvqZRuE3cgfyJ5PwHVaaTQWoj9GQdg9ruEFFHo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=dpsmith@apertussolutions.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; arc=pass (i=1 dmarc=pass fromdomain=apertussolutions.com) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1745101311130553.9395893344871; Sat, 19 Apr 2025 15:21:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.960264.1352373 (Exim 4.92) (envelope-from ) id 1u6GZ0-0005tf-KT; Sat, 19 Apr 2025 22:21:30 +0000 Received: by outflank-mailman (output) from mailman id 960264.1352373; Sat, 19 Apr 2025 22:21:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u6GZ0-0005tB-FU; Sat, 19 Apr 2025 22:21:30 +0000 Received: by outflank-mailman (input) for mailman id 960264; Sat, 19 Apr 2025 22:21:29 +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 1u6GOp-0004yY-VT for xen-devel@lists.xenproject.org; Sat, 19 Apr 2025 22:10:59 +0000 Received: from sender4-of-o50.zoho.com (sender4-of-o50.zoho.com [136.143.188.50]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2acc19f6-1d6b-11f0-9eb0-5ba50f476ded; Sun, 20 Apr 2025 00:10:58 +0200 (CEST) Received: by mx.zohomail.com with SMTPS id 1745100530991699.508073613059; Sat, 19 Apr 2025 15:08:50 -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" X-Inumbo-ID: 2acc19f6-1d6b-11f0-9eb0-5ba50f476ded ARC-Seal: i=1; a=rsa-sha256; t=1745100533; cv=none; d=zohomail.com; s=zohoarc; b=TI47jSbImDojj0GoQCgsne6LcAcZPiY8E6rV68o5qK2N1XTsj8kbYgfM6Ox/0ew1TZEns4tb77pjlEZzYXJU2AsclfkUMh5YSR3DzPcLiPMlQipLLFePTvlAk9hH4QjxnedyQMP6vOzOC5MGYAStjz486RBGz/AjzRzniHCujlk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745100533; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=oYA+q2bu6uUk9qzE25f2Pzdoh1C0vsI/Nr7Od6zvzCs=; b=QjwyOaC4kX8OZDeQWWm7/p/Rkq21KDVq1D4NqliOJI7lQmEj/PrIIWmEkvQWtAj35nZMfuKjc7QLrNJEGjVFOKjPBWJGiMPcSRQCrCZSTVSAwgHoYwJo8ZltpXv32ab+Coo/zNm3PVXsz8NWwPm+7fT77CWz2ObYZCpfxIwBQQk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1745100533; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-Id:Message-Id:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Reply-To; bh=oYA+q2bu6uUk9qzE25f2Pzdoh1C0vsI/Nr7Od6zvzCs=; b=Y3y8tM7Hzyn6awXzgbx8ZPcZshgVrY8EL+1GoPXJS2W9iEy/J9M5beqXh2mH4QVR 3+Oous/KS8lqEOelc35XwbVERRSWwJscnli7KwYPwTmWM0eHup1doyWyNAQmWEdUEc/ HXI0ynDLq1yWnpzfyp/PrM//EaXlFmsdH2W37uA8= From: "Daniel P. Smith" To: xen-devel@lists.xenproject.org Cc: "Daniel P. Smith" , jason.andryuk@amd.com, stefano.stabellini@amd.com, agarciav@amd.com, Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [RFC 14/38] x86/hyperlaunch: move pvh p2m init to domain builder Date: Sat, 19 Apr 2025 18:07:56 -0400 Message-Id: <20250419220820.4234-15-dpsmith@apertussolutions.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250419220820.4234-1-dpsmith@apertussolutions.com> References: <20250419220820.4234-1-dpsmith@apertussolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-ZohoMail-DKIM: pass (identity dpsmith@apertussolutions.com) X-ZM-MESSAGEID: 1745101313247019000 Content-Type: text/plain; charset="utf-8" Generalize pvh_init_p2m() for use on domU and relocate under the domain builder. To support moving the function, dom0_pvh_setup_e820() was exported. Signed-off-by: Daniel P. Smith --- xen/arch/x86/hvm/dom0_build.c | 23 +---------------------- xen/arch/x86/hvm/dom_build.c | 25 +++++++++++++++++++++++++ xen/arch/x86/include/asm/dom0_build.h | 2 ++ 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index f59af0e72810..4a371dfd66d7 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -323,7 +323,7 @@ static int __init pvh_setup_vmx_realmode_helpers(struct= domain *d) return 0; } =20 -static __init void pvh_setup_e820(struct domain *d, unsigned long nr_pages) +void __init dom0_pvh_setup_e820(struct domain *d, unsigned long nr_pages) { struct e820entry *entry, *entry_guest; unsigned int i; @@ -399,20 +399,6 @@ static __init void pvh_setup_e820(struct domain *d, un= signed long nr_pages) ASSERT(cur_pages =3D=3D nr_pages); } =20 -static void __init pvh_init_p2m(struct boot_domain *bd) -{ - unsigned long nr_pages =3D dom_compute_nr_pages(bd, NULL); - bool preempted; - - pvh_setup_e820(bd->d, nr_pages); - do { - preempted =3D false; - paging_set_allocation(bd->d, dom_paging_pages(bd, nr_pages), - &preempted); - process_pending_softirqs(); - } while ( preempted ); -} - static int __init pvh_populate_p2m(struct domain *d) { struct vcpu *v =3D d->vcpu[0]; @@ -1319,13 +1305,6 @@ int __init dom0_construct_pvh(struct boot_domain *bd) struct domain *d =3D bd->d; int rc; =20 - /* - * Craft dom0 physical memory map and set the paging allocation. This = must - * be done before the iommu initializion, since iommu initialization c= ode - * will likely add mappings required by devices to the p2m (ie: RMRRs). - */ - pvh_init_p2m(bd); - iommu_hwdom_init(d); =20 rc =3D pvh_populate_p2m(d); diff --git a/xen/arch/x86/hvm/dom_build.c b/xen/arch/x86/hvm/dom_build.c index b6e534226434..05064ae9ba96 100644 --- a/xen/arch/x86/hvm/dom_build.c +++ b/xen/arch/x86/hvm/dom_build.c @@ -10,13 +10,16 @@ =20 #include #include +#include #include =20 #include =20 #include #include +#include #include +#include #include =20 static void __hwdom_init pvh_setup_mmcfg(struct domain *d) @@ -37,6 +40,20 @@ static void __hwdom_init pvh_setup_mmcfg(struct domain *= d) } } =20 +static void __init pvh_init_p2m(struct boot_domain *bd) +{ + unsigned long nr_pages =3D dom_compute_nr_pages(bd, NULL); + bool preempted; + + dom0_pvh_setup_e820(bd->d, nr_pages); + do { + preempted =3D false; + paging_set_allocation(bd->d, dom_paging_pages(bd, nr_pages), + &preempted); + process_pending_softirqs(); + } while ( preempted ); +} + int __init dom_construct_pvh(struct boot_domain *bd) { int rc; @@ -67,6 +84,14 @@ int __init dom_construct_pvh(struct boot_domain *bd) } } =20 + /* + * Craft domain physical memory map and set the paging allocation. This + * must be done before the iommu initializion, since iommu initializat= ion + * code will likely add mappings required by devices to the p2m (ie: + * RMRRs). + */ + pvh_init_p2m(bd); + return dom0_construct_pvh(bd); } =20 diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/a= sm/dom0_build.h index 43a402af15b7..e5debd5adf9f 100644 --- a/xen/arch/x86/include/asm/dom0_build.h +++ b/xen/arch/x86/include/asm/dom0_build.h @@ -18,6 +18,8 @@ void calculate_dom0_pages(struct boot_domain *bd, unsigne= d long avail); void dom0_pv_restrict_pages( struct boot_domain *bd, struct elf_dom_parms *parms); =20 +void dom0_pvh_setup_e820(struct domain *d, unsigned long nr_pages); + int dom0_construct_pv(struct boot_domain *bd); int dom0_construct_pvh(struct boot_domain *bd); =20 --=20 2.30.2