hvtramp.S 2.6 KB

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