2010-04-16 00:11:34 +02:00
/ *
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify
* it u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e , v e r s i o n 2 , a s
* published b y t h e F r e e S o f t w a r e F o u n d a t i o n .
*
* This p r o g r a m i s d i s t r i b u t e d i n t h e h o p e t h a t i t w i l l b e u s e f u l ,
* but W I T H O U T A N Y W A R R A N T Y ; without even the implied warranty of
* MERCHANTABILITY o r F I T N E S S F O R A P A R T I C U L A R P U R P O S E . S e e t h e
* GNU G e n e r a l P u b l i c L i c e n s e f o r m o r e d e t a i l s .
*
* You s h o u l d h a v e r e c e i v e d a c o p y o f t h e G N U G e n e r a l P u b l i c L i c e n s e
* along w i t h t h i s p r o g r a m ; if not, write to the Free Software
* Foundation, 5 1 F r a n k l i n S t r e e t , F i f t h F l o o r , B o s t o n , M A 0 2 1 1 0 - 1 3 0 1 , U S A .
*
* Copyright S U S E L i n u x P r o d u c t s G m b H 2 0 0 9
*
* Authors : Alexander G r a f < a g r a f @suse.de>
* /
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Entry c o d e *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
.macro LOAD_GUEST_SEGMENTS
/ * Required s t a t e :
*
* MSR = ~ I R | D R
* R1 = h o s t R 1
* R2 = h o s t R 2
* R3 = s h a d o w v c p u
2011-07-23 17:41:44 +10:00
* all o t h e r v o l a t i l e G P R S = f r e e e x c e p t R 4 , R 6
2010-04-16 00:11:34 +02:00
* SVCPU[ C R ] = g u e s t C R
* SVCPU[ X E R ] = g u e s t X E R
* SVCPU[ C T R ] = g u e s t C T R
* SVCPU[ L R ] = g u e s t L R
* /
# define X C H G _ S R ( n ) l w z r9 , ( S V C P U _ S R + ( n * 4 ) ) ( r3 ) ; \
mtsr n , r9
XCHG_ S R ( 0 )
XCHG_ S R ( 1 )
XCHG_ S R ( 2 )
XCHG_ S R ( 3 )
XCHG_ S R ( 4 )
XCHG_ S R ( 5 )
XCHG_ S R ( 6 )
XCHG_ S R ( 7 )
XCHG_ S R ( 8 )
XCHG_ S R ( 9 )
XCHG_ S R ( 1 0 )
XCHG_ S R ( 1 1 )
XCHG_ S R ( 1 2 )
XCHG_ S R ( 1 3 )
XCHG_ S R ( 1 4 )
XCHG_ S R ( 1 5 )
/* Clear BATs. */
# define K V M _ K I L L _ B A T ( n , r e g ) \
mtspr S P R N _ I B A T ## n # # U , r e g ; \
mtspr S P R N _ I B A T ## n # # L , r e g ; \
mtspr S P R N _ D B A T ## n # # U , r e g ; \
mtspr S P R N _ D B A T ## n # # L , r e g ; \
li r9 , 0
KVM_ K I L L _ B A T ( 0 , r9 )
KVM_ K I L L _ B A T ( 1 , r9 )
KVM_ K I L L _ B A T ( 2 , r9 )
KVM_ K I L L _ B A T ( 3 , r9 )
.endm
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Exit c o d e *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
.macro LOAD_HOST_SEGMENTS
/ * Register u s a g e a t t h i s p o i n t :
*
* R1 = h o s t R 1
* R2 = h o s t R 2
* R1 2 = e x i t h a n d l e r i d
* R1 3 = s h a d o w v c p u - S H A D O W _ V C P U _ O F F
* SVCPU. * = g u e s t *
* SVCPU[ C R ] = g u e s t C R
* SVCPU[ X E R ] = g u e s t X E R
* SVCPU[ C T R ] = g u e s t C T R
* SVCPU[ L R ] = g u e s t L R
*
* /
/* Restore BATs */
/ * We o n l y o v e r w r i t e t h e u p p e r p a r t , s o w e o n l y r e s t o r e e
the u p p e r p a r t . * /
# define K V M _ L O A D _ B A T ( n , r e g , R A , R B ) \
lwz R A ,( n * 1 6 ) + 0 ( r e g ) ; \
lwz R B ,( n * 1 6 ) + 4 ( r e g ) ; \
mtspr S P R N _ I B A T ## n # # U , R A ; \
mtspr S P R N _ I B A T ## n # # L , R B ; \
lwz R A ,( n * 1 6 ) + 8 ( r e g ) ; \
lwz R B ,( n * 1 6 ) + 1 2 ( r e g ) ; \
mtspr S P R N _ D B A T ## n # # U , R A ; \
mtspr S P R N _ D B A T ## n # # L , R B ; \
lis r9 , B A T S @ha
addi r9 , r9 , B A T S @l
tophys( r9 , r9 )
KVM_ L O A D _ B A T ( 0 , r9 , r10 , r11 )
KVM_ L O A D _ B A T ( 1 , r9 , r10 , r11 )
KVM_ L O A D _ B A T ( 2 , r9 , r10 , r11 )
KVM_ L O A D _ B A T ( 3 , r9 , r10 , r11 )
/* Restore Segment Registers */
/* 0xc - 0xf */
li r0 , 4
mtctr r0
LOAD_ R E G _ I M M E D I A T E ( r3 , 0 x20 0 0 0 0 0 0 | ( 0 x11 1 * 0 x c ) )
lis r4 , 0 x c00 0
3 : mtsrin r3 , r4
addi r3 , r3 , 0 x11 1 / * i n c r e m e n t V S I D * /
addis r4 , r4 , 0 x10 0 0 / * a d d r e s s o f n e x t s e g m e n t * /
bdnz 3 b
/* 0x0 - 0xb */
/* 'current->mm' needs to be in r4 */
tophys( r4 , r2 )
lwz r4 , M M ( r4 )
tophys( r4 , r4 )
/* This only clobbers r0, r3, r4 and r5 */
bl s w i t c h _ m m u _ c o n t e x t
.endm