]>
Commit | Line | Data |
---|---|---|
4c071ee5 | 1 | #include <xen/xen.h> |
b3b52fd8 SS |
2 | #include <xen/grant_table.h> |
3 | #include <xen/hvm.h> | |
4c071ee5 SS |
4 | #include <xen/interface/xen.h> |
5 | #include <xen/interface/memory.h> | |
b3b52fd8 | 6 | #include <xen/interface/hvm/params.h> |
ef61ee0d | 7 | #include <xen/features.h> |
4c071ee5 | 8 | #include <xen/platform_pci.h> |
b3b52fd8 | 9 | #include <xen/xenbus.h> |
4c071ee5 SS |
10 | #include <asm/xen/hypervisor.h> |
11 | #include <asm/xen/hypercall.h> | |
12 | #include <linux/module.h> | |
2e01f166 SS |
13 | #include <linux/of.h> |
14 | #include <linux/of_irq.h> | |
15 | #include <linux/of_address.h> | |
4c071ee5 SS |
16 | |
17 | struct start_info _xen_start_info; | |
18 | struct start_info *xen_start_info = &_xen_start_info; | |
19 | EXPORT_SYMBOL_GPL(xen_start_info); | |
20 | ||
21 | enum xen_domain_type xen_domain_type = XEN_NATIVE; | |
22 | EXPORT_SYMBOL_GPL(xen_domain_type); | |
23 | ||
24 | struct shared_info xen_dummy_shared_info; | |
25 | struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info; | |
26 | ||
27 | DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu); | |
28 | ||
29 | /* TODO: to be removed */ | |
30 | __read_mostly int xen_have_vector_callback; | |
31 | EXPORT_SYMBOL_GPL(xen_have_vector_callback); | |
32 | ||
33 | int xen_platform_pci_unplug = XEN_UNPLUG_ALL; | |
34 | EXPORT_SYMBOL_GPL(xen_platform_pci_unplug); | |
35 | ||
36 | int xen_remap_domain_mfn_range(struct vm_area_struct *vma, | |
37 | unsigned long addr, | |
38 | unsigned long mfn, int nr, | |
39 | pgprot_t prot, unsigned domid) | |
40 | { | |
41 | return -ENOSYS; | |
42 | } | |
43 | EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range); | |
2e01f166 SS |
44 | |
45 | /* | |
46 | * see Documentation/devicetree/bindings/arm/xen.txt for the | |
47 | * documentation of the Xen Device Tree format. | |
48 | */ | |
b3b52fd8 | 49 | #define GRANT_TABLE_PHYSADDR 0 |
2e01f166 SS |
50 | static int __init xen_guest_init(void) |
51 | { | |
52 | struct xen_add_to_physmap xatp; | |
53 | static struct shared_info *shared_info_page = 0; | |
54 | struct device_node *node; | |
55 | int len; | |
56 | const char *s = NULL; | |
57 | const char *version = NULL; | |
58 | const char *xen_prefix = "xen,xen-"; | |
b3b52fd8 | 59 | struct resource res; |
2e01f166 SS |
60 | |
61 | node = of_find_compatible_node(NULL, NULL, "xen,xen"); | |
62 | if (!node) { | |
63 | pr_debug("No Xen support\n"); | |
64 | return 0; | |
65 | } | |
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"); | |
72 | return 0; | |
73 | } | |
b3b52fd8 SS |
74 | if (of_address_to_resource(node, GRANT_TABLE_PHYSADDR, &res)) |
75 | return 0; | |
76 | xen_hvm_resume_frames = res.start >> PAGE_SHIFT; | |
2e01f166 SS |
77 | xen_domain_type = XEN_HVM_DOMAIN; |
78 | ||
ef61ee0d SS |
79 | xen_setup_features(); |
80 | if (xen_feature(XENFEAT_dom0)) | |
81 | xen_start_info->flags |= SIF_INITDOMAIN|SIF_PRIVILEGED; | |
82 | else | |
83 | xen_start_info->flags &= ~(SIF_INITDOMAIN|SIF_PRIVILEGED); | |
84 | ||
2e01f166 SS |
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"); | |
90 | return -ENOMEM; | |
91 | } | |
92 | xatp.domid = DOMID_SELF; | |
93 | xatp.idx = 0; | |
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)) | |
97 | BUG(); | |
98 | ||
99 | HYPERVISOR_shared_info = (struct shared_info *)shared_info_page; | |
100 | ||
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 | |
105 | * HVM. | |
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]; | |
b3b52fd8 SS |
110 | |
111 | gnttab_init(); | |
112 | if (!xen_initial_domain()) | |
113 | xenbus_probe(NULL); | |
114 | ||
2e01f166 SS |
115 | return 0; |
116 | } | |
117 | core_initcall(xen_guest_init); |