trampoline_32.S 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. *
  4. * Trampoline.S Derived from Setup.S by Linus Torvalds
  5. *
  6. * 4 Jan 1997 Michael Chastain: changed to gnu as.
  7. *
  8. * This is only used for booting secondary CPUs in SMP machine
  9. *
  10. * Entry: CS:IP point to the start of our code, we are
  11. * in real mode with no stack, but the rest of the
  12. * trampoline page to make our stack and everything else
  13. * is a mystery.
  14. *
  15. * We jump into arch/x86/kernel/head_32.S.
  16. *
  17. * On entry to trampoline_start, the processor is in real mode
  18. * with 16-bit addressing and 16-bit data. CS has some value
  19. * and IP is zero. Thus, we load CS to the physical segment
  20. * of the real mode code before doing anything further.
  21. */
  22. #include <linux/linkage.h>
  23. #include <asm/segment.h>
  24. #include <asm/page_types.h>
  25. #include "realmode.h"
  26. .text
  27. .code16
  28. .balign PAGE_SIZE
  29. SYM_CODE_START(trampoline_start)
  30. wbinvd # Needed for NUMA-Q should be harmless for others
  31. LJMPW_RM(1f)
  32. 1:
  33. mov %cs, %ax # Code and data in the same place
  34. mov %ax, %ds
  35. cli # We should be safe anyway
  36. movl tr_start, %eax # where we need to go
  37. /*
  38. * GDT tables in non default location kernel can be beyond 16MB and
  39. * lgdt will not be able to load the address as in real mode default
  40. * operand size is 16bit. Use lgdtl instead to force operand size
  41. * to 32 bit.
  42. */
  43. lidtl tr_idt # load idt with 0, 0
  44. lgdtl tr_gdt # load gdt with whatever is appropriate
  45. movw $1, %dx # protected mode (PE) bit
  46. lmsw %dx # into protected mode
  47. ljmpl $__BOOT_CS, $pa_startup_32
  48. SYM_CODE_END(trampoline_start)
  49. .section ".text32","ax"
  50. .code32
  51. SYM_CODE_START(startup_32) # note: also used from wakeup_asm.S
  52. jmp *%eax
  53. SYM_CODE_END(startup_32)
  54. .bss
  55. .balign 8
  56. SYM_DATA_START(trampoline_header)
  57. SYM_DATA_LOCAL(tr_start, .space 4)
  58. SYM_DATA_LOCAL(tr_gdt_pad, .space 2)
  59. SYM_DATA_LOCAL(tr_gdt, .space 6)
  60. SYM_DATA_END(trampoline_header)
  61. #include "trampoline_common.S"