Commit ecc635f9 authored by Stefano Stabellini's avatar Stefano Stabellini Committed by Konrad Rzeszutek Wilk

xen/arm: compile and run xenbus

bind_evtchn_to_irqhandler can legitimately return 0 (irq 0): it is not
an error.

If Linux is running as an HVM domain and is running as Dom0, use
xenstored_local_init to initialize the xenstore page and event channel.

Changes in v4:
- do not xs_reset_watches on dom0.

Changes in v2:
- refactor xenbus_init.
Signed-off-by: default avatarStefano Stabellini <stefano.stabellini@eu.citrix.com>
[v5: Fixed case switch indentations]
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
parent e58f5b55
...@@ -224,7 +224,7 @@ int xb_init_comms(void) ...@@ -224,7 +224,7 @@ int xb_init_comms(void)
int err; int err;
err = bind_evtchn_to_irqhandler(xen_store_evtchn, wake_waiting, err = bind_evtchn_to_irqhandler(xen_store_evtchn, wake_waiting,
0, "xenbus", &xb_waitq); 0, "xenbus", &xb_waitq);
if (err <= 0) { if (err < 0) {
printk(KERN_ERR "XENBUS request irq failed %i\n", err); printk(KERN_ERR "XENBUS request irq failed %i\n", err);
return err; return err;
} }
......
...@@ -719,17 +719,47 @@ static int __init xenstored_local_init(void) ...@@ -719,17 +719,47 @@ static int __init xenstored_local_init(void)
return err; return err;
} }
enum xenstore_init {
UNKNOWN,
PV,
HVM,
LOCAL,
};
static int __init xenbus_init(void) static int __init xenbus_init(void)
{ {
int err = 0; int err = 0;
enum xenstore_init usage = UNKNOWN;
uint64_t v = 0;
if (!xen_domain()) if (!xen_domain())
return -ENODEV; return -ENODEV;
xenbus_ring_ops_init(); xenbus_ring_ops_init();
if (xen_hvm_domain()) { if (xen_pv_domain())
uint64_t v = 0; usage = PV;
if (xen_hvm_domain())
usage = HVM;
if (xen_hvm_domain() && xen_initial_domain())
usage = LOCAL;
if (xen_pv_domain() && !xen_start_info->store_evtchn)
usage = LOCAL;
if (xen_pv_domain() && xen_start_info->store_evtchn)
xenstored_ready = 1;
switch (usage) {
case LOCAL:
err = xenstored_local_init();
if (err)
goto out_error;
xen_store_interface = mfn_to_virt(xen_store_mfn);
break;
case PV:
xen_store_evtchn = xen_start_info->store_evtchn;
xen_store_mfn = xen_start_info->store_mfn;
xen_store_interface = mfn_to_virt(xen_store_mfn);
break;
case HVM:
err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
if (err) if (err)
goto out_error; goto out_error;
...@@ -738,18 +768,12 @@ static int __init xenbus_init(void) ...@@ -738,18 +768,12 @@ static int __init xenbus_init(void)
if (err) if (err)
goto out_error; goto out_error;
xen_store_mfn = (unsigned long)v; xen_store_mfn = (unsigned long)v;
xen_store_interface = ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE); xen_store_interface =
} else { ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE);
xen_store_evtchn = xen_start_info->store_evtchn; break;
xen_store_mfn = xen_start_info->store_mfn; default:
if (xen_store_evtchn) pr_warn("Xenstore state unknown\n");
xenstored_ready = 1; break;
else {
err = xenstored_local_init();
if (err)
goto out_error;
}
xen_store_interface = mfn_to_virt(xen_store_mfn);
} }
/* Initialize the interface to xenstore. */ /* Initialize the interface to xenstore. */
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include <linux/rwsem.h> #include <linux/rwsem.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <asm/xen/hypervisor.h>
#include <xen/xenbus.h> #include <xen/xenbus.h>
#include <xen/xen.h> #include <xen/xen.h>
#include "xenbus_comms.h" #include "xenbus_comms.h"
...@@ -622,7 +623,7 @@ static void xs_reset_watches(void) ...@@ -622,7 +623,7 @@ static void xs_reset_watches(void)
{ {
int err, supported = 0; int err, supported = 0;
if (!xen_hvm_domain()) if (!xen_hvm_domain() || xen_initial_domain())
return; return;
err = xenbus_scanf(XBT_NIL, "control", err = xenbus_scanf(XBT_NIL, "control",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment