urtt_fill.S 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #include <asm/thread_info.h>
  3. #include <asm/trap_block.h>
  4. #include <asm/spitfire.h>
  5. #include <asm/ptrace.h>
  6. #include <asm/head.h>
  7. .text
  8. .align 8
  9. .globl user_rtt_fill_fixup_common
  10. user_rtt_fill_fixup_common:
  11. rdpr %cwp, %g1
  12. add %g1, 1, %g1
  13. wrpr %g1, 0x0, %cwp
  14. rdpr %wstate, %g2
  15. sll %g2, 3, %g2
  16. wrpr %g2, 0x0, %wstate
  17. /* We know %canrestore and %otherwin are both zero. */
  18. sethi %hi(sparc64_kern_pri_context), %g2
  19. ldx [%g2 + %lo(sparc64_kern_pri_context)], %g2
  20. mov PRIMARY_CONTEXT, %g1
  21. 661: stxa %g2, [%g1] ASI_DMMU
  22. .section .sun4v_1insn_patch, "ax"
  23. .word 661b
  24. stxa %g2, [%g1] ASI_MMU
  25. .previous
  26. sethi %hi(KERNBASE), %g1
  27. flush %g1
  28. mov %g4, %l4
  29. mov %g5, %l5
  30. brnz,pn %g3, 1f
  31. mov %g3, %l3
  32. or %g4, FAULT_CODE_WINFIXUP, %g4
  33. stb %g4, [%g6 + TI_FAULT_CODE]
  34. stx %g5, [%g6 + TI_FAULT_ADDR]
  35. 1:
  36. mov %g6, %l1
  37. wrpr %g0, 0x0, %tl
  38. 661: nop
  39. .section .sun4v_1insn_patch, "ax"
  40. .word 661b
  41. SET_GL(0)
  42. .previous
  43. 661: wrpr %g0, RTRAP_PSTATE, %pstate
  44. .section .sun_m7_1insn_patch, "ax"
  45. .word 661b
  46. /* Re-enable PSTATE.mcde to maintain ADI security */
  47. wrpr %g0, RTRAP_PSTATE|PSTATE_MCDE, %pstate
  48. .previous
  49. mov %l1, %g6
  50. ldx [%g6 + TI_TASK], %g4
  51. LOAD_PER_CPU_BASE(%g5, %g6, %g1, %g2, %g3)
  52. brnz,pn %l3, 1f
  53. nop
  54. call do_sparc64_fault
  55. add %sp, PTREGS_OFF, %o0
  56. ba,pt %xcc, rtrap
  57. nop
  58. 1: cmp %g3, 2
  59. bne,pn %xcc, 2f
  60. nop
  61. sethi %hi(tlb_type), %g1
  62. lduw [%g1 + %lo(tlb_type)], %g1
  63. cmp %g1, 3
  64. bne,pt %icc, 1f
  65. add %sp, PTREGS_OFF, %o0
  66. mov %l4, %o2
  67. call sun4v_do_mna
  68. mov %l5, %o1
  69. ba,a,pt %xcc, rtrap
  70. 1: mov %l4, %o1
  71. mov %l5, %o2
  72. call mem_address_unaligned
  73. nop
  74. ba,a,pt %xcc, rtrap
  75. 2: sethi %hi(tlb_type), %g1
  76. mov %l4, %o1
  77. lduw [%g1 + %lo(tlb_type)], %g1
  78. mov %l5, %o2
  79. cmp %g1, 3
  80. bne,pt %icc, 1f
  81. add %sp, PTREGS_OFF, %o0
  82. call sun4v_data_access_exception
  83. nop
  84. ba,a,pt %xcc, rtrap
  85. nop
  86. 1: call spitfire_data_access_exception
  87. nop
  88. ba,a,pt %xcc, rtrap