[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFCv2 29/38] x86/hyperlaunch: allocate console for domu


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Date: Thu, 15 May 2025 09:19:12 -0400
  • Arc-authentication-results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@xxxxxxxxxxxxxxxxxxxx; dmarc=pass header.from=<dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747315178; 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=6T1Z5XGS9ysURjGTHl7V7vt25/W8+XJnWeYBM57YXlo=; b=g3OuP1e/3kiufNc6opq1dJnYQcLgkhbRIPeqnZCY0gmoVAPN/tmTxitz84B1YHwwnjEx/cQkLT1658jC5VqbhfIDotqXlXLqbKMpJppL0EScpW0NfNgM0M2GXdVBUutQd4drGrfUMKY+16718xMV7D8vwfwcwAeCIDcosrpsnhg=
  • Arc-seal: i=1; a=rsa-sha256; t=1747315178; cv=none; d=zohomail.com; s=zohoarc; b=RGp/50pqPKu5D8LmRJqPf2A7s3rFWp7UgP0ImR6+IvRugIYxm+NPvatduNRVxqukKK29JdobvQ8L8AoDhKiDLVHW2oSXgAFhh8wrXKAqvw/Tg1+BBmV3FJie4tujAykq67KYPyGJ6wqD1QLjXe0CftILHgNq6TpzoEmMf4D5xdE=
  • Cc: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, jason.andryuk@xxxxxxx, stefano.stabellini@xxxxxxx, agarciav@xxxxxxx, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Thu, 15 May 2025 13:33:18 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

During domU construction, a page of memory and an event channel must be setup
for the console connection. In this commit, a page from the special page region
of domU is setup as the console page along with an event channel. The page
address and event channel are published in the HVM parameters, so they may be
published in Xenstore once it is online.

Signed-off-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>

---

Changes in RFCv2:
- rewrote inline with xenstore changes for event chan
---
 xen/arch/x86/domain-builder/domain.c   | 24 +++++++++++++++++++++++-
 xen/arch/x86/hvm/dom_build.c           | 24 ++++++++++++++++++++++++
 xen/arch/x86/include/asm/boot-domain.h |  2 +-
 3 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/domain-builder/domain.c 
b/xen/arch/x86/domain-builder/domain.c
index de0ee0fcd62c..673fc5b16ed3 100644
--- a/xen/arch/x86/domain-builder/domain.c
+++ b/xen/arch/x86/domain-builder/domain.c
@@ -355,7 +355,7 @@ struct domain *__init arch_create_dom(
 int __init arch_builder_finalize(struct boot_info *bi)
 {
     unsigned int i;
-    struct boot_domain *xs_bd = NULL;
+    struct boot_domain *xs_bd = NULL, *hw_bd = NULL;
 
     i = first_boot_domain_index(bi, DOMAIN_CAPS_XENSTORE);
     if ( i > MAX_NR_BOOTDOMS )
@@ -363,6 +363,12 @@ int __init arch_builder_finalize(struct boot_info *bi)
     else
         xs_bd = &bi->domains[i];
 
+    i = first_boot_domain_index(bi, DOMAIN_CAPS_HARDWARE);
+    if ( i > MAX_NR_BOOTDOMS )
+        printk(XENLOG_WARNING "No xenstore domain configured\n");
+    else
+        hw_bd = &bi->domains[i];
+
     for ( i = 0; i < bi->nr_domains; i++ )
     {
         struct boot_domain *bd = &bi->domains[i];
@@ -382,6 +388,22 @@ int __init arch_builder_finalize(struct boot_info *bi)
                 params[HVM_PARAM_STORE_EVTCHN] = xs_evtchn;
             }
         }
+
+        if ( hw_bd && hw_bd->d && (bd != hw_bd) && bd->cons_page )
+        {
+            evtchn_port_t ec = 0;
+
+            if ( alloc_dom_evtchn(bd, hw_bd, &ec) < 0 )
+                continue;
+
+            /* Is HVM/PVH */
+            if ( !(bd->mode & BUILD_MODE_PARAVIRT) )
+            {
+                uint64_t *params = bd->d->arch.hvm.params;
+                params[HVM_PARAM_CONSOLE_PFN] = bd->cons_page;
+                params[HVM_PARAM_CONSOLE_EVTCHN] = ec;
+            }
+        }
     }
 
     /* Free temporary buffers. */
diff --git a/xen/arch/x86/hvm/dom_build.c b/xen/arch/x86/hvm/dom_build.c
index aec356cb2e46..3eab97b5288b 100644
--- a/xen/arch/x86/hvm/dom_build.c
+++ b/xen/arch/x86/hvm/dom_build.c
@@ -919,6 +919,27 @@ static int __init alloc_xenstore_page(struct boot_domain 
*bd)
     return 0;
 }
 
+static int __init alloc_console_page(struct boot_domain *bd)
+{
+    paddr_t con_addr = special_pfn(SPECIALPAGE_CONSOLE) << PAGE_SHIFT;
+    uint32_t fields[4] = { 0 };
+
+    /*
+     * Clear the xencons_interface fields that are located after a 1024 rx and
+     * a 2048 tx buffer, 3072 bytes.
+     */
+    if ( hvm_copy_to_guest_phys(con_addr + 3072, fields, sizeof(fields),
+                                bd->d->vcpu[0]) )
+    {
+        printk("Unable to set xenstore connection state\n");
+        return -EFAULT;
+    }
+
+    bd->cons_page = PFN_DOWN(con_addr);
+
+    return 0;
+}
+
 int __init dom_construct_pvh(struct boot_domain *bd)
 {
     paddr_t entry, start_info;
@@ -998,6 +1019,9 @@ int __init dom_construct_pvh(struct boot_domain *bd)
     if ( !is_xenstore_domain(bd->d) )
         alloc_xenstore_page(bd);
 
+    if ( !is_hardware_domain(bd->d) )
+        alloc_console_page(bd);
+
     if ( opt_dom0_verbose )
     {
         printk("Dom%u memory map:\n", bd->domid);
diff --git a/xen/arch/x86/include/asm/boot-domain.h 
b/xen/arch/x86/include/asm/boot-domain.h
index a527342768de..66f3a71fd597 100644
--- a/xen/arch/x86/include/asm/boot-domain.h
+++ b/xen/arch/x86/include/asm/boot-domain.h
@@ -35,7 +35,7 @@ struct boot_domain {
 
     struct domain *d;
 
-    xen_pfn_t xs_page;
+    xen_pfn_t xs_page, cons_page;
 };
 
 static inline bool __init has_dom0_caps(const struct boot_domain *bd)
-- 
2.30.2




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.