2005-09-21 19:50:51 -06:00
|
|
|
/* arch/sparc64/kernel/ktlb.S: Kernel mapping TLB miss handling.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995, 1997, 2005 David S. Miller <davem@davemloft.net>
|
|
|
|
* Copyright (C) 1996 Eddie C. Dost (ecd@brainaid.de)
|
|
|
|
* Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
|
|
|
|
* Copyright (C) 1996,98,99 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
|
2006-01-31 19:29:18 -07:00
|
|
|
*/
|
2005-09-21 19:50:51 -06:00
|
|
|
|
|
|
|
#include <linux/config.h>
|
|
|
|
#include <asm/head.h>
|
|
|
|
#include <asm/asi.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/pgtable.h>
|
2006-01-31 19:29:18 -07:00
|
|
|
#include <asm/tsb.h>
|
2005-09-21 19:50:51 -06:00
|
|
|
|
|
|
|
.text
|
|
|
|
.align 32
|
|
|
|
|
2006-01-31 19:29:18 -07:00
|
|
|
kvmap_itlb:
|
|
|
|
/* g6: TAG TARGET */
|
|
|
|
mov TLB_TAG_ACCESS, %g4
|
|
|
|
ldxa [%g4] ASI_IMMU, %g4
|
|
|
|
|
2006-02-07 00:44:37 -07:00
|
|
|
/* sun4v_itlb_miss branches here with the missing virtual
|
|
|
|
* address already loaded into %g4
|
|
|
|
*/
|
|
|
|
kvmap_itlb_4v:
|
|
|
|
|
2006-01-31 19:29:18 -07:00
|
|
|
kvmap_itlb_nonlinear:
|
|
|
|
/* Catch kernel NULL pointer calls. */
|
|
|
|
sethi %hi(PAGE_SIZE), %g5
|
|
|
|
cmp %g4, %g5
|
|
|
|
bleu,pn %xcc, kvmap_dtlb_longpath
|
|
|
|
nop
|
|
|
|
|
|
|
|
KERN_TSB_LOOKUP_TL1(%g4, %g6, %g5, %g1, %g2, %g3, kvmap_itlb_load)
|
|
|
|
|
|
|
|
kvmap_itlb_tsb_miss:
|
2005-09-21 19:50:51 -06:00
|
|
|
sethi %hi(LOW_OBP_ADDRESS), %g5
|
|
|
|
cmp %g4, %g5
|
2006-01-31 19:29:18 -07:00
|
|
|
blu,pn %xcc, kvmap_itlb_vmalloc_addr
|
2005-09-21 19:50:51 -06:00
|
|
|
mov 0x1, %g5
|
|
|
|
sllx %g5, 32, %g5
|
|
|
|
cmp %g4, %g5
|
2006-01-31 19:29:18 -07:00
|
|
|
blu,pn %xcc, kvmap_itlb_obp
|
2005-09-21 19:50:51 -06:00
|
|
|
nop
|
|
|
|
|
2006-01-31 19:29:18 -07:00
|
|
|
kvmap_itlb_vmalloc_addr:
|
|
|
|
KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_itlb_longpath)
|
|
|
|
|
2006-02-11 13:21:20 -07:00
|
|
|
KTSB_LOCK_TAG(%g1, %g2, %g7)
|
2006-01-31 19:29:18 -07:00
|
|
|
|
|
|
|
/* Load and check PTE. */
|
|
|
|
ldxa [%g5] ASI_PHYS_USE_EC, %g5
|
|
|
|
brgez,a,pn %g5, kvmap_itlb_longpath
|
2006-02-01 16:55:21 -07:00
|
|
|
KTSB_STORE(%g1, %g0)
|
2005-09-21 19:50:51 -06:00
|
|
|
|
2006-02-01 16:55:21 -07:00
|
|
|
KTSB_WRITE(%g1, %g5, %g6)
|
2006-01-31 19:29:18 -07:00
|
|
|
|
|
|
|
/* fallthrough to TLB load */
|
|
|
|
|
|
|
|
kvmap_itlb_load:
|
2006-02-11 13:21:20 -07:00
|
|
|
|
|
|
|
661: stxa %g5, [%g0] ASI_ITLB_DATA_IN
|
2005-09-21 19:50:51 -06:00
|
|
|
retry
|
2006-02-11 13:21:20 -07:00
|
|
|
.section .sun4v_2insn_patch, "ax"
|
|
|
|
.word 661b
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
.previous
|
|
|
|
|
|
|
|
/* For sun4v the ASI_ITLB_DATA_IN store and the retry
|
|
|
|
* instruction get nop'd out and we get here to branch
|
|
|
|
* to the sun4v tlb load code. The registers are setup
|
|
|
|
* as follows:
|
|
|
|
*
|
|
|
|
* %g4: vaddr
|
|
|
|
* %g5: PTE
|
|
|
|
* %g6: TAG
|
|
|
|
*
|
|
|
|
* The sun4v TLB load wants the PTE in %g3 so we fix that
|
|
|
|
* up here.
|
|
|
|
*/
|
|
|
|
ba,pt %xcc, sun4v_itlb_load
|
|
|
|
mov %g5, %g3
|
2005-09-21 19:50:51 -06:00
|
|
|
|
2006-01-31 19:29:18 -07:00
|
|
|
kvmap_itlb_longpath:
|
2006-02-05 23:27:28 -07:00
|
|
|
|
|
|
|
661: rdpr %pstate, %g5
|
2006-01-31 19:29:18 -07:00
|
|
|
wrpr %g5, PSTATE_AG | PSTATE_MG, %pstate
|
2006-02-07 01:00:16 -07:00
|
|
|
.section .sun4v_2insn_patch, "ax"
|
2006-02-05 23:27:28 -07:00
|
|
|
.word 661b
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
.previous
|
|
|
|
|
2006-01-31 19:29:18 -07:00
|
|
|
rdpr %tpc, %g5
|
|
|
|
ba,pt %xcc, sparc64_realfault_common
|
|
|
|
mov FAULT_CODE_ITLB, %g4
|
|
|
|
|
|
|
|
kvmap_itlb_obp:
|
|
|
|
OBP_TRANS_LOOKUP(%g4, %g5, %g2, %g3, kvmap_itlb_longpath)
|
|
|
|
|
2006-02-11 13:21:20 -07:00
|
|
|
KTSB_LOCK_TAG(%g1, %g2, %g7)
|
2006-01-31 19:29:18 -07:00
|
|
|
|
2006-02-01 16:55:21 -07:00
|
|
|
KTSB_WRITE(%g1, %g5, %g6)
|
2006-01-31 19:29:18 -07:00
|
|
|
|
|
|
|
ba,pt %xcc, kvmap_itlb_load
|
|
|
|
nop
|
|
|
|
|
|
|
|
kvmap_dtlb_obp:
|
|
|
|
OBP_TRANS_LOOKUP(%g4, %g5, %g2, %g3, kvmap_dtlb_longpath)
|
|
|
|
|
2006-02-11 13:21:20 -07:00
|
|
|
KTSB_LOCK_TAG(%g1, %g2, %g7)
|
2006-01-31 19:29:18 -07:00
|
|
|
|
2006-02-01 16:55:21 -07:00
|
|
|
KTSB_WRITE(%g1, %g5, %g6)
|
2006-01-31 19:29:18 -07:00
|
|
|
|
|
|
|
ba,pt %xcc, kvmap_dtlb_load
|
|
|
|
nop
|
2005-10-12 13:22:46 -06:00
|
|
|
|
2005-09-21 19:50:51 -06:00
|
|
|
.align 32
|
2006-01-31 19:29:18 -07:00
|
|
|
kvmap_dtlb:
|
|
|
|
/* %g6: TAG TARGET */
|
|
|
|
mov TLB_TAG_ACCESS, %g4
|
|
|
|
ldxa [%g4] ASI_DMMU, %g4
|
2006-02-07 00:44:37 -07:00
|
|
|
|
|
|
|
/* sun4v_dtlb_miss branches here with the missing virtual
|
|
|
|
* address already loaded into %g4
|
|
|
|
*/
|
|
|
|
kvmap_dtlb_4v:
|
2006-01-31 19:29:18 -07:00
|
|
|
brgez,pn %g4, kvmap_dtlb_nonlinear
|
2005-09-25 17:46:57 -06:00
|
|
|
nop
|
|
|
|
|
2006-02-11 22:57:54 -07:00
|
|
|
sethi %hi(kern_linear_pte_xor), %g2
|
|
|
|
ldx [%g2 + %lo(kern_linear_pte_xor)], %g2
|
2006-01-31 19:29:18 -07:00
|
|
|
|
2005-09-25 17:46:57 -06:00
|
|
|
.globl kvmap_linear_patch
|
|
|
|
kvmap_linear_patch:
|
2006-01-31 19:29:18 -07:00
|
|
|
ba,pt %xcc, kvmap_dtlb_load
|
2005-09-21 19:50:51 -06:00
|
|
|
xor %g2, %g4, %g5
|
|
|
|
|
2006-01-31 19:29:18 -07:00
|
|
|
kvmap_dtlb_vmalloc_addr:
|
|
|
|
KERN_PGTABLE_WALK(%g4, %g5, %g2, kvmap_dtlb_longpath)
|
|
|
|
|
2006-02-11 13:21:20 -07:00
|
|
|
KTSB_LOCK_TAG(%g1, %g2, %g7)
|
2006-01-31 19:29:18 -07:00
|
|
|
|
|
|
|
/* Load and check PTE. */
|
|
|
|
ldxa [%g5] ASI_PHYS_USE_EC, %g5
|
|
|
|
brgez,a,pn %g5, kvmap_dtlb_longpath
|
2006-02-01 16:55:21 -07:00
|
|
|
KTSB_STORE(%g1, %g0)
|
2006-01-31 19:29:18 -07:00
|
|
|
|
2006-02-01 16:55:21 -07:00
|
|
|
KTSB_WRITE(%g1, %g5, %g6)
|
2006-01-31 19:29:18 -07:00
|
|
|
|
|
|
|
/* fallthrough to TLB load */
|
|
|
|
|
|
|
|
kvmap_dtlb_load:
|
2006-02-11 13:21:20 -07:00
|
|
|
|
|
|
|
661: stxa %g5, [%g0] ASI_DTLB_DATA_IN ! Reload TLB
|
2006-01-31 19:29:18 -07:00
|
|
|
retry
|
2006-02-11 13:21:20 -07:00
|
|
|
.section .sun4v_2insn_patch, "ax"
|
|
|
|
.word 661b
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
.previous
|
|
|
|
|
|
|
|
/* For sun4v the ASI_DTLB_DATA_IN store and the retry
|
|
|
|
* instruction get nop'd out and we get here to branch
|
|
|
|
* to the sun4v tlb load code. The registers are setup
|
|
|
|
* as follows:
|
|
|
|
*
|
|
|
|
* %g4: vaddr
|
|
|
|
* %g5: PTE
|
|
|
|
* %g6: TAG
|
|
|
|
*
|
|
|
|
* The sun4v TLB load wants the PTE in %g3 so we fix that
|
|
|
|
* up here.
|
|
|
|
*/
|
|
|
|
ba,pt %xcc, sun4v_dtlb_load
|
|
|
|
mov %g5, %g3
|
2006-01-31 19:29:18 -07:00
|
|
|
|
|
|
|
kvmap_dtlb_nonlinear:
|
|
|
|
/* Catch kernel NULL pointer derefs. */
|
|
|
|
sethi %hi(PAGE_SIZE), %g5
|
|
|
|
cmp %g4, %g5
|
|
|
|
bleu,pn %xcc, kvmap_dtlb_longpath
|
2005-09-25 17:46:57 -06:00
|
|
|
nop
|
|
|
|
|
2006-01-31 19:29:18 -07:00
|
|
|
KERN_TSB_LOOKUP_TL1(%g4, %g6, %g5, %g1, %g2, %g3, kvmap_dtlb_load)
|
|
|
|
|
|
|
|
kvmap_dtlb_tsbmiss:
|
2005-09-21 19:50:51 -06:00
|
|
|
sethi %hi(MODULES_VADDR), %g5
|
|
|
|
cmp %g4, %g5
|
2006-01-31 19:29:18 -07:00
|
|
|
blu,pn %xcc, kvmap_dtlb_longpath
|
2005-09-21 19:50:51 -06:00
|
|
|
mov (VMALLOC_END >> 24), %g5
|
|
|
|
sllx %g5, 24, %g5
|
|
|
|
cmp %g4, %g5
|
2006-01-31 19:29:18 -07:00
|
|
|
bgeu,pn %xcc, kvmap_dtlb_longpath
|
2005-09-21 19:50:51 -06:00
|
|
|
nop
|
|
|
|
|
|
|
|
kvmap_check_obp:
|
|
|
|
sethi %hi(LOW_OBP_ADDRESS), %g5
|
|
|
|
cmp %g4, %g5
|
2006-01-31 19:29:18 -07:00
|
|
|
blu,pn %xcc, kvmap_dtlb_vmalloc_addr
|
2005-09-21 19:50:51 -06:00
|
|
|
mov 0x1, %g5
|
|
|
|
sllx %g5, 32, %g5
|
|
|
|
cmp %g4, %g5
|
2006-01-31 19:29:18 -07:00
|
|
|
blu,pn %xcc, kvmap_dtlb_obp
|
2005-09-21 19:50:51 -06:00
|
|
|
nop
|
2006-01-31 19:29:18 -07:00
|
|
|
ba,pt %xcc, kvmap_dtlb_vmalloc_addr
|
2005-09-21 19:50:51 -06:00
|
|
|
nop
|
|
|
|
|
2006-01-31 19:29:18 -07:00
|
|
|
kvmap_dtlb_longpath:
|
2006-02-05 23:27:28 -07:00
|
|
|
|
|
|
|
661: rdpr %pstate, %g5
|
2006-01-31 19:29:18 -07:00
|
|
|
wrpr %g5, PSTATE_AG | PSTATE_MG, %pstate
|
2006-02-07 01:00:16 -07:00
|
|
|
.section .sun4v_2insn_patch, "ax"
|
2006-02-05 23:27:28 -07:00
|
|
|
.word 661b
|
|
|
|
nop
|
|
|
|
nop
|
|
|
|
.previous
|
|
|
|
|
2006-02-11 13:21:20 -07:00
|
|
|
rdpr %tl, %g3
|
|
|
|
cmp %g3, 1
|
|
|
|
|
|
|
|
661: mov TLB_TAG_ACCESS, %g4
|
2006-01-31 19:29:18 -07:00
|
|
|
ldxa [%g4] ASI_DMMU, %g5
|
2006-02-11 13:21:20 -07:00
|
|
|
.section .sun4v_2insn_patch, "ax"
|
|
|
|
.word 661b
|
|
|
|
mov %g4, %g5
|
|
|
|
nop
|
|
|
|
.previous
|
|
|
|
|
2006-01-31 19:29:18 -07:00
|
|
|
be,pt %xcc, sparc64_realfault_common
|
|
|
|
mov FAULT_CODE_DTLB, %g4
|
|
|
|
ba,pt %xcc, winfix_trampoline
|
|
|
|
nop
|