winfixup.S 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* winfixup.S: Handle cases where user stack pointer is found to be bogus.
  2. *
  3. * Copyright (C) 1997, 2006 David S. Miller (davem@davemloft.net)
  4. */
  5. #include <asm/asi.h>
  6. #include <asm/head.h>
  7. #include <asm/page.h>
  8. #include <asm/ptrace.h>
  9. #include <asm/processor.h>
  10. #include <asm/spitfire.h>
  11. #include <asm/thread_info.h>
  12. .text
  13. /* It used to be the case that these register window fault
  14. * handlers could run via the save and restore instructions
  15. * done by the trap entry and exit code. They now do the
  16. * window spill/fill by hand, so that case no longer can occur.
  17. */
  18. .align 32
  19. fill_fixup:
  20. TRAP_LOAD_THREAD_REG(%g6, %g1)
  21. rdpr %tstate, %g1
  22. and %g1, TSTATE_CWP, %g1
  23. or %g4, FAULT_CODE_WINFIXUP, %g4
  24. stb %g4, [%g6 + TI_FAULT_CODE]
  25. stx %g5, [%g6 + TI_FAULT_ADDR]
  26. wrpr %g1, %cwp
  27. ba,pt %xcc, etrap
  28. rd %pc, %g7
  29. call do_sparc64_fault
  30. add %sp, PTREGS_OFF, %o0
  31. ba,a,pt %xcc, rtrap
  32. /* Be very careful about usage of the trap globals here.
  33. * You cannot touch %g5 as that has the fault information.
  34. */
  35. spill_fixup:
  36. spill_fixup_mna:
  37. spill_fixup_dax:
  38. TRAP_LOAD_THREAD_REG(%g6, %g1)
  39. ldx [%g6 + TI_FLAGS], %g1
  40. andcc %sp, 0x1, %g0
  41. movne %icc, 0, %g1
  42. andcc %g1, _TIF_32BIT, %g0
  43. ldub [%g6 + TI_WSAVED], %g1
  44. sll %g1, 3, %g3
  45. add %g6, %g3, %g3
  46. stx %sp, [%g3 + TI_RWIN_SPTRS]
  47. sll %g1, 7, %g3
  48. bne,pt %xcc, 1f
  49. add %g6, %g3, %g3
  50. stx %l0, [%g3 + TI_REG_WINDOW + 0x00]
  51. stx %l1, [%g3 + TI_REG_WINDOW + 0x08]
  52. stx %l2, [%g3 + TI_REG_WINDOW + 0x10]
  53. stx %l3, [%g3 + TI_REG_WINDOW + 0x18]
  54. stx %l4, [%g3 + TI_REG_WINDOW + 0x20]
  55. stx %l5, [%g3 + TI_REG_WINDOW + 0x28]
  56. stx %l6, [%g3 + TI_REG_WINDOW + 0x30]
  57. stx %l7, [%g3 + TI_REG_WINDOW + 0x38]
  58. stx %i0, [%g3 + TI_REG_WINDOW + 0x40]
  59. stx %i1, [%g3 + TI_REG_WINDOW + 0x48]
  60. stx %i2, [%g3 + TI_REG_WINDOW + 0x50]
  61. stx %i3, [%g3 + TI_REG_WINDOW + 0x58]
  62. stx %i4, [%g3 + TI_REG_WINDOW + 0x60]
  63. stx %i5, [%g3 + TI_REG_WINDOW + 0x68]
  64. stx %i6, [%g3 + TI_REG_WINDOW + 0x70]
  65. ba,pt %xcc, 2f
  66. stx %i7, [%g3 + TI_REG_WINDOW + 0x78]
  67. 1: stw %l0, [%g3 + TI_REG_WINDOW + 0x00]
  68. stw %l1, [%g3 + TI_REG_WINDOW + 0x04]
  69. stw %l2, [%g3 + TI_REG_WINDOW + 0x08]
  70. stw %l3, [%g3 + TI_REG_WINDOW + 0x0c]
  71. stw %l4, [%g3 + TI_REG_WINDOW + 0x10]
  72. stw %l5, [%g3 + TI_REG_WINDOW + 0x14]
  73. stw %l6, [%g3 + TI_REG_WINDOW + 0x18]
  74. stw %l7, [%g3 + TI_REG_WINDOW + 0x1c]
  75. stw %i0, [%g3 + TI_REG_WINDOW + 0x20]
  76. stw %i1, [%g3 + TI_REG_WINDOW + 0x24]
  77. stw %i2, [%g3 + TI_REG_WINDOW + 0x28]
  78. stw %i3, [%g3 + TI_REG_WINDOW + 0x2c]
  79. stw %i4, [%g3 + TI_REG_WINDOW + 0x30]
  80. stw %i5, [%g3 + TI_REG_WINDOW + 0x34]
  81. stw %i6, [%g3 + TI_REG_WINDOW + 0x38]
  82. stw %i7, [%g3 + TI_REG_WINDOW + 0x3c]
  83. 2: add %g1, 1, %g1
  84. stb %g1, [%g6 + TI_WSAVED]
  85. rdpr %tstate, %g1
  86. andcc %g1, TSTATE_PRIV, %g0
  87. saved
  88. be,pn %xcc, 1f
  89. and %g1, TSTATE_CWP, %g1
  90. retry
  91. 1: mov FAULT_CODE_WRITE | FAULT_CODE_DTLB | FAULT_CODE_WINFIXUP, %g4
  92. stb %g4, [%g6 + TI_FAULT_CODE]
  93. stx %g5, [%g6 + TI_FAULT_ADDR]
  94. wrpr %g1, %cwp
  95. ba,pt %xcc, etrap
  96. rd %pc, %g7
  97. call do_sparc64_fault
  98. add %sp, PTREGS_OFF, %o0
  99. ba,a,pt %xcc, rtrap
  100. winfix_mna:
  101. andn %g3, 0x7f, %g3
  102. add %g3, 0x78, %g3
  103. wrpr %g3, %tnpc
  104. done
  105. fill_fixup_mna:
  106. rdpr %tstate, %g1
  107. and %g1, TSTATE_CWP, %g1
  108. wrpr %g1, %cwp
  109. ba,pt %xcc, etrap
  110. rd %pc, %g7
  111. sethi %hi(tlb_type), %g1
  112. lduw [%g1 + %lo(tlb_type)], %g1
  113. cmp %g1, 3
  114. bne,pt %icc, 1f
  115. add %sp, PTREGS_OFF, %o0
  116. mov %l4, %o2
  117. call sun4v_do_mna
  118. mov %l5, %o1
  119. ba,a,pt %xcc, rtrap
  120. 1: mov %l4, %o1
  121. mov %l5, %o2
  122. call mem_address_unaligned
  123. nop
  124. ba,a,pt %xcc, rtrap
  125. winfix_dax:
  126. andn %g3, 0x7f, %g3
  127. add %g3, 0x74, %g3
  128. wrpr %g3, %tnpc
  129. done
  130. fill_fixup_dax:
  131. rdpr %tstate, %g1
  132. and %g1, TSTATE_CWP, %g1
  133. wrpr %g1, %cwp
  134. ba,pt %xcc, etrap
  135. rd %pc, %g7
  136. sethi %hi(tlb_type), %g1
  137. mov %l4, %o1
  138. lduw [%g1 + %lo(tlb_type)], %g1
  139. mov %l5, %o2
  140. cmp %g1, 3
  141. bne,pt %icc, 1f
  142. add %sp, PTREGS_OFF, %o0
  143. call sun4v_data_access_exception
  144. nop
  145. ba,a,pt %xcc, rtrap
  146. 1: call spitfire_data_access_exception
  147. nop
  148. ba,a,pt %xcc, rtrap