xen-head.S 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* Xen-specific pieces of head.S, intended to be included in the right
  2. place in head.S */
  3. #ifdef CONFIG_XEN
  4. #include <linux/elfnote.h>
  5. #include <linux/init.h>
  6. #include <asm/boot.h>
  7. #include <asm/asm.h>
  8. #include <asm/page_types.h>
  9. #include <xen/interface/elfnote.h>
  10. #include <xen/interface/features.h>
  11. #include <xen/interface/xen.h>
  12. #include <xen/interface/xen-mca.h>
  13. #include <asm/xen/interface.h>
  14. #ifdef CONFIG_XEN_PVH
  15. #define PVH_FEATURES_STR "|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel"
  16. /* Note the lack of 'hvm_callback_vector'. Older hypervisor will
  17. * balk at this being part of XEN_ELFNOTE_FEATURES, so we put it in
  18. * XEN_ELFNOTE_SUPPORTED_FEATURES which older hypervisors will ignore.
  19. */
  20. #define PVH_FEATURES ((1 << XENFEAT_writable_page_tables) | \
  21. (1 << XENFEAT_auto_translated_physmap) | \
  22. (1 << XENFEAT_supervisor_mode_kernel) | \
  23. (1 << XENFEAT_hvm_callback_vector))
  24. /* The XENFEAT_writable_page_tables is not stricly neccessary as we set that
  25. * up regardless whether this CONFIG option is enabled or not, but it
  26. * clarifies what the right flags need to be.
  27. */
  28. #else
  29. #define PVH_FEATURES_STR ""
  30. #define PVH_FEATURES (0)
  31. #endif
  32. __INIT
  33. ENTRY(startup_xen)
  34. cld
  35. #ifdef CONFIG_X86_32
  36. mov %esi,xen_start_info
  37. mov $init_thread_union+THREAD_SIZE,%esp
  38. #else
  39. mov %rsi,xen_start_info
  40. mov $init_thread_union+THREAD_SIZE,%rsp
  41. #endif
  42. jmp xen_start_kernel
  43. __FINIT
  44. #ifdef CONFIG_XEN_PVH
  45. /*
  46. * xen_pvh_early_cpu_init() - early PVH VCPU initialization
  47. * @cpu: this cpu number (%rdi)
  48. * @entry: true if this is a secondary vcpu coming up on this entry
  49. * point, false if this is the boot CPU being initialized for
  50. * the first time (%rsi)
  51. *
  52. * Note: This is called as a function on the boot CPU, and is the entry point
  53. * on the secondary CPU.
  54. */
  55. ENTRY(xen_pvh_early_cpu_init)
  56. mov %rsi, %r11
  57. /* Gather features to see if NX implemented. */
  58. mov $0x80000001, %eax
  59. cpuid
  60. mov %edx, %esi
  61. mov $MSR_EFER, %ecx
  62. rdmsr
  63. bts $_EFER_SCE, %eax
  64. bt $20, %esi
  65. jnc 1f /* No NX, skip setting it */
  66. bts $_EFER_NX, %eax
  67. 1: wrmsr
  68. #ifdef CONFIG_SMP
  69. cmp $0, %r11b
  70. jne cpu_bringup_and_idle
  71. #endif
  72. ret
  73. #endif /* CONFIG_XEN_PVH */
  74. .pushsection .text
  75. .balign PAGE_SIZE
  76. ENTRY(hypercall_page)
  77. .skip PAGE_SIZE
  78. #define HYPERCALL(n) \
  79. .equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \
  80. .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32
  81. #include <asm/xen-hypercalls.h>
  82. #undef HYPERCALL
  83. .popsection
  84. ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux")
  85. ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6")
  86. ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")
  87. #ifdef CONFIG_X86_32
  88. ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __PAGE_OFFSET)
  89. #else
  90. ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map)
  91. /* Map the p2m table to a 512GB-aligned user address. */
  92. ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M, .quad PGDIR_SIZE)
  93. #endif
  94. ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR startup_xen)
  95. ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
  96. ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii "!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR)
  97. ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES, .long (PVH_FEATURES) |
  98. (1 << XENFEAT_writable_page_tables) |
  99. (1 << XENFEAT_dom0))
  100. ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes")
  101. ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
  102. ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
  103. .quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
  104. ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
  105. ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1)
  106. ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, _ASM_PTR __HYPERVISOR_VIRT_START)
  107. ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0)
  108. #endif /*CONFIG_XEN */