Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Stefano Stabellini and committed by
Konrad Rzeszutek Wilk
ecc635f9 e58f5b55

+41 -16
+1 -1
drivers/xen/xenbus/xenbus_comms.c
··· 224 224 int err; 225 225 err = bind_evtchn_to_irqhandler(xen_store_evtchn, wake_waiting, 226 226 0, "xenbus", &xb_waitq); 227 - if (err <= 0) { 227 + if (err < 0) { 228 228 printk(KERN_ERR "XENBUS request irq failed %i\n", err); 229 229 return err; 230 230 }
+38 -14
drivers/xen/xenbus/xenbus_probe.c
··· 719 719 return err; 720 720 } 721 721 722 + enum xenstore_init { 723 + UNKNOWN, 724 + PV, 725 + HVM, 726 + LOCAL, 727 + }; 722 728 static int __init xenbus_init(void) 723 729 { 724 730 int err = 0; 731 + enum xenstore_init usage = UNKNOWN; 732 + uint64_t v = 0; 725 733 726 734 if (!xen_domain()) 727 735 return -ENODEV; 728 736 729 737 xenbus_ring_ops_init(); 730 738 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: 733 763 err = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN, &v); 734 764 if (err) 735 765 goto out_error; ··· 768 738 if (err) 769 739 goto out_error; 770 740 xen_store_mfn = (unsigned long)v; 771 - xen_store_interface = ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE); 772 - } else { 773 - xen_store_evtchn = xen_start_info->store_evtchn; 774 - xen_store_mfn = xen_start_info->store_mfn; 775 - if (xen_store_evtchn) 776 - xenstored_ready = 1; 777 - else { 778 - err = xenstored_local_init(); 779 - if (err) 780 - goto out_error; 781 - } 782 - xen_store_interface = mfn_to_virt(xen_store_mfn); 741 + xen_store_interface = 742 + ioremap(xen_store_mfn << PAGE_SHIFT, PAGE_SIZE); 743 + break; 744 + default: 745 + pr_warn("Xenstore state unknown\n"); 746 + break; 783 747 } 784 748 785 749 /* Initialize the interface to xenstore. */
+2 -1
drivers/xen/xenbus/xenbus_xs.c
··· 44 44 #include <linux/rwsem.h> 45 45 #include <linux/module.h> 46 46 #include <linux/mutex.h> 47 + #include <asm/xen/hypervisor.h> 47 48 #include <xen/xenbus.h> 48 49 #include <xen/xen.h> 49 50 #include "xenbus_comms.h" ··· 623 622 { 624 623 int err, supported = 0; 625 624 626 - if (!xen_hvm_domain()) 625 + if (!xen_hvm_domain() || xen_initial_domain()) 627 626 return; 628 627 629 628 err = xenbus_scanf(XBT_NIL, "control",