2005-04-17 02:20:36 +04:00
/ *
* arch/ p p c64 / m m / s l b _ l o w . S
*
* Low- l e v e l S L B r o u t i n e s
*
* Copyright ( C ) 2 0 0 4 D a v i d G i b s o n < d w g @au.ibm.com>, IBM
*
* Based o n e a r l i e r C v e r s i o n :
* Dave E n g e b r e t s e n a n d M i k e C o r r i g a n { e n g e b r e t | m i k e j c } @us.ibm.com
* Copyright ( c ) 2 0 0 1 D a v e E n g e b r e t s e n
* Copyright ( C ) 2 0 0 2 A n t o n B l a n c h a r d < a n t o n @au.ibm.com>, IBM
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or
* modify i t u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e
* as p u b l i s h e d b y t h e F r e e S o f t w a r e F o u n d a t i o n ; either version
* 2 of t h e L i c e n s e , o r ( a t y o u r o p t i o n ) a n y l a t e r v e r s i o n .
* /
# include < l i n u x / c o n f i g . h >
# include < a s m / p r o c e s s o r . h >
# include < a s m / p a g e . h >
# include < a s m / m m u . h >
# include < a s m / p p c _ a s m . h >
2005-09-09 22:57:26 +04:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-17 02:20:36 +04:00
# include < a s m / c p u t a b l e . h >
/ * void s l b _ a l l o c a t e ( u n s i g n e d l o n g e a ) ;
*
* Create a n S L B e n t r y f o r t h e g i v e n E A ( u s e r o r k e r n e l ) .
* r3 = f a u l t i n g a d d r e s s , r13 = P A C A
* r9 , r10 , r11 a r e c l o b b e r e d b y t h i s f u n c t i o n
* No o t h e r r e g i s t e r s a r e e x a m i n e d o r c h a n g e d .
* /
_ GLOBAL( s l b _ a l l o c a t e )
/ *
* First f i n d a s l o t , r o u n d r o b i n . P r e v i o u s l y w e t r i e d t o f i n d
* a f r e e s l o t f i r s t b u t t h a t t o o k t o o l o n g . U n f o r t u n a t e l y w e
* dont h a v e a n y L R U i n f o r m a t i o n t o h e l p u s c h o o s e a s l o t .
* /
# ifdef C O N F I G _ P P C _ I S E R I E S
/ *
* On i S e r i e s , t h e " b o l t e d " s t a c k s e g m e n t c a n b e c a s t o u t o n
* shared p r o c e s s o r s w i t c h s o w e n e e d t o c h e c k f o r a m i s s o n
* it a n d r e s t o r e i t t o t h e r i g h t s l o t .
* /
ld r9 ,P A C A K S A V E ( r13 )
clrrdi r9 ,r9 ,2 8
clrrdi r11 ,r3 ,2 8
li r10 ,S L B _ N U M _ B O L T E D - 1 / * S t a c k g o e s i n l a s t b o l t e d s l o t * /
cmpld r9 ,r11
beq 3 f
# endif / * C O N F I G _ P P C _ I S E R I E S * /
ld r10 ,P A C A S T A B R R ( r13 )
addi r10 ,r10 ,1
/* use a cpu feature mask if we ever change our slb size */
cmpldi r10 ,S L B _ N U M _ E N T R I E S
blt+ 4 f
li r10 ,S L B _ N U M _ B O L T E D
4 :
std r10 ,P A C A S T A B R R ( r13 )
3 :
/* r3 = faulting address, r10 = entry */
srdi r9 ,r3 ,6 0 / * g e t r e g i o n * /
srdi r3 ,r3 ,2 8 / * g e t e s i d * /
cmpldi c r7 ,r9 ,0 x c / * c m p K E R N E L B A S E f o r l a t e r u s e * /
rldimi r10 ,r3 ,2 8 ,0 / * r10 = E S I D < < 2 8 | e n t r y * /
oris r10 ,r10 ,S L B _ E S I D _ V @h /* r10 |= SLB_ESID_V */
/* r3 = esid, r10 = esid_data, cr7 = <>KERNELBASE */
blt c r7 ,0 f / * u s e r o r k e r n e l ? * /
/* kernel address: proto-VSID = ESID */
/ * WARNING - M A G I C : w e d o n ' t u s e t h e V S I D 0 x f f f f f f f f f , b u t
* this c o d e w i l l g e n e r a t e t h e p r o t o V S I D 0 x f f f f f f f f f f o r t h e
* top s e g m e n t . T h a t ' s o k , t h e s c r a m b l e b e l o w w i l l t r a n s l a t e
* it t o V S I D 0 , w h i c h i s r e s e r v e d a s a b a d V S I D - o n e w h i c h
* will n e v e r h a v e a n y p a g e s i n i t . * /
li r11 ,S L B _ V S I D _ K E R N E L
BEGIN_ F T R _ S E C T I O N
bne c r7 ,9 f
li r11 ,( S L B _ V S I D _ K E R N E L | S L B _ V S I D _ L )
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ 1 6 M _ P A G E )
b 9 f
0 : /* user address: proto-VSID = context<<15 | ESID */
2005-08-05 13:39:06 +04:00
srdi. r9 ,r3 ,U S E R _ E S I D _ B I T S
2005-04-17 02:20:36 +04:00
bne- 8 f / * i n v a l i d e a b i t s s e t * /
# ifdef C O N F I G _ H U G E T L B _ P A G E
BEGIN_ F T R _ S E C T I O N
2005-08-11 10:55:21 +04:00
lhz r9 ,P A C A H I G H H T L B A R E A S ( r13 )
srdi r11 ,r3 ,( H T L B _ A R E A _ S H I F T - S I D _ S H I F T )
srd r9 ,r9 ,r11
2005-08-31 08:34:05 +04:00
lhz r11 ,P A C A L O W H T L B A R E A S ( r13 )
srd r11 ,r11 ,r3
or r9 ,r9 ,r11
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ 1 6 M _ P A G E )
# endif / * C O N F I G _ H U G E T L B _ P A G E * /
2005-08-11 10:55:21 +04:00
li r11 ,S L B _ V S I D _ U S E R
2005-08-31 08:34:05 +04:00
# ifdef C O N F I G _ H U G E T L B _ P A G E
BEGIN_ F T R _ S E C T I O N
rldimi r11 ,r9 ,8 ,5 5 / * s h i f t m a s k e d b i t i n t o S L B _ V S I D _ L * /
2005-04-17 02:20:36 +04:00
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ 1 6 M _ P A G E )
# endif / * C O N F I G _ H U G E T L B _ P A G E * /
2005-08-31 08:34:05 +04:00
ld r9 ,P A C A C O N T E X T I D ( r13 )
2005-04-17 02:20:36 +04:00
rldimi r3 ,r9 ,U S E R _ E S I D _ B I T S ,0
9 : /* r3 = protovsid, r11 = flags, r10 = esid_data, cr7 = <>KERNELBASE */
ASM_ V S I D _ S C R A M B L E ( r3 ,r9 )
rldimi r11 ,r3 ,S L B _ V S I D _ S H I F T ,1 6 / * c o m b i n e V S I D a n d f l a g s * /
/ *
* No n e e d f o r a n i s y n c b e f o r e o r a f t e r t h i s s l b m t e . T h e e x c e p t i o n
* we e n t e r w i t h a n d t h e r f i d w e e x i t w i t h a r e c o n t e x t s y n c h r o n i z i n g .
* /
slbmte r11 ,r10
bgelr c r7 / * w e ' r e d o n e f o r k e r n e l a d d r e s s e s * /
/* Update the slb cache */
lhz r3 ,P A C A S L B C A C H E P T R ( r13 ) / * o f f s e t = p a c a - > s l b _ c a c h e _ p t r * /
cmpldi r3 ,S L B _ C A C H E _ E N T R I E S
bge 1 f
/* still room in the slb cache */
sldi r11 ,r3 ,1 / * r11 = o f f s e t * s i z e o f ( u 1 6 ) * /
rldicl r10 ,r10 ,3 6 ,2 8 / * g e t l o w 1 6 b i t s o f t h e E S I D * /
add r11 ,r11 ,r13 / * r11 = ( u 1 6 * ) p a c a + o f f s e t * /
sth r10 ,P A C A S L B C A C H E ( r11 ) / * p a c a - > s l b _ c a c h e [ o f f s e t ] = e s i d * /
addi r3 ,r3 ,1 / * o f f s e t + + * /
b 2 f
1 : /* offset >= SLB_CACHE_ENTRIES */
li r3 ,S L B _ C A C H E _ E N T R I E S + 1
2 :
sth r3 ,P A C A S L B C A C H E P T R ( r13 ) / * p a c a - > s l b _ c a c h e _ p t r = o f f s e t * /
blr
8 : /* invalid EA */
li r3 ,0 / * B A D _ V S I D * /
li r11 ,S L B _ V S I D _ U S E R / * f l a g s d o n ' t m u c h m a t t e r * /
b 9 b