2005-04-17 02:20:36 +04:00
/ *
* Linux/ P A - R I S C P r o j e c t ( h t t p : / / w w w . p a r i s c - l i n u x . o r g / )
*
* kernel e n t r y p o i n t s ( i n t e r r u p t i o n s , s y s t e m c a l l w r a p p e r s )
* Copyright ( C ) 1 9 9 9 ,2 0 0 0 P h i l i p p R u m p f
* Copyright ( C ) 1 9 9 9 S u S E G m b H N u e r n b e r g
* Copyright ( C ) 2 0 0 0 H e w l e t t - P a c k a r d ( J o h n M a r v i n )
* Copyright ( C ) 1 9 9 9 H e w l e t t - P a c k a r d ( F r a n k R o w a n d )
*
* 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
* it 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 a s p u b l i s h e d b y
* the 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, or (at your option)
* any l a t e r v e r s i o n .
*
* This p r o g r a m i s d i s t r i b u t e d i n t h e h o p e t h a t i t w i l l b e u s e f u l ,
* but W I T H O U T A N Y W A R R A N T Y ; without even the implied warranty of
* MERCHANTABILITY o r F I T N E S S F O R A P A R T I C U L A R P U R P O S E . S e e t h e
* GNU G e n e r a l P u b l i c L i c e n s e f o r m o r e d e t a i l s .
*
* You s h o u l d h a v e r e c e i v e d a c o p y 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
* along w i t h t h i s p r o g r a m ; if not, write to the Free Software
* Foundation, I n c . , 6 7 5 M a s s A v e , C a m b r i d g e , M A 0 2 1 3 9 , U S A .
* /
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
/ * we h a v e t h e f o l l o w i n g p o s s i b i l i t i e s t o a c t o n a n i n t e r r u p t i o n :
* - handle i n a s s e m b l y a n d u s e s h a d o w e d r e g i s t e r s o n l y
* - save r e g i s t e r s t o k e r n e l s t a c k a n d h a n d l e i n a s s e m b l y o r C * /
2005-10-22 06:40:07 +04:00
# include < a s m / p s w . h >
2006-08-14 06:17:19 +04:00
# include < a s m / c a c h e . h > / * f o r L 1 _ C A C H E _ S H I F T * /
2005-04-17 02:20:36 +04:00
# include < a s m / a s s e m b l y . h > / * f o r L D R E G / S T R E G d e f i n e s * /
# include < a s m / p g t a b l e . h >
# include < a s m / s i g n a l . h >
# include < a s m / u n i s t d . h >
# include < a s m / t h r e a d _ i n f o . h >
2007-01-23 22:50:59 +03:00
# include < l i n u x / l i n k a g e . h >
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
.level 2 .0w
# else
.level 2 .0
# endif
.import pa_ d b i t _ l o c k ,d a t a
/* space_to_prot macro creates a prot id from a space id */
# if ( S P A C E I D _ S H I F T ) = = 0
.macro space_to_prot spc p r o t
depd,z \ s p c ,6 2 ,3 1 ,\ p r o t
.endm
# else
.macro space_to_prot spc p r o t
extrd,u \ s p c ,( 6 4 - ( S P A C E I D _ S H I F T ) ) ,3 2 ,\ p r o t
.endm
# endif
/* Switch to virtual mapping, trashing only %r1 */
.macro virt_map
2005-10-22 06:40:07 +04:00
/* pcxt_ssm_bug */
rsm P S W _ S M _ I , % r0 / * b a r r i e r f o r " R e l i e d u p o n T r a n s l a t i o n * /
2005-04-17 02:20:36 +04:00
mtsp % r0 , % s r4
mtsp % r0 , % s r5
2005-10-22 06:40:07 +04:00
mfsp % s r7 , % r1
or,= % r0 ,% r1 ,% r0 / * O n l y s a v e s r7 i n s r3 i f s r7 ! = 0 * /
mtsp % r1 , % s r3
tovirt_ r1 % r29
load3 2 K E R N E L _ P S W , % r1
rsm P S W _ S M _ Q U I E T ,% r0 / * s e c o n d " h e a v y w e i g h t " c t l o p * /
2005-04-17 02:20:36 +04:00
mtsp % r0 , % s r6
mtsp % r0 , % s r7
mtctl % r0 , % c r17 / * C l e a r I I A S Q t a i l * /
mtctl % r0 , % c r17 / * C l e a r I I A S Q h e a d * /
2005-10-22 06:40:07 +04:00
mtctl % r1 , % i p s w
2005-04-17 02:20:36 +04:00
load3 2 4 f , % r1
mtctl % r1 , % c r18 / * S e t I I A O Q t a i l * /
ldo 4 ( % r1 ) , % r1
mtctl % r1 , % c r18 / * S e t I I A O Q h e a d * /
rfir
nop
4 :
.endm
/ *
* The " g e t _ s t a c k " m a c r o s a r e r e s p o n s i b l e f o r d e t e r m i n i n g t h e
* kernel s t a c k v a l u e .
*
* If s r7 = = 0
* Already u s i n g a k e r n e l s t a c k , s o c a l l t h e
* get_ s t a c k _ u s e _ r30 m a c r o t o p u s h a p t _ r e g s s t r u c t u r e
* on t h e s t a c k , a n d s t o r e r e g i s t e r s t h e r e .
* else
* Need t o s e t u p a k e r n e l s t a c k , s o c a l l t h e
* get_ s t a c k _ u s e _ c r30 m a c r o t o s e t u p a p o i n t e r
* to t h e p t _ r e g s s t r u c t u r e c o n t a i n e d w i t h i n t h e
* task p o i n t e r p o i n t e d t o b y c r30 . S e t t h e s t a c k
* pointer t o p o i n t t o t h e e n d o f t h e t a s k s t r u c t u r e .
*
* Note t h a t w e u s e s h a d o w e d r e g i s t e r s f o r t e m p s u n t i l
* we c a n s a v e % r26 a n d % r29 . % r26 i s u s e d t o p r e s e r v e
* % r8 ( a s h a d o w e d r e g i s t e r ) w h i c h t e m p o r a r i l y c o n t a i n e d
* either t h e f a u l t t y p e ( " c o d e " ) o r t h e e i r r . W e n e e d
* to u s e a n o n - s h a d o w e d r e g i s t e r t o c a r r y t h e v a l u e o v e r
* the r f i r i n v i r t _ m a p . W e u s e % r26 s i n c e t h i s v a l u e w i n d s
* up b e i n g p a s s e d a s t h e a r g u m e n t t o e i t h e r d o _ c p u _ i r q _ m a s k
* or h a n d l e _ i n t e r r u p t i o n . % r29 i s u s e d t o h o l d a p o i n t e r
* the r e g i s t e r s a v e a r e a , a n d o n c e a g a i n , i t n e e d s t o
* be a n o n - s h a d o w e d r e g i s t e r s o t h a t i t s u r v i v e s t h e r f i r .
*
* N. B . T A S K _ S Z _ A L G N a n d P T _ S Z _ A L G N i n c l u d e s p a c e f o r a s t a c k f r a m e .
* /
.macro get_stack_use_cr30
/* we save the registers in the task struct */
mfctl % c r30 , % r1
tophys % r1 ,% r9
LDREG T I _ T A S K ( % r9 ) , % r1 / * t h r e a d _ i n f o - > t a s k _ s t r u c t * /
tophys % r1 ,% r9
ldo T A S K _ R E G S ( % r9 ) ,% r9
STREG % r30 , P T _ G R 3 0 ( % r9 )
STREG % r29 ,P T _ G R 2 9 ( % r9 )
STREG % r26 ,P T _ G R 2 6 ( % r9 )
copy % r9 ,% r29
mfctl % c r30 , % r1
ldo T H R E A D _ S Z _ A L G N ( % r1 ) , % r30
.endm
.macro get_stack_use_r30
/* we put a struct pt_regs on the stack and save the registers there */
tophys % r30 ,% r9
STREG % r30 ,P T _ G R 3 0 ( % r9 )
ldo P T _ S Z _ A L G N ( % r30 ) ,% r30
STREG % r29 ,P T _ G R 2 9 ( % r9 )
STREG % r26 ,P T _ G R 2 6 ( % r9 )
copy % r9 ,% r29
.endm
.macro rest_stack
LDREG P T _ G R 1 ( % r29 ) , % r1
LDREG P T _ G R 3 0 ( % r29 ) ,% r30
LDREG P T _ G R 2 9 ( % r29 ) ,% r29
.endm
/ * default i n t e r r u p t i o n h a n d l e r
* ( calls t r a p s . c : h a n d l e _ i n t e r r u p t i o n ) * /
.macro def code
b i n t r _ s a v e
ldi \ c o d e , % r8
.align 32
.endm
/ * Interrupt i n t e r r u p t i o n h a n d l e r
* ( calls i r q . c : d o _ c p u _ i r q _ m a s k ) * /
.macro extint code
b i n t r _ e x t i n t
mfsp % s r7 ,% r16
.align 32
.endm
.import os_ h p m c , c o d e
/* HPMC handler */
.macro hpmc code
nop / * m u s t b e a N O P , w i l l b e p a t c h e d l a t e r * /
load3 2 P A ( o s _ h p m c ) , % r3
bv,n 0 ( % r3 )
nop
.word 0 /* checksum (will be patched) */
.word PA( o s _ h p m c ) / * a d d r e s s o f h a n d l e r * /
.word 0 /* length of handler */
.endm
/ *
* Performance N o t e : I n s t r u c t i o n s w i l l b e m o v e d u p i n t o
* this p a r t o f t h e c o d e l a t e r o n , o n c e w e a r e s u r e
* that t h e t l b m i s s h a n d l e r s a r e c l o s e t o f i n a l f o r m .
* /
/* Register definitions for tlb miss handler macros */
2011-03-31 05:57:33 +04:00
va = r8 / * v i r t u a l a d d r e s s f o r w h i c h t h e t r a p o c c u r r e d * /
spc = r24 / * s p a c e f o r w h i c h t h e t r a p o c c u r r e d * /
2005-04-17 02:20:36 +04:00
2005-10-22 06:46:48 +04:00
# ifndef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
/ *
* itlb m i s s i n t e r r u p t i o n h a n d l e r ( p a r i s c 1 . 1 - 3 2 b i t )
* /
.macro itlb_11 code
mfctl % p c s q , s p c
b i t l b _ m i s s _ 1 1
mfctl % p c o q , v a
.align 32
.endm
# endif
/ *
* itlb m i s s i n t e r r u p t i o n h a n d l e r ( p a r i s c 2 . 0 )
* /
.macro itlb_20 code
mfctl % p c s q , s p c
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
b i t l b _ m i s s _ 2 0 w
# else
b i t l b _ m i s s _ 2 0
# endif
mfctl % p c o q , v a
.align 32
.endm
2005-10-22 06:46:48 +04:00
# ifndef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
/ *
* naitlb m i s s i n t e r r u p t i o n h a n d l e r ( p a r i s c 1 . 1 - 3 2 b i t )
* /
.macro naitlb_11 code
mfctl % i s r ,s p c
2010-12-22 19:22:11 +03:00
b n a i t l b _ m i s s _ 1 1
2005-04-17 02:20:36 +04:00
mfctl % i o r ,v a
.align 32
.endm
# endif
/ *
* naitlb m i s s i n t e r r u p t i o n h a n d l e r ( p a r i s c 2 . 0 )
* /
.macro naitlb_20 code
mfctl % i s r ,s p c
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2010-12-22 19:22:11 +03:00
b n a i t l b _ m i s s _ 2 0 w
2005-04-17 02:20:36 +04:00
# else
2010-12-22 19:22:11 +03:00
b n a i t l b _ m i s s _ 2 0
2005-04-17 02:20:36 +04:00
# endif
mfctl % i o r ,v a
.align 32
.endm
2005-10-22 06:46:48 +04:00
# ifndef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
/ *
* dtlb m i s s i n t e r r u p t i o n h a n d l e r ( p a r i s c 1 . 1 - 3 2 b i t )
* /
.macro dtlb_11 code
mfctl % i s r , s p c
b d t l b _ m i s s _ 1 1
mfctl % i o r , v a
.align 32
.endm
# endif
/ *
* dtlb m i s s i n t e r r u p t i o n h a n d l e r ( p a r i s c 2 . 0 )
* /
.macro dtlb_20 code
mfctl % i s r , s p c
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
b d t l b _ m i s s _ 2 0 w
# else
b d t l b _ m i s s _ 2 0
# endif
mfctl % i o r , v a
.align 32
.endm
2005-10-22 06:46:48 +04:00
# ifndef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
/* nadtlb miss interruption handler (parisc 1.1 - 32 bit) */
.macro nadtlb_11 code
mfctl % i s r ,s p c
b n a d t l b _ m i s s _ 1 1
mfctl % i o r ,v a
.align 32
.endm
# endif
/* nadtlb miss interruption handler (parisc 2.0) */
.macro nadtlb_20 code
mfctl % i s r ,s p c
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
b n a d t l b _ m i s s _ 2 0 w
# else
b n a d t l b _ m i s s _ 2 0
# endif
mfctl % i o r ,v a
.align 32
.endm
2005-10-22 06:46:48 +04:00
# ifndef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
/ *
* dirty b i t t r a p i n t e r r u p t i o n h a n d l e r ( p a r i s c 1 . 1 - 3 2 b i t )
* /
.macro dbit_11 code
mfctl % i s r ,s p c
b d b i t _ t r a p _ 1 1
mfctl % i o r ,v a
.align 32
.endm
# endif
/ *
* dirty b i t t r a p i n t e r r u p t i o n h a n d l e r ( p a r i s c 2 . 0 )
* /
.macro dbit_20 code
mfctl % i s r ,s p c
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
b d b i t _ t r a p _ 2 0 w
# else
b d b i t _ t r a p _ 2 0
# endif
mfctl % i o r ,v a
.align 32
.endm
/ * In L P 6 4 , t h e s p a c e c o n t a i n s p a r t o f t h e u p p e r 3 2 b i t s o f t h e
* fault. W e h a v e t o e x t r a c t t h i s a n d p l a c e i t i n t h e v a ,
* zeroing t h e c o r r e s p o n d i n g b i t s i n t h e s p a c e r e g i s t e r * /
.macro space_adjust spc,v a ,t m p
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
extrd,u \ s p c ,6 3 ,S P A C E I D _ S H I F T ,\ t m p
depd % r0 ,6 3 ,S P A C E I D _ S H I F T ,\ s p c
depd \ t m p ,3 1 ,S P A C E I D _ S H I F T ,\ v a
# endif
.endm
.import swapper_ p g _ d i r ,c o d e
/ * Get t h e p g d . F o r f a u l t s o n s p a c e z e r o ( k e r n e l s p a c e ) , t h i s
* is s i m p l y s w a p p e r _ p g _ d i r . F o r u s e r s p a c e f a u l t s , t h e
* pgd i s s t o r e d i n % c r25 * /
.macro get_pgd spc,r e g
ldil L % P A ( s w a p p e r _ p g _ d i r ) ,\ r e g
ldo R % P A ( s w a p p e r _ p g _ d i r ) ( \ r e g ) ,\ r e g
or,C O N D ( = ) % r0 ,\ s p c ,% r0
mfctl % c r25 ,\ r e g
.endm
/ *
space_ c h e c k ( s p c ,t m p ,f a u l t )
spc - T h e s p a c e w e s a w t h e f a u l t w i t h .
tmp - T h e p l a c e t o s t o r e t h e c u r r e n t s p a c e .
fault - F u n c t i o n t o c a l l o n f a i l u r e .
Only a l l o w f a u l t s o n d i f f e r e n t s p a c e s f r o m t h e
currently a c t i v e o n e i f w e ' r e t h e k e r n e l
* /
.macro space_check spc,t m p ,f a u l t
mfsp % s r7 ,\ t m p
or,C O N D ( < > ) % r0 ,\ s p c ,% r0 / * u s e r m a y e x e c u t e g a t e w a y p a g e
* as k e r n e l , s o d e f e a t t h e s p a c e
* check i f i t i s * /
copy \ s p c ,\ t m p
or,C O N D ( = ) % r0 ,\ t m p ,% r0 / * n u l l i f y i f e x e c u t i n g a s k e r n e l * /
cmpb,C O N D ( < > ) ,n \ t m p ,\ s p c ,\ f a u l t
.endm
/ * Look u p a P T E i n a 2 - L e v e l s c h e m e ( f a u l t i n g a t e a c h
* level i f t h e e n t r y i s n ' t p r e s e n t
*
* NOTE : we u s e l d w e v e n f o r L P 6 4 , s i n c e t h e s h o r t p o i n t e r s
* can a d d r e s s u p t o 1 T B
* /
.macro L2_ptep pmd,p t e ,i n d e x ,v a ,f a u l t
# if P T _ N L E V E L S = = 3
2010-04-11 21:03:54 +04:00
extru \ v a ,3 1 - A S M _ P M D _ S H I F T ,A S M _ B I T S _ P E R _ P M D ,\ i n d e x
2005-04-17 02:20:36 +04:00
# else
2013-05-03 00:41:45 +04:00
# if d e f i n e d ( C O N F I G _ 6 4 B I T )
extrd,u \ v a ,6 3 - A S M _ P G D I R _ S H I F T ,A S M _ B I T S _ P E R _ P G D ,\ i n d e x
# else
# if P A G E _ S I Z E > 4 0 9 6
extru \ v a ,3 1 - A S M _ P G D I R _ S H I F T ,3 2 - A S M _ P G D I R _ S H I F T ,\ i n d e x
# else
2010-04-11 21:03:54 +04:00
extru \ v a ,3 1 - A S M _ P G D I R _ S H I F T ,A S M _ B I T S _ P E R _ P G D ,\ i n d e x
2013-05-03 00:41:45 +04:00
# endif
# endif
2005-04-17 02:20:36 +04:00
# endif
2010-04-11 21:03:54 +04:00
dep % r0 ,3 1 ,P A G E _ S H I F T ,\ p m d / * c l e a r o f f s e t * /
2005-04-17 02:20:36 +04:00
copy % r0 ,\ p t e
ldw,s \ i n d e x ( \ p m d ) ,\ p m d
bb,> = ,n \ p m d ,_ P x D _ P R E S E N T _ B I T ,\ f a u l t
2010-04-11 21:03:54 +04:00
dep % r0 ,3 1 ,P x D _ F L A G _ S H I F T ,\ p m d / * c l e a r f l a g s * /
2005-04-17 02:20:36 +04:00
copy \ p m d ,% r9
2006-08-14 06:17:19 +04:00
SHLREG % r9 ,P x D _ V A L U E _ S H I F T ,\ p m d
2010-04-11 21:03:54 +04:00
extru \ v a ,3 1 - P A G E _ S H I F T ,A S M _ B I T S _ P E R _ P T E ,\ i n d e x
dep % r0 ,3 1 ,P A G E _ S H I F T ,\ p m d / * c l e a r o f f s e t * /
2005-04-17 02:20:36 +04:00
shladd \ i n d e x ,B I T S _ P E R _ P T E _ E N T R Y ,\ p m d ,\ p m d
LDREG % r0 ( \ p m d ) ,\ p t e / * p m d i s n o w p t e * /
bb,> = ,n \ p t e ,_ P A G E _ P R E S E N T _ B I T ,\ f a u l t
.endm
/ * Look u p P T E i n a 3 - L e v e l s c h e m e .
*
* Here w e i m p l e m e n t a H y b r i d L 2 / L 3 s c h e m e : w e a l l o c a t e t h e
* first p m d a d j a c e n t t o t h e p g d . T h i s m e a n s t h a t w e c a n
* subtract a c o n s t a n t o f f s e t t o g e t t o i t . T h e p m d a n d p g d
* sizes a r e a r r a n g e d s o t h a t a s i n g l e p m d c o v e r s 4 G B ( g i v i n g
* a f u l l L P 6 4 p r o c e s s a c c e s s t o 8 T B ) s o o u r l o o k u p s a r e
* effectively L 2 f o r t h e f i r s t 4 G B o f t h e k e r n e l ( i . e . f o r
* all I L P 3 2 p r o c e s s e s a n d a l l t h e k e r n e l f o r m a c h i n e s w i t h
* under 4 G B o f m e m o r y ) * /
.macro L3_ptep pgd,p t e ,i n d e x ,v a ,f a u l t
2006-04-21 00:40:23 +04:00
# if P T _ N L E V E L S = = 3 / * w e m i g h t h a v e a 2 - L e v e l s c h e m e , e . g . w i t h 1 6 k b p a g e s i z e * /
2005-04-17 02:20:36 +04:00
extrd,u \ v a ,6 3 - A S M _ P G D I R _ S H I F T ,A S M _ B I T S _ P E R _ P G D ,\ i n d e x
copy % r0 ,\ p t e
2006-04-21 00:40:23 +04:00
extrd,u ,* = \ v a ,6 3 - A S M _ P G D I R _ S H I F T ,6 4 - A S M _ P G D I R _ S H I F T ,% r0
2005-04-17 02:20:36 +04:00
ldw,s \ i n d e x ( \ p g d ) ,\ p g d
2006-04-21 00:40:23 +04:00
extrd,u ,* = \ v a ,6 3 - A S M _ P G D I R _ S H I F T ,6 4 - A S M _ P G D I R _ S H I F T ,% r0
2005-04-17 02:20:36 +04:00
bb,> = ,n \ p g d ,_ P x D _ P R E S E N T _ B I T ,\ f a u l t
2006-04-21 00:40:23 +04:00
extrd,u ,* = \ v a ,6 3 - A S M _ P G D I R _ S H I F T ,6 4 - A S M _ P G D I R _ S H I F T ,% r0
2005-04-17 02:20:36 +04:00
shld \ p g d ,P x D _ V A L U E _ S H I F T ,\ i n d e x
2006-04-21 00:40:23 +04:00
extrd,u ,* = \ v a ,6 3 - A S M _ P G D I R _ S H I F T ,6 4 - A S M _ P G D I R _ S H I F T ,% r0
2005-04-17 02:20:36 +04:00
copy \ i n d e x ,\ p g d
2006-04-21 00:40:23 +04:00
extrd,u ,* < > \ v a ,6 3 - A S M _ P G D I R _ S H I F T ,6 4 - A S M _ P G D I R _ S H I F T ,% r0
2005-04-17 02:20:36 +04:00
ldo A S M _ P G D _ P M D _ O F F S E T ( \ p g d ) ,\ p g d
2006-04-21 00:40:23 +04:00
# endif
2005-04-17 02:20:36 +04:00
L2 _ p t e p \ p g d ,\ p t e ,\ i n d e x ,\ v a ,\ f a u l t
.endm
/ * Set t h e _ P A G E _ A C C E S S E D b i t o f t h e P T E . B e c l e v e r a n d
* don' t n e e d l e s s l y d i r t y t h e c a c h e l i n e i f i t w a s a l r e a d y s e t * /
.macro update_ptep ptep,p t e ,t m p ,t m p1
ldi _ P A G E _ A C C E S S E D ,\ t m p1
or \ t m p1 ,\ p t e ,\ t m p
and,C O N D ( < > ) \ t m p1 ,\ p t e ,% r0
STREG \ t m p ,0 ( \ p t e p )
.endm
/ * Set t h e d i r t y b i t ( a n d a c c e s s e d b i t ) . N o n e e d t o b e
* clever, t h i s i s o n l y u s e d f r o m t h e d i r t y f a u l t * /
.macro update_dirty ptep,p t e ,t m p
ldi _ P A G E _ A C C E S S E D | _ P A G E _ D I R T Y ,\ t m p
or \ t m p ,\ p t e ,\ p t e
STREG \ p t e ,0 ( \ p t e p )
.endm
2009-02-05 02:06:00 +03:00
/ * bitshift d i f f e r e n c e b e t w e e n a P F N ( b a s e d o n k e r n e l ' s P A G E _ S I Z E )
* to a C P U T L B 4 k P F N ( 4 k = > 1 2 b i t s t o s h i f t ) * /
# define P A G E _ A D D _ S H I F T ( P A G E _ S H I F T - 1 2 )
/* Drop prot bits and convert to page addr for iitlbt and idtlbt */
.macro convert_for_tlb_insert20 pte
extrd,u \ p t e ,( 6 3 - A S M _ P F N _ P T E _ S H I F T ) + ( 6 3 - 5 8 ) + P A G E _ A D D _ S H I F T ,\
6 4 - PAGE_ S H I F T - P A G E _ A D D _ S H I F T ,\ p t e
depdi _ P A G E _ S I Z E _ E N C O D I N G _ D E F A U L T ,6 3 ,\
( 6 3 - 5 8 ) + PAGE_ A D D _ S H I F T ,\ p t e
.endm
2005-04-17 02:20:36 +04:00
/ * Convert t h e p t e a n d p r o t t o t l b i n s e r t i o n v a l u e s . H o w
* this h a p p e n s i s q u i t e s u b t l e , r e a d b e l o w * /
.macro make_insert_tlb spc,p t e ,p r o t
space_ t o _ p r o t \ s p c \ p r o t / * c r e a t e p r o t i d f r o m s p a c e * /
/ * The f o l l o w i n g i s t h e r e a l s u b t l e t y . T h i s i s d e p o s i t i n g
* T < - > _ P A G E _ R E F T R A P
* D < - > _ P A G E _ D I R T Y
* B < - > _ P A G E _ D M B ( m e m o r y b r e a k )
*
* Then i n c r e d i b l e s u b t l e t y : T h e a c c e s s r i g h t s a r e
2013-01-14 02:04:18 +04:00
* _ PAGE_ G A T E W A Y , _ P A G E _ E X E C a n d _ P A G E _ W R I T E
2005-04-17 02:20:36 +04:00
* See 3 - 1 4 o f t h e p a r i s c 2 . 0 m a n u a l
*
* Finally, _ P A G E _ R E A D g o e s i n t h e t o p b i t o f P L 1 ( s o w e
* trigger a n a c c e s s r i g h t s t r a p i n u s e r s p a c e i f t h e u s e r
* tries t o r e a d a n u n r e a d a b l e p a g e * /
depd \ p t e ,8 ,7 ,\ p r o t
/ * PAGE_ U S E R i n d i c a t e s t h e p a g e c a n b e r e a d w i t h u s e r p r i v i l e g e s ,
* so d e p o s i t X 1 | 1 1 t o P L 1 | P L 2 ( r e m e m b e r t h e u p p e r b i t o f P L 1
2013-01-14 02:04:18 +04:00
* contains _ P A G E _ R E A D ) * /
2005-04-17 02:20:36 +04:00
extrd,u ,* = \ p t e ,_ P A G E _ U S E R _ B I T + 3 2 ,1 ,% r0
depdi 7 ,1 1 ,3 ,\ p r o t
/ * If w e ' r e a g a t e w a y p a g e , d r o p P L 2 b a c k t o z e r o f o r p r o m o t i o n
* to k e r n e l p r i v i l e g e ( s o w e c a n e x e c u t e t h e p a g e a s k e r n e l ) .
* Any p r i v i l e g e p r o m o t i o n p a g e a l w a y s d e n y s r e a d a n d w r i t e * /
extrd,u ,* = \ p t e ,_ P A G E _ G A T E W A Y _ B I T + 3 2 ,1 ,% r0
depd % r0 ,1 1 ,2 ,\ p r o t / * I f G a t e w a y , S e t P L 2 t o 0 * /
2006-04-21 00:40:23 +04:00
/ * Enforce u n c a c h e a b l e p a g e s .
* This s h o u l d O N L Y b e u s e f o r M M I O o n P A 2 . 0 m a c h i n e s .
* Memory/ D M A i s c a c h e c o h e r e n t o n a l l P A 2 . 0 m a c h i n e s w e s u p p o r t
* ( that m e a n s T - c l a s s i s N O T s u p p o r t e d ) a n d t h e m e m o r y c o n t r o l l e r s
* on m o s t o f t h o s e m a c h i n e s o n l y h a n d l e s c a c h e t r a n s a c t i o n s .
* /
extrd,u ,* = \ p t e ,_ P A G E _ N O _ C A C H E _ B I T + 3 2 ,1 ,% r0
2009-07-13 05:44:37 +04:00
depdi 1 ,1 2 ,1 ,\ p r o t
2005-04-17 02:20:36 +04:00
2006-04-21 00:40:23 +04:00
/* Drop prot bits and convert to page addr for iitlbt and idtlbt */
2009-02-05 02:06:00 +03:00
convert_ f o r _ t l b _ i n s e r t 2 0 \ p t e
2005-04-17 02:20:36 +04:00
.endm
/ * Identical m a c r o t o m a k e _ i n s e r t _ t l b a b o v e , e x c e p t i t
* makes t h e t l b e n t r y f o r t h e d i f f e r e n t l y f o r m a t t e d p a11
* insertion i n s t r u c t i o n s * /
.macro make_insert_tlb_11 spc,p t e ,p r o t
zdep \ s p c ,3 0 ,1 5 ,\ p r o t
dep \ p t e ,8 ,7 ,\ p r o t
extru,= \ p t e ,_ P A G E _ N O _ C A C H E _ B I T ,1 ,% r0
depi 1 ,1 2 ,1 ,\ p r o t
extru,= \ p t e ,_ P A G E _ U S E R _ B I T ,1 ,% r0
depi 7 ,1 1 ,3 ,\ p r o t / * S e t f o r u s e r s p a c e ( 1 r s v d f o r r e a d ) * /
extru,= \ p t e ,_ P A G E _ G A T E W A Y _ B I T ,1 ,% r0
depi 0 ,1 1 ,2 ,\ p r o t / * I f G a t e w a y , S e t P L 2 t o 0 * /
/* Get rid of prot bits and convert to page addr for iitlba */
2009-01-18 21:30:18 +03:00
depi 0 ,3 1 ,A S M _ P F N _ P T E _ S H I F T ,\ p t e
SHRREG \ p t e ,( A S M _ P F N _ P T E _ S H I F T - ( 3 1 - 2 6 ) ) ,\ p t e
2005-04-17 02:20:36 +04:00
.endm
/ * This i s f o r I L P 3 2 P A 2 . 0 o n l y . T h e T L B i n s e r t i o n n e e d s
* to e x t e n d i n t o I / O s p a c e i f t h e a d d r e s s i s 0 x f X X X X X X X
* so w e e x t e n d t h e f ' s i n t o t h e t o p w o r d o f t h e p t e i n
* this c a s e * /
.macro f_extend pte,t m p
extrd,s \ p t e ,4 2 ,4 ,\ t m p
addi,< > 1 ,\ t m p ,% r0
extrd,s \ p t e ,6 3 ,2 5 ,\ p t e
.endm
/ * The a l i a s r e g i o n i s a n 8 M B a l i g n e d 1 6 M B t o d o c l e a r a n d
* copy u s e r p a g e s a t a d d r e s s e s c o n g r u e n t w i t h t h e u s e r
* virtual a d d r e s s .
*
* To u s e t h e a l i a s p a g e , y o u s e t % r26 u p w i t h t h e t o T L B
* entry ( i d e n t i f y i n g t h e p h y s i c a l p a g e ) a n d % r23 u p w i t h
* the f r o m t l b e n t r y ( o r n o t h i n g i f o n l y a t o e n t r y - - - f o r
* clear_ u s e r _ p a g e _ a s m ) * /
2012-05-21 10:49:01 +04:00
.macro do_alias spc,t m p ,t m p1 ,v a ,p t e ,p r o t ,f a u l t ,p a t y p e
2005-04-17 02:20:36 +04:00
cmpib,C O N D ( < > ) ,n 0 ,\ s p c ,\ f a u l t
ldil L % ( T M P A L I A S _ M A P _ S T A R T ) ,\ t m p
2005-10-22 06:46:48 +04:00
# if d e f i n e d ( C O N F I G _ 6 4 B I T ) & & ( T M P A L I A S _ M A P _ S T A R T > = 0 x80 0 0 0 0 0 0 )
2005-04-17 02:20:36 +04:00
/ * on L P 6 4 , l d i w i l l s i g n e x t e n d i n t o t h e u p p e r 3 2 b i t s ,
* which i s b e h a v i o u r w e d o n ' t w a n t * /
depdi 0 ,3 1 ,3 2 ,\ t m p
# endif
copy \ v a ,\ t m p1
2010-04-11 21:03:54 +04:00
depi 0 ,3 1 ,2 3 ,\ t m p1
2005-04-17 02:20:36 +04:00
cmpb,C O N D ( < > ) ,n \ t m p ,\ t m p1 ,\ f a u l t
2010-12-22 19:22:11 +03:00
mfctl % c r19 ,\ t m p / * i i r * /
/* get the opcode (first six bits) into \tmp */
extrw,u \ t m p ,5 ,6 ,\ t m p
/ *
* Only s e t t i n g t h e T b i t p r e v e n t s d a t a c a c h e m o v e i n
* Setting a c c e s s r i g h t s t o z e r o p r e v e n t s i n s t r u c t i o n c a c h e m o v e i n
*
* Note s u b t l e t y h e r e : _ P A G E _ G A T E W A Y , _ P A G E _ E X E C a n d _ P A G E _ W R I T E g o
* to t y p e f i e l d a n d _ P A G E _ R E A D g o e s t o t o p b i t o f P L 1
* /
ldi ( _ P A G E _ R E F T R A P | _ P A G E _ R E A D | _ P A G E _ W R I T E ) ,\ p r o t
/ *
* so i f t h e o p c o d e i s o n e ( i . e . t h i s i s a m e m o r y m a n a g e m e n t
* instruction) n u l l i f y t h e n e x t l o a d s o \ p r o t i s o n l y T .
* Otherwise t h i s i s a n o r m a l d a t a o p e r a t i o n
* /
cmpiclr,= 0 x01 ,\ t m p ,% r0
ldi ( _ P A G E _ D I R T Y | _ P A G E _ R E A D | _ P A G E _ W R I T E ) ,\ p r o t
2012-05-21 10:49:01 +04:00
.ifc \ patype,2 0
2005-04-17 02:20:36 +04:00
depd,z \ p r o t ,8 ,7 ,\ p r o t
2012-05-21 10:49:01 +04:00
.else
.ifc \ patype,1 1
2012-05-15 14:04:19 +04:00
depw,z \ p r o t ,8 ,7 ,\ p r o t
2012-05-21 10:49:01 +04:00
.else
.error " undefined P A t y p e t o d o _ a l i a s "
.endif
.endif
2005-04-17 02:20:36 +04:00
/ *
* OK, i t i s i n t h e t e m p a l i a s r e g i o n , c h e c k w h e t h e r " f r o m " o r " t o " .
* Check " s u b t l e " n o t e i n p a c a c h e . S r e : r23 / r26 .
* /
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
extrd,u ,* = \ v a ,4 1 ,1 ,% r0
# else
extrw,u ,= \ v a ,9 ,1 ,% r0
# endif
or,C O N D ( t r ) % r23 ,% r0 ,\ p t e
or % r26 ,% r0 ,\ p t e
.endm
/ *
* Align f a u l t _ v e c t o r _ 2 0 o n 4 K b o u n d a r y s o t h a t b o t h
* fault_ v e c t o r _ 1 1 a n d f a u l t _ v e c t o r _ 2 0 a r e o n t h e
* same p a g e . T h i s i s o n l y n e c e s s a r y a s l o n g a s w e
* write p r o t e c t t h e k e r n e l t e x t , w h i c h w e m a y s t o p
* doing o n c e w e u s e l a r g e p a g e t r a n s l a t i o n s t o c o v e r
* the s t a t i c p a r t o f t h e k e r n e l a d d r e s s s p a c e .
* /
2008-05-22 22:36:31 +04:00
.text
2005-04-17 02:20:36 +04:00
2013-05-03 00:41:45 +04:00
.align 4096
2005-04-17 02:20:36 +04:00
2007-01-23 22:50:59 +03:00
ENTRY( f a u l t _ v e c t o r _ 2 0 )
2005-04-17 02:20:36 +04:00
/* First vector is invalid (0) */
.ascii " cows c a n f l y "
.byte 0
.align 32
hpmc 1
def 2
def 3
extint 4
def 5
itlb_ 2 0 6
def 7
def 8
def 9
def 1 0
def 1 1
def 1 2
def 1 3
def 1 4
dtlb_ 2 0 1 5
naitlb_ 2 0 1 6
nadtlb_ 2 0 1 7
def 1 8
def 1 9
dbit_ 2 0 2 0
def 2 1
def 2 2
def 2 3
def 2 4
def 2 5
def 2 6
def 2 7
def 2 8
def 2 9
def 3 0
def 3 1
2007-01-23 22:50:59 +03:00
END( f a u l t _ v e c t o r _ 2 0 )
2005-04-17 02:20:36 +04:00
2005-10-22 06:46:48 +04:00
# ifndef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
.align 2048
2007-01-23 22:50:59 +03:00
ENTRY( f a u l t _ v e c t o r _ 1 1 )
2005-04-17 02:20:36 +04:00
/* First vector is invalid (0) */
.ascii " cows c a n f l y "
.byte 0
.align 32
hpmc 1
def 2
def 3
extint 4
def 5
itlb_ 1 1 6
def 7
def 8
def 9
def 1 0
def 1 1
def 1 2
def 1 3
def 1 4
dtlb_ 1 1 1 5
naitlb_ 1 1 1 6
nadtlb_ 1 1 1 7
def 1 8
def 1 9
dbit_ 1 1 2 0
def 2 1
def 2 2
def 2 3
def 2 4
def 2 5
def 2 6
def 2 7
def 2 8
def 2 9
def 3 0
def 3 1
2007-01-23 22:50:59 +03:00
END( f a u l t _ v e c t o r _ 1 1 )
2005-04-17 02:20:36 +04:00
# endif
2011-04-15 03:25:21 +04:00
/* Fault vector is separately protected and *must* be on its own page */
.align PAGE_SIZE
ENTRY( e n d _ f a u l t _ v e c t o r )
2005-04-17 02:20:36 +04:00
.import handle_ i n t e r r u p t i o n ,c o d e
.import do_ c p u _ i r q _ m a s k ,c o d e
/ *
* Child R e t u r n s h e r e
*
2012-10-04 07:28:08 +04:00
* copy_ t h r e a d m o v e d a r g s i n t o t a s k s a v e a r e a .
2005-04-17 02:20:36 +04:00
* /
2007-01-23 22:50:59 +03:00
ENTRY( r e t _ f r o m _ k e r n e l _ t h r e a d )
2005-04-17 02:20:36 +04:00
/* Call schedule_tail first though */
BL s c h e d u l e _ t a i l , % r2
nop
2012-10-06 02:55:57 +04:00
LDREG T I _ T A S K - T H R E A D _ S Z _ A L G N - F R A M E _ S I Z E ( % r30 ) , % r1
2005-04-17 02:20:36 +04:00
LDREG T A S K _ P T _ G R 2 5 ( % r1 ) , % r26
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
LDREG T A S K _ P T _ G R 2 7 ( % r1 ) , % r27
# endif
LDREG T A S K _ P T _ G R 2 6 ( % r1 ) , % r1
ble 0 ( % s r7 , % r1 )
copy % r31 , % r2
2012-10-12 01:22:16 +04:00
b f i n i s h _ c h i l d _ r e t u r n
nop
2007-01-23 22:50:59 +03:00
ENDPROC( r e t _ f r o m _ k e r n e l _ t h r e a d )
2005-04-17 02:20:36 +04:00
/ *
* struct t a s k _ s t r u c t * _ s w i t c h _ t o ( s t r u c t t a s k _ s t r u c t * p r e v ,
* struct t a s k _ s t r u c t * n e x t )
*
* switch k e r n e l s t a c k s a n d r e t u r n p r e v * /
2007-01-23 22:50:59 +03:00
ENTRY( _ s w i t c h _ t o )
2005-04-17 02:20:36 +04:00
STREG % r2 , - R P _ O F F S E T ( % r30 )
2005-10-22 06:53:26 +04:00
callee_ s a v e _ f l o a t
2005-04-17 02:20:36 +04:00
callee_ s a v e
load3 2 _ s w i t c h _ t o _ r e t , % r2
STREG % r2 , T A S K _ P T _ K P C ( % r26 )
LDREG T A S K _ P T _ K P C ( % r25 ) , % r2
STREG % r30 , T A S K _ P T _ K S P ( % r26 )
LDREG T A S K _ P T _ K S P ( % r25 ) , % r30
LDREG T A S K _ T H R E A D _ I N F O ( % r25 ) , % r25
bv % r0 ( % r2 )
mtctl % r25 ,% c r30
_switch_to_ret :
mtctl % r0 , % c r0 / * N e e d e d f o r s i n g l e s t e p p i n g * /
callee_ r e s t
2005-10-22 06:53:26 +04:00
callee_ r e s t _ f l o a t
2005-04-17 02:20:36 +04:00
LDREG - R P _ O F F S E T ( % r30 ) , % r2
bv % r0 ( % r2 )
copy % r26 , % r28
2007-01-23 22:50:59 +03:00
ENDPROC( _ s w i t c h _ t o )
2005-04-17 02:20:36 +04:00
/ *
* Common r f i r e t u r n p a t h f o r i n t e r r u p t i o n s , k e r n e l e x e c v e , a n d
* sys_ r t _ s i g r e t u r n ( s o m e t i m e s ) . T h e s y s _ r t _ s i g r e t u r n s y s c a l l w i l l
* return v i a t h i s p a t h i f t h e s i g n a l w a s r e c e i v e d w h e n t h e p r o c e s s
* was r u n n i n g ; if the process was blocked on a syscall then the
* normal s y s c a l l _ e x i t p a t h i s u s e d . A l l s y s c a l l s f o r t r a c e d
* proceses e x i t v i a i n t r _ r e s t o r e .
*
* XXX I f a n y s y s c a l l s t h a t c h a n g e a p r o c e s s e s s p a c e i d e v e r e x i t
* this w a y , t h e n w e w i l l n e e d t o c o p y % s r3 i n t o P T _ S R [ 3 . . 7 ] , a n d
* adjust I A S Q [ 0 . . 1 ] .
*
* /
2007-10-18 11:04:53 +04:00
.align PAGE_SIZE
2005-04-17 02:20:36 +04:00
2007-01-23 22:50:59 +03:00
ENTRY( s y s c a l l _ e x i t _ r f i )
2005-04-17 02:20:36 +04:00
mfctl % c r30 ,% r16
LDREG T I _ T A S K ( % r16 ) , % r16 / * t h r e a d _ i n f o - > t a s k _ s t r u c t * /
ldo T A S K _ R E G S ( % r16 ) ,% r16
/ * Force i a o q t o u s e r s p a c e , a s t h e u s e r h a s h a d a c c e s s t o o u r c u r r e n t
* context v i a s i g c o n t e x t . A l s o F i l t e r t h e P S W f o r t h e s a m e r e a s o n .
* /
LDREG P T _ I A O Q 0 ( % r16 ) ,% r19
depi 3 ,3 1 ,2 ,% r19
STREG % r19 ,P T _ I A O Q 0 ( % r16 )
LDREG P T _ I A O Q 1 ( % r16 ) ,% r19
depi 3 ,3 1 ,2 ,% r19
STREG % r19 ,P T _ I A O Q 1 ( % r16 )
LDREG P T _ P S W ( % r16 ) ,% r19
load3 2 U S E R _ P S W _ M A S K ,% r1
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
load3 2 U S E R _ P S W _ H I _ M A S K ,% r20
depd % r20 ,3 1 ,3 2 ,% r1
# endif
and % r19 ,% r1 ,% r19 / * M a s k o u t b i t s t h a t u s e r s h o u l d n ' t p l a y w i t h * /
load3 2 U S E R _ P S W ,% r1
or % r19 ,% r1 ,% r19 / * M a k e s u r e d e f a u l t U S E R _ P S W b i t s a r e s e t * /
STREG % r19 ,P T _ P S W ( % r16 )
/ *
* If w e a r e n ' t b e i n g t r a c e d , w e n e v e r s a v e d s p a c e r e g i s t e r s
* ( we d o n ' t s t o r e t h e m i n t h e s i g c o n t e x t ) , s o s e t t h e m
* to " p r o p e r " v a l u e s n o w ( o t h e r w i s e w e ' l l w i n d u p r e s t o r i n g
* whatever w a s l a s t s t o r e d i n t h e t a s k s t r u c t u r e , w h i c h m i g h t
2011-03-31 05:57:33 +04:00
* be i n c o n s i s t e n t i f a n i n t e r r u p t o c c u r r e d w h i l e o n t h e g a t e w a y
2006-10-04 00:21:02 +04:00
* page) . N o t e t h a t w e m a y b e " t r a s h i n g " v a l u e s t h e u s e r p u t i n
* them, b u t w e d o n ' t s u p p o r t t h e u s e r c h a n g i n g t h e m .
2005-04-17 02:20:36 +04:00
* /
STREG % r0 ,P T _ S R 2 ( % r16 )
mfsp % s r3 ,% r19
STREG % r19 ,P T _ S R 0 ( % r16 )
STREG % r19 ,P T _ S R 1 ( % r16 )
STREG % r19 ,P T _ S R 3 ( % r16 )
STREG % r19 ,P T _ S R 4 ( % r16 )
STREG % r19 ,P T _ S R 5 ( % r16 )
STREG % r19 ,P T _ S R 6 ( % r16 )
STREG % r19 ,P T _ S R 7 ( % r16 )
intr_return :
/* NOTE: Need to enable interrupts incase we schedule. */
ssm P S W _ S M _ I , % r0
intr_check_resched :
/* check for reschedule */
mfctl % c r30 ,% r1
LDREG T I _ F L A G S ( % r1 ) ,% r19 / * s c h e d . h : T I F _ N E E D _ R E S C H E D * /
bb,< ,n % r19 ,3 1 - T I F _ N E E D _ R E S C H E D ,i n t r _ d o _ r e s c h e d / * f o r w a r d * /
2007-01-09 00:28:06 +03:00
.import do_ n o t i f y _ r e s u m e ,c o d e
2005-04-17 02:20:36 +04:00
intr_check_sig :
/* As above */
mfctl % c r30 ,% r1
2007-01-09 00:28:06 +03:00
LDREG T I _ F L A G S ( % r1 ) ,% r19
2012-05-23 23:28:58 +04:00
ldi ( _ T I F _ S I G P E N D I N G | _ T I F _ N O T I F Y _ R E S U M E ) , % r20
2007-01-09 00:28:06 +03:00
and,C O N D ( < > ) % r19 , % r20 , % r0
b,n i n t r _ r e s t o r e / * s k i p p a s t i f w e ' v e n o t h i n g t o d o * /
/ * This c h e c k i s c r i t i c a l t o h a v i n g L W S
* working. T h e I A S Q i s z e r o o n t h e g a t e w a y
* page a n d w e c a n n o t d e l i v e r a n y s i g n a l s u n t i l
* we g e t o f f t h e g a t e w a y p a g e .
*
* Only d o s i g n a l s i f w e a r e r e t u r n i n g t o u s e r s p a c e
* /
LDREG P T _ I A S Q 0 ( % r16 ) , % r20
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n 0 ,% r20 ,i n t r _ r e s t o r e / * b a c k w a r d * /
2007-01-09 00:28:06 +03:00
LDREG P T _ I A S Q 1 ( % r16 ) , % r20
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n 0 ,% r20 ,i n t r _ r e s t o r e / * b a c k w a r d * /
2007-01-09 00:28:06 +03:00
copy % r0 , % r25 / * l o n g i n _ s y s c a l l = 0 * /
# ifdef C O N F I G _ 6 4 B I T
ldo - 1 6 ( % r30 ) ,% r29 / * R e f e r e n c e p a r a m s a v e a r e a * /
# endif
BL d o _ n o t i f y _ r e s u m e ,% r2
copy % r16 , % r26 / * s t r u c t p t _ r e g s * r e g s * /
2007-01-09 21:57:38 +03:00
b,n i n t r _ c h e c k _ s i g
2005-04-17 02:20:36 +04:00
intr_restore :
copy % r16 ,% r29
ldo P T _ F R 3 1 ( % r29 ) ,% r1
rest_ f p % r1
rest_ g e n e r a l % r29
2005-10-22 06:40:07 +04:00
/* inverse of virt_map */
pcxt_ s s m _ b u g
rsm P S W _ S M _ Q U I E T ,% r0 / * p r e p a r e f o r r f i * /
2005-04-17 02:20:36 +04:00
tophys_ r1 % r29
/ * Restore s p a c e i d ' s a n d s p e c i a l c r ' s f r o m P T _ R E G S
2005-10-22 06:40:07 +04:00
* structure p o i n t e d t o b y r29
* /
2005-04-17 02:20:36 +04:00
rest_ s p e c i a l s % r29
2005-10-22 06:40:07 +04:00
/ * IMPORTANT : rest_ s t a c k r e s t o r e s r29 l a s t ( w e a r e u s i n g i t ) !
* It a l s o r e s t o r e s r1 a n d r30 .
* /
2005-04-17 02:20:36 +04:00
rest_ s t a c k
rfi
nop
2006-03-25 07:24:21 +03:00
# ifndef C O N F I G _ P R E E M P T
# define i n t r _ d o _ p r e e m p t i n t r _ r e s t o r e
# endif / * ! C O N F I G _ P R E E M P T * /
2005-04-17 02:20:36 +04:00
.import schedule,c o d e
intr_do_resched :
2006-03-25 07:24:21 +03:00
/ * Only c a l l s c h e d u l e o n r e t u r n t o u s e r s p a c e . I f w e ' r e r e t u r n i n g
* to k e r n e l s p a c e , w e m a y s c h e d u l e i f C O N F I G _ P R E E M P T , o t h e r w i s e
* we j u m p b a c k t o i n t r _ r e s t o r e .
* /
2005-04-17 02:20:36 +04:00
LDREG P T _ I A S Q 0 ( % r16 ) , % r20
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) 0 , % r20 , i n t r _ d o _ p r e e m p t
2005-04-17 02:20:36 +04:00
nop
LDREG P T _ I A S Q 1 ( % r16 ) , % r20
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) 0 , % r20 , i n t r _ d o _ p r e e m p t
2005-04-17 02:20:36 +04:00
nop
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
ldo - 1 6 ( % r30 ) ,% r29 / * R e f e r e n c e p a r a m s a v e a r e a * /
# endif
ldil L % i n t r _ c h e c k _ s i g , % r2
2005-10-22 06:42:57 +04:00
# ifndef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
b s c h e d u l e
2005-10-22 06:42:57 +04:00
# else
load3 2 s c h e d u l e , % r20
bv % r0 ( % r20 )
# endif
2005-04-17 02:20:36 +04:00
ldo R % i n t r _ c h e c k _ s i g ( % r2 ) , % r2
2006-03-25 07:24:21 +03:00
/ * preempt t h e c u r r e n t t a s k o n r e t u r n i n g t o k e r n e l
* mode f r o m a n i n t e r r u p t , i f f n e e d _ r e s c h e d i s s e t ,
* and p r e e m p t _ c o u n t i s 0 . o t h e r w i s e , w e c o n t i n u e o n
* our m e r r y w a y b a c k t o t h e c u r r e n t r u n n i n g t a s k .
* /
# ifdef C O N F I G _ P R E E M P T
.import preempt_ s c h e d u l e _ i r q ,c o d e
intr_do_preempt :
rsm P S W _ S M _ I , % r0 / * d i s a b l e i n t e r r u p t s * /
/* current_thread_info()->preempt_count */
mfctl % c r30 , % r1
LDREG T I _ P R E _ C O U N T ( % r1 ) , % r19
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( < > ) 0 , % r19 , i n t r _ r e s t o r e / * i f p r e e m p t _ c o u n t > 0 * /
2006-03-25 07:24:21 +03:00
nop / * p r e v i n s n b r a n c h e d b a c k w a r d s * /
/* check if we interrupted a critical path */
LDREG P T _ P S W ( % r16 ) , % r20
bb,< ,n % r20 , 3 1 - P S W _ S M _ I , i n t r _ r e s t o r e
nop
BL p r e e m p t _ s c h e d u l e _ i r q , % r2
nop
2006-08-28 23:42:07 +04:00
b,n i n t r _ r e s t o r e / * s s m P S W _ S M _ I d o n e b y i n t r _ r e s t o r e * /
2006-03-25 07:24:21 +03:00
# endif / * C O N F I G _ P R E E M P T * /
2005-04-17 02:20:36 +04:00
/ *
* External i n t e r r u p t s .
* /
intr_extint :
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n 0 ,% r16 ,1 f
2007-10-18 11:04:56 +04:00
2005-04-17 02:20:36 +04:00
get_ s t a c k _ u s e _ c r30
2007-10-18 11:04:56 +04:00
b,n 2 f
2005-04-17 02:20:36 +04:00
1 :
get_ s t a c k _ u s e _ r30
2007-10-18 11:04:56 +04:00
2 :
2005-04-17 02:20:36 +04:00
save_ s p e c i a l s % r29
virt_ m a p
save_ g e n e r a l % r29
ldo P T _ F R 0 ( % r29 ) , % r24
save_ f p % r24
loadgp
copy % r29 , % r26 / * a r g 0 i s p t _ r e g s * /
copy % r29 , % r16 / * s a v e p t _ r e g s * /
ldil L % i n t r _ r e t u r n , % r2
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
ldo - 1 6 ( % r30 ) ,% r29 / * R e f e r e n c e p a r a m s a v e a r e a * /
# endif
b d o _ c p u _ i r q _ m a s k
ldo R % i n t r _ r e t u r n ( % r2 ) , % r2 / * r e t u r n t o i n t r _ r e t u r n , n o t h e r e * /
2007-01-23 22:50:59 +03:00
ENDPROC( s y s c a l l _ e x i t _ r f i )
2005-04-17 02:20:36 +04:00
/* Generic interruptions (illegal insn, unaligned, page fault, etc) */
2007-01-23 22:50:59 +03:00
ENTRY( i n t r _ s a v e ) / * f o r o s _ h p m c * /
2005-04-17 02:20:36 +04:00
mfsp % s r7 ,% r16
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n 0 ,% r16 ,1 f
2005-04-17 02:20:36 +04:00
get_ s t a c k _ u s e _ c r30
b 2 f
copy % r8 ,% r26
1 :
get_ s t a c k _ u s e _ r30
copy % r8 ,% r26
2 :
save_ s p e c i a l s % r29
/* If this trap is a itlb miss, skip saving/adjusting isr/ior */
/ *
* FIXME : 1 ) Use a #d e f i n e f o r t h e h a r d w i r e d " 6 " b e l o w ( a n d i n
* traps. c .
* 2 ) Once w e s t a r t e x e c u t i n g c o d e a b o v e 4 G b , w e n e e d
* to a d j u s t i a s q / i a o q h e r e i n t h e s a m e w a y w e
* adjust i s r / i o r b e l o w .
* /
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n 6 ,% r26 ,s k i p _ s a v e _ i o r
2005-04-17 02:20:36 +04:00
mfctl % c r20 , % r16 / * i s r * /
2005-10-22 06:40:07 +04:00
nop / * s e r i a l i z e m f c t l o n P A 2 . 0 t o a v o i d 4 c y c l e p e n a l t y * /
2005-04-17 02:20:36 +04:00
mfctl % c r21 , % r17 / * i o r * /
2005-10-22 06:40:07 +04:00
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
/ *
* If t h e i n t e r r u p t e d c o d e w a s r u n n i n g w i t h W b i t o f f ( 3 2 b i t ) ,
* clear t h e b b i t s ( b i t s 0 & 1 ) i n t h e i o r .
2005-10-22 06:40:07 +04:00
* save_ s p e c i a l s l e f t i p s w v a l u e i n r8 f o r u s t o t e s t .
2005-04-17 02:20:36 +04:00
* /
extrd,u ,* < > % r8 ,P S W _ W _ B I T ,1 ,% r0
depdi 0 ,1 ,2 ,% r17
/ *
* FIXME : This c o d e h a s h a r d w i r e d a s s u m p t i o n s a b o u t t h e s p l i t
* between s p a c e b i t s a n d o f f s e t b i t s . T h i s w i l l c h a n g e
* when w e a l l o w a l t e r n a t e p a g e s i z e s .
* /
/* adjust isr/ior. */
2006-04-21 00:40:23 +04:00
extrd,u % r16 ,6 3 ,S P A C E I D _ S H I F T ,% r1 / * g e t h i g h b i t s f r o m i s r f o r i o r * /
depd % r1 ,3 1 ,S P A C E I D _ S H I F T ,% r17 / * d e p o s i t t h e m i n t o i o r * /
depdi 0 ,6 3 ,S P A C E I D _ S H I F T ,% r16 / * c l e a r t h e m f r o m i s r * /
2005-04-17 02:20:36 +04:00
# endif
STREG % r16 , P T _ I S R ( % r29 )
STREG % r17 , P T _ I O R ( % r29 )
skip_save_ior :
virt_ m a p
save_ g e n e r a l % r29
ldo P T _ F R 0 ( % r29 ) , % r25
save_ f p % r25
loadgp
copy % r29 , % r25 / * a r g 1 i s p t _ r e g s * /
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
ldo - 1 6 ( % r30 ) ,% r29 / * R e f e r e n c e p a r a m s a v e a r e a * /
# endif
ldil L % i n t r _ c h e c k _ s i g , % r2
copy % r25 , % r16 / * s a v e p t _ r e g s * /
b h a n d l e _ i n t e r r u p t i o n
ldo R % i n t r _ c h e c k _ s i g ( % r2 ) , % r2
2007-01-23 22:50:59 +03:00
ENDPROC( i n t r _ s a v e )
2005-04-17 02:20:36 +04:00
/ *
* Note f o r a l l t l b m i s s h a n d l e r s :
*
* cr2 4 c o n t a i n s a p o i n t e r t o t h e k e r n e l a d d r e s s s p a c e
* page d i r e c t o r y .
*
* cr2 5 c o n t a i n s a p o i n t e r t o t h e c u r r e n t u s e r a d d r e s s
* space p a g e d i r e c t o r y .
*
* sr3 w i l l c o n t a i n t h e s p a c e i d o f t h e u s e r a d d r e s s s p a c e
* of t h e c u r r e n t r u n n i n g t h r e a d w h i l e t h a t t h r e a d i s
* running i n t h e k e r n e l .
* /
/ *
* register n u m b e r a l l o c a t i o n s . N o t e t h a t t h e s e a r e a l l
* in t h e s h a d o w e d r e g i s t e r s
* /
t0 = r1 / * t e m p o r a r y r e g i s t e r 0 * /
2011-03-31 05:57:33 +04:00
va = r8 / * v i r t u a l a d d r e s s f o r w h i c h t h e t r a p o c c u r r e d * /
2005-04-17 02:20:36 +04:00
t1 = r9 / * t e m p o r a r y r e g i s t e r 1 * /
pte = r16 / * p t e / p h y s p a g e # * /
prot = r17 / * p r o t b i t s * /
2011-03-31 05:57:33 +04:00
spc = r24 / * s p a c e f o r w h i c h t h e t r a p o c c u r r e d * /
2005-04-17 02:20:36 +04:00
ptp = r25 / * p a g e d i r e c t o r y / p a g e t a b l e p o i n t e r * /
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
dtlb_miss_20w :
space_ a d j u s t s p c ,v a ,t 0
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,d t l b _ f a u l t
L3 _ p t e p p t p ,p t e ,t 0 ,v a ,d t l b _ c h e c k _ a l i a s _ 2 0 w
update_ p t e p p t p ,p t e ,t 0 ,t 1
make_ i n s e r t _ t l b s p c ,p t e ,p r o t
idtlbt p t e ,p r o t
rfir
nop
dtlb_check_alias_20w :
2012-05-21 10:49:01 +04:00
do_ a l i a s s p c ,t 0 ,t 1 ,v a ,p t e ,p r o t ,d t l b _ f a u l t ,2 0
2005-04-17 02:20:36 +04:00
idtlbt p t e ,p r o t
rfir
nop
nadtlb_miss_20w :
space_ a d j u s t s p c ,v a ,t 0
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,n a d t l b _ f a u l t
2010-12-22 19:22:11 +03:00
L3 _ p t e p p t p ,p t e ,t 0 ,v a ,n a d t l b _ c h e c k _ a l i a s _ 2 0 w
2005-04-17 02:20:36 +04:00
update_ p t e p p t p ,p t e ,t 0 ,t 1
make_ i n s e r t _ t l b s p c ,p t e ,p r o t
idtlbt p t e ,p r o t
rfir
nop
2010-12-22 19:22:11 +03:00
nadtlb_check_alias_20w :
2012-05-21 10:49:01 +04:00
do_ a l i a s s p c ,t 0 ,t 1 ,v a ,p t e ,p r o t ,n a d t l b _ e m u l a t e ,2 0
2005-04-17 02:20:36 +04:00
idtlbt p t e ,p r o t
rfir
nop
# else
dtlb_miss_11 :
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,d t l b _ f a u l t
L2 _ p t e p p t p ,p t e ,t 0 ,v a ,d t l b _ c h e c k _ a l i a s _ 1 1
update_ p t e p p t p ,p t e ,t 0 ,t 1
make_ i n s e r t _ t l b _ 1 1 s p c ,p t e ,p r o t
mfsp % s r1 ,t 0 / * S a v e s r1 s o w e c a n u s e i t i n t l b i n s e r t s * /
mtsp s p c ,% s r1
idtlba p t e ,( % s r1 ,v a )
idtlbp p r o t ,( % s r1 ,v a )
mtsp t 0 , % s r1 / * R e s t o r e s r1 * /
rfir
nop
dtlb_check_alias_11 :
2012-05-21 10:49:01 +04:00
do_ a l i a s s p c ,t 0 ,t 1 ,v a ,p t e ,p r o t ,d t l b _ f a u l t ,1 1
2005-04-17 02:20:36 +04:00
idtlba p t e ,( v a )
idtlbp p r o t ,( v a )
rfir
nop
nadtlb_miss_11 :
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,n a d t l b _ f a u l t
2010-12-22 19:22:11 +03:00
L2 _ p t e p p t p ,p t e ,t 0 ,v a ,n a d t l b _ c h e c k _ a l i a s _ 1 1
2005-04-17 02:20:36 +04:00
update_ p t e p p t p ,p t e ,t 0 ,t 1
make_ i n s e r t _ t l b _ 1 1 s p c ,p t e ,p r o t
mfsp % s r1 ,t 0 / * S a v e s r1 s o w e c a n u s e i t i n t l b i n s e r t s * /
mtsp s p c ,% s r1
idtlba p t e ,( % s r1 ,v a )
idtlbp p r o t ,( % s r1 ,v a )
mtsp t 0 , % s r1 / * R e s t o r e s r1 * /
rfir
nop
2010-12-22 19:22:11 +03:00
nadtlb_check_alias_11 :
2012-05-21 10:49:01 +04:00
do_ a l i a s s p c ,t 0 ,t 1 ,v a ,p t e ,p r o t ,n a d t l b _ e m u l a t e ,1 1
2010-12-22 19:22:11 +03:00
idtlba p t e ,( v a )
idtlbp p r o t ,( v a )
rfir
nop
2005-04-17 02:20:36 +04:00
dtlb_miss_20 :
space_ a d j u s t s p c ,v a ,t 0
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,d t l b _ f a u l t
L2 _ p t e p p t p ,p t e ,t 0 ,v a ,d t l b _ c h e c k _ a l i a s _ 2 0
update_ p t e p p t p ,p t e ,t 0 ,t 1
make_ i n s e r t _ t l b s p c ,p t e ,p r o t
f_ e x t e n d p t e ,t 0
idtlbt p t e ,p r o t
rfir
nop
dtlb_check_alias_20 :
2012-05-21 10:49:01 +04:00
do_ a l i a s s p c ,t 0 ,t 1 ,v a ,p t e ,p r o t ,d t l b _ f a u l t ,2 0
2005-04-17 02:20:36 +04:00
idtlbt p t e ,p r o t
rfir
nop
nadtlb_miss_20 :
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,n a d t l b _ f a u l t
2010-12-22 19:22:11 +03:00
L2 _ p t e p p t p ,p t e ,t 0 ,v a ,n a d t l b _ c h e c k _ a l i a s _ 2 0
2005-04-17 02:20:36 +04:00
update_ p t e p p t p ,p t e ,t 0 ,t 1
make_ i n s e r t _ t l b s p c ,p t e ,p r o t
f_ e x t e n d p t e ,t 0
idtlbt p t e ,p r o t
rfir
nop
2010-12-22 19:22:11 +03:00
nadtlb_check_alias_20 :
2012-05-21 10:49:01 +04:00
do_ a l i a s s p c ,t 0 ,t 1 ,v a ,p t e ,p r o t ,n a d t l b _ e m u l a t e ,2 0
2010-12-22 19:22:11 +03:00
idtlbt p t e ,p r o t
rfir
nop
2005-04-17 02:20:36 +04:00
# endif
nadtlb_emulate :
/ *
* Non a c c e s s m i s s e s c a n b e c a u s e d b y f d c ,f i c ,p d c ,l p a ,p r o b e a n d
* probei i n s t r u c t i o n s . W e d o n ' t w a n t t o f a u l t f o r t h e s e
* instructions ( n o t o n l y d o e s i t n o t m a k e s e n s e , i t c a n c a u s e
* deadlocks, s i n c e s o m e f l u s h e s a r e d o n e w i t h t h e m m a p
* semaphore h e l d ) . I f t h e t r a n s l a t i o n d o e s n ' t e x i s t , w e c a n ' t
* insert a t r a n s l a t i o n , s o h a v e t o e m u l a t e t h e s i d e e f f e c t s
* of t h e i n s t r u c t i o n . S i n c e w e d o n ' t i n s e r t a t r a n s l a t i o n
* we c a n g e t a l o t o f f a u l t s d u r i n g a f l u s h l o o p , s o i t m a k e s
* sense t o t r y t o d o i t h e r e w i t h m i n i m u m o v e r h e a d . W e o n l y
* emulate f d c ,f i c ,p d c ,p r o b e w ,p r o b e r i n s t r u c t i o n s w h o s e b a s e
* and i n d e x r e g i s t e r s a r e n o t s h a d o w e d . W e d e f e r e v e r y t h i n g
* else t o t h e " s l o w " p a t h .
* /
mfctl % c r19 ,% r9 / * G e t i i r * /
/ * PA 2 . 0 A r c h R e f . B o o k p g 3 8 2 h a s a g o o d d e s c r i p t i o n o f t h e i n s n b i t s .
Checks f o r f d c ,f d c e ,p d c ," f i c ,4 f " ,p r o b e r ,p r o b e i r ,p r o b e w , p r o b e i w * /
/* Checks for fdc,fdce,pdc,"fic,4f" only */
ldi 0 x28 0 ,% r16
and % r9 ,% r16 ,% r17
cmpb,< > ,n % r16 ,% r17 ,n a d t l b _ p r o b e _ c h e c k
bb,> = ,n % r9 ,2 6 ,n a d t l b _ n u l l i f y / * m b i t n o t s e t , j u s t n u l l i f y * /
BL g e t _ r e g i s t e r ,% r25
extrw,u % r9 ,1 5 ,5 ,% r8 / * G e t i n d e x r e g i s t e r # * /
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n - 1 ,% r1 ,n a d t l b _ f a u l t / * h a v e t o u s e s l o w p a t h * /
2005-04-17 02:20:36 +04:00
copy % r1 ,% r24
BL g e t _ r e g i s t e r ,% r25
extrw,u % r9 ,1 0 ,5 ,% r8 / * G e t b a s e r e g i s t e r # * /
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n - 1 ,% r1 ,n a d t l b _ f a u l t / * h a v e t o u s e s l o w p a t h * /
2005-04-17 02:20:36 +04:00
BL s e t _ r e g i s t e r ,% r25
add,l % r1 ,% r24 ,% r1 / * d o e s n ' t a f f e c t c / b b i t s * /
nadtlb_nullify :
2005-10-22 06:40:07 +04:00
mfctl % i p s w ,% r8
2005-04-17 02:20:36 +04:00
ldil L % P S W _ N ,% r9
or % r8 ,% r9 ,% r8 / * S e t P S W _ N * /
2005-10-22 06:40:07 +04:00
mtctl % r8 ,% i p s w
2005-04-17 02:20:36 +04:00
rfir
nop
/ *
When t h e r e i s n o t r a n s l a t i o n f o r t h e p r o b e a d d r e s s t h e n w e
must n u l l i f y t h e i n s n a n d r e t u r n z e r o i n t h e t a r g e t r e g s i t e r .
This w i l l i n d i c a t e t o t h e c a l l i n g c o d e t h a t i t d o e s n o t h a v e
write/ r e a d p r i v i l e g e s t o t h i s a d d r e s s .
This s h o u l d t e c h n i c a l l y w o r k f o r p r o b e r a n d p r o b e w i n P A 1 . 1 ,
and a l s o p r o b e ,r a n d p r o b e ,w i n P A 2 . 0
WARNING : USE O N L Y N O N - S H A D O W R E G I S T E R S W I T H P R O B E I N S N !
THE S L O W - P A T H E M U L A T I O N H A S N O T B E E N W R I T T E N Y E T .
* /
nadtlb_probe_check :
ldi 0 x80 ,% r16
and % r9 ,% r16 ,% r17
cmpb,< > ,n % r16 ,% r17 ,n a d t l b _ f a u l t / * M u s t b e p r o b e ,[ r w ] * /
BL g e t _ r e g i s t e r ,% r25 / * F i n d t h e t a r g e t r e g i s t e r * /
extrw,u % r9 ,3 1 ,5 ,% r8 / * G e t t a r g e t r e g i s t e r * /
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n - 1 ,% r1 ,n a d t l b _ f a u l t / * h a v e t o u s e s l o w p a t h * /
2005-04-17 02:20:36 +04:00
BL s e t _ r e g i s t e r ,% r25
copy % r0 ,% r1 / * W r i t e z e r o t o t a r g e t r e g i s t e r * /
b n a d t l b _ n u l l i f y / * N u l l i f y r e t u r n i n s n * /
nop
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
itlb_miss_20w :
/ *
* I m i s s i s a l i t t l e d i f f e r e n t , s i n c e w e a l l o w u s e r s t o f a u l t
* on t h e g a t e w a y p a g e w h i c h i s i n t h e k e r n e l a d d r e s s s p a c e .
* /
space_ a d j u s t s p c ,v a ,t 0
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,i t l b _ f a u l t
L3 _ p t e p p t p ,p t e ,t 0 ,v a ,i t l b _ f a u l t
update_ p t e p p t p ,p t e ,t 0 ,t 1
make_ i n s e r t _ t l b s p c ,p t e ,p r o t
iitlbt p t e ,p r o t
rfir
nop
2010-12-22 19:22:11 +03:00
naitlb_miss_20w :
/ *
* I m i s s i s a l i t t l e d i f f e r e n t , s i n c e w e a l l o w u s e r s t o f a u l t
* on t h e g a t e w a y p a g e w h i c h i s i n t h e k e r n e l a d d r e s s s p a c e .
* /
space_ a d j u s t s p c ,v a ,t 0
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,n a i t l b _ f a u l t
L3 _ p t e p p t p ,p t e ,t 0 ,v a ,n a i t l b _ c h e c k _ a l i a s _ 2 0 w
update_ p t e p p t p ,p t e ,t 0 ,t 1
make_ i n s e r t _ t l b s p c ,p t e ,p r o t
iitlbt p t e ,p r o t
rfir
nop
naitlb_check_alias_20w :
2012-05-21 10:49:01 +04:00
do_ a l i a s s p c ,t 0 ,t 1 ,v a ,p t e ,p r o t ,n a i t l b _ f a u l t ,2 0
2010-12-22 19:22:11 +03:00
iitlbt p t e ,p r o t
rfir
nop
2005-04-17 02:20:36 +04:00
# else
itlb_miss_11 :
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,i t l b _ f a u l t
L2 _ p t e p p t p ,p t e ,t 0 ,v a ,i t l b _ f a u l t
update_ p t e p p t p ,p t e ,t 0 ,t 1
make_ i n s e r t _ t l b _ 1 1 s p c ,p t e ,p r o t
mfsp % s r1 ,t 0 / * S a v e s r1 s o w e c a n u s e i t i n t l b i n s e r t s * /
mtsp s p c ,% s r1
iitlba p t e ,( % s r1 ,v a )
iitlbp p r o t ,( % s r1 ,v a )
mtsp t 0 , % s r1 / * R e s t o r e s r1 * /
rfir
nop
2010-12-22 19:22:11 +03:00
naitlb_miss_11 :
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,n a i t l b _ f a u l t
L2 _ p t e p p t p ,p t e ,t 0 ,v a ,n a i t l b _ c h e c k _ a l i a s _ 1 1
update_ p t e p p t p ,p t e ,t 0 ,t 1
make_ i n s e r t _ t l b _ 1 1 s p c ,p t e ,p r o t
mfsp % s r1 ,t 0 / * S a v e s r1 s o w e c a n u s e i t i n t l b i n s e r t s * /
mtsp s p c ,% s r1
iitlba p t e ,( % s r1 ,v a )
iitlbp p r o t ,( % s r1 ,v a )
mtsp t 0 , % s r1 / * R e s t o r e s r1 * /
rfir
nop
naitlb_check_alias_11 :
2012-05-21 10:49:01 +04:00
do_ a l i a s s p c ,t 0 ,t 1 ,v a ,p t e ,p r o t ,i t l b _ f a u l t ,1 1
2010-12-22 19:22:11 +03:00
iitlba p t e ,( % s r0 , v a )
iitlbp p r o t ,( % s r0 , v a )
rfir
nop
2005-04-17 02:20:36 +04:00
itlb_miss_20 :
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,i t l b _ f a u l t
L2 _ p t e p p t p ,p t e ,t 0 ,v a ,i t l b _ f a u l t
update_ p t e p p t p ,p t e ,t 0 ,t 1
make_ i n s e r t _ t l b s p c ,p t e ,p r o t
f_ e x t e n d p t e ,t 0
iitlbt p t e ,p r o t
rfir
nop
2010-12-22 19:22:11 +03:00
naitlb_miss_20 :
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,n a i t l b _ f a u l t
L2 _ p t e p p t p ,p t e ,t 0 ,v a ,n a i t l b _ c h e c k _ a l i a s _ 2 0
update_ p t e p p t p ,p t e ,t 0 ,t 1
make_ i n s e r t _ t l b s p c ,p t e ,p r o t
f_ e x t e n d p t e ,t 0
iitlbt p t e ,p r o t
rfir
nop
naitlb_check_alias_20 :
2012-05-21 10:49:01 +04:00
do_ a l i a s s p c ,t 0 ,t 1 ,v a ,p t e ,p r o t ,n a i t l b _ f a u l t ,2 0
2010-12-22 19:22:11 +03:00
iitlbt p t e ,p r o t
rfir
nop
2005-04-17 02:20:36 +04:00
# endif
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
dbit_trap_20w :
space_ a d j u s t s p c ,v a ,t 0
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,d b i t _ f a u l t
L3 _ p t e p p t p ,p t e ,t 0 ,v a ,d b i t _ f a u l t
# ifdef C O N F I G _ S M P
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n 0 ,s p c ,d b i t _ n o l o c k _ 2 0 w
2005-04-17 02:20:36 +04:00
load3 2 P A ( p a _ d b i t _ l o c k ) ,t 0
dbit_spin_20w :
2006-04-22 10:48:22 +04:00
LDCW 0 ( t 0 ) ,t 1
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) 0 ,t 1 ,d b i t _ s p i n _ 2 0 w
2005-04-17 02:20:36 +04:00
nop
dbit_nolock_20w :
# endif
update_ d i r t y p t p ,p t e ,t 1
make_ i n s e r t _ t l b s p c ,p t e ,p r o t
idtlbt p t e ,p r o t
# ifdef C O N F I G _ S M P
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n 0 ,s p c ,d b i t _ n o u n l o c k _ 2 0 w
2005-04-17 02:20:36 +04:00
ldi 1 ,t 1
stw t 1 ,0 ( t 0 )
dbit_nounlock_20w :
# endif
rfir
nop
# else
dbit_trap_11 :
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,d b i t _ f a u l t
L2 _ p t e p p t p ,p t e ,t 0 ,v a ,d b i t _ f a u l t
# ifdef C O N F I G _ S M P
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n 0 ,s p c ,d b i t _ n o l o c k _ 1 1
2005-04-17 02:20:36 +04:00
load3 2 P A ( p a _ d b i t _ l o c k ) ,t 0
dbit_spin_11 :
2006-04-22 10:48:22 +04:00
LDCW 0 ( t 0 ) ,t 1
2005-04-17 02:20:36 +04:00
cmpib,= 0 ,t 1 ,d b i t _ s p i n _ 1 1
nop
dbit_nolock_11 :
# endif
update_ d i r t y p t p ,p t e ,t 1
make_ i n s e r t _ t l b _ 1 1 s p c ,p t e ,p r o t
mfsp % s r1 ,t 1 / * S a v e s r1 s o w e c a n u s e i t i n t l b i n s e r t s * /
mtsp s p c ,% s r1
idtlba p t e ,( % s r1 ,v a )
idtlbp p r o t ,( % s r1 ,v a )
mtsp t 1 , % s r1 / * R e s t o r e s r1 * /
# ifdef C O N F I G _ S M P
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n 0 ,s p c ,d b i t _ n o u n l o c k _ 1 1
2005-04-17 02:20:36 +04:00
ldi 1 ,t 1
stw t 1 ,0 ( t 0 )
dbit_nounlock_11 :
# endif
rfir
nop
dbit_trap_20 :
get_ p g d s p c ,p t p
space_ c h e c k s p c ,t 0 ,d b i t _ f a u l t
L2 _ p t e p p t p ,p t e ,t 0 ,v a ,d b i t _ f a u l t
# ifdef C O N F I G _ S M P
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n 0 ,s p c ,d b i t _ n o l o c k _ 2 0
2005-04-17 02:20:36 +04:00
load3 2 P A ( p a _ d b i t _ l o c k ) ,t 0
dbit_spin_20 :
2006-04-22 10:48:22 +04:00
LDCW 0 ( t 0 ) ,t 1
2005-04-17 02:20:36 +04:00
cmpib,= 0 ,t 1 ,d b i t _ s p i n _ 2 0
nop
dbit_nolock_20 :
# endif
update_ d i r t y p t p ,p t e ,t 1
make_ i n s e r t _ t l b s p c ,p t e ,p r o t
f_ e x t e n d p t e ,t 1
idtlbt p t e ,p r o t
# ifdef C O N F I G _ S M P
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( = ) ,n 0 ,s p c ,d b i t _ n o u n l o c k _ 2 0
2005-04-17 02:20:36 +04:00
ldi 1 ,t 1
stw t 1 ,0 ( t 0 )
dbit_nounlock_20 :
# endif
rfir
nop
# endif
.import handle_ i n t e r r u p t i o n ,c o d e
kernel_bad_space :
b i n t r _ s a v e
ldi 3 1 ,% r8 / * U s e a n u n u s e d c o d e * /
dbit_fault :
b i n t r _ s a v e
ldi 2 0 ,% r8
itlb_fault :
b i n t r _ s a v e
ldi 6 ,% r8
nadtlb_fault :
b i n t r _ s a v e
ldi 1 7 ,% r8
2010-12-22 19:22:11 +03:00
naitlb_fault :
b i n t r _ s a v e
ldi 1 6 ,% r8
2005-04-17 02:20:36 +04:00
dtlb_fault :
b i n t r _ s a v e
ldi 1 5 ,% r8
/ * Register s a v i n g s e m a n t i c s f o r s y s t e m c a l l s :
% r1 c l o b b e r e d b y s y s t e m c a l l m a c r o i n u s e r s p a c e
% r2 s a v e d i n P T _ R E G S b y g a t e w a y p a g e
% r3 - % r18 p r e s e r v e d b y C c o d e ( s a v e d b y s i g n a l c o d e )
% r1 9 - % r20 s a v e d i n P T _ R E G S b y g a t e w a y p a g e
% r2 1 - % r22 n o n - s t a n d a r d s y s c a l l a r g s
stored i n k e r n e l s t a c k b y g a t e w a y p a g e
% r2 3 - % r26 a r g 3 - a r g 0 , s a v e d i n P T _ R E G S b y g a t e w a y p a g e
% r2 7 - % r30 s a v e d i n P T _ R E G S b y g a t e w a y p a g e
% r3 1 s y s c a l l r e t u r n p o i n t e r
* /
/ * Floating p o i n t r e g i s t e r s ( F I X M E : w h a t d o w e d o w i t h t h e s e ? )
% fr0 - % f r3 s t a t u s / e x c e p t i o n , n o t p r e s e r v e d
% fr4 - % f r7 a r g u m e n t s
% fr8 - % f r11 n o t p r e s e r v e d b y C c o d e
% fr1 2 - % f r21 p r e s e r v e d b y C c o d e
% fr2 2 - % f r31 n o t p r e s e r v e d b y C c o d e
* /
.macro reg_save regs
STREG % r3 , P T _ G R 3 ( \ r e g s )
STREG % r4 , P T _ G R 4 ( \ r e g s )
STREG % r5 , P T _ G R 5 ( \ r e g s )
STREG % r6 , P T _ G R 6 ( \ r e g s )
STREG % r7 , P T _ G R 7 ( \ r e g s )
STREG % r8 , P T _ G R 8 ( \ r e g s )
STREG % r9 , P T _ G R 9 ( \ r e g s )
STREG % r10 ,P T _ G R 1 0 ( \ r e g s )
STREG % r11 ,P T _ G R 1 1 ( \ r e g s )
STREG % r12 ,P T _ G R 1 2 ( \ r e g s )
STREG % r13 ,P T _ G R 1 3 ( \ r e g s )
STREG % r14 ,P T _ G R 1 4 ( \ r e g s )
STREG % r15 ,P T _ G R 1 5 ( \ r e g s )
STREG % r16 ,P T _ G R 1 6 ( \ r e g s )
STREG % r17 ,P T _ G R 1 7 ( \ r e g s )
STREG % r18 ,P T _ G R 1 8 ( \ r e g s )
.endm
.macro reg_restore regs
LDREG P T _ G R 3 ( \ r e g s ) , % r3
LDREG P T _ G R 4 ( \ r e g s ) , % r4
LDREG P T _ G R 5 ( \ r e g s ) , % r5
LDREG P T _ G R 6 ( \ r e g s ) , % r6
LDREG P T _ G R 7 ( \ r e g s ) , % r7
LDREG P T _ G R 8 ( \ r e g s ) , % r8
LDREG P T _ G R 9 ( \ r e g s ) , % r9
LDREG P T _ G R 1 0 ( \ r e g s ) ,% r10
LDREG P T _ G R 1 1 ( \ r e g s ) ,% r11
LDREG P T _ G R 1 2 ( \ r e g s ) ,% r12
LDREG P T _ G R 1 3 ( \ r e g s ) ,% r13
LDREG P T _ G R 1 4 ( \ r e g s ) ,% r14
LDREG P T _ G R 1 5 ( \ r e g s ) ,% r15
LDREG P T _ G R 1 6 ( \ r e g s ) ,% r16
LDREG P T _ G R 1 7 ( \ r e g s ) ,% r17
LDREG P T _ G R 1 8 ( \ r e g s ) ,% r18
.endm
2012-10-27 03:59:16 +04:00
.macro fork_like name
ENTRY( s y s _ \ n a m e \ ( ) _ w r a p p e r )
2005-04-17 02:20:36 +04:00
LDREG T I _ T A S K - T H R E A D _ S Z _ A L G N - F R A M E _ S I Z E ( % r30 ) , % r1
ldo T A S K _ R E G S ( % r1 ) ,% r1
reg_ s a v e % r1
2012-10-06 02:55:57 +04:00
mfctl % c r27 , % r28
2012-10-27 03:59:16 +04:00
b s y s _ \ n a m e
2012-10-06 02:55:57 +04:00
STREG % r28 , P T _ C R 2 7 ( % r1 )
2012-10-27 03:59:16 +04:00
ENDPROC( s y s _ \ n a m e \ ( ) _ w r a p p e r )
.endm
2005-04-17 02:20:36 +04:00
2012-10-27 03:59:16 +04:00
fork_ l i k e c l o n e
fork_ l i k e f o r k
fork_ l i k e v f o r k
2005-04-17 02:20:36 +04:00
/* Set the return value for the child */
2007-01-23 22:50:59 +03:00
ENTRY( c h i l d _ r e t u r n )
2005-04-17 02:20:36 +04:00
BL s c h e d u l e _ t a i l , % r2
nop
2012-10-12 01:22:16 +04:00
finish_child_return :
2012-10-06 02:55:57 +04:00
LDREG T I _ T A S K - T H R E A D _ S Z _ A L G N - F R A M E _ S I Z E ( % r30 ) , % r1
ldo T A S K _ R E G S ( % r1 ) ,% r1 / * g e t p t r e g s * /
LDREG P T _ C R 2 7 ( % r1 ) , % r3
mtctl % r3 , % c r27
reg_ r e s t o r e % r1
b s y s c a l l _ e x i t
2005-04-17 02:20:36 +04:00
copy % r0 ,% r28
2007-01-23 22:50:59 +03:00
ENDPROC( c h i l d _ r e t u r n )
2005-04-17 02:20:36 +04:00
2007-01-23 22:50:59 +03:00
ENTRY( s y s _ r t _ s i g r e t u r n _ w r a p p e r )
2005-04-17 02:20:36 +04:00
LDREG T I _ T A S K - T H R E A D _ S Z _ A L G N - F R A M E _ S I Z E ( % r30 ) ,% r26
ldo T A S K _ R E G S ( % r26 ) ,% r26 / * g e t p t r e g s * /
/* Don't save regs, we are going to restore them from sigcontext. */
STREG % r2 , - R P _ O F F S E T ( % r30 )
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
ldo F R A M E _ S I Z E ( % r30 ) , % r30
BL s y s _ r t _ s i g r e t u r n ,% r2
ldo - 1 6 ( % r30 ) ,% r29 / * R e f e r e n c e p a r a m s a v e a r e a * /
# else
BL s y s _ r t _ s i g r e t u r n ,% r2
ldo F R A M E _ S I Z E ( % r30 ) , % r30
# endif
ldo - F R A M E _ S I Z E ( % r30 ) , % r30
LDREG - R P _ O F F S E T ( % r30 ) , % r2
/* FIXME: I think we need to restore a few more things here. */
LDREG T I _ T A S K - T H R E A D _ S Z _ A L G N - F R A M E _ S I Z E ( % r30 ) ,% r1
ldo T A S K _ R E G S ( % r1 ) ,% r1 / * g e t p t r e g s * /
reg_ r e s t o r e % r1
/ * If t h e s i g n a l w a s r e c e i v e d w h i l e t h e p r o c e s s w a s b l o c k e d o n a
* syscall, t h e n r2 w i l l t a k e u s t o s y s c a l l _ e x i t ; otherwise r2 will
* take u s t o s y s c a l l _ e x i t _ r f i a n d o n t o i n t r _ r e t u r n .
* /
bv % r0 ( % r2 )
LDREG P T _ G R 2 8 ( % r1 ) ,% r28 / * r e l o a d o r i g i n a l r28 f o r s y s c a l l _ e x i t * /
2007-01-23 22:50:59 +03:00
ENDPROC( s y s _ r t _ s i g r e t u r n _ w r a p p e r )
2005-04-17 02:20:36 +04:00
2007-01-23 22:50:59 +03:00
ENTRY( s y s c a l l _ e x i t )
2005-04-17 02:20:36 +04:00
/ * NOTE : HP- U X s y s c a l l s a l s o c o m e t h r o u g h h e r e
* after h p u x _ s y s c a l l _ e x i t f i x e s u p r e t u r n
* values. * /
/ * NOTE : Not a l l s y s c a l l s e x i t t h i s w a y . r t _ s i g r e t u r n w i l l e x i t
* via s y s c a l l _ e x i t _ r f i i f t h e s i g n a l w a s r e c e i v e d w h i l e t h e p r o c e s s
* was r u n n i n g .
* /
/* save return value now */
mfctl % c r30 , % r1
LDREG T I _ T A S K ( % r1 ) ,% r1
STREG % r28 ,T A S K _ P T _ G R 2 8 ( % r1 )
# ifdef C O N F I G _ H P U X
/* <linux/personality.h> cannot be easily included */
# define P E R _ H P U X 0 x10
2007-05-30 10:27:46 +04:00
ldw T A S K _ P E R S O N A L I T Y ( % r1 ) ,% r19
2005-04-17 02:20:36 +04:00
/* We can't use "CMPIB<> PER_HPUX" since "im5" field is sign extended */
ldo - P E R _ H P U X ( % r19 ) , % r19
2008-05-15 18:53:57 +04:00
cmpib,C O N D ( < > ) ,n 0 ,% r19 ,1 f
2005-04-17 02:20:36 +04:00
/* Save other hpux returns if personality is PER_HPUX */
STREG % r22 ,T A S K _ P T _ G R 2 2 ( % r1 )
STREG % r29 ,T A S K _ P T _ G R 2 9 ( % r1 )
1 :
# endif / * C O N F I G _ H P U X * /
/ * Seems t o m e t h a t d p c o u l d b e w r o n g h e r e , i f t h e s y s c a l l i n v o l v e d
* calling a m o d u l e , a n d n o t h i n g g o t r o u n d t o r e s t o r i n g d p o n r e t u r n .
* /
loadgp
syscall_check_resched :
/* check for reschedule */
LDREG T I _ F L A G S - T H R E A D _ S Z _ A L G N - F R A M E _ S I Z E ( % r30 ) ,% r19 / * l o n g * /
bb,< ,n % r19 , 3 1 - T I F _ N E E D _ R E S C H E D , s y s c a l l _ d o _ r e s c h e d / * f o r w a r d * /
2007-01-09 00:28:06 +03:00
.import do_ s i g n a l ,c o d e
2005-04-17 02:20:36 +04:00
syscall_check_sig :
2007-01-09 00:28:06 +03:00
LDREG T I _ F L A G S - T H R E A D _ S Z _ A L G N - F R A M E _ S I Z E ( % r30 ) ,% r19
2012-05-23 23:28:58 +04:00
ldi ( _ T I F _ S I G P E N D I N G | _ T I F _ N O T I F Y _ R E S U M E ) , % r26
2007-01-09 00:28:06 +03:00
and,C O N D ( < > ) % r19 , % r26 , % r0
b,n s y s c a l l _ r e s t o r e / * s k i p p a s t i f w e ' v e n o t h i n g t o d o * /
syscall_do_signal :
/ * Save c a l l e e - s a v e r e g i s t e r s ( f o r s i g c o n t e x t ) .
* FIXME : After t h i s p o i n t t h e p r o c e s s s t r u c t u r e s h o u l d b e
* consistent w i t h a l l t h e r e l e v a n t s t a t e o f t h e p r o c e s s
* before t h e s y s c a l l . W e n e e d t o v e r i f y t h i s .
* /
LDREG T I _ T A S K - T H R E A D _ S Z _ A L G N - F R A M E _ S I Z E ( % r30 ) ,% r1
ldo T A S K _ R E G S ( % r1 ) , % r26 / * s t r u c t p t _ r e g s * r e g s * /
reg_ s a v e % r26
# ifdef C O N F I G _ 6 4 B I T
ldo - 1 6 ( % r30 ) ,% r29 / * R e f e r e n c e p a r a m s a v e a r e a * /
# endif
BL d o _ n o t i f y _ r e s u m e ,% r2
ldi 1 , % r25 / * l o n g i n _ s y s c a l l = 1 * /
LDREG T I _ T A S K - T H R E A D _ S Z _ A L G N - F R A M E _ S I Z E ( % r30 ) ,% r1
ldo T A S K _ R E G S ( % r1 ) , % r20 / * r e l o a d p t _ r e g s * /
reg_ r e s t o r e % r20
b,n s y s c a l l _ c h e c k _ s i g
2005-04-17 02:20:36 +04:00
syscall_restore :
LDREG T I _ T A S K - T H R E A D _ S Z _ A L G N - F R A M E _ S I Z E ( % r30 ) ,% r1
2009-09-28 07:03:02 +04:00
/* Are we being ptraced? */
ldw T A S K _ F L A G S ( % r1 ) ,% r19
2012-12-29 03:18:01 +04:00
ldi _ T I F _ S Y S C A L L _ T R A C E _ M A S K ,% r2
2009-09-28 07:03:02 +04:00
and,C O N D ( = ) % r19 ,% r2 ,% r0
b,n s y s c a l l _ r e s t o r e _ r f i
2005-04-17 02:20:36 +04:00
ldo T A S K _ P T _ F R 3 1 ( % r1 ) ,% r19 / * r e l o a d f p r e g s * /
rest_ f p % r19
LDREG T A S K _ P T _ S A R ( % r1 ) ,% r19 / * r e s t o r e S A R * /
mtsar % r19
LDREG T A S K _ P T _ G R 2 ( % r1 ) ,% r2 / * r e s t o r e u s e r r p * /
LDREG T A S K _ P T _ G R 1 9 ( % r1 ) ,% r19
LDREG T A S K _ P T _ G R 2 0 ( % r1 ) ,% r20
LDREG T A S K _ P T _ G R 2 1 ( % r1 ) ,% r21
LDREG T A S K _ P T _ G R 2 2 ( % r1 ) ,% r22
LDREG T A S K _ P T _ G R 2 3 ( % r1 ) ,% r23
LDREG T A S K _ P T _ G R 2 4 ( % r1 ) ,% r24
LDREG T A S K _ P T _ G R 2 5 ( % r1 ) ,% r25
LDREG T A S K _ P T _ G R 2 6 ( % r1 ) ,% r26
LDREG T A S K _ P T _ G R 2 7 ( % r1 ) ,% r27 / * r e s t o r e u s e r d p * /
LDREG T A S K _ P T _ G R 2 8 ( % r1 ) ,% r28 / * s y s c a l l r e t u r n v a l u e * /
LDREG T A S K _ P T _ G R 2 9 ( % r1 ) ,% r29
LDREG T A S K _ P T _ G R 3 1 ( % r1 ) ,% r31 / * r e s t o r e s y s c a l l r p * /
/* NOTE: We use rsm/ssm pair to make this operation atomic */
2010-04-11 21:12:56 +04:00
LDREG T A S K _ P T _ G R 3 0 ( % r1 ) ,% r1 / * G e t u s e r s p * /
2005-04-17 02:20:36 +04:00
rsm P S W _ S M _ I , % r0
2010-04-11 21:12:56 +04:00
copy % r1 ,% r30 / * R e s t o r e u s e r s p * /
mfsp % s r3 ,% r1 / * G e t u s e r s p a c e i d * /
2005-04-17 02:20:36 +04:00
mtsp % r1 ,% s r7 / * R e s t o r e s r7 * /
ssm P S W _ S M _ I , % r0
/* Set sr2 to zero for userspace syscalls to work. */
mtsp % r0 ,% s r2
mtsp % r1 ,% s r4 / * R e s t o r e s r4 * /
mtsp % r1 ,% s r5 / * R e s t o r e s r5 * /
mtsp % r1 ,% s r6 / * R e s t o r e s r6 * /
depi 3 ,3 1 ,2 ,% r31 / * e n s u r e r e t u r n t o u s e r m o d e . * /
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
/ * decide w h e t h e r t o r e s e t t h e w i d e m o d e b i t
*
* For a s y s c a l l , t h e W b i t i s s t o r e d i n t h e l o w e s t b i t
* of s p . E x t r a c t i t a n d r e s e t W i f i t i s z e r o * /
extrd,u ,* < > % r30 ,6 3 ,1 ,% r1
rsm P S W _ S M _ W , % r0
/* now reset the lowest bit of sp if it was set */
xor % r30 ,% r1 ,% r30
# endif
be,n 0 ( % s r3 ,% r31 ) / * r e t u r n t o u s e r s p a c e * /
/ * We h a v e t o r e t u r n v i a a n R F I , s o t h a t P S W T a n d R b i t s c a n b e s e t
* appropriately.
* This s e t s u p p t _ r e g s s o w e c a n r e t u r n v i a i n t r _ r e s t o r e , w h i c h i s n o t
* the m o s t e f f i c i e n t w a y o f d o i n g t h i n g s , b u t i t w o r k s .
* /
syscall_restore_rfi :
ldo - 1 ( % r0 ) ,% r2 / * S e t r e c o v e r y c n t r t o - 1 * /
mtctl % r2 ,% c r0 / * f o r i m m e d i a t e t r a p * /
LDREG T A S K _ P T _ P S W ( % r1 ) ,% r2 / * G e t o l d P S W * /
ldi 0 x0 b ,% r20 / * C r e a t e n e w P S W * /
depi - 1 ,1 3 ,1 ,% r20 / * C , Q , D , a n d I b i t s * /
2009-09-28 07:03:02 +04:00
/ * The v a l u e s o f S I N G L E S T E P _ B I T a n d B L O C K S T E P _ B I T a r e
* set i n t h r e a d _ i n f o . h a n d c o n v e r t e d t o P A b i t m a p
2005-04-17 02:20:36 +04:00
* numbers i n a s m - o f f s e t s . c * /
2009-09-28 07:03:02 +04:00
/* if ((%r19.SINGLESTEP_BIT)) { %r20.27=1} */
extru,= % r19 ,T I F _ S I N G L E S T E P _ P A _ B I T ,1 ,% r0
2005-04-17 02:20:36 +04:00
depi - 1 ,2 7 ,1 ,% r20 / * R b i t * /
2009-09-28 07:03:02 +04:00
/* if ((%r19.BLOCKSTEP_BIT)) { %r20.7=1} */
extru,= % r19 ,T I F _ B L O C K S T E P _ P A _ B I T ,1 ,% r0
2005-04-17 02:20:36 +04:00
depi - 1 ,7 ,1 ,% r20 / * T b i t * /
STREG % r20 ,T A S K _ P T _ P S W ( % r1 )
/* Always store space registers, since sr3 can be changed (e.g. fork) */
mfsp % s r3 ,% r25
STREG % r25 ,T A S K _ P T _ S R 3 ( % r1 )
STREG % r25 ,T A S K _ P T _ S R 4 ( % r1 )
STREG % r25 ,T A S K _ P T _ S R 5 ( % r1 )
STREG % r25 ,T A S K _ P T _ S R 6 ( % r1 )
STREG % r25 ,T A S K _ P T _ S R 7 ( % r1 )
STREG % r25 ,T A S K _ P T _ I A S Q 0 ( % r1 )
STREG % r25 ,T A S K _ P T _ I A S Q 1 ( % r1 )
/* XXX W bit??? */
/ * Now i f o l d D b i t i s c l e a r , i t m e a n s w e d i d n ' t s a v e a l l r e g i s t e r s
* on s y s c a l l e n t r y , s o d o t h a t n o w . T h i s o n l y h a p p e n s o n T R A C E M E
* calls, o r i f s o m e o n e a t t a c h e d t o u s w h i l e w e w e r e o n a s y s c a l l .
* We c o u l d m a k e t h i s m o r e e f f i c i e n t b y n o t s a v i n g r3 - r18 , b u t
* then w e w o u l d n ' t b e a b l e t o u s e t h e c o m m o n i n t r _ r e s t o r e p a t h .
* It i s o n l y f o r t r a c e d p r o c e s s e s a n y w a y , s o p e r f o r m a n c e i s n o t
* an i s s u e .
* /
bb,< % r2 ,3 0 ,p t _ r e g s _ o k / * B r a n c h i f D s e t * /
ldo T A S K _ R E G S ( % r1 ) ,% r25
reg_ s a v e % r25 / * S a v e r3 t o r18 * /
/* Save the current sr */
mfsp % s r0 ,% r2
STREG % r2 ,T A S K _ P T _ S R 0 ( % r1 )
/* Save the scratch sr */
mfsp % s r1 ,% r2
STREG % r2 ,T A S K _ P T _ S R 1 ( % r1 )
/* sr2 should be set to zero for userspace syscalls */
STREG % r0 ,T A S K _ P T _ S R 2 ( % r1 )
LDREG T A S K _ P T _ G R 3 1 ( % r1 ) ,% r2
2012-12-29 03:18:01 +04:00
depi 3 ,3 1 ,2 ,% r2 / * e n s u r e r e t u r n t o u s e r m o d e . * /
STREG % r2 ,T A S K _ P T _ I A O Q 0 ( % r1 )
2005-04-17 02:20:36 +04:00
ldo 4 ( % r2 ) ,% r2
STREG % r2 ,T A S K _ P T _ I A O Q 1 ( % r1 )
2012-12-29 03:18:01 +04:00
b i n t r _ r e s t o r e
2005-04-17 02:20:36 +04:00
copy % r25 ,% r16
2012-12-29 03:18:01 +04:00
pt_regs_ok :
LDREG T A S K _ P T _ I A O Q 0 ( % r1 ) ,% r2
depi 3 ,3 1 ,2 ,% r2 / * e n s u r e r e t u r n t o u s e r m o d e . * /
STREG % r2 ,T A S K _ P T _ I A O Q 0 ( % r1 )
LDREG T A S K _ P T _ I A O Q 1 ( % r1 ) ,% r2
depi 3 ,3 1 ,2 ,% r2
STREG % r2 ,T A S K _ P T _ I A O Q 1 ( % r1 )
2005-04-17 02:20:36 +04:00
b i n t r _ r e s t o r e
2012-12-29 03:18:01 +04:00
copy % r25 ,% r16
2005-04-17 02:20:36 +04:00
.import schedule,c o d e
syscall_do_resched :
BL s c h e d u l e ,% r2
2005-10-22 06:46:48 +04:00
# ifdef C O N F I G _ 6 4 B I T
2005-04-17 02:20:36 +04:00
ldo - 1 6 ( % r30 ) ,% r29 / * R e f e r e n c e p a r a m s a v e a r e a * /
# else
nop
# endif
2007-05-29 02:31:59 +04:00
b s y s c a l l _ c h e c k _ r e s c h e d / * i f r e s c h e d , w e s t a r t o v e r a g a i n * /
2005-04-17 02:20:36 +04:00
nop
2007-01-23 22:50:59 +03:00
ENDPROC( s y s c a l l _ e x i t )
2005-04-17 02:20:36 +04:00
2007-01-23 22:50:59 +03:00
2009-02-09 02:43:36 +03:00
# ifdef C O N F I G _ F U N C T I O N _ T R A C E R
.import ftrace_ f u n c t i o n _ t r a m p o l i n e ,c o d e
ENTRY( _ m c o u n t )
copy % r3 , % a r g 2
b f t r a c e _ f u n c t i o n _ t r a m p o l i n e
nop
ENDPROC( _ m c o u n t )
ENTRY( r e t u r n _ t o _ h a n d l e r )
load3 2 r e t u r n _ t r a m p o l i n e , % r p
copy % r e t 0 , % a r g 0
copy % r e t 1 , % a r g 1
b f t r a c e _ r e t u r n _ t o _ h a n d l e r
nop
return_trampoline :
copy % r e t 0 , % r p
copy % r23 , % r e t 0
copy % r24 , % r e t 1
.globl ftrace_stub
ftrace_stub :
bv % r0 ( % r p )
nop
ENDPROC( r e t u r n _ t o _ h a n d l e r )
# endif / * C O N F I G _ F U N C T I O N _ T R A C E R * /
2007-01-28 18:58:43 +03:00
get_register :
2005-04-17 02:20:36 +04:00
/ *
* get_ r e g i s t e r i s u s e d b y t h e n o n a c c e s s t l b m i s s h a n d l e r s t o
* copy t h e v a l u e o f t h e g e n e r a l r e g i s t e r s p e c i f i e d i n r8 i n t o
* r1 . T h i s r o u t i n e c a n ' t b e u s e d f o r s h a d o w e d r e g i s t e r s , s i n c e
* the r f i r w i l l r e s t o r e t h e o r i g i n a l v a l u e . S o , f o r t h e s h a d o w e d
* registers w e p u t a - 1 i n t o r1 t o i n d i c a t e t h a t t h e r e g i s t e r
* should n o t b e u s e d ( t h e r e g i s t e r b e i n g c o p i e d c o u l d a l s o h a v e
* a - 1 i n i t , b u t t h a t i s O K , i t j u s t m e a n s t h a t w e w i l l h a v e
* to u s e t h e s l o w p a t h i n s t e a d ) .
* /
blr % r8 ,% r0
nop
bv % r0 ( % r25 ) / * r0 * /
copy % r0 ,% r1
bv % r0 ( % r25 ) / * r1 - s h a d o w e d * /
ldi - 1 ,% r1
bv % r0 ( % r25 ) / * r2 * /
copy % r2 ,% r1
bv % r0 ( % r25 ) / * r3 * /
copy % r3 ,% r1
bv % r0 ( % r25 ) / * r4 * /
copy % r4 ,% r1
bv % r0 ( % r25 ) / * r5 * /
copy % r5 ,% r1
bv % r0 ( % r25 ) / * r6 * /
copy % r6 ,% r1
bv % r0 ( % r25 ) / * r7 * /
copy % r7 ,% r1
bv % r0 ( % r25 ) / * r8 - s h a d o w e d * /
ldi - 1 ,% r1
bv % r0 ( % r25 ) / * r9 - s h a d o w e d * /
ldi - 1 ,% r1
bv % r0 ( % r25 ) / * r10 * /
copy % r10 ,% r1
bv % r0 ( % r25 ) / * r11 * /
copy % r11 ,% r1
bv % r0 ( % r25 ) / * r12 * /
copy % r12 ,% r1
bv % r0 ( % r25 ) / * r13 * /
copy % r13 ,% r1
bv % r0 ( % r25 ) / * r14 * /
copy % r14 ,% r1
bv % r0 ( % r25 ) / * r15 * /
copy % r15 ,% r1
bv % r0 ( % r25 ) / * r16 - s h a d o w e d * /
ldi - 1 ,% r1
bv % r0 ( % r25 ) / * r17 - s h a d o w e d * /
ldi - 1 ,% r1
bv % r0 ( % r25 ) / * r18 * /
copy % r18 ,% r1
bv % r0 ( % r25 ) / * r19 * /
copy % r19 ,% r1
bv % r0 ( % r25 ) / * r20 * /
copy % r20 ,% r1
bv % r0 ( % r25 ) / * r21 * /
copy % r21 ,% r1
bv % r0 ( % r25 ) / * r22 * /
copy % r22 ,% r1
bv % r0 ( % r25 ) / * r23 * /
copy % r23 ,% r1
bv % r0 ( % r25 ) / * r24 - s h a d o w e d * /
ldi - 1 ,% r1
bv % r0 ( % r25 ) / * r25 - s h a d o w e d * /
ldi - 1 ,% r1
bv % r0 ( % r25 ) / * r26 * /
copy % r26 ,% r1
bv % r0 ( % r25 ) / * r27 * /
copy % r27 ,% r1
bv % r0 ( % r25 ) / * r28 * /
copy % r28 ,% r1
bv % r0 ( % r25 ) / * r29 * /
copy % r29 ,% r1
bv % r0 ( % r25 ) / * r30 * /
copy % r30 ,% r1
bv % r0 ( % r25 ) / * r31 * /
copy % r31 ,% r1
2007-01-23 22:50:59 +03:00
2007-01-28 18:58:43 +03:00
set_register :
2005-04-17 02:20:36 +04:00
/ *
* set_ r e g i s t e r i s u s e d b y t h e n o n a c c e s s t l b m i s s h a n d l e r s t o
* copy t h e v a l u e o f r1 i n t o t h e g e n e r a l r e g i s t e r s p e c i f i e d i n
* r8 .
* /
blr % r8 ,% r0
nop
bv % r0 ( % r25 ) / * r0 ( s i l l y , b u t i t i s a p l a c e h o l d e r ) * /
copy % r1 ,% r0
bv % r0 ( % r25 ) / * r1 * /
copy % r1 ,% r1
bv % r0 ( % r25 ) / * r2 * /
copy % r1 ,% r2
bv % r0 ( % r25 ) / * r3 * /
copy % r1 ,% r3
bv % r0 ( % r25 ) / * r4 * /
copy % r1 ,% r4
bv % r0 ( % r25 ) / * r5 * /
copy % r1 ,% r5
bv % r0 ( % r25 ) / * r6 * /
copy % r1 ,% r6
bv % r0 ( % r25 ) / * r7 * /
copy % r1 ,% r7
bv % r0 ( % r25 ) / * r8 * /
copy % r1 ,% r8
bv % r0 ( % r25 ) / * r9 * /
copy % r1 ,% r9
bv % r0 ( % r25 ) / * r10 * /
copy % r1 ,% r10
bv % r0 ( % r25 ) / * r11 * /
copy % r1 ,% r11
bv % r0 ( % r25 ) / * r12 * /
copy % r1 ,% r12
bv % r0 ( % r25 ) / * r13 * /
copy % r1 ,% r13
bv % r0 ( % r25 ) / * r14 * /
copy % r1 ,% r14
bv % r0 ( % r25 ) / * r15 * /
copy % r1 ,% r15
bv % r0 ( % r25 ) / * r16 * /
copy % r1 ,% r16
bv % r0 ( % r25 ) / * r17 * /
copy % r1 ,% r17
bv % r0 ( % r25 ) / * r18 * /
copy % r1 ,% r18
bv % r0 ( % r25 ) / * r19 * /
copy % r1 ,% r19
bv % r0 ( % r25 ) / * r20 * /
copy % r1 ,% r20
bv % r0 ( % r25 ) / * r21 * /
copy % r1 ,% r21
bv % r0 ( % r25 ) / * r22 * /
copy % r1 ,% r22
bv % r0 ( % r25 ) / * r23 * /
copy % r1 ,% r23
bv % r0 ( % r25 ) / * r24 * /
copy % r1 ,% r24
bv % r0 ( % r25 ) / * r25 * /
copy % r1 ,% r25
bv % r0 ( % r25 ) / * r26 * /
copy % r1 ,% r26
bv % r0 ( % r25 ) / * r27 * /
copy % r1 ,% r27
bv % r0 ( % r25 ) / * r28 * /
copy % r1 ,% r28
bv % r0 ( % r25 ) / * r29 * /
copy % r1 ,% r29
bv % r0 ( % r25 ) / * r30 * /
copy % r1 ,% r30
bv % r0 ( % r25 ) / * r31 * /
copy % r1 ,% r31
2007-01-23 22:50:59 +03:00