2019-05-27 08:55:01 +02:00
/* SPDX-License-Identifier: GPL-2.0-or-later */
2005-04-16 15:20:36 -07:00
/ *
* This f i l e c o n t a i n s t h e g e n e r i c c o d e t o p e r f o r m a c a l l t o t h e
* pSeries L P A R h y p e r v i s o r .
* /
2015-04-09 13:51:32 +10:00
# include < l i n u x / j u m p _ l a b e l . h >
2005-04-16 15:20:36 -07:00
# include < a s m / h v c a l l . h >
# include < a s m / p r o c e s s o r . h >
# include < a s m / p p c _ a s m . h >
2006-09-06 16:23:12 -07:00
# include < a s m / a s m - o f f s e t s . h >
2010-11-18 15:06:17 +00:00
# include < a s m / p t r a c e . h >
2018-07-05 16:25:01 +00:00
# include < a s m / f e a t u r e - f i x u p s . h >
2014-07-03 15:52:03 +10:00
.section " .text "
2005-04-16 15:20:36 -07:00
2009-10-26 18:50:29 +00:00
# ifdef C O N F I G _ T R A C E P O I N T S
2018-12-31 00:14:15 +09:00
# ifndef C O N F I G _ J U M P _ L A B E L
2009-10-26 18:50:29 +00:00
.section " .toc " , " aw"
.globl hcall_tracepoint_refcount
hcall_tracepoint_refcount :
2017-03-09 16:42:12 +11:00
.8byte 0
2009-10-26 18:50:29 +00:00
.section " .text "
2014-07-03 15:52:03 +10:00
# endif
2009-10-26 18:50:29 +00:00
2006-09-06 16:23:12 -07:00
/ *
2012-06-25 13:33:14 +00:00
* precall m u s t p r e s e r v e a l l r e g i s t e r s . u s e u n u s e d S T K _ P A R A M ( )
2014-07-03 15:52:03 +10:00
* areas t o s a v e s n a p s h o t s a n d o p c o d e .
2006-09-06 16:23:12 -07:00
* /
2009-10-26 18:51:09 +00:00
# define H C A L L _ I N S T _ P R E C A L L ( F I R S T _ R E G ) \
2009-10-26 18:50:29 +00:00
mflr r0 ; \
2012-06-25 13:33:14 +00:00
std r3 ,S T K _ P A R A M ( R 3 ) ( r1 ) ; \
std r4 ,S T K _ P A R A M ( R 4 ) ( r1 ) ; \
std r5 ,S T K _ P A R A M ( R 5 ) ( r1 ) ; \
std r6 ,S T K _ P A R A M ( R 6 ) ( r1 ) ; \
std r7 ,S T K _ P A R A M ( R 7 ) ( r1 ) ; \
std r8 ,S T K _ P A R A M ( R 8 ) ( r1 ) ; \
std r9 ,S T K _ P A R A M ( R 9 ) ( r1 ) ; \
std r10 ,S T K _ P A R A M ( R 1 0 ) ( r1 ) ; \
2009-10-26 18:50:29 +00:00
std r0 ,1 6 ( r1 ) ; \
2012-06-25 13:33:14 +00:00
addi r4 ,r1 ,S T K _ P A R A M ( F I R S T _ R E G ) ; \
2009-10-26 18:50:29 +00:00
stdu r1 ,- S T A C K _ F R A M E _ O V E R H E A D ( r1 ) ; \
2014-02-04 16:04:35 +11:00
bl _ _ t r a c e _ h c a l l _ e n t r y ; \
2014-07-03 15:52:56 +10:00
ld r3 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 3 ) ( r1 ) ; \
ld r4 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 4 ) ( r1 ) ; \
ld r5 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 5 ) ( r1 ) ; \
ld r6 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 6 ) ( r1 ) ; \
ld r7 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 7 ) ( r1 ) ; \
ld r8 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 8 ) ( r1 ) ; \
ld r9 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 9 ) ( r1 ) ; \
ld r10 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 1 0 ) ( r1 )
2009-10-26 18:50:29 +00:00
2006-09-06 16:23:12 -07:00
/ *
* postcall i s p e r f o r m e d i m m e d i a t e l y b e f o r e f u n c t i o n r e t u r n w h i c h
2014-07-03 15:52:03 +10:00
* allows l i b e r a l u s e o f v o l a t i l e r e g i s t e r s .
2006-09-06 16:23:12 -07:00
* /
2009-10-26 18:51:09 +00:00
# define _ _ H C A L L _ I N S T _ P O S T C A L L \
2014-07-03 15:52:56 +10:00
ld r0 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 3 ) ( r1 ) ; \
std r3 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 3 ) ( r1 ) ; \
2009-10-26 18:50:29 +00:00
mr r4 ,r3 ; \
2014-07-03 15:52:56 +10:00
mr r3 ,r0 ; \
2014-02-04 16:04:35 +11:00
bl _ _ t r a c e _ h c a l l _ e x i t ; \
2014-07-03 15:52:56 +10:00
ld r0 ,S T A C K _ F R A M E _ O V E R H E A D + 1 6 ( r1 ) ; \
2009-10-26 18:50:29 +00:00
addi r1 ,r1 ,S T A C K _ F R A M E _ O V E R H E A D ; \
2012-06-25 13:33:14 +00:00
ld r3 ,S T K _ P A R A M ( R 3 ) ( r1 ) ; \
2014-07-03 15:52:03 +10:00
mtlr r0
2009-10-26 18:51:09 +00:00
# define H C A L L _ I N S T _ P O S T C A L L _ N O R E T S \
li r5 ,0 ; \
_ _ HCALL_ I N S T _ P O S T C A L L
# define H C A L L _ I N S T _ P O S T C A L L ( B U F R E G ) \
mr r5 ,B U F R E G ; \
_ _ HCALL_ I N S T _ P O S T C A L L
2018-12-31 00:14:15 +09:00
# ifdef C O N F I G _ J U M P _ L A B E L
2014-07-03 15:52:03 +10:00
# define H C A L L _ B R A N C H ( L A B E L ) \
ARCH_ S T A T I C _ B R A N C H ( L A B E L , h c a l l _ t r a c e p o i n t _ k e y )
# else
/ *
* We b r a n c h a r o u n d t h i s i n e a r l y i n i t ( e g w h e n p o p u l a t i n g t h e M M U
* hashtable) b y u s i n g a n u n c o n d i t i o n a l c p u f e a t u r e .
* /
# define H C A L L _ B R A N C H ( L A B E L ) \
BEGIN_ F T R _ S E C T I O N ; \
b 1 f ; \
END_ F T R _ S E C T I O N ( 0 , 1 ) ; \
ld r12 ,h c a l l _ t r a c e p o i n t _ r e f c o u n t @toc(r2); \
std r12 ,3 2 ( r1 ) ; \
cmpdi r12 ,0 ; \
bne- L A B E L ; \
1 :
# endif
2006-09-06 16:23:12 -07:00
# else
2009-10-26 18:51:09 +00:00
# define H C A L L _ I N S T _ P R E C A L L ( F I R S T _ A R G )
# define H C A L L _ I N S T _ P O S T C A L L _ N O R E T S
# define H C A L L _ I N S T _ P O S T C A L L ( B U F R E G )
2014-07-03 15:52:03 +10:00
# define H C A L L _ B R A N C H ( L A B E L )
2006-09-06 16:23:12 -07:00
# endif
2014-05-13 20:48:57 +10:00
_ GLOBAL_ T O C ( p l p a r _ h c a l l _ n o r e t s )
2005-05-01 08:58:46 -07:00
HMT_ M E D I U M
2005-04-16 15:20:36 -07:00
mfcr r0
stw r0 ,8 ( r1 )
2014-07-03 15:52:03 +10:00
HCALL_ B R A N C H ( p l p a r _ h c a l l _ n o r e t s _ t r a c e )
2005-04-16 15:20:36 -07:00
HVSC / * i n v o k e t h e h y p e r v i s o r * /
lwz r0 ,8 ( r1 )
mtcrf 0 x f f ,r0
blr / * r e t u r n r3 = s t a t u s * /
2014-07-03 15:52:03 +10:00
# ifdef C O N F I G _ T R A C E P O I N T S
plpar_hcall_norets_trace :
HCALL_ I N S T _ P R E C A L L ( R 4 )
HVSC
HCALL_ I N S T _ P O S T C A L L _ N O R E T S
lwz r0 ,8 ( r1 )
mtcrf 0 x f f ,r0
blr
# endif
2014-05-13 20:48:57 +10:00
_ GLOBAL_ T O C ( p l p a r _ h c a l l )
2005-05-01 08:58:46 -07:00
HMT_ M E D I U M
2005-04-16 15:20:36 -07:00
mfcr r0
stw r0 ,8 ( r1 )
2014-07-03 15:52:03 +10:00
HCALL_ B R A N C H ( p l p a r _ h c a l l _ t r a c e )
2006-09-06 16:23:12 -07:00
2012-06-25 13:33:14 +00:00
std r4 ,S T K _ P A R A M ( R 4 ) ( r1 ) / * S a v e r e t b u f f e r * /
2005-04-16 15:20:36 -07:00
2006-07-19 08:01:28 +10:00
mr r4 ,r5
mr r5 ,r6
mr r6 ,r7
mr r7 ,r8
mr r8 ,r9
mr r9 ,r10
2005-04-16 15:20:36 -07:00
HVSC / * i n v o k e t h e h y p e r v i s o r * /
2012-06-25 13:33:14 +00:00
ld r12 ,S T K _ P A R A M ( R 4 ) ( r1 )
2006-07-19 08:01:28 +10:00
std r4 , 0 ( r12 )
std r5 , 8 ( r12 )
std r6 , 1 6 ( r12 )
std r7 , 2 4 ( r12 )
2006-03-30 22:47:14 +02:00
2014-07-03 15:52:03 +10:00
lwz r0 ,8 ( r1 )
mtcrf 0 x f f ,r0
blr / * r e t u r n r3 = s t a t u s * /
# ifdef C O N F I G _ T R A C E P O I N T S
plpar_hcall_trace :
HCALL_ I N S T _ P R E C A L L ( R 5 )
std r4 ,S T K _ P A R A M ( R 4 ) ( r1 )
mr r0 ,r4
mr r4 ,r5
mr r5 ,r6
mr r6 ,r7
mr r7 ,r8
mr r8 ,r9
mr r9 ,r10
HVSC
ld r12 ,S T K _ P A R A M ( R 4 ) ( r1 )
std r4 ,0 ( r12 )
std r5 ,8 ( r12 )
std r6 ,1 6 ( r12 )
std r7 ,2 4 ( r12 )
2009-10-26 18:51:09 +00:00
HCALL_ I N S T _ P O S T C A L L ( r12 )
2006-09-06 16:23:12 -07:00
2006-03-30 22:47:14 +02:00
lwz r0 ,8 ( r1 )
mtcrf 0 x f f ,r0
2014-07-03 15:52:03 +10:00
blr
# endif
2006-03-30 22:47:14 +02:00
2007-03-21 11:21:32 +05:30
/ *
* plpar_ h c a l l _ r a w c a n b e c a l l e d i n r e a l m o d e . k e x e c / k d u m p n e e d s o m e
* hypervisor c a l l s t o b e e x e c u t e d i n r e a l m o d e . S o p l p a r _ h c a l l _ r a w
* does n o t a c c e s s t h e p e r c p u h y p e r v i s o r c a l l s t a t i s t i c s v a r i a b l e s ,
* since t h e s e v a r i a b l e s m a y n o t b e p r e s e n t i n t h e R M O r e g i o n .
* /
_ GLOBAL( p l p a r _ h c a l l _ r a w )
HMT_ M E D I U M
mfcr r0
stw r0 ,8 ( r1 )
2012-06-25 13:33:14 +00:00
std r4 ,S T K _ P A R A M ( R 4 ) ( r1 ) / * S a v e r e t b u f f e r * /
2007-03-21 11:21:32 +05:30
mr r4 ,r5
mr r5 ,r6
mr r6 ,r7
mr r7 ,r8
mr r8 ,r9
mr r9 ,r10
HVSC / * i n v o k e t h e h y p e r v i s o r * /
2012-06-25 13:33:14 +00:00
ld r12 ,S T K _ P A R A M ( R 4 ) ( r1 )
2007-03-21 11:21:32 +05:30
std r4 , 0 ( r12 )
std r5 , 8 ( r12 )
std r6 , 1 6 ( r12 )
std r7 , 2 4 ( r12 )
lwz r0 ,8 ( r1 )
mtcrf 0 x f f ,r0
blr / * r e t u r n r3 = s t a t u s * /
2014-05-13 20:48:57 +10:00
_ GLOBAL_ T O C ( p l p a r _ h c a l l 9 )
2006-03-30 22:47:14 +02:00
HMT_ M E D I U M
mfcr r0
stw r0 ,8 ( r1 )
2014-07-03 15:52:03 +10:00
HCALL_ B R A N C H ( p l p a r _ h c a l l 9 _ t r a c e )
2006-09-06 16:23:12 -07:00
2012-06-25 13:33:14 +00:00
std r4 ,S T K _ P A R A M ( R 4 ) ( r1 ) / * S a v e r e t b u f f e r * /
2006-07-19 08:01:28 +10:00
mr r4 ,r5
mr r5 ,r6
mr r6 ,r7
mr r7 ,r8
mr r8 ,r9
mr r9 ,r10
2012-06-25 13:33:14 +00:00
ld r10 ,S T K _ P A R A M ( R 1 1 ) ( r1 ) / * p u t a r g 7 i n R 1 0 * /
ld r11 ,S T K _ P A R A M ( R 1 2 ) ( r1 ) / * p u t a r g 8 i n R 1 1 * /
ld r12 ,S T K _ P A R A M ( R 1 3 ) ( r1 ) / * p u t a r g 9 i n R 1 2 * /
2006-03-30 22:47:14 +02:00
HVSC / * i n v o k e t h e h y p e r v i s o r * /
2007-01-09 02:37:16 +11:00
mr r0 ,r12
2012-06-25 13:33:14 +00:00
ld r12 ,S T K _ P A R A M ( R 4 ) ( r1 )
2006-07-19 08:01:28 +10:00
std r4 , 0 ( r12 )
std r5 , 8 ( r12 )
std r6 , 1 6 ( r12 )
std r7 , 2 4 ( r12 )
std r8 , 3 2 ( r12 )
std r9 , 4 0 ( r12 )
std r10 ,4 8 ( r12 )
std r11 ,5 6 ( r12 )
2007-01-09 02:37:16 +11:00
std r0 , 6 4 ( r12 )
2006-03-30 22:47:14 +02:00
2014-07-03 15:52:03 +10:00
lwz r0 ,8 ( r1 )
mtcrf 0 x f f ,r0
blr / * r e t u r n r3 = s t a t u s * /
# ifdef C O N F I G _ T R A C E P O I N T S
plpar_hcall9_trace :
HCALL_ I N S T _ P R E C A L L ( R 5 )
std r4 ,S T K _ P A R A M ( R 4 ) ( r1 )
mr r0 ,r4
mr r4 ,r5
mr r5 ,r6
mr r6 ,r7
mr r7 ,r8
mr r8 ,r9
mr r9 ,r10
2014-07-03 15:52:56 +10:00
ld r10 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 1 1 ) ( r1 )
ld r11 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 1 2 ) ( r1 )
ld r12 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 1 3 ) ( r1 )
2014-07-03 15:52:03 +10:00
HVSC
mr r0 ,r12
2014-07-03 15:52:56 +10:00
ld r12 ,S T A C K _ F R A M E _ O V E R H E A D + S T K _ P A R A M ( R 4 ) ( r1 )
2014-07-03 15:52:03 +10:00
std r4 ,0 ( r12 )
std r5 ,8 ( r12 )
std r6 ,1 6 ( r12 )
std r7 ,2 4 ( r12 )
std r8 ,3 2 ( r12 )
std r9 ,4 0 ( r12 )
std r10 ,4 8 ( r12 )
std r11 ,5 6 ( r12 )
std r0 ,6 4 ( r12 )
2009-10-26 18:51:09 +00:00
HCALL_ I N S T _ P O S T C A L L ( r12 )
2006-09-06 16:23:12 -07:00
2006-03-30 22:47:14 +02:00
lwz r0 ,8 ( r1 )
mtcrf 0 x f f ,r0
2014-07-03 15:52:03 +10:00
blr
# endif
2010-05-10 20:28:26 +00:00
/* See plpar_hcall_raw to see why this is needed */
_ GLOBAL( p l p a r _ h c a l l 9 _ r a w )
HMT_ M E D I U M
mfcr r0
stw r0 ,8 ( r1 )
2012-06-25 13:33:14 +00:00
std r4 ,S T K _ P A R A M ( R 4 ) ( r1 ) / * S a v e r e t b u f f e r * /
2010-05-10 20:28:26 +00:00
mr r4 ,r5
mr r5 ,r6
mr r6 ,r7
mr r7 ,r8
mr r8 ,r9
mr r9 ,r10
2012-06-25 13:33:14 +00:00
ld r10 ,S T K _ P A R A M ( R 1 1 ) ( r1 ) / * p u t a r g 7 i n R 1 0 * /
ld r11 ,S T K _ P A R A M ( R 1 2 ) ( r1 ) / * p u t a r g 8 i n R 1 1 * /
ld r12 ,S T K _ P A R A M ( R 1 3 ) ( r1 ) / * p u t a r g 9 i n R 1 2 * /
2010-05-10 20:28:26 +00:00
HVSC / * i n v o k e t h e h y p e r v i s o r * /
mr r0 ,r12
2012-06-25 13:33:14 +00:00
ld r12 ,S T K _ P A R A M ( R 4 ) ( r1 )
2010-05-10 20:28:26 +00:00
std r4 , 0 ( r12 )
std r5 , 8 ( r12 )
std r6 , 1 6 ( r12 )
std r7 , 2 4 ( r12 )
std r8 , 3 2 ( r12 )
std r9 , 4 0 ( r12 )
std r10 ,4 8 ( r12 )
std r11 ,5 6 ( r12 )
std r0 , 6 4 ( r12 )
lwz r0 ,8 ( r1 )
mtcrf 0 x f f ,r0
blr / * r e t u r n r3 = s t a t u s * /