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

Re: [LINUX PATCH v2 1/1] xen: add support for initializing xenstore later as HVM domain



On 13.01.22 02:00, Stefano Stabellini wrote:
From: Luca Miccio <lucmiccio@xxxxxxxxx>

When running as dom0less guest (HVM domain on ARM) the xenstore event
channel is available at domain creation but the shared xenstore
interface page only becomes available later on.

In that case, wait for a notification on the xenstore event channel,
then complete the xenstore initialization later, when the shared page
is actually available.

Signed-off-by: Luca Miccio <lucmiccio@xxxxxxxxx>
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>
---
Changes in v2:
- remove XENFEAT_xenstore_late_init
---
  drivers/xen/xenbus/xenbus_probe.c | 80 +++++++++++++++++++++++--------
  1 file changed, 61 insertions(+), 19 deletions(-)

diff --git a/drivers/xen/xenbus/xenbus_probe.c 
b/drivers/xen/xenbus/xenbus_probe.c
index fe360c33ce71..51e52e175892 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -65,6 +65,7 @@
  #include "xenbus.h"
+static int xs_init_irq;
  int xen_store_evtchn;
  EXPORT_SYMBOL_GPL(xen_store_evtchn);
@@ -750,6 +751,17 @@ static void xenbus_probe(void)
  {
        xenstored_ready = 1;
+ if (!xen_store_interface) {
+               xen_store_interface = xen_remap(xen_store_gfn << XEN_PAGE_SHIFT,
+                                               XEN_PAGE_SIZE);
+               /*
+                * Now it is safe to free the IRQ used for xenstore late
+                * initialization. No need to unbind: it is about to be
+                * bound again.
+                */
+               free_irq(xs_init_irq, &xb_waitq);
+       }
+
        /*
         * In the HVM case, xenbus_init() deferred its call to
         * xs_init() in case callbacks were not operational yet.
@@ -798,20 +810,22 @@ static int __init xenbus_probe_initcall(void)
  {
        /*
         * Probe XenBus here in the XS_PV case, and also XS_HVM unless we
-        * need to wait for the platform PCI device to come up.
+        * need to wait for the platform PCI device to come up or
+        * xen_store_interface is not ready.
         */
        if (xen_store_domain_type == XS_PV ||
            (xen_store_domain_type == XS_HVM &&
-            !xs_hvm_defer_init_for_callback()))
+            !xs_hvm_defer_init_for_callback() &&
+            xen_store_interface != NULL))
                xenbus_probe();
/*
-        * For XS_LOCAL, spawn a thread which will wait for xenstored
-        * or a xenstore-stubdom to be started, then probe. It will be
-        * triggered when communication starts happening, by waiting
-        * on xb_waitq.
+        * For XS_LOCAL or when xen_store_interface is not ready, spawn a
+        * thread which will wait for xenstored or a xenstore-stubdom to be
+        * started, then probe.  It will be triggered when communication
+        * starts happening, by waiting on xb_waitq.
         */
-       if (xen_store_domain_type == XS_LOCAL) {
+       if (xen_store_domain_type == XS_LOCAL || xen_store_interface == NULL) {
                struct task_struct *probe_task;
probe_task = kthread_run(xenbus_probe_thread, NULL,
@@ -907,6 +921,20 @@ static struct notifier_block xenbus_resume_nb = {
        .notifier_call = xenbus_resume_cb,
  };
+static irqreturn_t xenbus_late_init(int irq, void *unused)
+{
+       int err = 0;
+       uint64_t v = 0;
+
+       err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v);
+       if (err || !v || !~v)
+               return IRQ_HANDLED;
+       xen_store_gfn = (unsigned long)v;
+
+       wake_up(&xb_waitq);
+       return IRQ_HANDLED;
+}
+

Hmm, wouldn't it be easier to use a static key in the already existing
irq handler instead of switching the handler?


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


 


Rackspace

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