migrate_32.S 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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_SIZE 28
  39. /*
  40. * On entry:
  41. *
  42. * r0 low word of the new context PA to install (moved to r_context_lo)
  43. * r1 high word of the new context PA to install (moved to r_context_hi)
  44. * r2 low word of PTE to use for context access (moved to r_access_lo)
  45. * r3 high word of PTE to use for context access (moved to r_access_lo)
  46. * r4 ASID to use for new context (moved to r_asid)
  47. * r5 pointer to cpumask with just this cpu set in it (r_my_cpumask)
  48. */
  49. /* Arguments (caller-save) */
  50. #define r_context_lo_in r0
  51. #define r_context_hi_in r1
  52. #define r_access_lo_in r2
  53. #define r_access_hi_in r3
  54. #define r_asid_in r4
  55. #define r_my_cpumask r5
  56. /* Locals (callee-save); must not be more than FRAME_xxx above. */
  57. #define r_context_lo r30
  58. #define r_context_hi r31
  59. #define r_access_lo r32
  60. #define r_access_hi r33
  61. #define r_asid r34
  62. STD_ENTRY(flush_and_install_context)
  63. /*
  64. * Create a stack frame; we can't touch it once we flush the
  65. * cache until we install the new page table and flush the TLB.
  66. */
  67. {
  68. move r_save_sp, sp
  69. sw sp, lr
  70. addi sp, sp, -FRAME_SIZE
  71. }
  72. addi r_tmp, sp, FRAME_SP
  73. {
  74. sw r_tmp, r_save_sp
  75. addi r_tmp, sp, FRAME_R30
  76. }
  77. {
  78. sw r_tmp, r30
  79. addi r_tmp, sp, FRAME_R31
  80. }
  81. {
  82. sw r_tmp, r31
  83. addi r_tmp, sp, FRAME_R32
  84. }
  85. {
  86. sw r_tmp, r32
  87. addi r_tmp, sp, FRAME_R33
  88. }
  89. {
  90. sw r_tmp, r33
  91. addi r_tmp, sp, FRAME_R34
  92. }
  93. sw r_tmp, r34
  94. /* Move some arguments to callee-save registers. */
  95. {
  96. move r_context_lo, r_context_lo_in
  97. move r_context_hi, r_context_hi_in
  98. }
  99. {
  100. move r_access_lo, r_access_lo_in
  101. move r_access_hi, r_access_hi_in
  102. }
  103. move r_asid, r_asid_in
  104. /* First, flush our L2 cache. */
  105. {
  106. move r0, zero /* cache_pa */
  107. move r1, zero
  108. }
  109. {
  110. auli r2, zero, ha16(HV_FLUSH_EVICT_L2) /* cache_control */
  111. move r3, r_my_cpumask /* cache_cpumask */
  112. }
  113. {
  114. move r4, zero /* tlb_va */
  115. move r5, zero /* tlb_length */
  116. }
  117. {
  118. move r6, zero /* tlb_pgsize */
  119. move r7, zero /* tlb_cpumask */
  120. }
  121. {
  122. move r8, zero /* asids */
  123. move r9, zero /* asidcount */
  124. }
  125. jal _hv_flush_remote
  126. bnz r0, .Ldone
  127. /* Now install the new page table. */
  128. {
  129. move r0, r_context_lo
  130. move r1, r_context_hi
  131. }
  132. {
  133. move r2, r_access_lo
  134. move r3, r_access_hi
  135. }
  136. {
  137. move r4, r_asid
  138. moveli r5, HV_CTX_DIRECTIO | CTX_PAGE_FLAG
  139. }
  140. jal _hv_install_context
  141. bnz r0, .Ldone
  142. /* Finally, flush the TLB. */
  143. {
  144. movei r0, 0 /* preserve_global */
  145. jal hv_flush_all
  146. }
  147. .Ldone:
  148. /* Restore the callee-saved registers and return. */
  149. addli lr, sp, FRAME_SIZE
  150. {
  151. lw lr, lr
  152. addli r_tmp, sp, FRAME_R30
  153. }
  154. {
  155. lw r30, r_tmp
  156. addli r_tmp, sp, FRAME_R31
  157. }
  158. {
  159. lw r31, r_tmp
  160. addli r_tmp, sp, FRAME_R32
  161. }
  162. {
  163. lw r32, r_tmp
  164. addli r_tmp, sp, FRAME_R33
  165. }
  166. {
  167. lw r33, r_tmp
  168. addli r_tmp, sp, FRAME_R34
  169. }
  170. {
  171. lw r34, r_tmp
  172. addi sp, sp, FRAME_SIZE
  173. }
  174. jrp lr
  175. STD_ENDPROC(flush_and_install_context)