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

[RFC 30/38] x86/hyperlaunch: allocate xenstore for domu


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Date: Sat, 19 Apr 2025 18:08: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=1745100571; 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=xTTdPfDolfNjAS0Qvmz0FxzFVp9V69k5pb2zgYetYhg=; b=PI1y5fbyqhMuuMmwVBO8UJrEUHmh4QVtiKXtKZhnR+yLI2gVTRsAGHtg/UaQ9XUMqwPw+NE/Oq77sRiKnZl4hcuH0BpDY1Cd57xEZCsZ0WEEzgnLybG0nUozddfdJsiKEVuv6O0uej/qnY/vNbEo3qWTOpxVUwB6SnQNoHiVtes=
  • Arc-seal: i=1; a=rsa-sha256; t=1745100571; cv=none; d=zohomail.com; s=zohoarc; b=anWjUrDEW6/RaRHcc8BAKESuY1HNFS30V8ANqIDZoiceXVZn27xsv2RbJGuRHjZ0IaHMwVcRu+7zVHlohroibwI22bER1d9BKQ7UmDclWChyY9EIMIqYzJx3bcF8Ub6dIFllkJMVDwY9r8kMt1rizFTKJ9Xgl0TtBN96UMxFTEQ=
  • 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: Sat, 19 Apr 2025 22:21:25 +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 xenstore connection. In this commit, a page from the special page region of
domU is setup as the xenstore page along with an event channel. The page
address and event channel are published in the HVM parameters, so the domain
can be announced to Xenstore.

Signed-off-by: Daniel P. Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
---
 xen/arch/x86/domain-builder/domain.c   | 38 ++++++++++++++++++++++++--
 xen/arch/x86/hvm/dom_build.c           | 32 ++++++++++++++++++++++
 xen/arch/x86/include/asm/boot-domain.h |  2 +-
 3 files changed, 69 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/domain-builder/domain.c 
b/xen/arch/x86/domain-builder/domain.c
index 7ce069a57c5d..b413a87cc9c9 100644
--- a/xen/arch/x86/domain-builder/domain.c
+++ b/xen/arch/x86/domain-builder/domain.c
@@ -240,6 +240,38 @@ static int __init alloc_console_evtchn(
     return 0;
 }
 
+static int __init alloc_store_evtchn(
+    const struct boot_info *bi, struct boot_domain *bd)
+{
+    evtchn_alloc_unbound_t evtchn_req;
+    const struct boot_domain *xsdom;
+    int idx, rc;
+
+    idx = first_boot_domain_index(bi, BUILD_CAPS_XENSTORE);
+    if ( idx < 0 )
+    {
+        printk(XENLOG_WARNING "No backing xenstore domain for %pdv\n",
+               bd->d);
+        return -EINVAL;
+    }
+
+    if ( bi->domains[idx].d )
+        xsdom = &bi->domains[idx];
+    else
+    {
+        printk(XENLOG_WARNING "Xenstore domain for %pd console not 
constructed\n",
+               bd->d);
+        return -EINVAL;
+    }
+
+    if ( (rc = alloc_dom_evtchn(bd, xsdom, &evtchn_req)) < 0 )
+        return rc;
+
+    bd->store.evtchn = evtchn_req.port;
+
+    return 0;
+}
+
 static size_t __init domain_cmdline_size(
     struct boot_info *bi, struct boot_domain *bd)
 {
@@ -362,8 +394,10 @@ struct domain *__init arch_create_dom(
         bd->cmdline = cmdline;
     }
 
-   if ( !(bd->capabilities & BUILD_CAPS_HARDWARE) )
-       alloc_console_evtchn(bi, bd);
+    if ( !(bd->capabilities & BUILD_CAPS_XENSTORE) )
+        alloc_store_evtchn(bi, bd);
+    if ( !(bd->capabilities & BUILD_CAPS_HARDWARE) )
+        alloc_console_evtchn(bi, bd);
 
     if ( construct_dom0(bd) != 0 )
         panic("Could not construct domain 0\n");
diff --git a/xen/arch/x86/hvm/dom_build.c b/xen/arch/x86/hvm/dom_build.c
index 934ae138e58f..2798542e5483 100644
--- a/xen/arch/x86/hvm/dom_build.c
+++ b/xen/arch/x86/hvm/dom_build.c
@@ -930,6 +930,35 @@ static int __init alloc_console_page(struct boot_domain 
*bd)
     return 0;
 }
 
+static int __init alloc_xenstore_page(struct boot_domain *bd)
+{
+    paddr_t xs_addr = special_pfn(SPECIALPAGE_XENSTORE) << PAGE_SHIFT;
+    uint32_t fields[7] = { 0, 0, 0, 0, 0, 1, 0};
+
+    if ( !port_is_valid(bd->d, bd->store.evtchn) )
+    {
+        printk("No event channel available for %pd xenstore\n", bd->d);
+        return -EINVAL;
+    }
+
+    /*
+     * Set connection field to XENSTORE_RECONNECT, where the
+     * xenstore_domain_interface fields are located after the 2 1024 buffers
+     */
+    if ( hvm_copy_to_guest_phys(xs_addr + 2048, fields, sizeof(fields),
+                                bd->d->vcpu[0]) )
+    {
+        printk("Unable to set xenstore connection state\n");
+        return -EFAULT;
+    }
+
+    bd->store.gfn = gfn_x(gaddr_to_gfn(xs_addr));
+    bd->d->arch.hvm.params[HVM_PARAM_STORE_PFN] = bd->store.gfn;
+    bd->d->arch.hvm.params[HVM_PARAM_STORE_EVTCHN] = bd->store.evtchn;
+
+    return 0;
+}
+
 int __init dom_construct_pvh(struct boot_domain *bd)
 {
     paddr_t entry, start_info;
@@ -1009,6 +1038,9 @@ int __init dom_construct_pvh(struct boot_domain *bd)
     if ( !is_hardware_domain(bd->d) )
         alloc_console_page(bd);
 
+    if ( !is_xenstore_domain(bd->d) )
+        alloc_xenstore_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 cb6e1fab23ba..df2bfa0c94fa 100644
--- a/xen/arch/x86/include/asm/boot-domain.h
+++ b/xen/arch/x86/include/asm/boot-domain.h
@@ -41,7 +41,7 @@ struct boot_domain {
     struct {
         xen_pfn_t gfn;
         evtchn_port_t evtchn;
-    } console;
+    } console, store;
 };
 
 #endif
-- 
2.30.2




 


Rackspace

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