2005-04-17 02:20:36 +04:00
/ *
* S3 9 0 l o w - l e v e l e n t r y p o i n t s .
*
2012-07-20 13:15:04 +04:00
* Copyright I B M C o r p . 1 9 9 9 , 2 0 1 2
2005-04-17 02:20:36 +04:00
* Author( s ) : M a r t i n S c h w i d e f s k y ( s c h w i d e f s k y @de.ibm.com),
2006-09-28 18:56:37 +04:00
* Hartmut P e n n e r ( h p @de.ibm.com),
* Denis J o s e p h B a r r o w ( d j b a r r o w @de.ibm.com,barrow_dj@yahoo.com),
2005-06-26 01:55:30 +04:00
* Heiko C a r s t e n s < h e i k o . c a r s t e n s @de.ibm.com>
2005-04-17 02:20:36 +04:00
* /
2008-02-05 18:50:40 +03:00
# include < l i n u x / i n i t . h >
2011-07-24 12:48:19 +04:00
# include < l i n u x / l i n k a g e . h >
2012-09-05 15:26:11 +04:00
# include < a s m / p r o c e s s o r . h >
2005-04-17 02:20:36 +04:00
# include < a s m / c a c h e . h >
# include < a s m / e r r n o . h >
# include < a s m / p t r a c e . h >
# include < a s m / t h r e a d _ i n f o . 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 / u n i s t d . h >
# include < a s m / p a g e . h >
2012-06-04 17:05:43 +04:00
# include < a s m / s i g p . h >
2013-06-27 11:01:09 +04:00
# include < a s m / i r q . h >
2005-04-17 02:20:36 +04:00
2011-12-27 14:27:15 +04:00
_ _ PT_ R 0 = _ _ P T _ G P R S
_ _ PT_ R 1 = _ _ P T _ G P R S + 8
_ _ PT_ R 2 = _ _ P T _ G P R S + 1 6
_ _ PT_ R 3 = _ _ P T _ G P R S + 2 4
_ _ PT_ R 4 = _ _ P T _ G P R S + 3 2
_ _ PT_ R 5 = _ _ P T _ G P R S + 4 0
_ _ PT_ R 6 = _ _ P T _ G P R S + 4 8
_ _ PT_ R 7 = _ _ P T _ G P R S + 5 6
_ _ PT_ R 8 = _ _ P T _ G P R S + 6 4
_ _ PT_ R 9 = _ _ P T _ G P R S + 7 2
_ _ PT_ R 1 0 = _ _ P T _ G P R S + 8 0
_ _ PT_ R 1 1 = _ _ P T _ G P R S + 8 8
_ _ PT_ R 1 2 = _ _ P T _ G P R S + 9 6
_ _ PT_ R 1 3 = _ _ P T _ G P R S + 1 0 4
_ _ PT_ R 1 4 = _ _ P T _ G P R S + 1 1 2
_ _ PT_ R 1 5 = _ _ P T _ G P R S + 1 2 0
2005-04-17 02:20:36 +04:00
STACK_ S H I F T = P A G E _ S H I F T + T H R E A D _ O R D E R
STACK_ S I Z E = 1 < < S T A C K _ S H I F T
2013-04-24 12:20:43 +04:00
STACK_ I N I T = S T A C K _ S I Z E - S T A C K _ F R A M E _ O V E R H E A D - _ _ P T _ S I Z E
2005-04-17 02:20:36 +04:00
2014-09-22 18:39:06 +04:00
_ TIF_ W O R K = ( _ 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 | _ T I F _ N E E D _ R E S C H E D | \
_ TIF_ U P R O B E )
2014-04-15 14:55:07 +04:00
_ TIF_ T R A C E = ( _ T I F _ S Y S C A L L _ T R A C E | _ T I F _ S Y S C A L L _ A U D I T | _ T I F _ S E C C O M P | \
_ TIF_ S Y S C A L L _ T R A C E P O I N T )
_ CIF_ W O R K = ( _ C I F _ M C C K _ P E N D I N G | _ C I F _ A S C E )
_ PIF_ W O R K = ( _ P I F _ P E R _ T R A P )
2005-04-17 02:20:36 +04:00
# define B A S E D ( n a m e ) n a m e - s y s t e m _ c a l l ( % r13 )
2006-07-03 11:24:46 +04:00
.macro TRACE_IRQS_ON
2011-12-27 14:27:15 +04:00
# ifdef C O N F I G _ T R A C E _ I R Q F L A G S
2010-05-17 12:00:02 +04:00
basr % r2 ,% r0
brasl % r14 ,t r a c e _ h a r d i r q s _ o n _ c a l l e r
2011-12-27 14:27:15 +04:00
# endif
2006-07-03 11:24:46 +04:00
.endm
.macro TRACE_IRQS_OFF
2011-12-27 14:27:15 +04:00
# ifdef C O N F I G _ T R A C E _ I R Q F L A G S
2010-05-17 12:00:02 +04:00
basr % r2 ,% r0
brasl % r14 ,t r a c e _ h a r d i r q s _ o f f _ c a l l e r
2007-11-20 13:13:32 +03:00
# endif
2011-12-27 14:27:15 +04:00
.endm
2007-11-20 13:13:32 +03:00
.macro LOCKDEP_SYS_EXIT
2011-12-27 14:27:15 +04:00
# ifdef C O N F I G _ L O C K D E P
tm _ _ P T _ P S W + 1 ( % r11 ) ,0 x01 # r e t u r n i n g t o u s e r ?
jz . + 1 0
2007-11-20 13:13:32 +03:00
brasl % r14 ,l o c k d e p _ s y s _ e x i t
2006-07-03 11:24:46 +04:00
# endif
2005-04-17 02:20:36 +04:00
.endm
2013-02-11 21:11:09 +04:00
.macro LPP newpp
2013-11-01 13:08:20 +04:00
# if I S _ E N A B L E D ( C O N F I G _ K V M )
2013-02-11 21:11:09 +04:00
tm _ _ L C _ M A C H I N E _ F L A G S + 6 ,0 x20 # M A C H I N E _ F L A G _ L P P
2011-12-27 14:27:15 +04:00
jz . + 8
.insn s,0 x b28 0 0 0 0 0 ,\ n e w p p
# endif
.endm
2005-04-17 02:20:36 +04:00
2013-05-17 16:41:37 +04:00
.macro HANDLE_SIE_INTERCEPT scratch,r e a s o n
2013-11-01 13:08:20 +04:00
# if I S _ E N A B L E D ( C O N F I G _ K V M )
2012-05-09 18:27:36 +04:00
tmhh % r8 ,0 x00 0 1 # i n t e r r u p t i n g f r o m u s e r ?
2013-05-17 16:41:37 +04:00
jnz . + 6 2
2011-12-27 14:27:15 +04:00
lgr \ s c r a t c h ,% r9
2013-05-17 16:41:37 +04:00
slg \ s c r a t c h ,B A S E D ( . L s i e _ c r i t i c a l )
clg \ s c r a t c h ,B A S E D ( . L s i e _ c r i t i c a l _ l e n g t h )
.if \ reason= =1
2012-11-15 12:35:16 +04:00
# Some p r o g r a m i n t e r r u p t s a r e s u p p r e s s i n g ( e . g . p r o t e c t i o n ) .
# We m u s t a l s o c h e c k t h e i n s t r u c t i o n a f t e r S I E i n t h a t c a s e .
# do_ p r o t e c t i o n _ e x c e p t i o n w i l l r e w i n d t o r e w i n d _ p a d
2013-05-17 16:41:37 +04:00
jh . + 4 2
2012-11-15 12:35:16 +04:00
.else
2013-05-17 16:41:37 +04:00
jhe . + 4 2
2012-11-15 12:35:16 +04:00
.endif
2013-05-17 16:41:37 +04:00
lg % r14 ,_ _ S F _ E M P T Y ( % r15 ) # g e t c o n t r o l b l o c k p o i n t e r
LPP _ _ S F _ E M P T Y + 1 6 ( % r15 ) # s e t h o s t i d
2013-05-17 16:41:34 +04:00
ni _ _ S I E _ P R O G 0 C + 3 ( % r14 ) ,0 x f e # n o l o n g e r i n S I E
2013-05-17 16:41:37 +04:00
lctlg % c1 ,% c1 ,_ _ L C _ U S E R _ A S C E # l o a d p r i m a r y a s c e
larl % r9 ,s i e _ e x i t # s k i p f o r w a r d t o s i e _ e x i t
mvi _ _ S F _ E M P T Y + 3 1 ( % r15 ) ,\ r e a s o n # s e t e x i t r e a s o n
2011-12-27 14:27:15 +04:00
# endif
2007-07-10 13:24:18 +04:00
.endm
2011-12-27 14:27:15 +04:00
.macro CHECK_STACK stacksize,s a v e a r e a
2006-06-29 16:58:05 +04:00
# ifdef C O N F I G _ C H E C K _ S T A C K
2011-12-27 14:27:15 +04:00
tml % r15 ,\ s t a c k s i z e - C O N F I G _ S T A C K _ G U A R D
lghi % r14 ,\ s a v e a r e a
jz s t a c k _ o v e r f l o w
2006-06-29 16:58:05 +04:00
# endif
.endm
2011-12-27 14:27:15 +04:00
.macro SWITCH_ASYNC savearea,s t a c k ,s h i f t
tmhh % r8 ,0 x00 0 1 # i n t e r r u p t i n g f r o m u s e r ?
jnz 1 f
lgr % r14 ,% r9
slg % r14 ,B A S E D ( . L c r i t i c a l _ s t a r t )
clg % r14 ,B A S E D ( . L c r i t i c a l _ l e n g t h )
2005-04-17 02:20:36 +04:00
jhe 0 f
2011-12-27 14:27:15 +04:00
lghi % r11 ,\ s a v e a r e a # i n s i d e c r i t i c a l s e c t i o n , d o c l e a n u p
2005-04-17 02:20:36 +04:00
brasl % r14 ,c l e a n u p _ c r i t i c a l
2011-12-27 14:27:15 +04:00
tmhh % r8 ,0 x00 0 1 # r e t e s t p r o b l e m s t a t e a f t e r c l e a n u p
2005-04-17 02:20:36 +04:00
jnz 1 f
2011-12-27 14:27:15 +04:00
0 : lg % r14 ,\ s t a c k # a r e w e a l r e a d y o n t h e t a r g e t s t a c k ?
2005-04-17 02:20:36 +04:00
slgr % r14 ,% r15
2011-12-27 14:27:15 +04:00
srag % r14 ,% r14 ,\ s h i f t
2010-05-17 12:00:05 +04:00
jnz 1 f
2011-12-27 14:27:15 +04:00
CHECK_ S T A C K 1 < < \ s h i f t ,\ s a v e a r e a
2013-04-24 12:20:43 +04:00
aghi % r15 ,- ( S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ S I Z E )
2011-12-27 14:27:15 +04:00
j 2 f
1 : lg % r15 ,\ s t a c k # l o a d t a r g e t s t a c k
2013-04-24 12:20:43 +04:00
2 : la % r11 ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 )
2006-09-28 18:56:37 +04:00
.endm
2005-04-17 02:20:36 +04:00
2011-12-27 14:27:15 +04:00
.macro UPDATE_VTIME scratch,e n t e r _ t i m e r
lg \ s c r a t c h ,_ _ L C _ E X I T _ T I M E R
slg \ s c r a t c h ,\ e n t e r _ t i m e r
alg \ s c r a t c h ,_ _ L C _ U S E R _ T I M E R
stg \ s c r a t c h ,_ _ L C _ U S E R _ T I M E R
lg \ s c r a t c h ,_ _ L C _ L A S T _ U P D A T E _ T I M E R
slg \ s c r a t c h ,_ _ L C _ E X I T _ T I M E R
alg \ s c r a t c h ,_ _ L C _ S Y S T E M _ T I M E R
stg \ s c r a t c h ,_ _ L C _ S Y S T E M _ T I M E R
mvc _ _ L C _ L A S T _ U P D A T E _ T I M E R ( 8 ) ,\ e n t e r _ t i m e r
2005-04-17 02:20:36 +04:00
.endm
2011-12-27 14:27:15 +04:00
.macro LAST_BREAK scratch
srag \ s c r a t c h ,% r10 ,2 3
jz . + 1 0
stg % r10 ,_ _ T I _ l a s t _ b r e a k ( % r12 )
2010-05-17 12:00:05 +04:00
.endm
2010-10-25 18:10:37 +04:00
.macro REENABLE_IRQS
2011-12-27 14:27:15 +04:00
stg % r8 ,_ _ L C _ R E T U R N _ P S W
ni _ _ L C _ R E T U R N _ P S W ,0 x b f
ssm _ _ L C _ R E T U R N _ P S W
2010-10-25 18:10:37 +04:00
.endm
2012-05-09 18:27:39 +04:00
.macro STCK savearea
2012-05-14 12:35:22 +04:00
# ifdef C O N F I G _ H A V E _ M A R C H _ Z 9 _ 1 0 9 _ F E A T U R E S
2012-05-09 18:27:39 +04:00
.insn s,0 x b27 c00 0 0 ,\ s a v e a r e a # s t o r e c l o c k f a s t
# else
.insn s,0 x b20 5 0 0 0 0 ,\ s a v e a r e a # s t o r e c l o c k
# endif
.endm
2011-01-05 14:47:25 +03:00
.section .kprobes .text , " ax"
2005-04-17 02:20:36 +04:00
/ *
* Scheduler r e s u m e f u n c t i o n , c a l l e d b y s w i t c h _ t o
* gpr2 = ( t a s k _ s t r u c t * ) p r e v
* gpr3 = ( t a s k _ s t r u c t * ) n e x t
* Returns :
* gpr2 = p r e v
* /
2011-07-24 12:48:19 +04:00
ENTRY( _ _ s w i t c h _ t o )
2012-05-15 11:20:06 +04:00
stmg % r6 ,% r15 ,_ _ S F _ G P R S ( % r15 ) # s t o r e g p r s o f p r e v t a s k
stg % r15 ,_ _ T H R E A D _ k s p ( % r2 ) # s t o r e k e r n e l s t a c k o f p r e v
2011-01-05 14:48:10 +03:00
lg % r4 ,_ _ T H R E A D _ i n f o ( % r2 ) # g e t t h r e a d _ i n f o o f p r e v
lg % r5 ,_ _ T H R E A D _ i n f o ( % r3 ) # g e t t h r e a d _ i n f o o f n e x t
2012-05-15 11:20:06 +04:00
lgr % r15 ,% r5
2013-04-24 12:20:43 +04:00
aghi % r15 ,S T A C K _ I N I T # e n d o f k e r n e l s t a c k o f n e x t
2012-05-15 11:20:06 +04:00
stg % r3 ,_ _ L C _ C U R R E N T # s t o r e t a s k s t r u c t o f n e x t
stg % r5 ,_ _ L C _ T H R E A D _ I N F O # s t o r e t h r e a d i n f o o f n e x t
stg % r15 ,_ _ L C _ K E R N E L _ S T A C K # s t o r e e n d o f k e r n e l s t a c k
lctl % c4 ,% c4 ,_ _ T A S K _ p i d ( % r3 ) # l o a d p i d t o c o n t r o l r e g . 4
mvc _ _ L C _ C U R R E N T _ P I D + 4 ( 4 ,% r0 ) ,_ _ T A S K _ p i d ( % r3 ) # s t o r e p i d o f n e x t
lg % r15 ,_ _ T H R E A D _ k s p ( % r3 ) # l o a d k e r n e l s t a c k o f n e x t
2014-04-15 14:55:07 +04:00
lmg % r6 ,% r15 ,_ _ S F _ G P R S ( % r15 ) # l o a d g p r s o f n e x t t a s k
2005-04-17 02:20:36 +04:00
br % r14
__critical_start :
/ *
* SVC i n t e r r u p t h a n d l e r r o u t i n e . S y s t e m c a l l s a r e s y n c h r o n o u s e v e n t s a n d
* are e x e c u t e d w i t h i n t e r r u p t s e n a b l e d .
* /
2011-07-24 12:48:19 +04:00
ENTRY( s y s t e m _ c a l l )
2008-12-25 15:39:25 +03:00
stpt _ _ L C _ S Y N C _ E N T E R _ T I M E R
2011-12-27 14:27:15 +04:00
sysc_stmg :
stmg % r8 ,% r15 ,_ _ L C _ S A V E _ A R E A _ S Y N C
lg % r10 ,_ _ L C _ L A S T _ B R E A K
lg % r12 ,_ _ L C _ T H R E A D _ I N F O
2014-04-15 14:55:07 +04:00
lghi % r14 ,_ P I F _ S Y S C A L L
2011-12-27 14:27:15 +04:00
sysc_per :
lg % r15 ,_ _ L C _ K E R N E L _ S T A C K
la % r11 ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 ) # p o i n t e r t o p t _ r e g s
2005-04-17 02:20:36 +04:00
sysc_vtime :
2011-12-27 14:27:15 +04:00
UPDATE_ V T I M E % r13 ,_ _ L C _ S Y N C _ E N T E R _ T I M E R
LAST_ B R E A K % r13
stmg % r0 ,% r7 ,_ _ P T _ R 0 ( % r11 )
mvc _ _ P T _ R 8 ( 6 4 ,% r11 ) ,_ _ L C _ S A V E _ A R E A _ S Y N C
mvc _ _ P T _ P S W ( 1 6 ,% r11 ) ,_ _ L C _ S V C _ O L D _ P S W
2011-12-27 14:27:18 +04:00
mvc _ _ P T _ I N T _ C O D E ( 4 ,% r11 ) ,_ _ L C _ S V C _ I L C
2014-04-15 14:55:07 +04:00
stg % r14 ,_ _ P T _ F L A G S ( % r11 )
2005-04-17 02:20:36 +04:00
sysc_do_svc :
2013-04-24 14:58:39 +04:00
lg % r10 ,_ _ T I _ s y s c _ t a b l e ( % r12 ) # a d d r e s s o f s y s t e m c a l l t a b l e
2011-12-27 14:27:18 +04:00
llgh % r8 ,_ _ P T _ I N T _ C O D E + 2 ( % r11 )
2011-12-27 14:27:15 +04:00
slag % r8 ,% r8 ,2 # s h i f t a n d t e s t f o r s v c 0
2005-04-17 02:20:36 +04:00
jnz s y s c _ n r _ o k
# svc 0 : system c a l l n u m b e r i n % r1
2011-12-27 14:27:15 +04:00
llgfr % r1 ,% r1 # c l e a r h i g h w o r d i n r 1
2010-05-17 12:00:05 +04:00
cghi % r1 ,N R _ s y s c a l l s
2005-04-17 02:20:36 +04:00
jnl s y s c _ n r _ o k
2011-12-27 14:27:18 +04:00
sth % r1 ,_ _ P T _ I N T _ C O D E + 2 ( % r11 )
2011-12-27 14:27:15 +04:00
slag % r8 ,% r1 ,2
2005-04-17 02:20:36 +04:00
sysc_nr_ok :
2011-12-27 14:27:15 +04:00
xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 )
stg % r2 ,_ _ P T _ O R I G _ G P R 2 ( % r11 )
stg % r7 ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 )
lgf % r9 ,0 ( % r8 ,% r10 ) # g e t s y s t e m c a l l a d d .
2014-04-15 14:55:07 +04:00
tm _ _ T I _ f l a g s + 7 ( % r12 ) ,_ T I F _ T R A C E
2006-09-28 18:56:37 +04:00
jnz s y s c _ t r a c e s y s
2011-12-27 14:27:15 +04:00
basr % r14 ,% r9 # c a l l s y s _ x x x x
stg % r2 ,_ _ P T _ R 2 ( % r11 ) # s t o r e r e t u r n v a l u e
2005-04-17 02:20:36 +04:00
sysc_return :
2010-05-17 12:00:02 +04:00
LOCKDEP_ S Y S _ E X I T
sysc_tif :
2011-12-27 14:27:15 +04:00
tm _ _ P T _ P S W + 1 ( % r11 ) ,0 x01 # r e t u r n i n g t o u s e r ?
2011-10-30 18:16:49 +04:00
jno s y s c _ r e s t o r e
2014-04-15 14:55:07 +04:00
tm _ _ P T _ F L A G S + 7 ( % r11 ) ,_ P I F _ W O R K
jnz s y s c _ w o r k
tm _ _ T I _ f l a g s + 7 ( % r12 ) ,_ T I F _ W O R K
2011-12-27 14:27:15 +04:00
jnz s y s c _ w o r k # c h e c k f o r w o r k
2014-04-15 14:55:07 +04:00
tm _ _ L C _ C P U _ F L A G S + 7 ,_ C I F _ W O R K
jnz s y s c _ w o r k
2007-11-20 13:13:32 +03:00
sysc_restore :
2011-12-27 14:27:15 +04:00
lg % r14 ,_ _ L C _ V D S O _ P E R _ C P U
lmg % r0 ,% r10 ,_ _ P T _ R 0 ( % r11 )
mvc _ _ L C _ R E T U R N _ P S W ( 1 6 ) ,_ _ P T _ P S W ( % r11 )
stpt _ _ L C _ E X I T _ T I M E R
mvc _ _ V D S O _ E C T G _ B A S E ( 1 6 ,% r14 ) ,_ _ L C _ E X I T _ T I M E R
lmg % r11 ,% r15 ,_ _ P T _ R 1 1 ( % r11 )
lpswe _ _ L C _ R E T U R N _ P S W
2007-11-20 13:13:32 +03:00
sysc_done :
2010-05-17 12:00:01 +04:00
#
# One o f t h e w o r k b i t s i s o n . F i n d o u t w h i c h o n e .
#
2011-10-30 18:16:49 +04:00
sysc_work :
2014-04-15 14:55:07 +04:00
tm _ _ L C _ C P U _ F L A G S + 7 ,_ C I F _ M C C K _ P E N D I N G
2005-06-26 01:55:30 +04:00
jo s y s c _ m c c k _ p e n d i n g
2010-05-17 12:00:05 +04:00
tm _ _ T I _ f l a g s + 7 ( % r12 ) ,_ T I F _ N E E D _ R E S C H E D
2005-04-17 02:20:36 +04:00
jo s y s c _ r e s c h e d u l e
2014-09-22 18:39:06 +04:00
# ifdef C O N F I G _ U P R O B E S
tm _ _ T I _ f l a g s + 7 ( % r12 ) ,_ T I F _ U P R O B E
jo s y s c _ u p r o b e _ n o t i f y
# endif
2014-04-15 14:55:07 +04:00
tm _ _ P T _ F L A G S + 7 ( % r11 ) ,_ P I F _ P E R _ T R A P
2012-11-21 19:36:27 +04:00
jo s y s c _ s i n g l e s t e p
2010-05-17 12:00:05 +04:00
tm _ _ T I _ f l a g s + 7 ( % r12 ) ,_ T I F _ S I G P E N D I N G
2010-05-17 12:00:01 +04:00
jo s y s c _ s i g p e n d i n g
2010-05-17 12:00:05 +04:00
tm _ _ T I _ f l a g s + 7 ( % r12 ) ,_ T I F _ N O T I F Y _ R E S U M E
2010-05-17 12:00:01 +04:00
jo s y s c _ n o t i f y _ r e s u m e
2014-04-15 14:55:07 +04:00
tm _ _ L C _ C P U _ F L A G S + 7 ,_ C I F _ A S C E
s390/uaccess: rework uaccess code - fix locking issues
The current uaccess code uses a page table walk in some circumstances,
e.g. in case of the in atomic futex operations or if running on old
hardware which doesn't support the mvcos instruction.
However it turned out that the page table walk code does not correctly
lock page tables when accessing page table entries.
In other words: a different cpu may invalidate a page table entry while
the current cpu inspects the pte. This may lead to random data corruption.
Adding correct locking however isn't trivial for all uaccess operations.
Especially copy_in_user() is problematic since that requires to hold at
least two locks, but must be protected against ABBA deadlock when a
different cpu also performs a copy_in_user() operation.
So the solution is a different approach where we change address spaces:
User space runs in primary address mode, or access register mode within
vdso code, like it currently already does.
The kernel usually also runs in home space mode, however when accessing
user space the kernel switches to primary or secondary address mode if
the mvcos instruction is not available or if a compare-and-swap (futex)
instruction on a user space address is performed.
KVM however is special, since that requires the kernel to run in home
address space while implicitly accessing user space with the sie
instruction.
So we end up with:
User space:
- runs in primary or access register mode
- cr1 contains the user asce
- cr7 contains the user asce
- cr13 contains the kernel asce
Kernel space:
- runs in home space mode
- cr1 contains the user or kernel asce
-> the kernel asce is loaded when a uaccess requires primary or
secondary address mode
- cr7 contains the user or kernel asce, (changed with set_fs())
- cr13 contains the kernel asce
In case of uaccess the kernel changes to:
- primary space mode in case of a uaccess (copy_to_user) and uses
e.g. the mvcp instruction to access user space. However the kernel
will stay in home space mode if the mvcos instruction is available
- secondary space mode in case of futex atomic operations, so that the
instructions come from primary address space and data from secondary
space
In case of kvm the kernel runs in home space mode, but cr1 gets switched
to contain the gmap asce before the sie instruction gets executed. When
the sie instruction is finished cr1 will be switched back to contain the
user asce.
A context switch between two processes will always load the kernel asce
for the next process in cr1. So the first exit to user space is a bit
more expensive (one extra load control register instruction) than before,
however keeps the code rather simple.
In sum this means there is no need to perform any error prone page table
walks anymore when accessing user space.
The patch seems to be rather large, however it mainly removes the
the page table walk code and restores the previously deleted "standard"
uaccess code, with a couple of changes.
The uaccess without mvcos mode can be enforced with the "uaccess_primary"
kernel parameter.
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2014-03-21 13:42:25 +04:00
jo s y s c _ u a c c e s s
2010-05-17 12:00:01 +04:00
j s y s c _ r e t u r n # b e w a r e o f c r i t i c a l s e c t i o n c l e a n u p
2005-04-17 02:20:36 +04:00
#
# _ TIF_ N E E D _ R E S C H E D i s s e t , c a l l s c h e d u l e
2006-09-28 18:56:37 +04:00
#
sysc_reschedule :
2010-05-17 12:00:02 +04:00
larl % r14 ,s y s c _ r e t u r n
2011-12-27 14:27:15 +04:00
jg s c h e d u l e
2005-04-17 02:20:36 +04:00
2005-06-26 01:55:30 +04:00
#
2014-04-15 14:55:07 +04:00
# _ CIF_ M C C K _ P E N D I N G i s s e t , c a l l h a n d l e r
2005-06-26 01:55:30 +04:00
#
sysc_mcck_pending :
2010-05-17 12:00:02 +04:00
larl % r14 ,s y s c _ r e t u r n
2006-09-28 18:56:37 +04:00
jg s39 0 _ h a n d l e _ m c c k # T I F b i t w i l l b e c l e a r e d b y h a n d l e r
2005-06-26 01:55:30 +04:00
s390/uaccess: rework uaccess code - fix locking issues
The current uaccess code uses a page table walk in some circumstances,
e.g. in case of the in atomic futex operations or if running on old
hardware which doesn't support the mvcos instruction.
However it turned out that the page table walk code does not correctly
lock page tables when accessing page table entries.
In other words: a different cpu may invalidate a page table entry while
the current cpu inspects the pte. This may lead to random data corruption.
Adding correct locking however isn't trivial for all uaccess operations.
Especially copy_in_user() is problematic since that requires to hold at
least two locks, but must be protected against ABBA deadlock when a
different cpu also performs a copy_in_user() operation.
So the solution is a different approach where we change address spaces:
User space runs in primary address mode, or access register mode within
vdso code, like it currently already does.
The kernel usually also runs in home space mode, however when accessing
user space the kernel switches to primary or secondary address mode if
the mvcos instruction is not available or if a compare-and-swap (futex)
instruction on a user space address is performed.
KVM however is special, since that requires the kernel to run in home
address space while implicitly accessing user space with the sie
instruction.
So we end up with:
User space:
- runs in primary or access register mode
- cr1 contains the user asce
- cr7 contains the user asce
- cr13 contains the kernel asce
Kernel space:
- runs in home space mode
- cr1 contains the user or kernel asce
-> the kernel asce is loaded when a uaccess requires primary or
secondary address mode
- cr7 contains the user or kernel asce, (changed with set_fs())
- cr13 contains the kernel asce
In case of uaccess the kernel changes to:
- primary space mode in case of a uaccess (copy_to_user) and uses
e.g. the mvcp instruction to access user space. However the kernel
will stay in home space mode if the mvcos instruction is available
- secondary space mode in case of futex atomic operations, so that the
instructions come from primary address space and data from secondary
space
In case of kvm the kernel runs in home space mode, but cr1 gets switched
to contain the gmap asce before the sie instruction gets executed. When
the sie instruction is finished cr1 will be switched back to contain the
user asce.
A context switch between two processes will always load the kernel asce
for the next process in cr1. So the first exit to user space is a bit
more expensive (one extra load control register instruction) than before,
however keeps the code rather simple.
In sum this means there is no need to perform any error prone page table
walks anymore when accessing user space.
The patch seems to be rather large, however it mainly removes the
the page table walk code and restores the previously deleted "standard"
uaccess code, with a couple of changes.
The uaccess without mvcos mode can be enforced with the "uaccess_primary"
kernel parameter.
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2014-03-21 13:42:25 +04:00
#
2014-04-15 14:55:07 +04:00
# _ CIF_ A S C E i s s e t , l o a d u s e r s p a c e a s c e
s390/uaccess: rework uaccess code - fix locking issues
The current uaccess code uses a page table walk in some circumstances,
e.g. in case of the in atomic futex operations or if running on old
hardware which doesn't support the mvcos instruction.
However it turned out that the page table walk code does not correctly
lock page tables when accessing page table entries.
In other words: a different cpu may invalidate a page table entry while
the current cpu inspects the pte. This may lead to random data corruption.
Adding correct locking however isn't trivial for all uaccess operations.
Especially copy_in_user() is problematic since that requires to hold at
least two locks, but must be protected against ABBA deadlock when a
different cpu also performs a copy_in_user() operation.
So the solution is a different approach where we change address spaces:
User space runs in primary address mode, or access register mode within
vdso code, like it currently already does.
The kernel usually also runs in home space mode, however when accessing
user space the kernel switches to primary or secondary address mode if
the mvcos instruction is not available or if a compare-and-swap (futex)
instruction on a user space address is performed.
KVM however is special, since that requires the kernel to run in home
address space while implicitly accessing user space with the sie
instruction.
So we end up with:
User space:
- runs in primary or access register mode
- cr1 contains the user asce
- cr7 contains the user asce
- cr13 contains the kernel asce
Kernel space:
- runs in home space mode
- cr1 contains the user or kernel asce
-> the kernel asce is loaded when a uaccess requires primary or
secondary address mode
- cr7 contains the user or kernel asce, (changed with set_fs())
- cr13 contains the kernel asce
In case of uaccess the kernel changes to:
- primary space mode in case of a uaccess (copy_to_user) and uses
e.g. the mvcp instruction to access user space. However the kernel
will stay in home space mode if the mvcos instruction is available
- secondary space mode in case of futex atomic operations, so that the
instructions come from primary address space and data from secondary
space
In case of kvm the kernel runs in home space mode, but cr1 gets switched
to contain the gmap asce before the sie instruction gets executed. When
the sie instruction is finished cr1 will be switched back to contain the
user asce.
A context switch between two processes will always load the kernel asce
for the next process in cr1. So the first exit to user space is a bit
more expensive (one extra load control register instruction) than before,
however keeps the code rather simple.
In sum this means there is no need to perform any error prone page table
walks anymore when accessing user space.
The patch seems to be rather large, however it mainly removes the
the page table walk code and restores the previously deleted "standard"
uaccess code, with a couple of changes.
The uaccess without mvcos mode can be enforced with the "uaccess_primary"
kernel parameter.
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2014-03-21 13:42:25 +04:00
#
sysc_uaccess :
2014-04-15 14:55:07 +04:00
ni _ _ L C _ C P U _ F L A G S + 7 ,2 5 5 - _ C I F _ A S C E
s390/uaccess: rework uaccess code - fix locking issues
The current uaccess code uses a page table walk in some circumstances,
e.g. in case of the in atomic futex operations or if running on old
hardware which doesn't support the mvcos instruction.
However it turned out that the page table walk code does not correctly
lock page tables when accessing page table entries.
In other words: a different cpu may invalidate a page table entry while
the current cpu inspects the pte. This may lead to random data corruption.
Adding correct locking however isn't trivial for all uaccess operations.
Especially copy_in_user() is problematic since that requires to hold at
least two locks, but must be protected against ABBA deadlock when a
different cpu also performs a copy_in_user() operation.
So the solution is a different approach where we change address spaces:
User space runs in primary address mode, or access register mode within
vdso code, like it currently already does.
The kernel usually also runs in home space mode, however when accessing
user space the kernel switches to primary or secondary address mode if
the mvcos instruction is not available or if a compare-and-swap (futex)
instruction on a user space address is performed.
KVM however is special, since that requires the kernel to run in home
address space while implicitly accessing user space with the sie
instruction.
So we end up with:
User space:
- runs in primary or access register mode
- cr1 contains the user asce
- cr7 contains the user asce
- cr13 contains the kernel asce
Kernel space:
- runs in home space mode
- cr1 contains the user or kernel asce
-> the kernel asce is loaded when a uaccess requires primary or
secondary address mode
- cr7 contains the user or kernel asce, (changed with set_fs())
- cr13 contains the kernel asce
In case of uaccess the kernel changes to:
- primary space mode in case of a uaccess (copy_to_user) and uses
e.g. the mvcp instruction to access user space. However the kernel
will stay in home space mode if the mvcos instruction is available
- secondary space mode in case of futex atomic operations, so that the
instructions come from primary address space and data from secondary
space
In case of kvm the kernel runs in home space mode, but cr1 gets switched
to contain the gmap asce before the sie instruction gets executed. When
the sie instruction is finished cr1 will be switched back to contain the
user asce.
A context switch between two processes will always load the kernel asce
for the next process in cr1. So the first exit to user space is a bit
more expensive (one extra load control register instruction) than before,
however keeps the code rather simple.
In sum this means there is no need to perform any error prone page table
walks anymore when accessing user space.
The patch seems to be rather large, however it mainly removes the
the page table walk code and restores the previously deleted "standard"
uaccess code, with a couple of changes.
The uaccess without mvcos mode can be enforced with the "uaccess_primary"
kernel parameter.
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2014-03-21 13:42:25 +04:00
lctlg % c1 ,% c1 ,_ _ L C _ U S E R _ A S C E # l o a d p r i m a r y a s c e
j s y s c _ r e t u r n
2005-04-17 02:20:36 +04:00
#
2008-04-30 11:53:08 +04:00
# _ TIF_ S I G P E N D I N G i s s e t , c a l l d o _ s i g n a l
2005-04-17 02:20:36 +04:00
#
2006-09-28 18:56:37 +04:00
sysc_sigpending :
2011-12-27 14:27:15 +04:00
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
brasl % r14 ,d o _ s i g n a l
2014-04-15 14:55:07 +04:00
tm _ _ P T _ F L A G S + 7 ( % r11 ) ,_ P I F _ S Y S C A L L
2011-10-30 18:16:49 +04:00
jno s y s c _ r e t u r n
2011-12-27 14:27:15 +04:00
lmg % r2 ,% r7 ,_ _ P T _ R 2 ( % r11 ) # l o a d s v c a r g u m e n t s
2013-09-27 17:24:38 +04:00
lg % r10 ,_ _ T I _ s y s c _ t a b l e ( % r12 ) # a d d r e s s o f s y s t e m c a l l t a b l e
2011-12-27 14:27:15 +04:00
lghi % r8 ,0 # s v c 0 r e t u r n s - E N O S Y S
2012-10-09 15:33:53 +04:00
llgh % r1 ,_ _ P T _ I N T _ C O D E + 2 ( % r11 ) # l o a d n e w s v c n u m b e r
2011-10-30 18:16:49 +04:00
cghi % r1 ,N R _ s y s c a l l s
jnl s y s c _ n r _ o k # i n v a l i d s v c n u m b e r - > d o s v c 0
2011-12-27 14:27:15 +04:00
slag % r8 ,% r1 ,2
2011-10-30 18:16:49 +04:00
j s y s c _ n r _ o k # r e s t a r t s v c
2005-04-17 02:20:36 +04:00
2008-10-10 23:33:20 +04:00
#
# _ TIF_ N O T I F Y _ R E S U M E i s s e t , c a l l d o _ n o t i f y _ r e s u m e
#
sysc_notify_resume :
2011-12-27 14:27:15 +04:00
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
2010-05-17 12:00:02 +04:00
larl % r14 ,s y s c _ r e t u r n
2011-12-27 14:27:15 +04:00
jg d o _ n o t i f y _ r e s u m e
2008-10-10 23:33:20 +04:00
2014-09-22 18:39:06 +04:00
#
# _ TIF_ U P R O B E i s s e t , c a l l u p r o b e _ n o t i f y _ r e s u m e
#
# ifdef C O N F I G _ U P R O B E S
sysc_uprobe_notify :
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
larl % r14 ,s y s c _ r e t u r n
jg u p r o b e _ n o t i f y _ r e s u m e
# endif
2005-04-17 02:20:36 +04:00
#
2014-04-15 14:55:07 +04:00
# _ PIF_ P E R _ T R A P i s s e t , c a l l d o _ p e r _ t r a p
2005-04-17 02:20:36 +04:00
#
sysc_singlestep :
2014-04-15 14:55:07 +04:00
ni _ _ P T _ F L A G S + 7 ( % r11 ) ,2 5 5 - _ P I F _ P E R _ T R A P
2011-12-27 14:27:15 +04:00
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
larl % r14 ,s y s c _ r e t u r n
2011-01-05 14:48:10 +03:00
jg d o _ p e r _ t r a p
2005-04-17 02:20:36 +04:00
#
2008-10-10 23:33:20 +04:00
# call t r a c e h o o k _ r e p o r t _ s y s c a l l _ e n t r y / t r a c e h o o k _ r e p o r t _ s y s c a l l _ e x i t b e f o r e
# and a f t e r t h e s y s t e m c a l l
2005-04-17 02:20:36 +04:00
#
sysc_tracesys :
2011-12-27 14:27:15 +04:00
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
2005-04-17 02:20:36 +04:00
la % r3 ,0
2011-12-27 14:27:18 +04:00
llgh % r0 ,_ _ P T _ I N T _ C O D E + 2 ( % r11 )
2011-12-27 14:27:15 +04:00
stg % r0 ,_ _ P T _ R 2 ( % r11 )
2008-10-10 23:33:20 +04:00
brasl % r14 ,d o _ s y s c a l l _ t r a c e _ e n t e r
2005-04-17 02:20:36 +04:00
lghi % r0 ,N R _ s y s c a l l s
2008-10-10 23:33:20 +04:00
clgr % r0 ,% r2
2005-04-17 02:20:36 +04:00
jnh s y s c _ t r a c e n o g o
2011-12-27 14:27:15 +04:00
sllg % r8 ,% r2 ,2
lgf % r9 ,0 ( % r8 ,% r10 )
2005-04-17 02:20:36 +04:00
sysc_tracego :
2011-12-27 14:27:15 +04:00
lmg % r3 ,% r7 ,_ _ P T _ R 3 ( % r11 )
stg % r7 ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 )
lg % r2 ,_ _ P T _ O R I G _ G P R 2 ( % r11 )
basr % r14 ,% r9 # c a l l s y s _ x x x
stg % r2 ,_ _ P T _ R 2 ( % r11 ) # s t o r e r e t u r n v a l u e
2005-04-17 02:20:36 +04:00
sysc_tracenogo :
2014-04-15 14:55:07 +04:00
tm _ _ T I _ f l a g s + 7 ( % r12 ) ,_ T I F _ T R A C E
2006-09-28 18:56:37 +04:00
jz s y s c _ r e t u r n
2011-12-27 14:27:15 +04:00
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
larl % r14 ,s y s c _ r e t u r n
2008-10-10 23:33:20 +04:00
jg d o _ s y s c a l l _ t r a c e _ e x i t
2005-04-17 02:20:36 +04:00
#
# a n e w p r o c e s s e x i t s t h e k e r n e l w i t h r e t _ f r o m _ f o r k
#
2011-07-24 12:48:19 +04:00
ENTRY( r e t _ f r o m _ f o r k )
2011-12-27 14:27:15 +04:00
la % r11 ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 )
lg % r12 ,_ _ L C _ T H R E A D _ I N F O
2012-09-11 02:03:41 +04:00
brasl % r14 ,s c h e d u l e _ t a i l
TRACE_ I R Q S _ O N
ssm _ _ L C _ S V C _ N E W _ P S W # r e e n a b l e i n t e r r u p t s
2012-10-11 23:30:14 +04:00
tm _ _ P T _ P S W + 1 ( % r11 ) ,0 x01 # f o r k i n g a k e r n e l t h r e a d ?
jne s y s c _ t r a c e n o g o
# it' s a k e r n e l t h r e a d
lmg % r9 ,% r10 ,_ _ P T _ R 9 ( % r11 ) # l o a d g p r s
2012-09-11 02:03:41 +04:00
ENTRY( k e r n e l _ t h r e a d _ s t a r t e r )
la % r2 ,0 ( % r10 )
basr % r14 ,% r9
2012-10-11 23:30:14 +04:00
j s y s c _ t r a c e n o g o
2005-04-17 02:20:36 +04:00
/ *
* Program c h e c k h a n d l e r r o u t i n e
* /
2011-07-24 12:48:19 +04:00
ENTRY( p g m _ c h e c k _ h a n d l e r )
2008-12-25 15:39:25 +03:00
stpt _ _ L C _ S Y N C _ E N T E R _ T I M E R
2011-12-27 14:27:15 +04:00
stmg % r8 ,% r15 ,_ _ L C _ S A V E _ A R E A _ S Y N C
lg % r10 ,_ _ L C _ L A S T _ B R E A K
lg % r12 ,_ _ L C _ T H R E A D _ I N F O
larl % r13 ,s y s t e m _ c a l l
lmg % r8 ,% r9 ,_ _ L C _ P G M _ O L D _ P S W
2012-11-15 12:35:16 +04:00
HANDLE_ S I E _ I N T E R C E P T % r14 ,1
2011-12-27 14:27:15 +04:00
tmhh % r8 ,0 x00 0 1 # t e s t p r o b l e m s t a t e b i t
jnz 1 f # - > f a u l t i n u s e r s p a c e
tmhh % r8 ,0 x40 0 0 # P E R b i t s e t i n o l d P S W ?
jnz 0 f # - > e n a b l e d , c a n ' t b e a d o u b l e f a u l t
tm _ _ L C _ P G M _ I L C + 3 ,0 x80 # c h e c k f o r p e r e x c e p t i o n
jnz p g m _ s v c p e r # - > s i n g l e s t e p p e d s v c
0 : CHECK_ S T A C K S T A C K _ S I Z E ,_ _ L C _ S A V E _ A R E A _ S Y N C
2013-04-24 12:20:43 +04:00
aghi % r15 ,- ( S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ S I Z E )
2011-12-27 14:27:15 +04:00
j 2 f
1 : UPDATE_ V T I M E % r14 ,_ _ L C _ S Y N C _ E N T E R _ T I M E R
LAST_ B R E A K % r14
lg % r15 ,_ _ L C _ K E R N E L _ S T A C K
2012-07-31 13:03:04 +04:00
lg % r14 ,_ _ T I _ t a s k ( % r12 )
lghi % r13 ,_ _ L C _ P G M _ T D B
tm _ _ L C _ P G M _ I L C + 2 ,0 x02 # c h e c k f o r t r a n s a c t i o n a b o r t
jz 2 f
mvc _ _ T H R E A D _ t r a p _ t d b ( 2 5 6 ,% r14 ) ,0 ( % r13 )
2013-04-24 12:20:43 +04:00
2 : la % r11 ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 )
2011-12-27 14:27:15 +04:00
stmg % r0 ,% r7 ,_ _ P T _ R 0 ( % r11 )
mvc _ _ P T _ R 8 ( 6 4 ,% r11 ) ,_ _ L C _ S A V E _ A R E A _ S Y N C
stmg % r8 ,% r9 ,_ _ P T _ P S W ( % r11 )
2011-12-27 14:27:18 +04:00
mvc _ _ P T _ I N T _ C O D E ( 4 ,% r11 ) ,_ _ L C _ P G M _ I L C
mvc _ _ P T _ I N T _ P A R M _ L O N G ( 8 ,% r11 ) ,_ _ L C _ T R A N S _ E X C _ C O D E
2014-04-15 14:55:07 +04:00
xc _ _ P T _ F L A G S ( 8 ,% r11 ) ,_ _ P T _ F L A G S ( % r11 )
2011-12-27 14:27:15 +04:00
stg % r10 ,_ _ P T _ A R G S ( % r11 )
tm _ _ L C _ P G M _ I L C + 3 ,0 x80 # c h e c k f o r p e r e x c e p t i o n
jz 0 f
tmhh % r8 ,0 x00 0 1 # k e r n e l p e r e v e n t ?
jz p g m _ k p r o b e
2014-04-15 14:55:07 +04:00
oi _ _ P T _ F L A G S + 7 ( % r11 ) ,_ P I F _ P E R _ T R A P
2012-07-31 13:03:04 +04:00
mvc _ _ T H R E A D _ p e r _ a d d r e s s ( 8 ,% r14 ) ,_ _ L C _ P E R _ A D D R E S S
2014-02-26 19:32:46 +04:00
mvc _ _ T H R E A D _ p e r _ c a u s e ( 2 ,% r14 ) ,_ _ L C _ P E R _ C O D E
mvc _ _ T H R E A D _ p e r _ p a i d ( 1 ,% r14 ) ,_ _ L C _ P E R _ A C C E S S _ I D
2011-12-27 14:27:18 +04:00
0 : REENABLE_ I R Q S
2011-12-27 14:27:15 +04:00
xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 )
2010-07-27 21:29:37 +04:00
larl % r1 ,p g m _ c h e c k _ t a b l e
2011-12-27 14:27:18 +04:00
llgh % r10 ,_ _ P T _ I N T _ C O D E + 2 ( % r11 )
nill % r10 ,0 x00 7 f
2012-10-18 20:10:06 +04:00
sll % r10 ,2
2011-12-27 14:27:18 +04:00
je s y s c _ r e t u r n
2012-10-18 20:10:06 +04:00
lgf % r1 ,0 ( % r10 ,% r1 ) # l o a d a d d r e s s o f h a n d l e r r o u t i n e
2011-12-27 14:27:15 +04:00
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
2010-07-27 21:29:37 +04:00
basr % r14 ,% r1 # b r a n c h t o i n t e r r u p t - h a n d l e r
j s y s c _ r e t u r n
2005-04-17 02:20:36 +04:00
#
2011-12-27 14:27:15 +04:00
# PER e v e n t i n s u p e r v i s o r s t a t e , m u s t b e k p r o b e s
2005-04-17 02:20:36 +04:00
#
2011-12-27 14:27:15 +04:00
pgm_kprobe :
REENABLE_ I R Q S
xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 )
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
brasl % r14 ,d o _ p e r _ t r a p
j s y s c _ r e t u r n
2005-04-17 02:20:36 +04:00
2006-09-20 17:58:39 +04:00
#
2011-12-27 14:27:15 +04:00
# single s t e p p e d s y s t e m c a l l
2006-09-20 17:58:39 +04:00
#
2011-12-27 14:27:15 +04:00
pgm_svcper :
mvc _ _ L C _ R E T U R N _ P S W ( 8 ) ,_ _ L C _ S V C _ N E W _ P S W
larl % r14 ,s y s c _ p e r
stg % r14 ,_ _ L C _ R E T U R N _ P S W + 8
2014-04-15 14:55:07 +04:00
lghi % r14 ,_ P I F _ S Y S C A L L | _ P I F _ P E R _ T R A P
2011-12-27 14:27:15 +04:00
lpswe _ _ L C _ R E T U R N _ P S W # b r a n c h t o s y s c _ p e r a n d e n a b l e i r q s
2006-09-20 17:58:39 +04:00
2005-04-17 02:20:36 +04:00
/ *
* IO i n t e r r u p t h a n d l e r r o u t i n e
* /
2011-07-24 12:48:19 +04:00
ENTRY( i o _ i n t _ h a n d l e r )
2012-05-09 18:27:39 +04:00
STCK _ _ L C _ I N T _ C L O C K
2008-12-31 17:11:41 +03:00
stpt _ _ L C _ A S Y N C _ E N T E R _ T I M E R
2011-12-27 14:27:15 +04:00
stmg % r8 ,% r15 ,_ _ L C _ S A V E _ A R E A _ A S Y N C
lg % r10 ,_ _ L C _ L A S T _ B R E A K
lg % r12 ,_ _ L C _ T H R E A D _ I N F O
larl % r13 ,s y s t e m _ c a l l
lmg % r8 ,% r9 ,_ _ L C _ I O _ O L D _ P S W
2013-05-17 16:41:37 +04:00
HANDLE_ S I E _ I N T E R C E P T % r14 ,2
2011-12-27 14:27:15 +04:00
SWITCH_ A S Y N C _ _ L C _ S A V E _ A R E A _ A S Y N C ,_ _ L C _ A S Y N C _ S T A C K ,S T A C K _ S H I F T
tmhh % r8 ,0 x00 0 1 # i n t e r r u p t i n g f r o m u s e r ?
jz i o _ s k i p
UPDATE_ V T I M E % r14 ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R
LAST_ B R E A K % r14
io_skip :
stmg % r0 ,% r7 ,_ _ P T _ R 0 ( % r11 )
mvc _ _ P T _ R 8 ( 6 4 ,% r11 ) ,_ _ L C _ S A V E _ A R E A _ A S Y N C
stmg % r8 ,% r9 ,_ _ P T _ P S W ( % r11 )
2013-06-17 16:54:02 +04:00
mvc _ _ P T _ I N T _ C O D E ( 1 2 ,% r11 ) ,_ _ L C _ S U B C H A N N E L _ I D
2014-04-15 14:55:07 +04:00
xc _ _ P T _ F L A G S ( 8 ,% r11 ) ,_ _ P T _ F L A G S ( % r11 )
2006-07-03 11:24:46 +04:00
TRACE_ I R Q S _ O F F
2011-12-27 14:27:15 +04:00
xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 )
2013-06-17 16:54:02 +04:00
io_loop :
2011-12-27 14:27:15 +04:00
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
2013-06-27 11:01:09 +04:00
lghi % r3 ,I O _ I N T E R R U P T
tm _ _ P T _ I N T _ C O D E + 8 ( % r11 ) ,0 x80 # a d a p t e r i n t e r r u p t ?
jz i o _ c a l l
lghi % r3 ,T H I N _ I N T E R R U P T
io_call :
2011-12-27 14:27:15 +04:00
brasl % r14 ,d o _ I R Q
2013-06-17 16:54:02 +04:00
tm _ _ L C _ M A C H I N E _ F L A G S + 6 ,0 x10 # M A C H I N E _ F L A G _ L P A R
jz i o _ r e t u r n
tpi 0
jz i o _ r e t u r n
mvc _ _ P T _ I N T _ C O D E ( 1 2 ,% r11 ) ,_ _ L C _ S U B C H A N N E L _ I D
j i o _ l o o p
2005-04-17 02:20:36 +04:00
io_return :
2010-05-17 12:00:02 +04:00
LOCKDEP_ S Y S _ E X I T
TRACE_ I R Q S _ O N
io_tif :
2014-04-15 14:55:07 +04:00
tm _ _ T I _ f l a g s + 7 ( % r12 ) ,_ T I F _ W O R K
2006-09-28 18:56:37 +04:00
jnz i o _ w o r k # t h e r e i s w o r k t o d o ( s i g n a l s e t c . )
2014-04-15 14:55:07 +04:00
tm _ _ L C _ C P U _ F L A G S + 7 ,_ C I F _ W O R K
jnz i o _ w o r k
2007-11-20 13:13:32 +03:00
io_restore :
2011-12-27 14:27:15 +04:00
lg % r14 ,_ _ L C _ V D S O _ P E R _ C P U
lmg % r0 ,% r10 ,_ _ P T _ R 0 ( % r11 )
mvc _ _ L C _ R E T U R N _ P S W ( 1 6 ) ,_ _ P T _ P S W ( % r11 )
stpt _ _ L C _ E X I T _ T I M E R
mvc _ _ V D S O _ E C T G _ B A S E ( 1 6 ,% r14 ) ,_ _ L C _ E X I T _ T I M E R
lmg % r11 ,% r15 ,_ _ P T _ R 1 1 ( % r11 )
lpswe _ _ L C _ R E T U R N _ P S W
2005-09-04 02:57:56 +04:00
io_done :
2005-04-17 02:20:36 +04:00
2008-05-07 11:22:52 +04:00
#
2010-05-17 12:00:01 +04:00
# There i s w o r k t o d o , f i n d o u t i n w h i c h c o n t e x t w e h a v e b e e n i n t e r r u p t e d :
2014-04-15 14:55:07 +04:00
# 1 ) if w e r e t u r n t o u s e r s p a c e w e c a n d o a l l _ T I F _ W O R K w o r k
2010-05-17 12:00:01 +04:00
# 2 ) if w e r e t u r n t o k e r n e l c o d e a n d k v m i s e n a b l e d c h e c k i f w e n e e d t o
# modify t h e p s w t o l e a v e S I E
# 3 ) if w e r e t u r n t o k e r n e l c o d e a n d p r e e m p t i v e s c h e d u l i n g i s e n a b l e d c h e c k
# the p r e e m p t i o n c o u n t e r a n d i f i t i s z e r o c a l l p r e e m p t _ s c h e d u l e _ i r q
# Before a n y w o r k c a n b e d o n e , a s w i t c h t o t h e k e r n e l s t a c k i s r e q u i r e d .
2008-05-07 11:22:52 +04:00
#
io_work :
2011-12-27 14:27:15 +04:00
tm _ _ P T _ P S W + 1 ( % r11 ) ,0 x01 # r e t u r n i n g t o u s e r ?
2010-05-17 12:00:01 +04:00
jo i o _ w o r k _ u s e r # y e s - > d o r e s c h e d & s i g n a l
# ifdef C O N F I G _ P R E E M P T
2008-05-07 11:22:52 +04:00
# check f o r p r e e m p t i v e s c h e d u l i n g
2010-05-17 12:00:05 +04:00
icm % r0 ,1 5 ,_ _ T I _ p r e c o u n t ( % r12 )
2008-05-07 11:22:52 +04:00
jnz i o _ r e s t o r e # p r e e m p t i o n i s d i s a b l e d
2010-05-17 12:00:02 +04:00
tm _ _ T I _ f l a g s + 7 ( % r12 ) ,_ T I F _ N E E D _ R E S C H E D
jno i o _ r e s t o r e
2005-04-17 02:20:36 +04:00
# switch t o k e r n e l s t a c k
2011-12-27 14:27:15 +04:00
lg % r1 ,_ _ P T _ R 1 5 ( % r11 )
aghi % r1 ,- ( S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ S I Z E )
mvc S T A C K _ F R A M E _ O V E R H E A D ( _ _ P T _ S I Z E ,% r1 ) ,0 ( % r11 )
xc _ _ S F _ B A C K C H A I N ( 8 ,% r1 ) ,_ _ S F _ B A C K C H A I N ( % r1 )
la % r11 ,S T A C K _ F R A M E _ O V E R H E A D ( % r1 )
2005-04-17 02:20:36 +04:00
lgr % r15 ,% r1
2010-05-17 12:00:02 +04:00
# TRACE_ I R Q S _ O N a l r e a d y d o n e a t i o _ r e t u r n , c a l l
# TRACE_ I R Q S _ O F F t o k e e p t h i n g s s y m m e t r i c a l
TRACE_ I R Q S _ O F F
brasl % r14 ,p r e e m p t _ s c h e d u l e _ i r q
j i o _ r e t u r n
# else
2010-05-17 12:00:01 +04:00
j i o _ r e s t o r e
2010-05-17 12:00:02 +04:00
# endif
2005-04-17 02:20:36 +04:00
2010-05-17 12:00:01 +04:00
#
# Need t o d o w o r k b e f o r e r e t u r n i n g t o u s e r s p a c e , s w i t c h t o k e r n e l s t a c k
#
2008-05-07 11:22:52 +04:00
io_work_user :
2005-04-17 02:20:36 +04:00
lg % r1 ,_ _ L C _ K E R N E L _ S T A C K
2011-12-27 14:27:15 +04:00
mvc S T A C K _ F R A M E _ O V E R H E A D ( _ _ P T _ S I Z E ,% r1 ) ,0 ( % r11 )
xc _ _ S F _ B A C K C H A I N ( 8 ,% r1 ) ,_ _ S F _ B A C K C H A I N ( % r1 )
la % r11 ,S T A C K _ F R A M E _ O V E R H E A D ( % r1 )
2005-04-17 02:20:36 +04:00
lgr % r15 ,% r1
2010-05-17 12:00:01 +04:00
2005-04-17 02:20:36 +04:00
#
# One o f t h e w o r k b i t s i s o n . F i n d o u t w h i c h o n e .
#
2010-05-17 12:00:02 +04:00
io_work_tif :
2014-04-15 14:55:07 +04:00
tm _ _ L C _ C P U _ F L A G S + 7 ,_ C I F _ M C C K _ P E N D I N G
2005-06-26 01:55:30 +04:00
jo i o _ m c c k _ p e n d i n g
2010-05-17 12:00:05 +04:00
tm _ _ T I _ f l a g s + 7 ( % r12 ) ,_ T I F _ N E E D _ R E S C H E D
2005-04-17 02:20:36 +04:00
jo i o _ r e s c h e d u l e
2010-05-17 12:00:05 +04:00
tm _ _ T I _ f l a g s + 7 ( % r12 ) ,_ T I F _ S I G P E N D I N G
2010-05-17 12:00:01 +04:00
jo i o _ s i g p e n d i n g
2010-05-17 12:00:05 +04:00
tm _ _ T I _ f l a g s + 7 ( % r12 ) ,_ T I F _ N O T I F Y _ R E S U M E
2010-05-17 12:00:01 +04:00
jo i o _ n o t i f y _ r e s u m e
2014-04-15 14:55:07 +04:00
tm _ _ L C _ C P U _ F L A G S + 7 ,_ C I F _ A S C E
s390/uaccess: rework uaccess code - fix locking issues
The current uaccess code uses a page table walk in some circumstances,
e.g. in case of the in atomic futex operations or if running on old
hardware which doesn't support the mvcos instruction.
However it turned out that the page table walk code does not correctly
lock page tables when accessing page table entries.
In other words: a different cpu may invalidate a page table entry while
the current cpu inspects the pte. This may lead to random data corruption.
Adding correct locking however isn't trivial for all uaccess operations.
Especially copy_in_user() is problematic since that requires to hold at
least two locks, but must be protected against ABBA deadlock when a
different cpu also performs a copy_in_user() operation.
So the solution is a different approach where we change address spaces:
User space runs in primary address mode, or access register mode within
vdso code, like it currently already does.
The kernel usually also runs in home space mode, however when accessing
user space the kernel switches to primary or secondary address mode if
the mvcos instruction is not available or if a compare-and-swap (futex)
instruction on a user space address is performed.
KVM however is special, since that requires the kernel to run in home
address space while implicitly accessing user space with the sie
instruction.
So we end up with:
User space:
- runs in primary or access register mode
- cr1 contains the user asce
- cr7 contains the user asce
- cr13 contains the kernel asce
Kernel space:
- runs in home space mode
- cr1 contains the user or kernel asce
-> the kernel asce is loaded when a uaccess requires primary or
secondary address mode
- cr7 contains the user or kernel asce, (changed with set_fs())
- cr13 contains the kernel asce
In case of uaccess the kernel changes to:
- primary space mode in case of a uaccess (copy_to_user) and uses
e.g. the mvcp instruction to access user space. However the kernel
will stay in home space mode if the mvcos instruction is available
- secondary space mode in case of futex atomic operations, so that the
instructions come from primary address space and data from secondary
space
In case of kvm the kernel runs in home space mode, but cr1 gets switched
to contain the gmap asce before the sie instruction gets executed. When
the sie instruction is finished cr1 will be switched back to contain the
user asce.
A context switch between two processes will always load the kernel asce
for the next process in cr1. So the first exit to user space is a bit
more expensive (one extra load control register instruction) than before,
however keeps the code rather simple.
In sum this means there is no need to perform any error prone page table
walks anymore when accessing user space.
The patch seems to be rather large, however it mainly removes the
the page table walk code and restores the previously deleted "standard"
uaccess code, with a couple of changes.
The uaccess without mvcos mode can be enforced with the "uaccess_primary"
kernel parameter.
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2014-03-21 13:42:25 +04:00
jo i o _ u a c c e s s
2010-05-17 12:00:01 +04:00
j i o _ r e t u r n # b e w a r e o f c r i t i c a l s e c t i o n c l e a n u p
2008-05-07 11:22:53 +04:00
2005-06-26 01:55:30 +04:00
#
2014-04-15 14:55:07 +04:00
# _ CIF_ M C C K _ P E N D I N G i s s e t , c a l l h a n d l e r
2005-06-26 01:55:30 +04:00
#
io_mcck_pending :
2010-05-17 12:00:02 +04:00
# TRACE_ I R Q S _ O N a l r e a d y d o n e a t i o _ r e t u r n
2007-07-27 14:29:18 +04:00
brasl % r14 ,s39 0 _ h a n d l e _ m c c k # T I F b i t w i l l b e c l e a r e d b y h a n d l e r
2010-05-17 12:00:02 +04:00
TRACE_ I R Q S _ O F F
j i o _ r e t u r n
2005-06-26 01:55:30 +04:00
s390/uaccess: rework uaccess code - fix locking issues
The current uaccess code uses a page table walk in some circumstances,
e.g. in case of the in atomic futex operations or if running on old
hardware which doesn't support the mvcos instruction.
However it turned out that the page table walk code does not correctly
lock page tables when accessing page table entries.
In other words: a different cpu may invalidate a page table entry while
the current cpu inspects the pte. This may lead to random data corruption.
Adding correct locking however isn't trivial for all uaccess operations.
Especially copy_in_user() is problematic since that requires to hold at
least two locks, but must be protected against ABBA deadlock when a
different cpu also performs a copy_in_user() operation.
So the solution is a different approach where we change address spaces:
User space runs in primary address mode, or access register mode within
vdso code, like it currently already does.
The kernel usually also runs in home space mode, however when accessing
user space the kernel switches to primary or secondary address mode if
the mvcos instruction is not available or if a compare-and-swap (futex)
instruction on a user space address is performed.
KVM however is special, since that requires the kernel to run in home
address space while implicitly accessing user space with the sie
instruction.
So we end up with:
User space:
- runs in primary or access register mode
- cr1 contains the user asce
- cr7 contains the user asce
- cr13 contains the kernel asce
Kernel space:
- runs in home space mode
- cr1 contains the user or kernel asce
-> the kernel asce is loaded when a uaccess requires primary or
secondary address mode
- cr7 contains the user or kernel asce, (changed with set_fs())
- cr13 contains the kernel asce
In case of uaccess the kernel changes to:
- primary space mode in case of a uaccess (copy_to_user) and uses
e.g. the mvcp instruction to access user space. However the kernel
will stay in home space mode if the mvcos instruction is available
- secondary space mode in case of futex atomic operations, so that the
instructions come from primary address space and data from secondary
space
In case of kvm the kernel runs in home space mode, but cr1 gets switched
to contain the gmap asce before the sie instruction gets executed. When
the sie instruction is finished cr1 will be switched back to contain the
user asce.
A context switch between two processes will always load the kernel asce
for the next process in cr1. So the first exit to user space is a bit
more expensive (one extra load control register instruction) than before,
however keeps the code rather simple.
In sum this means there is no need to perform any error prone page table
walks anymore when accessing user space.
The patch seems to be rather large, however it mainly removes the
the page table walk code and restores the previously deleted "standard"
uaccess code, with a couple of changes.
The uaccess without mvcos mode can be enforced with the "uaccess_primary"
kernel parameter.
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2014-03-21 13:42:25 +04:00
#
2014-04-15 14:55:07 +04:00
# _ CIF_ A S C E i s s e t , l o a d u s e r s p a c e a s c e
s390/uaccess: rework uaccess code - fix locking issues
The current uaccess code uses a page table walk in some circumstances,
e.g. in case of the in atomic futex operations or if running on old
hardware which doesn't support the mvcos instruction.
However it turned out that the page table walk code does not correctly
lock page tables when accessing page table entries.
In other words: a different cpu may invalidate a page table entry while
the current cpu inspects the pte. This may lead to random data corruption.
Adding correct locking however isn't trivial for all uaccess operations.
Especially copy_in_user() is problematic since that requires to hold at
least two locks, but must be protected against ABBA deadlock when a
different cpu also performs a copy_in_user() operation.
So the solution is a different approach where we change address spaces:
User space runs in primary address mode, or access register mode within
vdso code, like it currently already does.
The kernel usually also runs in home space mode, however when accessing
user space the kernel switches to primary or secondary address mode if
the mvcos instruction is not available or if a compare-and-swap (futex)
instruction on a user space address is performed.
KVM however is special, since that requires the kernel to run in home
address space while implicitly accessing user space with the sie
instruction.
So we end up with:
User space:
- runs in primary or access register mode
- cr1 contains the user asce
- cr7 contains the user asce
- cr13 contains the kernel asce
Kernel space:
- runs in home space mode
- cr1 contains the user or kernel asce
-> the kernel asce is loaded when a uaccess requires primary or
secondary address mode
- cr7 contains the user or kernel asce, (changed with set_fs())
- cr13 contains the kernel asce
In case of uaccess the kernel changes to:
- primary space mode in case of a uaccess (copy_to_user) and uses
e.g. the mvcp instruction to access user space. However the kernel
will stay in home space mode if the mvcos instruction is available
- secondary space mode in case of futex atomic operations, so that the
instructions come from primary address space and data from secondary
space
In case of kvm the kernel runs in home space mode, but cr1 gets switched
to contain the gmap asce before the sie instruction gets executed. When
the sie instruction is finished cr1 will be switched back to contain the
user asce.
A context switch between two processes will always load the kernel asce
for the next process in cr1. So the first exit to user space is a bit
more expensive (one extra load control register instruction) than before,
however keeps the code rather simple.
In sum this means there is no need to perform any error prone page table
walks anymore when accessing user space.
The patch seems to be rather large, however it mainly removes the
the page table walk code and restores the previously deleted "standard"
uaccess code, with a couple of changes.
The uaccess without mvcos mode can be enforced with the "uaccess_primary"
kernel parameter.
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2014-03-21 13:42:25 +04:00
#
io_uaccess :
2014-04-15 14:55:07 +04:00
ni _ _ L C _ C P U _ F L A G S + 7 ,2 5 5 - _ C I F _ A S C E
s390/uaccess: rework uaccess code - fix locking issues
The current uaccess code uses a page table walk in some circumstances,
e.g. in case of the in atomic futex operations or if running on old
hardware which doesn't support the mvcos instruction.
However it turned out that the page table walk code does not correctly
lock page tables when accessing page table entries.
In other words: a different cpu may invalidate a page table entry while
the current cpu inspects the pte. This may lead to random data corruption.
Adding correct locking however isn't trivial for all uaccess operations.
Especially copy_in_user() is problematic since that requires to hold at
least two locks, but must be protected against ABBA deadlock when a
different cpu also performs a copy_in_user() operation.
So the solution is a different approach where we change address spaces:
User space runs in primary address mode, or access register mode within
vdso code, like it currently already does.
The kernel usually also runs in home space mode, however when accessing
user space the kernel switches to primary or secondary address mode if
the mvcos instruction is not available or if a compare-and-swap (futex)
instruction on a user space address is performed.
KVM however is special, since that requires the kernel to run in home
address space while implicitly accessing user space with the sie
instruction.
So we end up with:
User space:
- runs in primary or access register mode
- cr1 contains the user asce
- cr7 contains the user asce
- cr13 contains the kernel asce
Kernel space:
- runs in home space mode
- cr1 contains the user or kernel asce
-> the kernel asce is loaded when a uaccess requires primary or
secondary address mode
- cr7 contains the user or kernel asce, (changed with set_fs())
- cr13 contains the kernel asce
In case of uaccess the kernel changes to:
- primary space mode in case of a uaccess (copy_to_user) and uses
e.g. the mvcp instruction to access user space. However the kernel
will stay in home space mode if the mvcos instruction is available
- secondary space mode in case of futex atomic operations, so that the
instructions come from primary address space and data from secondary
space
In case of kvm the kernel runs in home space mode, but cr1 gets switched
to contain the gmap asce before the sie instruction gets executed. When
the sie instruction is finished cr1 will be switched back to contain the
user asce.
A context switch between two processes will always load the kernel asce
for the next process in cr1. So the first exit to user space is a bit
more expensive (one extra load control register instruction) than before,
however keeps the code rather simple.
In sum this means there is no need to perform any error prone page table
walks anymore when accessing user space.
The patch seems to be rather large, however it mainly removes the
the page table walk code and restores the previously deleted "standard"
uaccess code, with a couple of changes.
The uaccess without mvcos mode can be enforced with the "uaccess_primary"
kernel parameter.
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2014-03-21 13:42:25 +04:00
lctlg % c1 ,% c1 ,_ _ L C _ U S E R _ A S C E # l o a d p r i m a r y a s c e
j i o _ r e t u r n
2005-04-17 02:20:36 +04:00
#
# _ TIF_ N E E D _ R E S C H E D i s s e t , c a l l s c h e d u l e
2006-09-28 18:56:37 +04:00
#
io_reschedule :
2010-05-17 12:00:02 +04:00
# TRACE_ I R Q S _ O N a l r e a d y d o n e a t i o _ r e t u r n
2011-12-27 14:27:15 +04:00
ssm _ _ L C _ S V C _ N E W _ P S W # r e e n a b l e i n t e r r u p t s
2006-09-28 18:56:37 +04:00
brasl % r14 ,s c h e d u l e # c a l l s c h e d u l e r
2011-12-27 14:27:15 +04:00
ssm _ _ L C _ P G M _ N E W _ P S W # d i s a b l e I / O a n d e x t . i n t e r r u p t s
2007-11-20 13:13:32 +03:00
TRACE_ I R Q S _ O F F
2010-05-17 12:00:02 +04:00
j i o _ r e t u r n
2005-04-17 02:20:36 +04:00
#
2008-04-30 11:53:08 +04:00
# _ TIF_ S I G P E N D I N G o r i s s e t , c a l l d o _ s i g n a l
2005-04-17 02:20:36 +04:00
#
2006-09-28 18:56:37 +04:00
io_sigpending :
2010-05-17 12:00:02 +04:00
# TRACE_ I R Q S _ O N a l r e a d y d o n e a t i o _ r e t u r n
2011-12-27 14:27:15 +04:00
ssm _ _ L C _ S V C _ N E W _ P S W # r e e n a b l e i n t e r r u p t s
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
brasl % r14 ,d o _ s i g n a l
ssm _ _ L C _ P G M _ N E W _ P S W # d i s a b l e I / O a n d e x t . i n t e r r u p t s
2007-11-20 13:13:32 +03:00
TRACE_ I R Q S _ O F F
2010-05-17 12:00:02 +04:00
j i o _ r e t u r n
2005-04-17 02:20:36 +04:00
2008-10-10 23:33:20 +04:00
#
# _ TIF_ N O T I F Y _ R E S U M E o r i s s e t , c a l l d o _ n o t i f y _ r e s u m e
#
io_notify_resume :
2010-05-17 12:00:02 +04:00
# TRACE_ I R Q S _ O N a l r e a d y d o n e a t i o _ r e t u r n
2011-12-27 14:27:15 +04:00
ssm _ _ L C _ S V C _ N E W _ P S W # r e e n a b l e i n t e r r u p t s
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
brasl % r14 ,d o _ n o t i f y _ r e s u m e
ssm _ _ L C _ P G M _ N E W _ P S W # d i s a b l e I / O a n d e x t . i n t e r r u p t s
2008-10-10 23:33:20 +04:00
TRACE_ I R Q S _ O F F
2010-05-17 12:00:02 +04:00
j i o _ r e t u r n
2008-10-10 23:33:20 +04:00
2005-04-17 02:20:36 +04:00
/ *
* External i n t e r r u p t h a n d l e r r o u t i n e
* /
2011-07-24 12:48:19 +04:00
ENTRY( e x t _ i n t _ h a n d l e r )
2012-05-09 18:27:39 +04:00
STCK _ _ L C _ I N T _ C L O C K
2008-12-31 17:11:41 +03:00
stpt _ _ L C _ A S Y N C _ E N T E R _ T I M E R
2011-12-27 14:27:15 +04:00
stmg % r8 ,% r15 ,_ _ L C _ S A V E _ A R E A _ A S Y N C
lg % r10 ,_ _ L C _ L A S T _ B R E A K
lg % r12 ,_ _ L C _ T H R E A D _ I N F O
larl % r13 ,s y s t e m _ c a l l
lmg % r8 ,% r9 ,_ _ L C _ E X T _ O L D _ P S W
2013-05-17 16:41:37 +04:00
HANDLE_ S I E _ I N T E R C E P T % r14 ,3
2011-12-27 14:27:15 +04:00
SWITCH_ A S Y N C _ _ L C _ S A V E _ A R E A _ A S Y N C ,_ _ L C _ A S Y N C _ S T A C K ,S T A C K _ S H I F T
tmhh % r8 ,0 x00 0 1 # i n t e r r u p t i n g f r o m u s e r ?
jz e x t _ s k i p
UPDATE_ V T I M E % r14 ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R
LAST_ B R E A K % r14
ext_skip :
stmg % r0 ,% r7 ,_ _ P T _ R 0 ( % r11 )
mvc _ _ P T _ R 8 ( 6 4 ,% r11 ) ,_ _ L C _ S A V E _ A R E A _ A S Y N C
stmg % r8 ,% r9 ,_ _ P T _ P S W ( % r11 )
2013-06-17 16:54:02 +04:00
lghi % r1 ,_ _ L C _ E X T _ P A R A M S 2
mvc _ _ P T _ I N T _ C O D E ( 4 ,% r11 ) ,_ _ L C _ E X T _ C P U _ A D D R
mvc _ _ P T _ I N T _ P A R M ( 4 ,% r11 ) ,_ _ L C _ E X T _ P A R A M S
mvc _ _ P T _ I N T _ P A R M _ L O N G ( 8 ,% r11 ) ,0 ( % r1 )
2014-04-15 14:55:07 +04:00
xc _ _ P T _ F L A G S ( 8 ,% r11 ) ,_ _ P T _ F L A G S ( % r11 )
2006-07-03 11:24:46 +04:00
TRACE_ I R Q S _ O F F
2012-05-09 18:27:35 +04:00
xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 )
2011-12-27 14:27:15 +04:00
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
2013-06-27 11:01:09 +04:00
lghi % r3 ,E X T _ I N T E R R U P T
brasl % r14 ,d o _ I R Q
2005-04-17 02:20:36 +04:00
j i o _ r e t u r n
2012-03-11 19:59:27 +04:00
/ *
* Load i d l e P S W . T h e s e c o n d " h a l f " o f t h i s f u n c t i o n i s i n c l e a n u p _ i d l e .
* /
ENTRY( p s w _ i d l e )
2012-07-20 13:15:08 +04:00
stg % r3 ,_ _ S F _ E M P T Y ( % r15 )
2012-03-11 19:59:27 +04:00
larl % r1 ,p s w _ i d l e _ l p s w + 4
stg % r1 ,_ _ S F _ E M P T Y + 8 ( % r15 )
2012-07-20 13:15:08 +04:00
STCK _ _ C L O C K _ I D L E _ E N T E R ( % r2 )
stpt _ _ T I M E R _ I D L E _ E N T E R ( % r2 )
2012-03-11 19:59:27 +04:00
psw_idle_lpsw :
lpswe _ _ S F _ E M P T Y ( % r15 )
br % r14
psw_idle_end :
2005-09-04 02:57:56 +04:00
__critical_end :
2005-04-17 02:20:36 +04:00
/ *
* Machine c h e c k h a n d l e r r o u t i n e s
* /
2011-07-24 12:48:19 +04:00
ENTRY( m c c k _ i n t _ h a n d l e r )
2012-05-09 18:27:39 +04:00
STCK _ _ L C _ M C C K _ C L O C K
2005-06-26 01:55:30 +04:00
la % r1 ,4 0 9 5 # r e v a l i d a t e r 1
spt _ _ L C _ C P U _ T I M E R _ S A V E _ A R E A - 4 0 9 5 ( % r1 ) # r e v a l i d a t e c p u t i m e r
2006-09-28 18:56:37 +04:00
lmg % r0 ,% r15 ,_ _ L C _ G P R E G S _ S A V E _ A R E A - 4 0 9 5 ( % r1 ) # r e v a l i d a t e g p r s
2011-12-27 14:27:15 +04:00
lg % r10 ,_ _ L C _ L A S T _ B R E A K
lg % r12 ,_ _ L C _ T H R E A D _ I N F O
2010-05-17 12:00:05 +04:00
larl % r13 ,s y s t e m _ c a l l
2011-12-27 14:27:15 +04:00
lmg % r8 ,% r9 ,_ _ L C _ M C K _ O L D _ P S W
2013-05-17 16:41:37 +04:00
HANDLE_ S I E _ I N T E R C E P T % r14 ,4
2006-09-28 18:56:37 +04:00
tm _ _ L C _ M C C K _ C O D E ,0 x80 # s y s t e m d a m a g e ?
2011-12-27 14:27:15 +04:00
jo m c c k _ p a n i c # y e s - > r e s t o f m c c k c o d e i n v a l i d
lghi % r14 ,_ _ L C _ C P U _ T I M E R _ S A V E _ A R E A
mvc _ _ L C _ M C C K _ E N T E R _ T I M E R ( 8 ) ,0 ( % r14 )
2006-06-29 16:58:05 +04:00
tm _ _ L C _ M C C K _ C O D E + 5 ,0 x02 # s t o r e d c p u t i m e r v a l u e v a l i d ?
2011-12-27 14:27:15 +04:00
jo 3 f
2006-06-29 16:58:05 +04:00
la % r14 ,_ _ L C _ S Y N C _ E N T E R _ T I M E R
clc 0 ( 8 ,% r14 ) ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R
jl 0 f
la % r14 ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R
0 : clc 0 ( 8 ,% r14 ) ,_ _ L C _ E X I T _ T I M E R
2011-12-27 14:27:15 +04:00
jl 1 f
2006-06-29 16:58:05 +04:00
la % r14 ,_ _ L C _ E X I T _ T I M E R
2011-12-27 14:27:15 +04:00
1 : clc 0 ( 8 ,% r14 ) ,_ _ L C _ L A S T _ U P D A T E _ T I M E R
jl 2 f
2006-06-29 16:58:05 +04:00
la % r14 ,_ _ L C _ L A S T _ U P D A T E _ T I M E R
2011-12-27 14:27:15 +04:00
2 : spt 0 ( % r14 )
2010-05-17 12:00:03 +04:00
mvc _ _ L C _ M C C K _ E N T E R _ T I M E R ( 8 ) ,0 ( % r14 )
2011-12-27 14:27:15 +04:00
3 : tm _ _ L C _ M C C K _ C O D E + 2 ,0 x09 # m w p + i a o f o l d p s w v a l i d ?
jno m c c k _ p a n i c # n o - > s k i p c l e a n u p c r i t i c a l
SWITCH_ A S Y N C _ _ L C _ G P R E G S _ S A V E _ A R E A + 6 4 ,_ _ L C _ P A N I C _ S T A C K ,P A G E _ S H I F T
tm % r8 ,0 x00 0 1 # i n t e r r u p t i n g f r o m u s e r ?
jz m c c k _ s k i p
UPDATE_ V T I M E % r14 ,_ _ L C _ M C C K _ E N T E R _ T I M E R
LAST_ B R E A K % r14
mcck_skip :
2013-02-28 19:28:41 +04:00
lghi % r14 ,_ _ L C _ G P R E G S _ S A V E _ A R E A + 6 4
stmg % r0 ,% r7 ,_ _ P T _ R 0 ( % r11 )
mvc _ _ P T _ R 8 ( 6 4 ,% r11 ) ,0 ( % r14 )
2011-12-27 14:27:15 +04:00
stmg % r8 ,% r9 ,_ _ P T _ P S W ( % r11 )
2014-04-15 14:55:07 +04:00
xc _ _ P T _ F L A G S ( 8 ,% r11 ) ,_ _ P T _ F L A G S ( % r11 )
2011-12-27 14:27:15 +04:00
xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 )
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
2005-06-26 01:55:30 +04:00
brasl % r14 ,s39 0 _ d o _ m a c h i n e _ c h e c k
2011-12-27 14:27:15 +04:00
tm _ _ P T _ P S W + 1 ( % r11 ) ,0 x01 # r e t u r n i n g t o u s e r ?
2005-06-26 01:55:30 +04:00
jno m c c k _ r e t u r n
lg % r1 ,_ _ L C _ K E R N E L _ S T A C K # s w i t c h t o k e r n e l s t a c k
2011-12-27 14:27:15 +04:00
mvc S T A C K _ F R A M E _ O V E R H E A D ( _ _ P T _ S I Z E ,% r1 ) ,0 ( % r11 )
xc _ _ S F _ B A C K C H A I N ( 8 ,% r1 ) ,_ _ S F _ B A C K C H A I N ( % r1 )
la % r11 ,S T A C K _ F R A M E _ O V E R H E A D ( % r1 )
2005-06-26 01:55:30 +04:00
lgr % r15 ,% r1
2011-12-27 14:27:15 +04:00
ssm _ _ L C _ P G M _ N E W _ P S W # t u r n d a t o n , k e e p i r q s o f f
2014-04-15 14:55:07 +04:00
tm _ _ L C _ C P U _ F L A G S + 7 ,_ C I F _ M C C K _ P E N D I N G
2005-06-26 01:55:30 +04:00
jno m c c k _ r e t u r n
2006-07-03 11:24:46 +04:00
TRACE_ I R Q S _ O F F
2005-06-26 01:55:30 +04:00
brasl % r14 ,s39 0 _ h a n d l e _ m c c k
2006-07-03 11:24:46 +04:00
TRACE_ I R Q S _ O N
2005-04-17 02:20:36 +04:00
mcck_return :
2011-12-27 14:27:15 +04:00
lg % r14 ,_ _ L C _ V D S O _ P E R _ C P U
lmg % r0 ,% r10 ,_ _ P T _ R 0 ( % r11 )
mvc _ _ L C _ R E T U R N _ M C C K _ P S W ( 1 6 ) ,_ _ P T _ P S W ( % r11 ) # m o v e r e t u r n P S W
2006-06-29 16:58:05 +04:00
tm _ _ L C _ R E T U R N _ M C C K _ P S W + 1 ,0 x01 # r e t u r n i n g t o u s e r ?
jno 0 f
stpt _ _ L C _ E X I T _ T I M E R
2011-12-27 14:27:15 +04:00
mvc _ _ V D S O _ E C T G _ B A S E ( 1 6 ,% r14 ) ,_ _ L C _ E X I T _ T I M E R
0 : lmg % r11 ,% r15 ,_ _ P T _ R 1 1 ( % r11 )
lpswe _ _ L C _ R E T U R N _ M C C K _ P S W
mcck_panic :
lg % r14 ,_ _ L C _ P A N I C _ S T A C K
slgr % r14 ,% r15
srag % r14 ,% r14 ,P A G E _ S H I F T
jz 0 f
lg % r15 ,_ _ L C _ P A N I C _ S T A C K
0 : aghi % r15 ,- ( S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ S I Z E )
j m c c k _ s k i p
2005-04-17 02:20:36 +04:00
2011-08-03 18:44:19 +04:00
#
# PSW r e s t a r t i n t e r r u p t h a n d l e r
#
2012-03-11 19:59:26 +04:00
ENTRY( r e s t a r t _ i n t _ h a n d l e r )
2011-12-27 14:27:15 +04:00
stg % r15 ,_ _ L C _ S A V E _ A R E A _ R E S T A R T
2012-03-11 19:59:26 +04:00
lg % r15 ,_ _ L C _ R E S T A R T _ S T A C K
2011-12-27 14:27:15 +04:00
aghi % r15 ,- _ _ P T _ S I Z E # c r e a t e p t _ r e g s o n s t a c k
2012-03-11 19:59:26 +04:00
xc 0 ( _ _ P T _ S I Z E ,% r15 ) ,0 ( % r15 )
2011-12-27 14:27:15 +04:00
stmg % r0 ,% r14 ,_ _ P T _ R 0 ( % r15 )
mvc _ _ P T _ R 1 5 ( 8 ,% r15 ) ,_ _ L C _ S A V E _ A R E A _ R E S T A R T
mvc _ _ P T _ P S W ( 1 6 ,% r15 ) ,_ _ L C _ R S T _ O L D _ P S W # s t o r e r e s t a r t o l d p s w
2012-03-11 19:59:26 +04:00
aghi % r15 ,- S T A C K _ F R A M E _ O V E R H E A D # c r e a t e s t a c k f r a m e o n s t a c k
xc 0 ( S T A C K _ F R A M E _ O V E R H E A D ,% r15 ) ,0 ( % r15 )
2012-06-05 11:59:52 +04:00
lg % r1 ,_ _ L C _ R E S T A R T _ F N # l o a d f n , p a r m & s o u r c e c p u
lg % r2 ,_ _ L C _ R E S T A R T _ D A T A
lg % r3 ,_ _ L C _ R E S T A R T _ S O U R C E
2012-03-11 19:59:26 +04:00
ltgr % r3 ,% r3 # t e s t s o u r c e c p u a d d r e s s
jm 1 f # n e g a t i v e - > s k i p s o u r c e s t o p
2012-06-04 17:05:43 +04:00
0 : sigp % r4 ,% r3 ,S I G P _ S E N S E # s i g p s e n s e t o s o u r c e c p u
2012-03-11 19:59:26 +04:00
brc 1 0 ,0 b # w a i t f o r s t a t u s s t o r e d
1 : basr % r14 ,% r1 # c a l l f u n c t i o n
stap _ _ S F _ E M P T Y ( % r15 ) # s t o r e c p u a d d r e s s
llgh % r3 ,_ _ S F _ E M P T Y ( % r15 )
2012-06-04 17:05:43 +04:00
2 : sigp % r4 ,% r3 ,S I G P _ S T O P # s i g p s t o p t o c u r r e n t c p u
2012-03-11 19:59:26 +04:00
brc 2 ,2 b
3 : j 3 b
2011-08-03 18:44:19 +04:00
2011-01-05 14:47:25 +03:00
.section .kprobes .text , " ax"
2005-04-17 02:20:36 +04:00
# ifdef C O N F I G _ C H E C K _ S T A C K
/ *
* The s y n c h r o n o u s o r t h e a s y n c h r o n o u s s t a c k o v e r f l o w e d . W e a r e d e a d .
* No n e e d t o p r o p e r l y s a v e t h e r e g i s t e r s , w e a r e g o i n g t o p a n i c a n y w a y .
* Setup a p t _ r e g s s o t h a t s h o w _ t r a c e c a n p r o v i d e a g o o d c a l l t r a c e .
* /
stack_overflow :
2013-04-24 12:20:43 +04:00
lg % r15 ,_ _ L C _ P A N I C _ S T A C K # c h a n g e t o p a n i c s t a c k
la % r11 ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 )
2011-12-27 14:27:15 +04:00
stmg % r0 ,% r7 ,_ _ P T _ R 0 ( % r11 )
stmg % r8 ,% r9 ,_ _ P T _ P S W ( % r11 )
mvc _ _ P T _ R 8 ( 6 4 ,% r11 ) ,0 ( % r14 )
stg % r10 ,_ _ P T _ O R I G _ G P R 2 ( % r11 ) # s t o r e l a s t b r e a k t o o r i g _ g p r 2
xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 )
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
2005-04-17 02:20:36 +04:00
jg k e r n e l _ s t a c k _ o v e r f l o w
# endif
2011-12-27 14:27:15 +04:00
.align 8
cleanup_table :
.quad system_call
.quad sysc_do_svc
.quad sysc_tif
.quad sysc_restore
.quad sysc_done
.quad io_tif
.quad io_restore
.quad io_done
2012-03-11 19:59:27 +04:00
.quad psw_idle
.quad psw_idle_end
2005-04-17 02:20:36 +04:00
cleanup_critical :
2011-12-27 14:27:15 +04:00
clg % r9 ,B A S E D ( c l e a n u p _ t a b l e ) # s y s t e m _ c a l l
2005-04-17 02:20:36 +04:00
jl 0 f
2011-12-27 14:27:15 +04:00
clg % r9 ,B A S E D ( c l e a n u p _ t a b l e + 8 ) # s y s c _ d o _ s v c
2005-04-17 02:20:36 +04:00
jl c l e a n u p _ s y s t e m _ c a l l
2011-12-27 14:27:15 +04:00
clg % r9 ,B A S E D ( c l e a n u p _ t a b l e + 1 6 ) # s y s c _ t i f
2005-04-17 02:20:36 +04:00
jl 0 f
2011-12-27 14:27:15 +04:00
clg % r9 ,B A S E D ( c l e a n u p _ t a b l e + 2 4 ) # s y s c _ r e s t o r e
2010-05-17 12:00:02 +04:00
jl c l e a n u p _ s y s c _ t i f
2011-12-27 14:27:15 +04:00
clg % r9 ,B A S E D ( c l e a n u p _ t a b l e + 3 2 ) # s y s c _ d o n e
2010-05-17 12:00:02 +04:00
jl c l e a n u p _ s y s c _ r e s t o r e
2011-12-27 14:27:15 +04:00
clg % r9 ,B A S E D ( c l e a n u p _ t a b l e + 4 0 ) # i o _ t i f
2006-06-29 16:58:05 +04:00
jl 0 f
2011-12-27 14:27:15 +04:00
clg % r9 ,B A S E D ( c l e a n u p _ t a b l e + 4 8 ) # i o _ r e s t o r e
2010-05-17 12:00:02 +04:00
jl c l e a n u p _ i o _ t i f
2011-12-27 14:27:15 +04:00
clg % r9 ,B A S E D ( c l e a n u p _ t a b l e + 5 6 ) # i o _ d o n e
2010-05-17 12:00:02 +04:00
jl c l e a n u p _ i o _ r e s t o r e
2012-03-11 19:59:27 +04:00
clg % r9 ,B A S E D ( c l e a n u p _ t a b l e + 6 4 ) # p s w _ i d l e
jl 0 f
clg % r9 ,B A S E D ( c l e a n u p _ t a b l e + 7 2 ) # p s w _ i d l e _ e n d
jl c l e a n u p _ i d l e
2011-12-27 14:27:15 +04:00
0 : br % r14
2005-04-17 02:20:36 +04:00
cleanup_system_call :
2011-12-27 14:27:15 +04:00
# check i f s t p t h a s b e e n e x e c u t e d
clg % r9 ,B A S E D ( c l e a n u p _ s y s t e m _ c a l l _ i n s n )
2005-04-17 02:20:36 +04:00
jh 0 f
mvc _ _ L C _ S Y N C _ E N T E R _ T I M E R ( 8 ) ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R
2011-12-27 14:27:15 +04:00
cghi % r11 ,_ _ L C _ S A V E _ A R E A _ A S Y N C
2010-05-17 12:00:03 +04:00
je 0 f
2011-12-27 14:27:15 +04:00
mvc _ _ L C _ S Y N C _ E N T E R _ T I M E R ( 8 ) ,_ _ L C _ M C C K _ E N T E R _ T I M E R
0 : # check i f s t m g h a s b e e n e x e c u t e d
clg % r9 ,B A S E D ( c l e a n u p _ s y s t e m _ c a l l _ i n s n + 8 )
2005-04-17 02:20:36 +04:00
jh 0 f
2011-12-27 14:27:15 +04:00
mvc _ _ L C _ S A V E _ A R E A _ S Y N C ( 6 4 ) ,0 ( % r11 )
0 : # check i f b a s e r e g i s t e r s e t u p + T I F b i t l o a d h a s b e e n d o n e
clg % r9 ,B A S E D ( c l e a n u p _ s y s t e m _ c a l l _ i n s n + 1 6 )
jhe 0 f
# set u p s a v e d r e g i s t e r s r10 a n d r12
stg % r10 ,1 6 ( % r11 ) # r 10 l a s t b r e a k
stg % r12 ,3 2 ( % r11 ) # r 12 t h r e a d - i n f o p o i n t e r
0 : # check i f t h e u s e r t i m e u p d a t e h a s b e e n d o n e
clg % r9 ,B A S E D ( c l e a n u p _ s y s t e m _ c a l l _ i n s n + 2 4 )
jh 0 f
lg % r15 ,_ _ L C _ E X I T _ T I M E R
slg % r15 ,_ _ L C _ S Y N C _ E N T E R _ T I M E R
alg % r15 ,_ _ L C _ U S E R _ T I M E R
stg % r15 ,_ _ L C _ U S E R _ T I M E R
0 : # check i f t h e s y s t e m t i m e u p d a t e h a s b e e n d o n e
clg % r9 ,B A S E D ( c l e a n u p _ s y s t e m _ c a l l _ i n s n + 3 2 )
jh 0 f
lg % r15 ,_ _ L C _ L A S T _ U P D A T E _ T I M E R
slg % r15 ,_ _ L C _ E X I T _ T I M E R
alg % r15 ,_ _ L C _ S Y S T E M _ T I M E R
stg % r15 ,_ _ L C _ S Y S T E M _ T I M E R
0 : # update a c c o u n t i n g t i m e s t a m p
2005-04-17 02:20:36 +04:00
mvc _ _ L C _ L A S T _ U P D A T E _ T I M E R ( 8 ) ,_ _ L C _ S Y N C _ E N T E R _ T I M E R
2011-12-27 14:27:15 +04:00
# do L A S T _ B R E A K
lg % r9 ,1 6 ( % r11 )
srag % r9 ,% r9 ,2 3
2010-05-17 12:00:05 +04:00
jz 0 f
2011-12-27 14:27:15 +04:00
mvc _ _ T I _ l a s t _ b r e a k ( 8 ,% r12 ) ,1 6 ( % r11 )
0 : # set u p s a v e d r e g i s t e r r11
lg % r15 ,_ _ L C _ K E R N E L _ S T A C K
2013-04-24 12:20:43 +04:00
la % r9 ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 )
stg % r9 ,2 4 ( % r11 ) # r 11 p t _ r e g s p o i n t e r
2011-12-27 14:27:15 +04:00
# fill p t _ r e g s
2013-04-24 12:20:43 +04:00
mvc _ _ P T _ R 8 ( 6 4 ,% r9 ) ,_ _ L C _ S A V E _ A R E A _ S Y N C
stmg % r0 ,% r7 ,_ _ P T _ R 0 ( % r9 )
mvc _ _ P T _ P S W ( 1 6 ,% r9 ) ,_ _ L C _ S V C _ O L D _ P S W
mvc _ _ P T _ I N T _ C O D E ( 4 ,% r9 ) ,_ _ L C _ S V C _ I L C
2014-04-15 14:55:07 +04:00
xc _ _ P T _ F L A G S ( 8 ,% r9 ) ,_ _ P T _ F L A G S ( % r9 )
mvi _ _ P T _ F L A G S + 7 ( % r9 ) ,_ P I F _ S Y S C A L L
2011-12-27 14:27:15 +04:00
# setup s a v e d r e g i s t e r r15
stg % r15 ,5 6 ( % r11 ) # r 15 s t a c k p o i n t e r
# set n e w p s w a d d r e s s a n d e x i t
larl % r9 ,s y s c _ d o _ s v c
2005-04-17 02:20:36 +04:00
br % r14
cleanup_system_call_insn :
2006-09-28 18:56:37 +04:00
.quad system_call
2011-12-27 14:27:15 +04:00
.quad sysc_stmg
.quad sysc_per
.quad sysc_ v t i m e + 1 8
.quad sysc_ v t i m e + 4 2
2005-04-17 02:20:36 +04:00
2010-05-17 12:00:02 +04:00
cleanup_sysc_tif :
2011-12-27 14:27:15 +04:00
larl % r9 ,s y s c _ t i f
2005-04-17 02:20:36 +04:00
br % r14
2010-05-17 12:00:02 +04:00
cleanup_sysc_restore :
2011-12-27 14:27:15 +04:00
clg % r9 ,B A S E D ( c l e a n u p _ s y s c _ r e s t o r e _ i n s n )
2010-05-17 12:00:03 +04:00
je 0 f
2011-12-27 14:27:15 +04:00
lg % r9 ,2 4 ( % r11 ) # g e t s a v e d p o i n t e r t o p t _ r e g s
mvc _ _ L C _ R E T U R N _ P S W ( 1 6 ) ,_ _ P T _ P S W ( % r9 )
mvc 0 ( 6 4 ,% r11 ) ,_ _ P T _ R 8 ( % r9 )
lmg % r0 ,% r7 ,_ _ P T _ R 0 ( % r9 )
0 : lmg % r8 ,% r9 ,_ _ L C _ R E T U R N _ P S W
2005-04-17 02:20:36 +04:00
br % r14
2010-05-17 12:00:02 +04:00
cleanup_sysc_restore_insn :
2007-11-20 13:13:32 +03:00
.quad sysc_done - 4
2005-04-17 02:20:36 +04:00
2010-05-17 12:00:02 +04:00
cleanup_io_tif :
2011-12-27 14:27:15 +04:00
larl % r9 ,i o _ t i f
2010-04-09 15:43:00 +04:00
br % r14
2010-05-17 12:00:02 +04:00
cleanup_io_restore :
2011-12-27 14:27:15 +04:00
clg % r9 ,B A S E D ( c l e a n u p _ i o _ r e s t o r e _ i n s n )
je 0 f
lg % r9 ,2 4 ( % r11 ) # g e t s a v e d r 11 p o i n t e r t o p t _ r e g s
mvc _ _ L C _ R E T U R N _ P S W ( 1 6 ) ,_ _ P T _ P S W ( % r9 )
mvc 0 ( 6 4 ,% r11 ) ,_ _ P T _ R 8 ( % r9 )
lmg % r0 ,% r7 ,_ _ P T _ R 0 ( % r9 )
0 : lmg % r8 ,% r9 ,_ _ L C _ R E T U R N _ P S W
2005-09-04 02:57:56 +04:00
br % r14
2010-05-17 12:00:02 +04:00
cleanup_io_restore_insn :
2007-11-20 13:13:32 +03:00
.quad io_done - 4
2005-09-04 02:57:56 +04:00
2012-03-11 19:59:27 +04:00
cleanup_idle :
# copy i n t e r r u p t c l o c k & c p u t i m e r
2012-07-20 13:15:08 +04:00
mvc _ _ C L O C K _ I D L E _ E X I T ( 8 ,% r2 ) ,_ _ L C _ I N T _ C L O C K
mvc _ _ T I M E R _ I D L E _ E X I T ( 8 ,% r2 ) ,_ _ L C _ A S Y N C _ E N T E R _ T I M E R
2012-03-11 19:59:27 +04:00
cghi % r11 ,_ _ L C _ S A V E _ A R E A _ A S Y N C
je 0 f
2012-07-20 13:15:08 +04:00
mvc _ _ C L O C K _ I D L E _ E X I T ( 8 ,% r2 ) ,_ _ L C _ M C C K _ C L O C K
mvc _ _ T I M E R _ I D L E _ E X I T ( 8 ,% r2 ) ,_ _ L C _ M C C K _ E N T E R _ T I M E R
2012-03-11 19:59:27 +04:00
0 : # check i f s t c k & s t p t h a v e b e e n e x e c u t e d
clg % r9 ,B A S E D ( c l e a n u p _ i d l e _ i n s n )
jhe 1 f
2012-07-20 13:15:08 +04:00
mvc _ _ C L O C K _ I D L E _ E N T E R ( 8 ,% r2 ) ,_ _ C L O C K _ I D L E _ E X I T ( % r2 )
mvc _ _ T I M E R _ I D L E _ E N T E R ( 8 ,% r2 ) ,_ _ T I M E R _ I D L E _ E X I T ( % r2 )
1 : # account s y s t e m t i m e g o i n g i d l e
2012-03-11 19:59:27 +04:00
lg % r9 ,_ _ L C _ S T E A L _ T I M E R
2012-07-20 13:15:08 +04:00
alg % r9 ,_ _ C L O C K _ I D L E _ E N T E R ( % r2 )
2012-03-11 19:59:27 +04:00
slg % r9 ,_ _ L C _ L A S T _ U P D A T E _ C L O C K
stg % r9 ,_ _ L C _ S T E A L _ T I M E R
2012-07-20 13:15:08 +04:00
mvc _ _ L C _ L A S T _ U P D A T E _ C L O C K ( 8 ) ,_ _ C L O C K _ I D L E _ E X I T ( % r2 )
2012-03-11 19:59:27 +04:00
lg % r9 ,_ _ L C _ S Y S T E M _ T I M E R
alg % r9 ,_ _ L C _ L A S T _ U P D A T E _ T I M E R
2012-07-20 13:15:08 +04:00
slg % r9 ,_ _ T I M E R _ I D L E _ E N T E R ( % r2 )
2012-03-11 19:59:27 +04:00
stg % r9 ,_ _ L C _ S Y S T E M _ T I M E R
2012-07-20 13:15:08 +04:00
mvc _ _ L C _ L A S T _ U P D A T E _ T I M E R ( 8 ) ,_ _ T I M E R _ I D L E _ E X I T ( % r2 )
2012-03-11 19:59:27 +04:00
# prepare r e t u r n p s w
2013-08-23 16:45:58 +04:00
nihh % r8 ,0 x f c f d # c l e a r i r q & w a i t s t a t e b i t s
2012-03-11 19:59:27 +04:00
lg % r9 ,4 8 ( % r11 ) # r e t u r n f r o m p s w _ i d l e
br % r14
cleanup_idle_insn :
.quad psw_idle_lpsw
2005-04-17 02:20:36 +04:00
/ *
* Integer c o n s t a n t s
* /
2011-12-27 14:27:15 +04:00
.align 8
2005-04-17 02:20:36 +04:00
.Lcritical_start :
2011-12-27 14:27:15 +04:00
.quad __critical_start
.Lcritical_length :
.quad __critical_end - _ _ critical_ s t a r t
2005-04-17 02:20:36 +04:00
2013-11-01 13:08:20 +04:00
# if I S _ E N A B L E D ( C O N F I G _ K V M )
2011-07-24 12:48:18 +04:00
/ *
* sie6 4 a c a l l i n g c o n v e n t i o n :
* % r2 p o i n t e r t o s i e c o n t r o l b l o c k
* % r3 g u e s t r e g i s t e r s a v e a r e a
* /
2011-07-24 12:48:19 +04:00
ENTRY( s i e 6 4 a )
2011-07-24 12:48:18 +04:00
stmg % r6 ,% r14 ,_ _ S F _ G P R S ( % r15 ) # s a v e k e r n e l r e g i s t e r s
stg % r2 ,_ _ S F _ E M P T Y ( % r15 ) # s a v e c o n t r o l b l o c k p o i n t e r
stg % r3 ,_ _ S F _ E M P T Y + 8 ( % r15 ) # s a v e g u e s t r e g i s t e r s a v e a r e a
2013-05-17 16:41:37 +04:00
xc _ _ S F _ E M P T Y + 1 6 ( 1 6 ,% r15 ) ,_ _ S F _ E M P T Y + 1 6 ( % r15 ) # h o s t i d & r e a s o n
2011-07-24 12:48:18 +04:00
lmg % r0 ,% r13 ,0 ( % r3 ) # l o a d g u e s t g p r s 0 - 1 3
2011-09-20 19:07:28 +04:00
lg % r14 ,_ _ L C _ G M A P # g e t g m a p p o i n t e r
ltgr % r14 ,% r14
jz s i e _ g m a p
lctlg % c1 ,% c1 ,_ _ G M A P _ A S C E ( % r14 ) # l o a d p r i m a r y a s c e
sie_gmap :
2011-07-24 12:48:18 +04:00
lg % r14 ,_ _ S F _ E M P T Y ( % r15 ) # g e t c o n t r o l b l o c k p o i n t e r
2013-05-17 16:41:35 +04:00
oi _ _ S I E _ P R O G 0 C + 3 ( % r14 ) ,1 # w e a r e g o i n g i n t o S I E n o w
tm _ _ S I E _ P R O G 2 0 + 3 ( % r14 ) ,1 # l a s t e x i t . . .
jnz s i e _ d o n e
2013-02-11 21:11:09 +04:00
LPP _ _ S F _ E M P T Y ( % r15 ) # s e t g u e s t i d
2011-07-24 12:48:18 +04:00
sie 0 ( % r14 )
sie_done :
2013-02-11 21:11:09 +04:00
LPP _ _ S F _ E M P T Y + 1 6 ( % r15 ) # s e t h o s t i d
2013-05-17 16:41:34 +04:00
ni _ _ S I E _ P R O G 0 C + 3 ( % r14 ) ,0 x f e # n o l o n g e r i n S I E
2011-09-20 19:07:28 +04:00
lctlg % c1 ,% c1 ,_ _ L C _ U S E R _ A S C E # l o a d p r i m a r y a s c e
2013-05-17 16:41:37 +04:00
# some p r o g r a m c h e c k s a r e s u p p r e s s i n g . C c o d e ( e . g . d o _ p r o t e c t i o n _ e x c e p t i o n )
# will r e w i n d t h e P S W b y t h e I L C , w h i c h i s 4 b y t e s i n c a s e o f S I E . O t h e r
2013-12-13 15:53:42 +04:00
# instructions b e t w e e n s i e 6 4 a a n d s i e _ d o n e s h o u l d n o t c a u s e p r o g r a m
2013-05-17 16:41:37 +04:00
# interrupts. S o l e t s u s e a n o p ( 4 7 0 0 0 0 0 0 ) a s a l a n d i n g p a d .
# See a l s o H A N D L E _ S I E _ I N T E R C E P T
rewind_pad :
nop 0
2013-06-12 15:54:56 +04:00
.globl sie_exit
2013-05-17 16:41:37 +04:00
sie_exit :
2011-07-24 12:48:18 +04:00
lg % r14 ,_ _ S F _ E M P T Y + 8 ( % r15 ) # l o a d g u e s t r e g i s t e r s a v e a r e a
stmg % r0 ,% r13 ,0 ( % r14 ) # s a v e g u e s t g p r s 0 - 1 3
lmg % r6 ,% r14 ,_ _ S F _ G P R S ( % r15 ) # r e s t o r e k e r n e l r e g i s t e r s
2013-05-17 16:41:37 +04:00
lg % r2 ,_ _ S F _ E M P T Y + 2 4 ( % r15 ) # r e t u r n e x i t r e a s o n c o d e
2011-07-24 12:48:18 +04:00
br % r14
sie_fault :
2013-05-17 16:41:37 +04:00
lghi % r14 ,- E F A U L T
stg % r14 ,_ _ S F _ E M P T Y + 2 4 ( % r15 ) # s e t e x i t r e a s o n c o d e
j s i e _ e x i t
2011-07-24 12:48:18 +04:00
.align 8
2013-05-17 16:41:37 +04:00
.Lsie_critical :
.quad sie_gmap
.Lsie_critical_length :
.quad sie_done - sie_ g m a p
2011-07-24 12:48:18 +04:00
2012-11-15 12:35:16 +04:00
EX_ T A B L E ( r e w i n d _ p a d ,s i e _ f a u l t )
2013-05-17 16:41:37 +04:00
EX_ T A B L E ( s i e _ e x i t ,s i e _ f a u l t )
2011-07-24 12:48:18 +04:00
# endif
2006-09-28 18:56:37 +04:00
.section .rodata , " a"
2005-04-17 02:20:36 +04:00
# define S Y S C A L L ( e s a ,e s a m e ,e m u ) . l o n g e s a m e
2009-06-12 12:26:47 +04:00
.globl sys_call_table
2005-04-17 02:20:36 +04:00
sys_call_table :
# include " s y s c a l l s . S "
# undef S Y S C A L L
2006-01-06 11:19:28 +03:00
# ifdef C O N F I G _ C O M P A T
2005-04-17 02:20:36 +04:00
# define S Y S C A L L ( e s a ,e s a m e ,e m u ) . l o n g e m u
2013-04-24 14:58:39 +04:00
.globl sys_call_table_emu
2005-04-17 02:20:36 +04:00
sys_call_table_emu :
# include " s y s c a l l s . S "
# undef S Y S C A L L
# endif