xen-head.S 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 necessary 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. /* Clear .bss */
  36. xor %eax,%eax
  37. mov $__bss_start, %_ASM_DI
  38. mov $__bss_stop, %_ASM_CX
  39. sub %_ASM_DI, %_ASM_CX
  40. shr $__ASM_SEL(2, 3), %_ASM_CX
  41. rep __ASM_SIZE(stos)
  42. mov %_ASM_SI, xen_start_info
  43. mov $init_thread_union+THREAD_SIZE, %_ASM_SP
  44. jmp xen_start_kernel
  45. __FINIT
  46. #ifdef CONFIG_XEN_PVH
  47. /*
  48. * xen_pvh_early_cpu_init() - early PVH VCPU initialization
  49. * @cpu: this cpu number (%rdi)
  50. * @entry: true if this is a secondary vcpu coming up on this entry
  51. * point, false if this is the boot CPU being initialized for
  52. * the first time (%rsi)
  53. *
  54. * Note: This is called as a function on the boot CPU, and is the entry point
  55. * on the secondary CPU.
  56. */
  57. ENTRY(xen_pvh_early_cpu_init)
  58. mov %rsi, %r11
  59. /* Gather features to see if NX implemented. */
  60. mov $0x80000001, %eax
  61. cpuid
  62. mov %edx, %esi
  63. mov $MSR_EFER, %ecx
  64. rdmsr
  65. bts $_EFER_SCE, %eax
  66. bt $20, %esi
  67. jnc 1f /* No NX, skip setting it */
  68. bts $_EFER_NX, %eax
  69. 1: wrmsr
  70. #ifdef CONFIG_SMP
  71. cmp $0, %r11b
  72. jne cpu_bringup_and_idle
  73. #endif
  74. ret
  75. #endif /* CONFIG_XEN_PVH */
  76. .pushsection .text
  77. .balign PAGE_SIZE
  78. ENTRY(hypercall_page)
  79. .skip PAGE_SIZE
  80. #define HYPERCALL(n) \
  81. .equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \
  82. .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32
  83. #include <asm/xen-hypercalls.h>
  84. #undef HYPERCALL
  85. .popsection
  86. ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux")
  87. ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6")
  88. ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")
  89. #ifdef CONFIG_X86_32
  90. ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __PAGE_OFFSET)
  91. #else
  92. ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map)
  93. /* Map the p2m table to a 512GB-aligned user address. */
  94. ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M, .quad PGDIR_SIZE)
  95. #endif
  96. ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR startup_xen)
  97. ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
  98. ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii "!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR)
  99. ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES, .long (PVH_FEATURES) |
  100. (1 << XENFEAT_writable_page_tables) |
  101. (1 << XENFEAT_dom0))
  102. ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes")
  103. ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
  104. ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
  105. .quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
  106. ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
  107. ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1)
  108. ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, _ASM_PTR __HYPERVISOR_VIRT_START)
  109. ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0)
  110. #endif /*CONFIG_XEN */