hvtramp.S 2.6 KB

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