migrate_64.S 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * Copyright 2011 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 8
  33. #define FRAME_R30 16
  34. #define FRAME_R31 24
  35. #define FRAME_R32 32
  36. #define FRAME_R33 40
  37. #define FRAME_SIZE 48
  38. /*
  39. * On entry:
  40. *
  41. * r0 the new context PA to install (moved to r_context)
  42. * r1 PTE to use for context access (moved to r_access)
  43. * r2 ASID to use for new context (moved to r_asid)
  44. * r3 pointer to cpumask with just this cpu set in it (r_my_cpumask)
  45. */
  46. /* Arguments (caller-save) */
  47. #define r_context_in r0
  48. #define r_access_in r1
  49. #define r_asid_in r2
  50. #define r_my_cpumask r3
  51. /* Locals (callee-save); must not be more than FRAME_xxx above. */
  52. #define r_save_ics r30
  53. #define r_context r31
  54. #define r_access r32
  55. #define r_asid r33
  56. /*
  57. * Caller-save locals and frame constants are the same as
  58. * for homecache_migrate_stack_and_flush.
  59. */
  60. STD_ENTRY(flush_and_install_context)
  61. /*
  62. * Create a stack frame; we can't touch it once we flush the
  63. * cache until we install the new page table and flush the TLB.
  64. */
  65. {
  66. move r_save_sp, sp
  67. st sp, lr
  68. addi sp, sp, -FRAME_SIZE
  69. }
  70. addi r_tmp, sp, FRAME_SP
  71. {
  72. st r_tmp, r_save_sp
  73. addi r_tmp, sp, FRAME_R30
  74. }
  75. {
  76. st r_tmp, r30
  77. addi r_tmp, sp, FRAME_R31
  78. }
  79. {
  80. st r_tmp, r31
  81. addi r_tmp, sp, FRAME_R32
  82. }
  83. {
  84. st r_tmp, r32
  85. addi r_tmp, sp, FRAME_R33
  86. }
  87. st r_tmp, r33
  88. /* Move some arguments to callee-save registers. */
  89. {
  90. move r_context, r_context_in
  91. move r_access, r_access_in
  92. }
  93. move r_asid, r_asid_in
  94. /* Disable interrupts, since we can't use our stack. */
  95. {
  96. mfspr r_save_ics, INTERRUPT_CRITICAL_SECTION
  97. movei r_tmp, 1
  98. }
  99. mtspr INTERRUPT_CRITICAL_SECTION, r_tmp
  100. /* First, flush our L2 cache. */
  101. {
  102. move r0, zero /* cache_pa */
  103. moveli r1, hw2_last(HV_FLUSH_EVICT_L2) /* cache_control */
  104. }
  105. {
  106. shl16insli r1, r1, hw1(HV_FLUSH_EVICT_L2)
  107. move r2, r_my_cpumask /* cache_cpumask */
  108. }
  109. {
  110. shl16insli r1, r1, hw0(HV_FLUSH_EVICT_L2)
  111. move r3, zero /* tlb_va */
  112. }
  113. {
  114. move r4, zero /* tlb_length */
  115. move r5, zero /* tlb_pgsize */
  116. }
  117. {
  118. move r6, zero /* tlb_cpumask */
  119. move r7, zero /* asids */
  120. }
  121. {
  122. move r8, zero /* asidcount */
  123. jal hv_flush_remote
  124. }
  125. bnez r0, 1f
  126. /* Now install the new page table. */
  127. {
  128. move r0, r_context
  129. move r1, r_access
  130. }
  131. {
  132. move r2, r_asid
  133. movei r3, HV_CTX_DIRECTIO
  134. }
  135. jal hv_install_context
  136. bnez r0, 1f
  137. /* Finally, flush the TLB. */
  138. {
  139. movei r0, 0 /* preserve_global */
  140. jal hv_flush_all
  141. }
  142. 1: /* Reset interrupts back how they were before. */
  143. mtspr INTERRUPT_CRITICAL_SECTION, r_save_ics
  144. /* Restore the callee-saved registers and return. */
  145. addli lr, sp, FRAME_SIZE
  146. {
  147. ld lr, lr
  148. addli r_tmp, sp, FRAME_R30
  149. }
  150. {
  151. ld r30, r_tmp
  152. addli r_tmp, sp, FRAME_R31
  153. }
  154. {
  155. ld r31, r_tmp
  156. addli r_tmp, sp, FRAME_R32
  157. }
  158. {
  159. ld r32, r_tmp
  160. addli r_tmp, sp, FRAME_R33
  161. }
  162. {
  163. ld r33, r_tmp
  164. addi sp, sp, FRAME_SIZE
  165. }
  166. jrp lr
  167. STD_ENDPROC(flush_and_install_context)