xen-head.S 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 <asm/xen/interface.h>
  12. #ifdef CONFIG_XEN_PVH
  13. #define PVH_FEATURES_STR "|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel"
  14. /* Note the lack of 'hvm_callback_vector'. Older hypervisor will
  15. * balk at this being part of XEN_ELFNOTE_FEATURES, so we put it in
  16. * XEN_ELFNOTE_SUPPORTED_FEATURES which older hypervisors will ignore.
  17. */
  18. #define PVH_FEATURES ((1 << XENFEAT_writable_page_tables) | \
  19. (1 << XENFEAT_auto_translated_physmap) | \
  20. (1 << XENFEAT_supervisor_mode_kernel) | \
  21. (1 << XENFEAT_hvm_callback_vector))
  22. /* The XENFEAT_writable_page_tables is not stricly neccessary as we set that
  23. * up regardless whether this CONFIG option is enabled or not, but it
  24. * clarifies what the right flags need to be.
  25. */
  26. #else
  27. #define PVH_FEATURES_STR ""
  28. #define PVH_FEATURES (0)
  29. #endif
  30. __INIT
  31. ENTRY(startup_xen)
  32. cld
  33. #ifdef CONFIG_X86_32
  34. mov %esi,xen_start_info
  35. mov $init_thread_union+THREAD_SIZE,%esp
  36. #else
  37. mov %rsi,xen_start_info
  38. mov $init_thread_union+THREAD_SIZE,%rsp
  39. #endif
  40. jmp xen_start_kernel
  41. __FINIT
  42. #ifdef CONFIG_XEN_PVH
  43. /*
  44. * xen_pvh_early_cpu_init() - early PVH VCPU initialization
  45. * @cpu: this cpu number (%rdi)
  46. * @entry: true if this is a secondary vcpu coming up on this entry
  47. * point, false if this is the boot CPU being initialized for
  48. * the first time (%rsi)
  49. *
  50. * Note: This is called as a function on the boot CPU, and is the entry point
  51. * on the secondary CPU.
  52. */
  53. ENTRY(xen_pvh_early_cpu_init)
  54. mov %rsi, %r11
  55. /* Gather features to see if NX implemented. */
  56. mov $0x80000001, %eax
  57. cpuid
  58. mov %edx, %esi
  59. mov $MSR_EFER, %ecx
  60. rdmsr
  61. bts $_EFER_SCE, %eax
  62. bt $20, %esi
  63. jnc 1f /* No NX, skip setting it */
  64. bts $_EFER_NX, %eax
  65. 1: wrmsr
  66. #ifdef CONFIG_SMP
  67. cmp $0, %r11b
  68. jne cpu_bringup_and_idle
  69. #endif
  70. ret
  71. #endif /* CONFIG_XEN_PVH */
  72. .pushsection .text
  73. .balign PAGE_SIZE
  74. ENTRY(hypercall_page)
  75. #define NEXT_HYPERCALL(x) \
  76. ENTRY(xen_hypercall_##x) \
  77. .skip 32
  78. NEXT_HYPERCALL(set_trap_table)
  79. NEXT_HYPERCALL(mmu_update)
  80. NEXT_HYPERCALL(set_gdt)
  81. NEXT_HYPERCALL(stack_switch)
  82. NEXT_HYPERCALL(set_callbacks)
  83. NEXT_HYPERCALL(fpu_taskswitch)
  84. NEXT_HYPERCALL(sched_op_compat)
  85. NEXT_HYPERCALL(platform_op)
  86. NEXT_HYPERCALL(set_debugreg)
  87. NEXT_HYPERCALL(get_debugreg)
  88. NEXT_HYPERCALL(update_descriptor)
  89. NEXT_HYPERCALL(ni)
  90. NEXT_HYPERCALL(memory_op)
  91. NEXT_HYPERCALL(multicall)
  92. NEXT_HYPERCALL(update_va_mapping)
  93. NEXT_HYPERCALL(set_timer_op)
  94. NEXT_HYPERCALL(event_channel_op_compat)
  95. NEXT_HYPERCALL(xen_version)
  96. NEXT_HYPERCALL(console_io)
  97. NEXT_HYPERCALL(physdev_op_compat)
  98. NEXT_HYPERCALL(grant_table_op)
  99. NEXT_HYPERCALL(vm_assist)
  100. NEXT_HYPERCALL(update_va_mapping_otherdomain)
  101. NEXT_HYPERCALL(iret)
  102. NEXT_HYPERCALL(vcpu_op)
  103. NEXT_HYPERCALL(set_segment_base)
  104. NEXT_HYPERCALL(mmuext_op)
  105. NEXT_HYPERCALL(xsm_op)
  106. NEXT_HYPERCALL(nmi_op)
  107. NEXT_HYPERCALL(sched_op)
  108. NEXT_HYPERCALL(callback_op)
  109. NEXT_HYPERCALL(xenoprof_op)
  110. NEXT_HYPERCALL(event_channel_op)
  111. NEXT_HYPERCALL(physdev_op)
  112. NEXT_HYPERCALL(hvm_op)
  113. NEXT_HYPERCALL(sysctl)
  114. NEXT_HYPERCALL(domctl)
  115. NEXT_HYPERCALL(kexec_op)
  116. NEXT_HYPERCALL(tmem_op) /* 38 */
  117. ENTRY(xen_hypercall_rsvr)
  118. .skip 320
  119. NEXT_HYPERCALL(mca) /* 48 */
  120. NEXT_HYPERCALL(arch_1)
  121. NEXT_HYPERCALL(arch_2)
  122. NEXT_HYPERCALL(arch_3)
  123. NEXT_HYPERCALL(arch_4)
  124. NEXT_HYPERCALL(arch_5)
  125. NEXT_HYPERCALL(arch_6)
  126. .balign PAGE_SIZE
  127. .popsection
  128. ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux")
  129. ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6")
  130. ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")
  131. #ifdef CONFIG_X86_32
  132. ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __PAGE_OFFSET)
  133. #else
  134. ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map)
  135. #endif
  136. ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR startup_xen)
  137. ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
  138. ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii "!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR)
  139. ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES, .long (PVH_FEATURES) |
  140. (1 << XENFEAT_writable_page_tables) |
  141. (1 << XENFEAT_dom0))
  142. ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes")
  143. ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
  144. ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
  145. .quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
  146. ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
  147. ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1)
  148. ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, _ASM_PTR __HYPERVISOR_VIRT_START)
  149. ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0)
  150. #endif /*CONFIG_XEN */