#include "xenbus.h"
-static int xs_init_irq;
+static int xs_init_irq = -1;
int xen_store_evtchn;
EXPORT_SYMBOL_GPL(xen_store_evtchn);
struct xenstore_domain_interface *xen_store_interface;
EXPORT_SYMBOL_GPL(xen_store_interface);
+#define XS_INTERFACE_READY \
+ ((xen_store_interface != NULL) && \
+ (xen_store_interface->connection == XENSTORE_CONNECTED))
+
enum xenstore_init xen_store_domain_type;
EXPORT_SYMBOL_GPL(xen_store_domain_type);
{
xenstored_ready = 1;
- if (!xen_store_interface) {
+ if (!xen_store_interface)
xen_store_interface = memremap(xen_store_gfn << XEN_PAGE_SHIFT,
XEN_PAGE_SIZE, MEMREMAP_WB);
- /*
- * Now it is safe to free the IRQ used for xenstore late
- * initialization. No need to unbind: it is about to be
- * bound again from xb_init_comms. Note that calling
- * unbind_from_irqhandler now would result in xen_evtchn_close()
- * being called and the event channel not being enabled again
- * afterwards, resulting in missed event notifications.
- */
+ /*
+ * Now it is safe to free the IRQ used for xenstore late
+ * initialization. No need to unbind: it is about to be
+ * bound again from xb_init_comms. Note that calling
+ * unbind_from_irqhandler now would result in xen_evtchn_close()
+ * being called and the event channel not being enabled again
+ * afterwards, resulting in missed event notifications.
+ */
+ if (xs_init_irq >= 0)
free_irq(xs_init_irq, &xb_waitq);
- }
/*
* In the HVM case, xenbus_init() deferred its call to
if (xen_store_domain_type == XS_PV ||
(xen_store_domain_type == XS_HVM &&
!xs_hvm_defer_init_for_callback() &&
- xen_store_interface != NULL))
+ XS_INTERFACE_READY))
xenbus_probe();
/*
* started, then probe. It will be triggered when communication
* starts happening, by waiting on xb_waitq.
*/
- if (xen_store_domain_type == XS_LOCAL || xen_store_interface == NULL) {
+ if (xen_store_domain_type == XS_LOCAL || !XS_INTERFACE_READY) {
struct task_struct *probe_task;
probe_task = kthread_run(xenbus_probe_thread, NULL,
xen_store_interface =
memremap(xen_store_gfn << XEN_PAGE_SHIFT,
XEN_PAGE_SIZE, MEMREMAP_WB);
+ if (!xen_store_interface) {
+ pr_err("%s: cannot map HVM_PARAM_STORE_PFN=%llx\n",
+ __func__, v);
+ err = -EINVAL;
+ goto out_error;
+ }
if (xen_store_interface->connection != XENSTORE_CONNECTED)
wait = true;
}