2005-09-22 05:50:51 +04:00
/ * arch/ s p a r c64 / k e r n e l / k t l b . S : K e r n e l m a p p i n g T L B m i s s h a n d l i n g .
*
2008-01-11 08:10:54 +03:00
* Copyright ( C ) 1 9 9 5 , 1 9 9 7 , 2 0 0 5 , 2 0 0 8 D a v i d S . M i l l e r < d a v e m @davemloft.net>
2005-09-22 05:50:51 +04:00
* Copyright ( C ) 1 9 9 6 E d d i e C . D o s t ( e c d @brainaid.de)
* Copyright ( C ) 1 9 9 6 M i g u e l d e I c a z a ( m i g u e l @nuclecu.unam.mx)
* Copyright ( C ) 1 9 9 6 ,9 8 ,9 9 J a k u b J e l i n e k ( j j @sunsite.mff.cuni.cz)
2006-02-01 05:29:18 +03:00
* /
2005-09-22 05:50:51 +04:00
# include < a s m / h e a d . h >
# include < a s m / a s i . h >
# include < a s m / p a g e . h >
# include < a s m / p g t a b l e . h >
2006-02-01 05:29:18 +03:00
# include < a s m / t s b . h >
2005-09-22 05:50:51 +04:00
.text
.align 32
2006-02-01 05:29:18 +03:00
kvmap_itlb :
/* g6: TAG TARGET */
mov T L B _ T A G _ A C C E S S , % g 4
ldxa [ % g 4 ] A S I _ I M M U , % g 4
2006-02-07 10:44:37 +03:00
/ * sun4 v _ i t l b _ m i s s b r a n c h e s h e r e w i t h t h e m i s s i n g v i r t u a l
* address a l r e a d y l o a d e d i n t o % g 4
* /
kvmap_itlb_4v :
2006-02-01 05:29:18 +03:00
kvmap_itlb_nonlinear :
/* Catch kernel NULL pointer calls. */
sethi % h i ( P A G E _ S I Z E ) , % g 5
cmp % g 4 , % g 5
bleu,p n % x c c , k v m a p _ d t l b _ l o n g p a t h
nop
KERN_ T S B _ L O O K U P _ T L 1 ( % g 4 , % g 6 , % g 5 , % g 1 , % g 2 , % g 3 , k v m a p _ i t l b _ l o a d )
kvmap_itlb_tsb_miss :
2005-09-22 05:50:51 +04:00
sethi % h i ( L O W _ O B P _ A D D R E S S ) , % g 5
cmp % g 4 , % g 5
2006-02-01 05:29:18 +03:00
blu,p n % x c c , k v m a p _ i t l b _ v m a l l o c _ a d d r
2005-09-22 05:50:51 +04:00
mov 0 x1 , % g 5
sllx % g 5 , 3 2 , % g 5
cmp % g 4 , % g 5
2006-02-01 05:29:18 +03:00
blu,p n % x c c , k v m a p _ i t l b _ o b p
2005-09-22 05:50:51 +04:00
nop
2006-02-01 05:29:18 +03:00
kvmap_itlb_vmalloc_addr :
KERN_ P G T A B L E _ W A L K ( % g 4 , % g 5 , % g 2 , k v m a p _ i t l b _ l o n g p a t h )
2006-02-11 23:21:20 +03:00
KTSB_ L O C K _ T A G ( % g 1 , % g 2 , % g 7 )
2006-02-01 05:29:18 +03:00
/* Load and check PTE. */
ldxa [ % g 5 ] A S I _ P H Y S _ U S E _ E C , % g 5
2006-02-18 05:01:02 +03:00
mov 1 , % g 7
sllx % g 7 , T S B _ T A G _ I N V A L I D _ B I T , % g 7
2006-02-01 05:29:18 +03:00
brgez,a ,p n % g 5 , k v m a p _ i t l b _ l o n g p a t h
2006-02-18 05:01:02 +03:00
KTSB_ S T O R E ( % g 1 , % g 7 )
2005-09-22 05:50:51 +04:00
2006-02-02 02:55:21 +03:00
KTSB_ W R I T E ( % g 1 , % g 5 , % g 6 )
2006-02-01 05:29:18 +03:00
/* fallthrough to TLB load */
kvmap_itlb_load :
2006-02-11 23:21:20 +03:00
661 : stxa % g 5 , [ % g 0 ] A S I _ I T L B _ D A T A _ I N
2005-09-22 05:50:51 +04:00
retry
2006-02-11 23:21:20 +03:00
.section .sun4v_2insn_patch , " ax"
.word 661b
nop
nop
.previous
/ * For s u n 4 v t h e A S I _ I T L B _ D A T A _ I N s t o r e a n d t h e r e t r y
* instruction g e t n o p ' d o u t a n d w e g e t h e r e t o b r a n c h
* to t h e s u n 4 v t l b l o a d c o d e . T h e r e g i s t e r s a r e s e t u p
* as f o l l o w s :
*
* % g4 : vaddr
* % g5 : PTE
* % g6 : TAG
*
* The s u n 4 v T L B l o a d w a n t s t h e P T E i n % g 3 s o w e f i x t h a t
* up h e r e .
* /
ba,p t % x c c , s u n 4 v _ i t l b _ l o a d
mov % g 5 , % g 3
2005-09-22 05:50:51 +04:00
2006-02-01 05:29:18 +03:00
kvmap_itlb_longpath :
2006-02-06 09:27:28 +03:00
661 : rdpr % p s t a t e , % g 5
2006-02-01 05:29:18 +03:00
wrpr % g 5 , P S T A T E _ A G | P S T A T E _ M G , % p s t a t e
2006-02-07 11:00:16 +03:00
.section .sun4v_2insn_patch , " ax"
2006-02-06 09:27:28 +03:00
.word 661b
2006-02-19 03:36:39 +03:00
SET_ G L ( 1 )
2006-02-06 09:27:28 +03:00
nop
.previous
2006-02-01 05:29:18 +03:00
rdpr % t p c , % g 5
ba,p t % x c c , s p a r c64 _ r e a l f a u l t _ c o m m o n
mov F A U L T _ C O D E _ I T L B , % g 4
kvmap_itlb_obp :
OBP_ T R A N S _ L O O K U P ( % g 4 , % g 5 , % g 2 , % g 3 , k v m a p _ i t l b _ l o n g p a t h )
2006-02-11 23:21:20 +03:00
KTSB_ L O C K _ T A G ( % g 1 , % g 2 , % g 7 )
2006-02-01 05:29:18 +03:00
2006-02-02 02:55:21 +03:00
KTSB_ W R I T E ( % g 1 , % g 5 , % g 6 )
2006-02-01 05:29:18 +03:00
ba,p t % x c c , k v m a p _ i t l b _ l o a d
nop
kvmap_dtlb_obp :
OBP_ T R A N S _ L O O K U P ( % g 4 , % g 5 , % g 2 , % g 3 , k v m a p _ d t l b _ l o n g p a t h )
2006-02-11 23:21:20 +03:00
KTSB_ L O C K _ T A G ( % g 1 , % g 2 , % g 7 )
2006-02-01 05:29:18 +03:00
2006-02-02 02:55:21 +03:00
KTSB_ W R I T E ( % g 1 , % g 5 , % g 6 )
2006-02-01 05:29:18 +03:00
ba,p t % x c c , k v m a p _ d t l b _ l o a d
nop
2005-10-12 23:22:46 +04:00
2005-09-22 05:50:51 +04:00
.align 32
2006-02-22 09:31:11 +03:00
kvmap_dtlb_tsb4m_load :
KTSB_ L O C K _ T A G ( % g 1 , % g 2 , % g 7 )
KTSB_ W R I T E ( % g 1 , % g 5 , % g 6 )
ba,p t % x c c , k v m a p _ d t l b _ l o a d
nop
2006-02-01 05:29:18 +03:00
kvmap_dtlb :
/* %g6: TAG TARGET */
mov T L B _ T A G _ A C C E S S , % g 4
ldxa [ % g 4 ] A S I _ D M M U , % g 4
2006-02-07 10:44:37 +03:00
/ * sun4 v _ d t l b _ m i s s b r a n c h e s h e r e w i t h t h e m i s s i n g v i r t u a l
* address a l r e a d y l o a d e d i n t o % g 4
* /
kvmap_dtlb_4v :
2006-02-01 05:29:18 +03:00
brgez,p n % g 4 , k v m a p _ d t l b _ n o n l i n e a r
2005-09-26 03:46:57 +04:00
nop
2007-03-17 03:20:28 +03:00
# ifdef C O N F I G _ D E B U G _ P A G E A L L O C
/ * Index t h r o u g h t h e b a s e p a g e s i z e T S B e v e n f o r l i n e a r
* mappings w h e n u s i n g p a g e a l l o c a t i o n d e b u g g i n g .
* /
KERN_ T S B _ L O O K U P _ T L 1 ( % g 4 , % g 6 , % g 5 , % g 1 , % g 2 , % g 3 , k v m a p _ d t l b _ l o a d )
# else
2006-02-22 09:31:11 +03:00
/* Correct TAG_TARGET is already in %g6, check 4mb TSB. */
KERN_ T S B 4 M _ L O O K U P _ T L 1 ( % g 6 , % g 5 , % g 1 , % g 2 , % g 3 , k v m a p _ d t l b _ l o a d )
2007-03-17 03:20:28 +03:00
# endif
2006-02-22 09:31:11 +03:00
/ * TSB e n t r y a d d r e s s l e f t i n % g 1 , l o o k u p l i n e a r P T E .
* Must p r e s e r v e % g 1 a n d % g 6 ( T A G ) .
* /
kvmap_dtlb_tsb4m_miss :
2006-02-22 07:51:13 +03:00
sethi % h i ( k p t e _ l i n e a r _ b i t m a p ) , % g 2
or % g 2 , % l o ( k p t e _ l i n e a r _ b i t m a p ) , % g 2
/ * Clear t h e P A G E _ O F F S E T t o p v i r t u a l b i t s , t h e n s h i f t
* down t o g e t a 2 5 6 M B p h y s i c a l a d d r e s s i n d e x .
* /
sllx % g 4 , 2 1 , % g 5
mov 1 , % g 7
srlx % g 5 , 2 1 + 2 8 , % g 5
/ * Don' t t r y t h i s a t h o m e k i d s . . . t h i s d e p e n d s u p o n s r l x
* only t a k i n g t h e l o w 6 b i t s o f t h e s h i f t c o u n t i n % g 5 .
* /
sllx % g 7 , % g 5 , % g 7
/* Divide by 64 to get the offset into the bitmask. */
srlx % g 5 , 6 , % g 5
2006-02-27 10:09:37 +03:00
sllx % g 5 , 3 , % g 5
2006-02-22 07:51:13 +03:00
/* kern_linear_pte_xor[((mask & bit) ? 1 : 0)] */
ldx [ % g 2 + % g 5 ] , % g 2
andcc % g 2 , % g 7 , % g 0
sethi % h i ( k e r n _ l i n e a r _ p t e _ x o r ) , % g 5
or % g 5 , % l o ( k e r n _ l i n e a r _ p t e _ x o r ) , % g 5
bne,a ,p t % x c c , 1 f
add % g 5 , 8 , % g 5
1 : ldx [ % g 5 ] , % g 2
2006-02-01 05:29:18 +03:00
2005-09-26 03:46:57 +04:00
.globl kvmap_linear_patch
kvmap_linear_patch :
2006-02-22 09:31:11 +03:00
ba,p t % x c c , k v m a p _ d t l b _ t s b4 m _ l o a d
2005-09-22 05:50:51 +04:00
xor % g 2 , % g 4 , % g 5
2006-02-01 05:29:18 +03:00
kvmap_dtlb_vmalloc_addr :
KERN_ P G T A B L E _ W A L K ( % g 4 , % g 5 , % g 2 , k v m a p _ d t l b _ l o n g p a t h )
2006-02-11 23:21:20 +03:00
KTSB_ L O C K _ T A G ( % g 1 , % g 2 , % g 7 )
2006-02-01 05:29:18 +03:00
/* Load and check PTE. */
ldxa [ % g 5 ] A S I _ P H Y S _ U S E _ E C , % g 5
2006-02-18 05:01:02 +03:00
mov 1 , % g 7
sllx % g 7 , T S B _ T A G _ I N V A L I D _ B I T , % g 7
2006-02-01 05:29:18 +03:00
brgez,a ,p n % g 5 , k v m a p _ d t l b _ l o n g p a t h
2006-02-18 05:01:02 +03:00
KTSB_ S T O R E ( % g 1 , % g 7 )
2006-02-01 05:29:18 +03:00
2006-02-02 02:55:21 +03:00
KTSB_ W R I T E ( % g 1 , % g 5 , % g 6 )
2006-02-01 05:29:18 +03:00
/* fallthrough to TLB load */
kvmap_dtlb_load :
2006-02-11 23:21:20 +03:00
661 : stxa % g 5 , [ % g 0 ] A S I _ D T L B _ D A T A _ I N ! R e l o a d T L B
2006-02-01 05:29:18 +03:00
retry
2006-02-11 23:21:20 +03:00
.section .sun4v_2insn_patch , " ax"
.word 661b
nop
nop
.previous
/ * For s u n 4 v t h e A S I _ D T L B _ D A T A _ I N s t o r e a n d t h e r e t r y
* instruction g e t n o p ' d o u t a n d w e g e t h e r e t o b r a n c h
* to t h e s u n 4 v t l b l o a d c o d e . T h e r e g i s t e r s a r e s e t u p
* as f o l l o w s :
*
* % g4 : vaddr
* % g5 : PTE
* % g6 : TAG
*
* The s u n 4 v T L B l o a d w a n t s t h e P T E i n % g 3 s o w e f i x t h a t
* up h e r e .
* /
ba,p t % x c c , s u n 4 v _ d t l b _ l o a d
mov % g 5 , % g 3
2006-02-01 05:29:18 +03:00
2008-01-11 08:10:54 +03:00
# ifdef C O N F I G _ S P A R S E M E M _ V M E M M A P
2007-10-16 12:24:16 +04:00
kvmap_vmemmap :
sub % g 4 , % g 5 , % g 5
srlx % g 5 , 2 2 , % g 5
sethi % h i ( v m e m m a p _ t a b l e ) , % g 1
sllx % g 5 , 3 , % g 5
or % g 1 , % l o ( v m e m m a p _ t a b l e ) , % g 1
ba,p t % x c c , k v m a p _ d t l b _ l o a d
ldx [ % g 1 + % g 5 ] , % g 5
2008-01-11 08:10:54 +03:00
# endif
2007-10-16 12:24:16 +04:00
2006-02-01 05:29:18 +03:00
kvmap_dtlb_nonlinear :
/* Catch kernel NULL pointer derefs. */
sethi % h i ( P A G E _ S I Z E ) , % g 5
cmp % g 4 , % g 5
bleu,p n % x c c , k v m a p _ d t l b _ l o n g p a t h
2005-09-26 03:46:57 +04:00
nop
2008-01-11 08:10:54 +03:00
# ifdef C O N F I G _ S P A R S E M E M _ V M E M M A P
2007-10-16 12:24:16 +04:00
/* Do not use the TSB for vmemmap. */
mov ( V M E M M A P _ B A S E > > 2 4 ) , % g 5
sllx % g 5 , 2 4 , % g 5
cmp % g 4 ,% g 5
bgeu,p n % x c c , k v m a p _ v m e m m a p
nop
2008-01-11 08:10:54 +03:00
# endif
2007-10-16 12:24:16 +04:00
2006-02-01 05:29:18 +03:00
KERN_ T S B _ L O O K U P _ T L 1 ( % g 4 , % g 6 , % g 5 , % g 1 , % g 2 , % g 3 , k v m a p _ d t l b _ l o a d )
kvmap_dtlb_tsbmiss :
2005-09-22 05:50:51 +04:00
sethi % h i ( M O D U L E S _ V A D D R ) , % g 5
cmp % g 4 , % g 5
2006-02-01 05:29:18 +03:00
blu,p n % x c c , k v m a p _ d t l b _ l o n g p a t h
2005-09-22 05:50:51 +04:00
mov ( V M A L L O C _ E N D > > 2 4 ) , % g 5
sllx % g 5 , 2 4 , % g 5
cmp % g 4 , % g 5
2006-02-01 05:29:18 +03:00
bgeu,p n % x c c , k v m a p _ d t l b _ l o n g p a t h
2005-09-22 05:50:51 +04:00
nop
kvmap_check_obp :
sethi % h i ( L O W _ O B P _ A D D R E S S ) , % g 5
cmp % g 4 , % g 5
2006-02-01 05:29:18 +03:00
blu,p n % x c c , k v m a p _ d t l b _ v m a l l o c _ a d d r
2005-09-22 05:50:51 +04:00
mov 0 x1 , % g 5
sllx % g 5 , 3 2 , % g 5
cmp % g 4 , % g 5
2006-02-01 05:29:18 +03:00
blu,p n % x c c , k v m a p _ d t l b _ o b p
2005-09-22 05:50:51 +04:00
nop
2006-02-01 05:29:18 +03:00
ba,p t % x c c , k v m a p _ d t l b _ v m a l l o c _ a d d r
2005-09-22 05:50:51 +04:00
nop
2006-02-01 05:29:18 +03:00
kvmap_dtlb_longpath :
2006-02-06 09:27:28 +03:00
661 : rdpr % p s t a t e , % g 5
2006-02-01 05:29:18 +03:00
wrpr % g 5 , P S T A T E _ A G | P S T A T E _ M G , % p s t a t e
2006-02-07 11:00:16 +03:00
.section .sun4v_2insn_patch , " ax"
2006-02-06 09:27:28 +03:00
.word 661b
2006-02-18 05:01:02 +03:00
SET_ G L ( 1 )
ldxa [ % g 0 ] A S I _ S C R A T C H P A D , % g 5
2006-02-06 09:27:28 +03:00
.previous
2006-02-11 23:21:20 +03:00
rdpr % t l , % g 3
cmp % g 3 , 1
661 : mov T L B _ T A G _ A C C E S S , % g 4
2006-02-01 05:29:18 +03:00
ldxa [ % g 4 ] A S I _ D M M U , % g 5
2006-02-11 23:21:20 +03:00
.section .sun4v_2insn_patch , " ax"
.word 661b
2006-02-18 05:01:02 +03:00
ldx [ % g 5 + H V _ F A U L T _ D _ A D D R _ O F F S E T ] , % g 5
2006-02-11 23:21:20 +03:00
nop
.previous
2006-02-01 05:29:18 +03:00
be,p t % x c c , s p a r c64 _ r e a l f a u l t _ c o m m o n
mov F A U L T _ C O D E _ D T L B , % g 4
ba,p t % x c c , w i n f i x _ t r a m p o l i n e
nop