1b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */ 27cafc0b8SDavid S. Miller#include <asm/thread_info.h> 37cafc0b8SDavid S. Miller#include <asm/trap_block.h> 47cafc0b8SDavid S. Miller#include <asm/spitfire.h> 57cafc0b8SDavid S. Miller#include <asm/ptrace.h> 67cafc0b8SDavid S. Miller#include <asm/head.h> 77cafc0b8SDavid S. Miller 87cafc0b8SDavid S. Miller .text 97cafc0b8SDavid S. Miller .align 8 107cafc0b8SDavid S. Miller .globl user_rtt_fill_fixup_common 117cafc0b8SDavid S. Milleruser_rtt_fill_fixup_common: 127cafc0b8SDavid S. Miller rdpr %cwp, %g1 137cafc0b8SDavid S. Miller add %g1, 1, %g1 147cafc0b8SDavid S. Miller wrpr %g1, 0x0, %cwp 157cafc0b8SDavid S. Miller 167cafc0b8SDavid S. Miller rdpr %wstate, %g2 177cafc0b8SDavid S. Miller sll %g2, 3, %g2 187cafc0b8SDavid S. Miller wrpr %g2, 0x0, %wstate 197cafc0b8SDavid S. Miller 207cafc0b8SDavid S. Miller /* We know %canrestore and %otherwin are both zero. */ 217cafc0b8SDavid S. Miller 227cafc0b8SDavid S. Miller sethi %hi(sparc64_kern_pri_context), %g2 237cafc0b8SDavid S. Miller ldx [%g2 + %lo(sparc64_kern_pri_context)], %g2 247cafc0b8SDavid S. Miller mov PRIMARY_CONTEXT, %g1 257cafc0b8SDavid S. Miller 267cafc0b8SDavid S. Miller661: stxa %g2, [%g1] ASI_DMMU 277cafc0b8SDavid S. Miller .section .sun4v_1insn_patch, "ax" 287cafc0b8SDavid S. Miller .word 661b 297cafc0b8SDavid S. Miller stxa %g2, [%g1] ASI_MMU 307cafc0b8SDavid S. Miller .previous 317cafc0b8SDavid S. Miller 327cafc0b8SDavid S. Miller sethi %hi(KERNBASE), %g1 337cafc0b8SDavid S. Miller flush %g1 347cafc0b8SDavid S. Miller 357cafc0b8SDavid S. Miller mov %g4, %l4 367cafc0b8SDavid S. Miller mov %g5, %l5 377cafc0b8SDavid S. Miller brnz,pn %g3, 1f 387cafc0b8SDavid S. Miller mov %g3, %l3 397cafc0b8SDavid S. Miller 407cafc0b8SDavid S. Miller or %g4, FAULT_CODE_WINFIXUP, %g4 417cafc0b8SDavid S. Miller stb %g4, [%g6 + TI_FAULT_CODE] 427cafc0b8SDavid S. Miller stx %g5, [%g6 + TI_FAULT_ADDR] 437cafc0b8SDavid S. Miller1: 447cafc0b8SDavid S. Miller mov %g6, %l1 457cafc0b8SDavid S. Miller wrpr %g0, 0x0, %tl 467cafc0b8SDavid S. Miller 477cafc0b8SDavid S. Miller661: nop 487cafc0b8SDavid S. Miller .section .sun4v_1insn_patch, "ax" 497cafc0b8SDavid S. Miller .word 661b 507cafc0b8SDavid S. Miller SET_GL(0) 517cafc0b8SDavid S. Miller .previous 527cafc0b8SDavid S. Miller 53*74a04967SKhalid Aziz661: wrpr %g0, RTRAP_PSTATE, %pstate 54*74a04967SKhalid Aziz .section .sun_m7_1insn_patch, "ax" 55*74a04967SKhalid Aziz .word 661b 56*74a04967SKhalid Aziz /* Re-enable PSTATE.mcde to maintain ADI security */ 57*74a04967SKhalid Aziz wrpr %g0, RTRAP_PSTATE|PSTATE_MCDE, %pstate 58*74a04967SKhalid Aziz .previous 597cafc0b8SDavid S. Miller 607cafc0b8SDavid S. Miller mov %l1, %g6 617cafc0b8SDavid S. Miller ldx [%g6 + TI_TASK], %g4 627cafc0b8SDavid S. Miller LOAD_PER_CPU_BASE(%g5, %g6, %g1, %g2, %g3) 637cafc0b8SDavid S. Miller 647cafc0b8SDavid S. Miller brnz,pn %l3, 1f 657cafc0b8SDavid S. Miller nop 667cafc0b8SDavid S. Miller 677cafc0b8SDavid S. Miller call do_sparc64_fault 687cafc0b8SDavid S. Miller add %sp, PTREGS_OFF, %o0 697cafc0b8SDavid S. Miller ba,pt %xcc, rtrap 707cafc0b8SDavid S. Miller nop 717cafc0b8SDavid S. Miller 727cafc0b8SDavid S. Miller1: cmp %g3, 2 737cafc0b8SDavid S. Miller bne,pn %xcc, 2f 747cafc0b8SDavid S. Miller nop 757cafc0b8SDavid S. Miller 767cafc0b8SDavid S. Miller sethi %hi(tlb_type), %g1 777cafc0b8SDavid S. Miller lduw [%g1 + %lo(tlb_type)], %g1 787cafc0b8SDavid S. Miller cmp %g1, 3 797cafc0b8SDavid S. Miller bne,pt %icc, 1f 807cafc0b8SDavid S. Miller add %sp, PTREGS_OFF, %o0 817cafc0b8SDavid S. Miller mov %l4, %o2 827cafc0b8SDavid S. Miller call sun4v_do_mna 837cafc0b8SDavid S. Miller mov %l5, %o1 847cafc0b8SDavid S. Miller ba,a,pt %xcc, rtrap 857cafc0b8SDavid S. Miller1: mov %l4, %o1 867cafc0b8SDavid S. Miller mov %l5, %o2 877cafc0b8SDavid S. Miller call mem_address_unaligned 887cafc0b8SDavid S. Miller nop 897cafc0b8SDavid S. Miller ba,a,pt %xcc, rtrap 907cafc0b8SDavid S. Miller 917cafc0b8SDavid S. Miller2: sethi %hi(tlb_type), %g1 927cafc0b8SDavid S. Miller mov %l4, %o1 937cafc0b8SDavid S. Miller lduw [%g1 + %lo(tlb_type)], %g1 947cafc0b8SDavid S. Miller mov %l5, %o2 957cafc0b8SDavid S. Miller cmp %g1, 3 967cafc0b8SDavid S. Miller bne,pt %icc, 1f 977cafc0b8SDavid S. Miller add %sp, PTREGS_OFF, %o0 987cafc0b8SDavid S. Miller call sun4v_data_access_exception 997cafc0b8SDavid S. Miller nop 1007cafc0b8SDavid S. Miller ba,a,pt %xcc, rtrap 1010ae2d26fSBabu Moger nop 1027cafc0b8SDavid S. Miller 1037cafc0b8SDavid S. Miller1: call spitfire_data_access_exception 1047cafc0b8SDavid S. Miller nop 1057cafc0b8SDavid S. Miller ba,a,pt %xcc, rtrap 106