enlighten.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #include <xen/xen.h>
  2. #include <xen/interface/xen.h>
  3. #include <xen/interface/memory.h>
  4. #include <xen/platform_pci.h>
  5. #include <asm/xen/hypervisor.h>
  6. #include <asm/xen/hypercall.h>
  7. #include <linux/module.h>
  8. #include <linux/of.h>
  9. #include <linux/of_irq.h>
  10. #include <linux/of_address.h>
  11. struct start_info _xen_start_info;
  12. struct start_info *xen_start_info = &_xen_start_info;
  13. EXPORT_SYMBOL_GPL(xen_start_info);
  14. enum xen_domain_type xen_domain_type = XEN_NATIVE;
  15. EXPORT_SYMBOL_GPL(xen_domain_type);
  16. struct shared_info xen_dummy_shared_info;
  17. struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info;
  18. DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
  19. /* TODO: to be removed */
  20. __read_mostly int xen_have_vector_callback;
  21. EXPORT_SYMBOL_GPL(xen_have_vector_callback);
  22. int xen_platform_pci_unplug = XEN_UNPLUG_ALL;
  23. EXPORT_SYMBOL_GPL(xen_platform_pci_unplug);
  24. int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
  25. unsigned long addr,
  26. unsigned long mfn, int nr,
  27. pgprot_t prot, unsigned domid)
  28. {
  29. return -ENOSYS;
  30. }
  31. EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range);
  32. /*
  33. * see Documentation/devicetree/bindings/arm/xen.txt for the
  34. * documentation of the Xen Device Tree format.
  35. */
  36. static int __init xen_guest_init(void)
  37. {
  38. struct xen_add_to_physmap xatp;
  39. static struct shared_info *shared_info_page = 0;
  40. struct device_node *node;
  41. int len;
  42. const char *s = NULL;
  43. const char *version = NULL;
  44. const char *xen_prefix = "xen,xen-";
  45. node = of_find_compatible_node(NULL, NULL, "xen,xen");
  46. if (!node) {
  47. pr_debug("No Xen support\n");
  48. return 0;
  49. }
  50. s = of_get_property(node, "compatible", &len);
  51. if (strlen(xen_prefix) + 3 < len &&
  52. !strncmp(xen_prefix, s, strlen(xen_prefix)))
  53. version = s + strlen(xen_prefix);
  54. if (version == NULL) {
  55. pr_debug("Xen version not found\n");
  56. return 0;
  57. }
  58. xen_domain_type = XEN_HVM_DOMAIN;
  59. if (!shared_info_page)
  60. shared_info_page = (struct shared_info *)
  61. get_zeroed_page(GFP_KERNEL);
  62. if (!shared_info_page) {
  63. pr_err("not enough memory\n");
  64. return -ENOMEM;
  65. }
  66. xatp.domid = DOMID_SELF;
  67. xatp.idx = 0;
  68. xatp.space = XENMAPSPACE_shared_info;
  69. xatp.gpfn = __pa(shared_info_page) >> PAGE_SHIFT;
  70. if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
  71. BUG();
  72. HYPERVISOR_shared_info = (struct shared_info *)shared_info_page;
  73. /* xen_vcpu is a pointer to the vcpu_info struct in the shared_info
  74. * page, we use it in the event channel upcall and in some pvclock
  75. * related functions. We don't need the vcpu_info placement
  76. * optimizations because we don't use any pv_mmu or pv_irq op on
  77. * HVM.
  78. * The shared info contains exactly 1 CPU (the boot CPU). The guest
  79. * is required to use VCPUOP_register_vcpu_info to place vcpu info
  80. * for secondary CPUs as they are brought up. */
  81. per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0];
  82. return 0;
  83. }
  84. core_initcall(xen_guest_init);