All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Smith" <dpsmith@apertussolutions.com>
To: xen-devel@lists.xenproject.org
Cc: "Daniel P. Smith" <dpsmith@apertussolutions.com>,
	jason.andryuk@amd.com, stefano.stabellini@amd.com,
	agarciav@amd.com, "Jan Beulich" <jbeulich@suse.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [RFCv2 35/38] x86/hyperlaunch: add multidomain construction logic
Date: Thu, 15 May 2025 09:19:47 -0400	[thread overview]
Message-ID: <20250515131951.5594-6-dpsmith@apertussolutions.com> (raw)
In-Reply-To: <20250515131951.5594-1-dpsmith@apertussolutions.com>

Introduce the logic to loop over boot_info->domains and construct
each valid entry in the array.

Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
---
 xen/arch/x86/domain-builder/core.c   | 30 ++++++++++++++++++++++++++++
 xen/arch/x86/domain-builder/domain.c |  7 +++++--
 xen/arch/x86/hvm/dom_build.c         |  5 ++++-
 xen/arch/x86/setup.c                 |  3 ++-
 4 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/domain-builder/core.c b/xen/arch/x86/domain-builder/core.c
index af79792b5316..367c0de33cfb 100644
--- a/xen/arch/x86/domain-builder/core.c
+++ b/xen/arch/x86/domain-builder/core.c
@@ -58,6 +58,7 @@ static int  __init build_core_domains(struct boot_info *bi)
 unsigned int __init builder_create_domains(struct boot_info *bi)
 {
     unsigned int build_count = 0;
+    int i;
 
     if ( bi->nr_domains == 0 )
         panic("%s: no domains defined\n", __func__);
@@ -70,10 +71,39 @@ unsigned int __init builder_create_domains(struct boot_info *bi)
             bi->domains[0].constructed = true;
             build_count++;
         }
+
+        goto out;
     }
     else
         build_count = build_core_domains(bi);
 
+    if ( !IS_ENABLED(CONFIG_MULTIDOMAIN_BUILDER) )
+        goto out;
+
+    for ( i = 0; i < bi->nr_domains; i++ )
+    {
+        struct boot_domain *bd = &bi->domains[i];
+
+        if ( bd->constructed )
+            continue;
+
+        if ( bd->mode & BUILD_MODE_PARAVIRT )
+        {
+            printk(XENLOG_WARNING "don't support PV DomU, skipping %d\n", i);
+            continue;
+        }
+
+        arch_create_dom(bi, bd);
+        if ( bd->d )
+        {
+            bd->constructed = true;
+            build_count++;
+        }
+        else
+            printk(XENLOG_WARNING "failed to construct build domain %d\n", i);
+    }
+
+ out:
     arch_builder_finalize(bi);
 
     return build_count;
diff --git a/xen/arch/x86/domain-builder/domain.c b/xen/arch/x86/domain-builder/domain.c
index c453629700c1..9d9901fad505 100644
--- a/xen/arch/x86/domain-builder/domain.c
+++ b/xen/arch/x86/domain-builder/domain.c
@@ -326,8 +326,11 @@ struct domain *__init arch_create_dom(
                            ((hvm_hap_supported() && !opt_dom0_shadow) ?
                             XEN_DOMCTL_CDF_hap : 0));
 
-        dom_cfg.arch.emulation_flags |=
-            XEN_X86_EMU_LAPIC | XEN_X86_EMU_IOAPIC | XEN_X86_EMU_VPCI;
+        if ( bd->capabilities & DOMAIN_CAPS_HARDWARE )
+            dom_cfg.arch.emulation_flags |=
+                XEN_X86_EMU_LAPIC | XEN_X86_EMU_IOAPIC | XEN_X86_EMU_VPCI;
+        else
+            dom_cfg.arch.emulation_flags |= X86_EMU_LAPIC;
     }
 
     if ( iommu_enabled && (bd->capabilities & DOMAIN_CAPS_HARDWARE) )
diff --git a/xen/arch/x86/hvm/dom_build.c b/xen/arch/x86/hvm/dom_build.c
index 170caac6716e..3118e3483e46 100644
--- a/xen/arch/x86/hvm/dom_build.c
+++ b/xen/arch/x86/hvm/dom_build.c
@@ -885,7 +885,10 @@ static int __init pvh_load_kernel(
     }
 
     start_info.magic = XEN_HVM_START_MAGIC_VALUE;
-    start_info.flags = SIF_PRIVILEGED | SIF_INITDOMAIN;
+    if ( is_control_domain(d) )
+        start_info.flags = SIF_PRIVILEGED;
+    if ( is_hardware_domain(d) )
+        start_info.flags = SIF_INITDOMAIN;
     rc = hvm_copy_to_guest_phys(last_addr, &start_info, sizeof(start_info), v);
     if ( rc )
     {
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 36e6ba11ddcd..422fef7ce02a 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1331,7 +1331,8 @@ void asmlinkage __init noreturn __start_xen(void)
         xen->size  = __2M_rwdata_end - _stext;
     }
 
-    arch_builder_headroom(&bi->domains[0]);
+    for ( i = 0; i < bi->nr_domains; i++ )
+        arch_builder_headroom(&bi->domains[i]);
 
 #ifndef highmem_start
     /* Don't allow split below 4Gb. */
-- 
2.30.2



  parent reply	other threads:[~2025-05-15 13:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-15 13:19 [RFCv2 30/38] x86/hyperlaunch: introduce concept of core domains Daniel P. Smith
2025-05-15 13:19 ` [RFCv2 31/38] common/gzip: add function to read isize field Daniel P. Smith
2025-05-15 13:19 ` [RFCv2 32/38] x86/hyperlaunch: move headroom under domain builder Daniel P. Smith
2025-05-15 13:19 ` [RFCv2 33/38] x86/hyperlaunch: move kernel extraction " Daniel P. Smith
2025-05-15 13:19 ` [RFCv2 34/38] x86/hyperlaunch: introduce multidomain kconfig option Daniel P. Smith
2025-05-15 13:19 ` Daniel P. Smith [this message]
2025-05-15 13:19 ` [RFCv2 36/38] x86/hyperlaunch: enable unpausing mulitple domains Daniel P. Smith
2025-05-15 13:19 ` [RFCv2 37/38] x86/hyperlaunch: generalize domid assignment Daniel P. Smith
2025-05-15 13:19 ` [RFCv2 38/38] tools: introduce hyperlaunch domain late init Daniel P. Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250515131951.5594-6-dpsmith@apertussolutions.com \
    --to=dpsmith@apertussolutions.com \
    --cc=agarciav@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jason.andryuk@amd.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=stefano.stabellini@amd.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.