Skip to content

Commit ecc635f

Browse files
Stefano Stabellinikonradwilk
authored andcommitted
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: Stefano Stabellini <stefano.stabellini@eu.citrix.com> [v5: Fixed case switch indentations] Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
1 parent e58f5b5 commit ecc635f

3 files changed

Lines changed: 41 additions & 16 deletions

File tree

‎drivers/xen/xenbus/xenbus_comms.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ int xb_init_comms(void)
224224
int err;
225225
err = bind_evtchn_to_irqhandler(xen_store_evtchn, wake_waiting,
226226
0, "xenbus", &xb_waitq);
227-
if (err <= 0) {
227+
if (err < 0) {
228228
printk(KERN_ERR "XENBUS request irq failed %i\n", err);
229229
return err;
230230
}

‎drivers/xen/xenbus/xenbus_probe.c‎

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -719,17 +719,47 @@ static int __init xenstored_local_init(void)
719719
return err;
720720
}
721721

722+
enum xenstore_init {
723+
UNKNOWN,
724+
PV,
725+
HVM,
726+
LOCAL,
727+
};
722728
static int __init xenbus_init(void)
723729
{
724730
int err = 0;
731+
enum xenstore_init usage = UNKNOWN;
732+
uint64_t v = 0;
725733

726734
if (!xen_domain())
727735
return -ENODEV;
728736

729737
xenbus_ring_ops_init();
730738

731-
if (xen_hvm_domain()) {
732-
uint64_t v = 0;
739+
if (xen_pv_domain())
740+
usage = PV;
741+
if (xen_hvm_domain())
742+
usage = HVM;
743+
if (xen_hvm_domain() && xen_initial_domain())
744+
usage = LOCAL;
745+
if (xen_pv_domain() && !xen_start_info->store_evtchn)
746+
usage = LOCAL;
747+
if (xen_pv_domain() && xen_start_info->store_evtchn)
748+
xenstored_ready = 1;
749+
750+
switch (usage) {
751+
case LOCAL:
752+
err = xenstored_local_init();
753+
if (err)
754+
goto out_error;
755+
xen_store_interface = mfn_to_virt(xen_store_mfn);
756+
break;
757+
case PV:
758+
xen_store_evtchn = xen_start_info->store_evtchn;
759+
xen_store_mfn = xen_start_info->store_mfn;
760+
xen_store_interface = mfn_to_virt(xen_store_mfn);
761+
break;
762+
case HVM:
733763
err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v);
734764
if (err)
735765
goto out_error;
@@ -738,18 +768,12 @@ static int __init xenbus_init(void)
738768
if (err)
739769
goto out_error;
740770
xen_store_mfn = (unsigned long)v;
741-
xen_store_interface = ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE);
742-
} else {
743-
xen_store_evtchn = xen_start_info->store_evtchn;
744-
xen_store_mfn = xen_start_info->store_mfn;
745-
if (xen_store_evtchn)
746-
xenstored_ready = 1;
747-
else {
748-
err = xenstored_local_init();
749-
if (err)
750-
goto out_error;
751-
}
752-
xen_store_interface = mfn_to_virt(xen_store_mfn);
771+
xen_store_interface =
772+
ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE);
773+
break;
774+
default:
775+
pr_warn("Xenstore state unknown\n");
776+
break;
753777
}
754778

755779
/* Initialize the interface to xenstore. */

‎drivers/xen/xenbus/xenbus_xs.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <linux/rwsem.h>
4545
#include <linux/module.h>
4646
#include <linux/mutex.h>
47+
#include <asm/xen/hypervisor.h>
4748
#include <xen/xenbus.h>
4849
#include <xen/xen.h>
4950
#include "xenbus_comms.h"
@@ -622,7 +623,7 @@ static void xs_reset_watches(void)
622623
{
623624
int err, supported = 0;
624625

625-
if (!xen_hvm_domain())
626+
if (!xen_hvm_domain() || xen_initial_domain())
626627
return;
627628

628629
err = xenbus_scanf(XBT_NIL, "control",

0 commit comments

Comments
 (0)