Skip to content

Commit

Permalink
xen/arm: compile and run xenbus
Browse files Browse the repository at this point in the history
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: Stefano Stabellini <[email protected]>
[v5: Fixed case switch indentations]
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
  • Loading branch information
Stefano Stabellini authored and konradwilk committed Sep 17, 2012
1 parent e58f5b5 commit ecc635f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 16 deletions.
2 changes: 1 addition & 1 deletion drivers/xen/xenbus/xenbus_comms.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ int xb_init_comms(void)
int err;
err = bind_evtchn_to_irqhandler(xen_store_evtchn, wake_waiting,
0, "xenbus", &xb_waitq);
if (err <= 0) {
if (err < 0) {
printk(KERN_ERR "XENBUS request irq failed %i\n", err);
return err;
}
Expand Down
52 changes: 38 additions & 14 deletions drivers/xen/xenbus/xenbus_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,17 +719,47 @@ static int __init xenstored_local_init(void)
return err;
}

enum xenstore_init {
UNKNOWN,
PV,
HVM,
LOCAL,
};
static int __init xenbus_init(void)
{
int err = 0;
enum xenstore_init usage = UNKNOWN;
uint64_t v = 0;

if (!xen_domain())
return -ENODEV;

xenbus_ring_ops_init();

if (xen_hvm_domain()) {
uint64_t v = 0;
if (xen_pv_domain())
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);
if (err)
goto out_error;
Expand All @@ -738,18 +768,12 @@ static int __init xenbus_init(void)
if (err)
goto out_error;
xen_store_mfn = (unsigned long)v;
xen_store_interface = ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE);
} else {
xen_store_evtchn = xen_start_info->store_evtchn;
xen_store_mfn = xen_start_info->store_mfn;
if (xen_store_evtchn)
xenstored_ready = 1;
else {
err = xenstored_local_init();
if (err)
goto out_error;
}
xen_store_interface = mfn_to_virt(xen_store_mfn);
xen_store_interface =
ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE);
break;
default:
pr_warn("Xenstore state unknown\n");
break;
}

/* Initialize the interface to xenstore. */
Expand Down
3 changes: 2 additions & 1 deletion drivers/xen/xenbus/xenbus_xs.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <linux/rwsem.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <asm/xen/hypervisor.h>
#include <xen/xenbus.h>
#include <xen/xen.h>
#include "xenbus_comms.h"
Expand Down Expand Up @@ -622,7 +623,7 @@ static void xs_reset_watches(void)
{
int err, supported = 0;

if (!xen_hvm_domain())
if (!xen_hvm_domain() || xen_initial_domain())
return;

err = xenbus_scanf(XBT_NIL, "control",
Expand Down

0 comments on commit ecc635f

Please sign in to comment.