2 #include <xen/grant_table.h>
4 #include <xen/interface/xen.h>
5 #include <xen/interface/memory.h>
6 #include <xen/interface/hvm/params.h>
7 #include <xen/features.h>
8 #include <xen/platform_pci.h>
9 #include <xen/xenbus.h>
10 #include <asm/xen/hypervisor.h>
11 #include <asm/xen/hypercall.h>
12 #include <linux/module.h>
14 #include <linux/of_irq.h>
15 #include <linux/of_address.h>
17 struct start_info _xen_start_info;
18 struct start_info *xen_start_info = &_xen_start_info;
19 EXPORT_SYMBOL_GPL(xen_start_info);
21 enum xen_domain_type xen_domain_type = XEN_NATIVE;
22 EXPORT_SYMBOL_GPL(xen_domain_type);
24 struct shared_info xen_dummy_shared_info;
25 struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info;
27 DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
29 /* TODO: to be removed */
30 __read_mostly int xen_have_vector_callback;
31 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33 int xen_platform_pci_unplug = XEN_UNPLUG_ALL;
34 EXPORT_SYMBOL_GPL(xen_platform_pci_unplug);
36 int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
38 unsigned long mfn, int nr,
39 pgprot_t prot, unsigned domid)
43 EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range);
46 * see Documentation/devicetree/bindings/arm/xen.txt for the
47 * documentation of the Xen Device Tree format.
49 #define GRANT_TABLE_PHYSADDR 0
50 static int __init xen_guest_init(void)
52 struct xen_add_to_physmap xatp;
53 static struct shared_info *shared_info_page = 0;
54 struct device_node *node;
57 const char *version = NULL;
58 const char *xen_prefix = "xen,xen-";
61 node = of_find_compatible_node(NULL, NULL, "xen,xen");
63 pr_debug("No Xen support\n");
66 s = of_get_property(node, "compatible", &len);
67 if (strlen(xen_prefix) + 3 < len &&
68 !strncmp(xen_prefix, s, strlen(xen_prefix)))
69 version = s + strlen(xen_prefix);
70 if (version == NULL) {
71 pr_debug("Xen version not found\n");
74 if (of_address_to_resource(node, GRANT_TABLE_PHYSADDR, &res))
76 xen_hvm_resume_frames = res.start >> PAGE_SHIFT;
77 xen_domain_type = XEN_HVM_DOMAIN;
80 if (xen_feature(XENFEAT_dom0))
81 xen_start_info->flags |= SIF_INITDOMAIN|SIF_PRIVILEGED;
83 xen_start_info->flags &= ~(SIF_INITDOMAIN|SIF_PRIVILEGED);
85 if (!shared_info_page)
86 shared_info_page = (struct shared_info *)
87 get_zeroed_page(GFP_KERNEL);
88 if (!shared_info_page) {
89 pr_err("not enough memory\n");
92 xatp.domid = DOMID_SELF;
94 xatp.space = XENMAPSPACE_shared_info;
95 xatp.gpfn = __pa(shared_info_page) >> PAGE_SHIFT;
96 if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
99 HYPERVISOR_shared_info = (struct shared_info *)shared_info_page;
101 /* xen_vcpu is a pointer to the vcpu_info struct in the shared_info
102 * page, we use it in the event channel upcall and in some pvclock
103 * related functions. We don't need the vcpu_info placement
104 * optimizations because we don't use any pv_mmu or pv_irq op on
106 * The shared info contains exactly 1 CPU (the boot CPU). The guest
107 * is required to use VCPUOP_register_vcpu_info to place vcpu info
108 * for secondary CPUs as they are brought up. */
109 per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0];
112 if (!xen_initial_domain())
117 core_initcall(xen_guest_init);