2008-02-10 01:24:09 +03:00
/ *
2005-04-17 02:20:36 +04:00
* This m a y n o t u s e a n y s t a c k , n o r a n y v a r i a b l e t h a t i s n o t " N o S a v e " :
*
* Its r e w r i t i n g o n e k e r n e l i m a g e w i t h a n o t h e r . W h a t i s s t a c k i n " o l d "
* image c o u l d v e r y w e l l b e d a t a p a g e i n " n e w " i m a g e , a n d o v e r w r i t i n g
* your o w n s t a c k u n d e r y o u i s b a d i d e a .
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / s e g m e n t . h >
2009-02-13 22:14:01 +03:00
# include < a s m / p a g e _ t y p e s . h >
2005-09-09 21:28:28 +04:00
# include < a s m / a s m - o f f s e t s . h >
2008-08-20 12:44:47 +04:00
# include < a s m / p r o c e s s o r - f l a g s . h >
2005-04-17 02:20:36 +04:00
2008-08-20 12:44:47 +04:00
.text
2005-04-17 02:20:36 +04:00
ENTRY( s w s u s p _ a r c h _ s u s p e n d )
movl % e s p , s a v e d _ c o n t e x t _ e s p
movl % e b x , s a v e d _ c o n t e x t _ e b x
movl % e b p , s a v e d _ c o n t e x t _ e b p
movl % e s i , s a v e d _ c o n t e x t _ e s i
movl % e d i , s a v e d _ c o n t e x t _ e d i
2008-08-20 12:44:47 +04:00
pushfl
popl s a v e d _ c o n t e x t _ e f l a g s
2005-04-17 02:20:36 +04:00
call s w s u s p _ s a v e
ret
2006-12-07 07:34:29 +03:00
ENTRY( r e s t o r e _ i m a g e )
2010-03-05 03:59:32 +03:00
movl m m u _ c r4 _ f e a t u r e s , % e c x
2008-08-18 08:03:40 +04:00
movl r e s u m e _ p g _ d i r , % e a x
subl $ _ _ P A G E _ O F F S E T , % e a x
movl % e a x , % c r3
2005-04-17 02:20:36 +04:00
2010-03-05 03:59:32 +03:00
jecxz 1 f # c r 4 P e n t i u m a n d h i g h e r , s k i p i f z e r o
andl $ ~ ( X 8 6 _ C R 4 _ P G E ) , % e c x
movl % e c x , % c r4 ; # turn off PGE
movl % c r3 , % e a x ; # flush TLB
movl % e a x , % c r3
1 :
2006-09-26 10:32:52 +04:00
movl r e s t o r e _ p b l i s t , % e d x
2005-04-17 02:20:36 +04:00
.p2align 4 , , 7
copy_loop :
testl % e d x , % e d x
jz d o n e
movl p b e _ a d d r e s s ( % e d x ) , % e s i
movl p b e _ o r i g _ a d d r e s s ( % e d x ) , % e d i
movl $ 1 0 2 4 , % e c x
rep
movsl
movl p b e _ n e x t ( % e d x ) , % e d x
jmp c o p y _ l o o p
.p2align 4 , , 7
done :
2006-12-07 07:34:29 +03:00
/* go back to the original page tables */
2008-08-18 08:03:40 +04:00
movl $ s w a p p e r _ p g _ d i r , % e a x
subl $ _ _ P A G E _ O F F S E T , % e a x
movl % e a x , % c r3
movl m m u _ c r4 _ f e a t u r e s , % e c x
jecxz 1 f # c r 4 P e n t i u m a n d h i g h e r , s k i p i f z e r o
movl % e c x , % c r4 ; # turn PGE back on
1 :
2005-04-17 02:20:36 +04:00
movl s a v e d _ c o n t e x t _ e s p , % e s p
movl s a v e d _ c o n t e x t _ e b p , % e b p
movl s a v e d _ c o n t e x t _ e b x , % e b x
movl s a v e d _ c o n t e x t _ e s i , % e s i
movl s a v e d _ c o n t e x t _ e d i , % e d i
2008-08-20 12:44:47 +04:00
pushl s a v e d _ c o n t e x t _ e f l a g s
popfl
2005-04-17 02:20:36 +04:00
2013-05-02 05:53:30 +04:00
/* Saved in save_processor_state. */
movl $ s a v e d _ c o n t e x t , % e a x
lgdt s a v e d _ c o n t e x t _ g d t _ d e s c ( % e a x )
2005-04-17 02:20:36 +04:00
xorl % e a x , % e a x
ret