2019-06-03 07:44:46 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2006-10-18 15:14:55 +02:00
/ *
* relocate_ k e r n e l . S f o r k e x e c
* Created b y < n s c h i c h a n @corp.free.fr> on Thu Oct 12 17:49:57 2006
* /
# include < a s m / a s m . h >
# include < a s m / a s m m a c r o . h >
# include < a s m / r e g d e f . h >
# include < a s m / m i p s r e g s . h >
# include < a s m / s t a c k f r a m e . h >
# include < a s m / a d d r s p a c e . h >
2007-07-31 15:17:21 +01:00
LEAF( r e l o c a t e _ n e w _ k e r n e l )
2012-10-11 18:14:58 +02:00
PTR_ L a0 , a r g 0
PTR_ L a1 , a r g 1
PTR_ L a2 , a r g 2
PTR_ L a3 , a r g 3
2007-07-31 15:17:21 +01:00
PTR_ L s0 , k e x e c _ i n d i r e c t i o n _ p a g e
PTR_ L s1 , k e x e c _ s t a r t _ a d d r e s s
2006-10-18 15:14:55 +02:00
process_entry :
2007-07-31 15:17:21 +01:00
PTR_ L s2 , ( s0 )
2015-06-17 17:12:50 +01:00
PTR_ A D D I U s0 , s0 , S Z R E G
2006-10-18 15:14:55 +02:00
2013-08-30 15:35:10 +05:30
/ *
* In c a s e o f a k d u m p / c r a s h k e r n e l , t h e i n d i r e c t i o n p a g e i s n o t
* populated a s t h e k e r n e l i s d i r e c t l y c o p i e d t o a r e s e r v e d l o c a t i o n
* /
beqz s2 , d o n e
2006-10-18 15:14:55 +02:00
/* destination page */
2007-07-31 15:17:21 +01:00
and s3 , s2 , 0 x1
beq s3 , z e r o , 1 f
and s4 , s2 , ~ 0 x1 / * s t o r e d e s t i n a t i o n a d d r i n s4 * /
b p r o c e s s _ e n t r y
2006-10-18 15:14:55 +02:00
1 :
2013-01-22 12:59:30 +01:00
/* indirection page, update s0 */
2007-07-31 15:17:21 +01:00
and s3 , s2 , 0 x2
beq s3 , z e r o , 1 f
and s0 , s2 , ~ 0 x2
b p r o c e s s _ e n t r y
2006-10-18 15:14:55 +02:00
1 :
/* done page */
2007-07-31 15:17:21 +01:00
and s3 , s2 , 0 x4
beq s3 , z e r o , 1 f
b d o n e
2006-10-18 15:14:55 +02:00
1 :
/* source page */
2007-07-31 15:17:21 +01:00
and s3 , s2 , 0 x8
beq s3 , z e r o , p r o c e s s _ e n t r y
and s2 , s2 , ~ 0 x8
2012-12-28 15:15:25 +01:00
li s6 , ( 1 < < _ P A G E _ S H I F T ) / S Z R E G
2006-10-18 15:14:55 +02:00
copy_word :
/* copy page word by word */
2007-07-31 15:17:21 +01:00
REG_ L s5 , ( s2 )
REG_ S s5 , ( s4 )
2015-06-17 17:12:50 +01:00
PTR_ A D D I U s4 , s4 , S Z R E G
PTR_ A D D I U s2 , s2 , S Z R E G
LONG_ A D D I U s6 , s6 , - 1
2007-07-31 15:17:21 +01:00
beq s6 , z e r o , p r o c e s s _ e n t r y
b c o p y _ w o r d
b p r o c e s s _ e n t r y
2006-10-18 15:14:55 +02:00
done :
2012-10-11 18:14:58 +02:00
# ifdef C O N F I G _ S M P
/ * kexec_ f l a g r e s e t i s s i g n a l t o o t h e r C P U s w h a t k e r n e l
was m o v e d t o i t ' s l o c a t i o n . N o t e - w e n e e d r e l o c a t e d a d d r e s s
of k e x e c _ f l a g . * /
bal 1 f
2013-01-22 12:59:30 +01:00
1 : move t 1 ,r a ;
2012-10-11 18:14:58 +02:00
PTR_ L A t 2 ,1 b
PTR_ L A t 0 ,k e x e c _ f l a g
PTR_ S U B t 0 ,t 0 ,t 2 ;
PTR_ A D D t 0 ,t 1 ,t 0 ;
LONG_ S z e r o ,( t 0 )
# endif
2012-10-25 16:23:31 +02:00
# ifdef C O N F I G _ C P U _ C A V I U M _ O C T E O N
/ * We n e e d t o f l u s h I - c a c h e b e f o r e j u m p i n g t o n e w k e r n e l .
2018-04-25 09:39:06 +02:00
* Unfortunately, t h i s c o d e i s c p u - s p e c i f i c .
2012-10-25 16:23:31 +02:00
* /
.set push
.set noreorder
syncw
syncw
synci 0 ( $ 0 )
.set pop
# else
2012-10-11 18:14:58 +02:00
sync
2012-10-25 16:23:31 +02:00
# endif
2006-10-18 15:14:55 +02:00
/* jump to kexec_start_address */
2007-07-31 15:17:21 +01:00
j s1
END( r e l o c a t e _ n e w _ k e r n e l )
2006-10-18 15:14:55 +02:00
2012-10-11 18:14:58 +02:00
# ifdef C O N F I G _ S M P
/ *
* Other C P U s s h o u l d w a i t u n t i l c o d e i s r e l o c a t e d a n d
* then s t a r t a t e n t r y ( ? ) p o i n t .
* /
LEAF( k e x e c _ s m p _ w a i t )
PTR_ L a0 , s _ a r g 0
PTR_ L a1 , s _ a r g 1
PTR_ L a2 , s _ a r g 2
PTR_ L a3 , s _ a r g 3
PTR_ L s1 , k e x e c _ s t a r t _ a d d r e s s
/ * Non- r e l o c a t e d a d d r e s s w o r k s f o r a r g s a n d k e x e c _ s t a r t _ a d d r e s s ( o l d
* kernel i s n o t o v e r w r i t t e n ) . B u t w e n e e d r e l o c a t e d a d d r e s s o f
* kexec_ f l a g .
* /
bal 1 f
1 : move t 1 ,r a ;
PTR_ L A t 2 ,1 b
PTR_ L A t 0 ,k e x e c _ f l a g
PTR_ S U B t 0 ,t 0 ,t 2 ;
PTR_ A D D t 0 ,t 1 ,t 0 ;
1 : LONG_ L s0 , ( t 0 )
bne s0 , z e r o ,1 b
2012-10-25 16:23:31 +02:00
# ifdef C O N F I G _ C P U _ C A V I U M _ O C T E O N
.set push
.set noreorder
synci 0 ( $ 0 )
.set pop
# else
2012-10-11 18:14:58 +02:00
sync
2012-10-25 16:23:31 +02:00
# endif
2012-10-11 18:14:58 +02:00
j s1
END( k e x e c _ s m p _ w a i t )
# endif
# ifdef _ _ m i p s64
/* all PTR's must be aligned to 8 byte in 64-bit mode */
.align 3
# endif
/ * All p a r a m e t e r s t o n e w k e r n e l a r e p a s s e d i n r e g i s t e r s a0 - a3 .
2018-04-25 09:39:06 +02:00
* kexec_ a r g s [ 0 . . 3 ] a r e u s e d t o p r e p a r e r e g i s t e r v a l u e s .
2012-10-11 18:14:58 +02:00
* /
kexec_args :
EXPORT( k e x e c _ a r g s )
arg0 : PTR 0 x0
arg1 : PTR 0 x0
arg2 : PTR 0 x0
arg3 : PTR 0 x0
.size kexec_ a r g s ,P T R S I Z E * 4
# ifdef C O N F I G _ S M P
/ *
* Secondary C P U s m a y h a v e d i f f e r e n t k e r n e l p a r a m e t e r s i n
* their r e g i s t e r s a0 - a3 . s e c o n d a r y _ k e x e c _ a r g s [ 0 . . 3 ] a r e u s e d
* to p r e p a r e r e g i s t e r v a l u e s .
* /
secondary_kexec_args :
EXPORT( s e c o n d a r y _ k e x e c _ a r g s )
2013-01-22 12:59:30 +01:00
s_arg0 : PTR 0 x0
s_arg1 : PTR 0 x0
s_arg2 : PTR 0 x0
s_arg3 : PTR 0 x0
2012-10-11 18:14:58 +02:00
.size secondary_ k e x e c _ a r g s ,P T R S I Z E * 4
kexec_flag :
LONG 0 x1
# endif
2006-10-18 15:14:55 +02:00
kexec_start_address :
2007-07-31 15:17:21 +01:00
EXPORT( k e x e c _ s t a r t _ a d d r e s s )
PTR 0 x0
.size kexec_ s t a r t _ a d d r e s s , P T R S I Z E
2006-10-18 15:14:55 +02:00
kexec_indirection_page :
2007-07-31 15:17:21 +01:00
EXPORT( k e x e c _ i n d i r e c t i o n _ p a g e )
PTR 0
.size kexec_ i n d i r e c t i o n _ p a g e , P T R S I Z E
2006-10-18 15:14:55 +02:00
relocate_new_kernel_end :
relocate_new_kernel_size :
2007-07-31 15:17:21 +01:00
EXPORT( r e l o c a t e _ n e w _ k e r n e l _ s i z e )
PTR r e l o c a t e _ n e w _ k e r n e l _ e n d - r e l o c a t e _ n e w _ k e r n e l
.size relocate_ n e w _ k e r n e l _ s i z e , P T R S I Z E