2019-06-03 08:44:50 +03:00
/* SPDX-License-Identifier: GPL-2.0-only */
2012-10-19 20:46:27 +04:00
/ *
* Hypervisor s t u b
*
* Copyright ( C ) 2 0 1 2 A R M L t d .
* Author : Marc Z y n g i e r < m a r c . z y n g i e r @arm.com>
* /
# include < l i n u x / i n i t . h >
# include < l i n u x / l i n k a g e . h >
2014-06-30 19:01:31 +04:00
# include < l i n u x / i r q c h i p / a r m - g i c - v3 . h >
2012-10-19 20:46:27 +04:00
# include < a s m / a s s e m b l e r . h >
2016-04-27 19:47:03 +03:00
# include < a s m / k v m _ a r m . h >
2016-04-27 19:47:04 +03:00
# include < a s m / k v m _ a s m . h >
2012-10-19 20:46:27 +04:00
# include < a s m / p t r a c e . h >
# include < a s m / v i r t . h >
.text
2019-01-24 19:32:56 +03:00
.pushsection .hyp .text , " ax"
2012-10-19 20:46:27 +04:00
.align 11
ENTRY( _ _ h y p _ s t u b _ v e c t o r s )
ventry e l 2 _ s y n c _ i n v a l i d / / S y n c h r o n o u s E L 2 t
ventry e l 2 _ i r q _ i n v a l i d / / I R Q E L 2 t
ventry e l 2 _ f i q _ i n v a l i d / / F I Q E L 2 t
ventry e l 2 _ e r r o r _ i n v a l i d / / E r r o r E L 2 t
ventry e l 2 _ s y n c _ i n v a l i d / / S y n c h r o n o u s E L 2 h
ventry e l 2 _ i r q _ i n v a l i d / / I R Q E L 2 h
ventry e l 2 _ f i q _ i n v a l i d / / F I Q E L 2 h
ventry e l 2 _ e r r o r _ i n v a l i d / / E r r o r E L 2 h
ventry e l 1 _ s y n c / / S y n c h r o n o u s 6 4 - b i t E L 1
ventry e l 1 _ i r q _ i n v a l i d / / I R Q 6 4 - b i t E L 1
ventry e l 1 _ f i q _ i n v a l i d / / F I Q 6 4 - b i t E L 1
ventry e l 1 _ e r r o r _ i n v a l i d / / E r r o r 6 4 - b i t E L 1
ventry e l 1 _ s y n c _ i n v a l i d / / S y n c h r o n o u s 3 2 - b i t E L 1
ventry e l 1 _ i r q _ i n v a l i d / / I R Q 3 2 - b i t E L 1
ventry e l 1 _ f i q _ i n v a l i d / / F I Q 3 2 - b i t E L 1
ventry e l 1 _ e r r o r _ i n v a l i d / / E r r o r 3 2 - b i t E L 1
ENDPROC( _ _ h y p _ s t u b _ v e c t o r s )
.align 11
el1_sync :
2017-04-03 21:38:04 +03:00
cmp x0 , #H V C _ S E T _ V E C T O R S
2016-04-27 19:47:03 +03:00
b. n e 2 f
msr v b a r _ e l 2 , x1
b 9 f
2016-06-23 20:54:48 +03:00
2 : cmp x0 , #H V C _ S O F T _ R E S T A R T
b. n e 3 f
mov x0 , x2
mov x2 , x4
mov x4 , x1
mov x1 , x3
br x4 / / n o r e t u r n
2017-04-03 21:37:39 +03:00
3 : cmp x0 , #H V C _ R E S E T _ V E C T O R S
beq 9 f / / N o t h i n g t o r e s e t !
2016-04-27 19:47:04 +03:00
/* Someone called kvm_call_hyp() against the hyp-stub... */
2017-04-03 21:37:39 +03:00
ldr x0 , =HVC_STUB_ERR
2017-04-03 21:38:05 +03:00
eret
2016-04-27 19:47:03 +03:00
2017-04-03 21:38:05 +03:00
9 : mov x0 , x z r
eret
2012-10-19 20:46:27 +04:00
ENDPROC( e l 1 _ s y n c )
.macro invalid_vector label
\ label :
b \ l a b e l
ENDPROC( \ l a b e l )
.endm
invalid_ v e c t o r e l 2 _ s y n c _ i n v a l i d
invalid_ v e c t o r e l 2 _ i r q _ i n v a l i d
invalid_ v e c t o r e l 2 _ f i q _ i n v a l i d
invalid_ v e c t o r e l 2 _ e r r o r _ i n v a l i d
invalid_ v e c t o r e l 1 _ s y n c _ i n v a l i d
invalid_ v e c t o r e l 1 _ i r q _ i n v a l i d
invalid_ v e c t o r e l 1 _ f i q _ i n v a l i d
invalid_ v e c t o r e l 1 _ e r r o r _ i n v a l i d
/ *
* __hyp_set_vectors : Call t h i s a f t e r b o o t t o s e t t h e i n i t i a l h y p e r v i s o r
* vectors a s p a r t o f h y p e r v i s o r i n s t a l l a t i o n . O n a n S M P s y s t e m , t h i s s h o u l d
* be c a l l e d o n e a c h C P U .
*
* x0 m u s t b e t h e p h y s i c a l a d d r e s s o f t h e n e w v e c t o r t a b l e , a n d m u s t b e
* 2 KB a l i g n e d .
*
* Before c a l l i n g t h i s , y o u m u s t c h e c k t h a t t h e s t u b h y p e r v i s o r i s i n s t a l l e d
* everywhere, b y w a i t i n g f o r a n y s e c o n d a r y C P U s t o b e b r o u g h t u p a n d t h e n
* checking t h a t i s _ h y p _ m o d e _ a v a i l a b l e ( ) i s t r u e .
*
* If n o t , t h e r e i s a p r e - e x i s t i n g h y p e r v i s o r , s o m e C P U s f a i l e d t o b o o t , o r
* something e l s e w e n t w r o n g . . . i n s u c h c a s e s , t r y i n g t o i n s t a l l a n e w
* hypervisor i s u n l i k e l y t o w o r k a s d e s i r e d .
*
* When y o u c a l l i n t o y o u r s h i n y n e w h y p e r v i s o r , s p _ e l 2 w i l l c o n t a i n j u n k ,
* so y o u w i l l n e e d t o s e t t h a t t o s o m e t h i n g s e n s i b l e a t t h e n e w h y p e r v i s o r ' s
* initialisation e n t r y p o i n t .
* /
2016-04-27 19:47:02 +03:00
ENTRY( _ _ h y p _ s e t _ v e c t o r s )
2016-04-27 19:47:03 +03:00
mov x1 , x0
mov x0 , #H V C _ S E T _ V E C T O R S
2016-04-27 19:47:02 +03:00
hvc #0
ret
2012-10-19 20:46:27 +04:00
ENDPROC( _ _ h y p _ s e t _ v e c t o r s )
2017-04-03 21:37:39 +03:00
ENTRY( _ _ h y p _ r e s e t _ v e c t o r s )
mov x0 , #H V C _ R E S E T _ V E C T O R S
hvc #0
ret
ENDPROC( _ _ h y p _ r e s e t _ v e c t o r s )