migrate_32.S 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. *
  14. * This routine is a helper for migrating the home of a set of pages to
  15. * a new cpu. See the documentation in homecache.c for more information.
  16. */
  17. #include <linux/linkage.h>
  18. #include <linux/threads.h>
  19. #include <asm/page.h>
  20. #include <asm/thread_info.h>
  21. #include <asm/types.h>
  22. #include <asm/asm-offsets.h>
  23. #include <hv/hypervisor.h>
  24. .text
  25. /*
  26. * First, some definitions that apply to all the code in the file.
  27. */
  28. /* Locals (caller-save) */
  29. #define r_tmp r10
  30. #define r_save_sp r11
  31. /* What we save where in the stack frame; must include all callee-saves. */
  32. #define FRAME_SP 4
  33. #define FRAME_R30 8
  34. #define FRAME_R31 12
  35. #define FRAME_R32 16
  36. #define FRAME_R33 20
  37. #define FRAME_R34 24
  38. #define FRAME_R35 28
  39. #define FRAME_SIZE 32
  40. /*
  41. * On entry:
  42. *
  43. * r0 low word of the new context PA to install (moved to r_context_lo)
  44. * r1 high word of the new context PA to install (moved to r_context_hi)
  45. * r2 low word of PTE to use for context access (moved to r_access_lo)
  46. * r3 high word of PTE to use for context access (moved to r_access_lo)
  47. * r4 ASID to use for new context (moved to r_asid)
  48. * r5 pointer to cpumask with just this cpu set in it (r_my_cpumask)
  49. */
  50. /* Arguments (caller-save) */
  51. #define r_context_lo_in r0
  52. #define r_context_hi_in r1
  53. #define r_access_lo_in r2
  54. #define r_access_hi_in r3
  55. #define r_asid_in r4
  56. #define r_my_cpumask r5
  57. /* Locals (callee-save); must not be more than FRAME_xxx above. */
  58. #define r_save_ics r30
  59. #define r_context_lo r31
  60. #define r_context_hi r32
  61. #define r_access_lo r33
  62. #define r_access_hi r34
  63. #define r_asid r35
  64. STD_ENTRY(flush_and_install_context)
  65. /*
  66. * Create a stack frame; we can't touch it once we flush the
  67. * cache until we install the new page table and flush the TLB.
  68. */
  69. {
  70. move r_save_sp, sp
  71. sw sp, lr
  72. addi sp, sp, -FRAME_SIZE
  73. }
  74. addi r_tmp, sp, FRAME_SP
  75. {
  76. sw r_tmp, r_save_sp
  77. addi r_tmp, sp, FRAME_R30
  78. }
  79. {
  80. sw r_tmp, r30
  81. addi r_tmp, sp, FRAME_R31
  82. }
  83. {
  84. sw r_tmp, r31
  85. addi r_tmp, sp, FRAME_R32
  86. }
  87. {
  88. sw r_tmp, r32
  89. addi r_tmp, sp, FRAME_R33
  90. }
  91. {
  92. sw r_tmp, r33
  93. addi r_tmp, sp, FRAME_R34
  94. }
  95. {
  96. sw r_tmp, r34
  97. addi r_tmp, sp, FRAME_R35
  98. }
  99. sw r_tmp, r35
  100. /* Move some arguments to callee-save registers. */
  101. {
  102. move r_context_lo, r_context_lo_in
  103. move r_context_hi, r_context_hi_in
  104. }
  105. {
  106. move r_access_lo, r_access_lo_in
  107. move r_access_hi, r_access_hi_in
  108. }
  109. move r_asid, r_asid_in
  110. /* Disable interrupts, since we can't use our stack. */
  111. {
  112. mfspr r_save_ics, INTERRUPT_CRITICAL_SECTION
  113. movei r_tmp, 1
  114. }
  115. mtspr INTERRUPT_CRITICAL_SECTION, r_tmp
  116. /* First, flush our L2 cache. */
  117. {
  118. move r0, zero /* cache_pa */
  119. move r1, zero
  120. }
  121. {
  122. auli r2, zero, ha16(HV_FLUSH_EVICT_L2) /* cache_control */
  123. move r3, r_my_cpumask /* cache_cpumask */
  124. }
  125. {
  126. move r4, zero /* tlb_va */
  127. move r5, zero /* tlb_length */
  128. }
  129. {
  130. move r6, zero /* tlb_pgsize */
  131. move r7, zero /* tlb_cpumask */
  132. }
  133. {
  134. move r8, zero /* asids */
  135. move r9, zero /* asidcount */
  136. }
  137. jal hv_flush_remote
  138. bnz r0, .Ldone
  139. /* Now install the new page table. */
  140. {
  141. move r0, r_context_lo
  142. move r1, r_context_hi
  143. }
  144. {
  145. move r2, r_access_lo
  146. move r3, r_access_hi
  147. }
  148. {
  149. move r4, r_asid
  150. movei r5, HV_CTX_DIRECTIO
  151. }
  152. jal hv_install_context
  153. bnz r0, .Ldone
  154. /* Finally, flush the TLB. */
  155. {
  156. movei r0, 0 /* preserve_global */
  157. jal hv_flush_all
  158. }
  159. .Ldone:
  160. /* Reset interrupts back how they were before. */
  161. mtspr INTERRUPT_CRITICAL_SECTION, r_save_ics
  162. /* Restore the callee-saved registers and return. */
  163. addli lr, sp, FRAME_SIZE
  164. {
  165. lw lr, lr
  166. addli r_tmp, sp, FRAME_R30
  167. }
  168. {
  169. lw r30, r_tmp
  170. addli r_tmp, sp, FRAME_R31
  171. }
  172. {
  173. lw r31, r_tmp
  174. addli r_tmp, sp, FRAME_R32
  175. }
  176. {
  177. lw r32, r_tmp
  178. addli r_tmp, sp, FRAME_R33
  179. }
  180. {
  181. lw r33, r_tmp
  182. addli r_tmp, sp, FRAME_R34
  183. }
  184. {
  185. lw r34, r_tmp
  186. addli r_tmp, sp, FRAME_R35
  187. }
  188. {
  189. lw r35, r_tmp
  190. addi sp, sp, FRAME_SIZE
  191. }
  192. jrp lr
  193. STD_ENDPROC(flush_and_install_context)