hvtramp.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* hvtramp.S: Hypervisor start-cpu trampoline code.
  3. *
  4. * Copyright (C) 2007, 2008 David S. Miller <davem@davemloft.net>
  5. */
  6. #include <asm/thread_info.h>
  7. #include <asm/hypervisor.h>
  8. #include <asm/scratchpad.h>
  9. #include <asm/spitfire.h>
  10. #include <asm/hvtramp.h>
  11. #include <asm/pstate.h>
  12. #include <asm/ptrace.h>
  13. #include <asm/head.h>
  14. #include <asm/asi.h>
  15. #include <asm/pil.h>
  16. .align 8
  17. .globl hv_cpu_startup, hv_cpu_startup_end
  18. /* This code executes directly out of the hypervisor
  19. * with physical addressing (va==pa). %o0 contains
  20. * our client argument which for Linux points to
  21. * a descriptor data structure which defines the
  22. * MMU entries we need to load up.
  23. *
  24. * After we set things up we enable the MMU and call
  25. * into the kernel.
  26. *
  27. * First setup basic privileged cpu state.
  28. */
  29. hv_cpu_startup:
  30. SET_GL(0)
  31. wrpr %g0, PIL_NORMAL_MAX, %pil
  32. wrpr %g0, 0, %canrestore
  33. wrpr %g0, 0, %otherwin
  34. wrpr %g0, 6, %cansave
  35. wrpr %g0, 6, %cleanwin
  36. wrpr %g0, 0, %cwp
  37. wrpr %g0, 0, %wstate
  38. wrpr %g0, 0, %tl
  39. sethi %hi(sparc64_ttable_tl0), %g1
  40. wrpr %g1, %tba
  41. mov %o0, %l0
  42. lduw [%l0 + HVTRAMP_DESCR_CPU], %g1
  43. mov SCRATCHPAD_CPUID, %g2
  44. stxa %g1, [%g2] ASI_SCRATCHPAD
  45. ldx [%l0 + HVTRAMP_DESCR_FAULT_INFO_VA], %g2
  46. stxa %g2, [%g0] ASI_SCRATCHPAD
  47. mov 0, %l1
  48. lduw [%l0 + HVTRAMP_DESCR_NUM_MAPPINGS], %l2
  49. add %l0, HVTRAMP_DESCR_MAPS, %l3
  50. 1: ldx [%l3 + HVTRAMP_MAPPING_VADDR], %o0
  51. clr %o1
  52. ldx [%l3 + HVTRAMP_MAPPING_TTE], %o2
  53. mov HV_MMU_IMMU | HV_MMU_DMMU, %o3
  54. mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
  55. ta HV_FAST_TRAP
  56. brnz,pn %o0, 80f
  57. nop
  58. add %l1, 1, %l1
  59. cmp %l1, %l2
  60. blt,a,pt %xcc, 1b
  61. add %l3, HVTRAMP_MAPPING_SIZE, %l3
  62. ldx [%l0 + HVTRAMP_DESCR_FAULT_INFO_PA], %o0
  63. mov HV_FAST_MMU_FAULT_AREA_CONF, %o5
  64. ta HV_FAST_TRAP
  65. brnz,pn %o0, 80f
  66. nop
  67. wrpr %g0, (PSTATE_PRIV | PSTATE_PEF), %pstate
  68. ldx [%l0 + HVTRAMP_DESCR_THREAD_REG], %l6
  69. mov 1, %o0
  70. set 1f, %o1
  71. mov HV_FAST_MMU_ENABLE, %o5
  72. ta HV_FAST_TRAP
  73. ba,pt %xcc, 80f
  74. nop
  75. 1:
  76. wr %g0, 0, %fprs
  77. wr %g0, ASI_P, %asi
  78. mov PRIMARY_CONTEXT, %g7
  79. stxa %g0, [%g7] ASI_MMU
  80. membar #Sync
  81. mov SECONDARY_CONTEXT, %g7
  82. stxa %g0, [%g7] ASI_MMU
  83. membar #Sync
  84. mov %l6, %g6
  85. ldx [%g6 + TI_TASK], %g4
  86. mov 1, %g5
  87. sllx %g5, THREAD_SHIFT, %g5
  88. sub %g5, (STACKFRAME_SZ + STACK_BIAS), %g5
  89. add %g6, %g5, %sp
  90. call init_irqwork_curcpu
  91. nop
  92. call hard_smp_processor_id
  93. nop
  94. call sun4v_register_mondo_queues
  95. nop
  96. call init_cur_cpu_trap
  97. mov %g6, %o0
  98. wrpr %g0, (PSTATE_PRIV | PSTATE_PEF | PSTATE_IE), %pstate
  99. call smp_callin
  100. nop
  101. call cpu_panic
  102. nop
  103. 80: ba,pt %xcc, 80b
  104. nop
  105. .align 8
  106. hv_cpu_startup_end: