xen-head.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Xen-specific pieces of head.S, intended to be included in the right
  3. place in head.S */
  4. #ifdef CONFIG_XEN
  5. #include <linux/elfnote.h>
  6. #include <linux/init.h>
  7. #include <asm/boot.h>
  8. #include <asm/asm.h>
  9. #include <asm/msr.h>
  10. #include <asm/page_types.h>
  11. #include <asm/percpu.h>
  12. #include <asm/unwind_hints.h>
  13. #include <xen/interface/elfnote.h>
  14. #include <xen/interface/features.h>
  15. #include <xen/interface/xen.h>
  16. #include <xen/interface/xen-mca.h>
  17. #include <asm/xen/interface.h>
  18. #ifdef CONFIG_XEN_PV
  19. __INIT
  20. ENTRY(startup_xen)
  21. UNWIND_HINT_EMPTY
  22. cld
  23. /* Clear .bss */
  24. xor %eax,%eax
  25. mov $__bss_start, %_ASM_DI
  26. mov $__bss_stop, %_ASM_CX
  27. sub %_ASM_DI, %_ASM_CX
  28. shr $__ASM_SEL(2, 3), %_ASM_CX
  29. rep __ASM_SIZE(stos)
  30. mov %_ASM_SI, xen_start_info
  31. mov $init_thread_union+THREAD_SIZE, %_ASM_SP
  32. #ifdef CONFIG_X86_64
  33. /* Set up %gs.
  34. *
  35. * The base of %gs always points to the bottom of the irqstack
  36. * union. If the stack protector canary is enabled, it is
  37. * located at %gs:40. Note that, on SMP, the boot cpu uses
  38. * init data section till per cpu areas are set up.
  39. */
  40. movl $MSR_GS_BASE,%ecx
  41. movq $INIT_PER_CPU_VAR(irq_stack_union),%rax
  42. cdq
  43. wrmsr
  44. #endif
  45. jmp xen_start_kernel
  46. END(startup_xen)
  47. __FINIT
  48. #endif
  49. .pushsection .text
  50. .balign PAGE_SIZE
  51. ENTRY(hypercall_page)
  52. .rept (PAGE_SIZE / 32)
  53. UNWIND_HINT_EMPTY
  54. .skip 32
  55. .endr
  56. #define HYPERCALL(n) \
  57. .equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \
  58. .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32
  59. #include <asm/xen-hypercalls.h>
  60. #undef HYPERCALL
  61. END(hypercall_page)
  62. .popsection
  63. ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux")
  64. ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6")
  65. ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")
  66. #ifdef CONFIG_X86_32
  67. ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __PAGE_OFFSET)
  68. #else
  69. ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map)
  70. /* Map the p2m table to a 512GB-aligned user address. */
  71. ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M, .quad (PUD_SIZE * PTRS_PER_PUD))
  72. #endif
  73. #ifdef CONFIG_XEN_PV
  74. ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR startup_xen)
  75. #endif
  76. ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
  77. ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,
  78. .ascii "!writable_page_tables|pae_pgdir_above_4gb")
  79. ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES,
  80. .long (1 << XENFEAT_writable_page_tables) | \
  81. (1 << XENFEAT_dom0) | \
  82. (1 << XENFEAT_linux_rsdp_unrestricted))
  83. ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes")
  84. ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
  85. ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
  86. .quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
  87. ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
  88. ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1)
  89. ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, _ASM_PTR __HYPERVISOR_VIRT_START)
  90. ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0)
  91. #endif /*CONFIG_XEN */