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