2021-05-28 19:07:21 +10:00
/* SPDX-License-Identifier: GPL-2.0-only */
# include < a s m / a s m - o f f s e t s . h >
# include < a s m / c a c h e . h >
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
# include < a s m / c o d e - p a t c h i n g - a s m . h >
2021-05-28 19:07:22 +10:00
# include < a s m / e x c e p t i o n - 6 4 s . h >
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
# include < a s m / e x p o r t . h >
2021-05-28 19:07:21 +10:00
# include < a s m / k v m _ a s m . h >
# include < a s m / k v m _ b o o k 3 s _ a s m . h >
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
# include < a s m / m m u . h >
2021-05-28 19:07:21 +10:00
# include < a s m / p p c _ a s m . h >
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
# include < a s m / p t r a c e . h >
2021-05-28 19:07:21 +10:00
# include < a s m / r e g . h >
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
# include < a s m / u l t r a v i s o r - a p i . h >
2021-05-28 19:07:21 +10:00
/ *
2021-05-28 19:07:23 +10:00
* These a r e b r a n c h e d t o f r o m i n t e r r u p t h a n d l e r s i n e x c e p t i o n - 6 4 s . S w h i c h s e t
2021-05-28 19:07:21 +10:00
* IKVM_ R E A L o r I K V M _ V I R T , i f H S T A T E _ I N _ G U E S T w a s f o u n d t o b e n o n - z e r o .
* /
2021-05-28 19:07:27 +10:00
/ *
* This i s a h c a l l , s o r e g i s t e r c o n v e n t i o n i s a s
* Documentation/ p o w e r p c / p a p r _ h c a l l s . r s t .
*
* This m a y a l s o b e a s y s c a l l f r o m P R - K V M u s e r s p a c e t h a t i s t o b e
* reflected t o t h e P R g u e s t k e r n e l , s o r e g i s t e r s m a y b e s e t u p f o r
* a s y s t e m c a l l r a t h e r t h a n h c a l l . W e d o n ' t c u r r e n t l y c l o b b e r
* anything h e r e , b u t t h e 0 x c00 h a n d l e r h a s a l r e a d y c l o b b e r e d C T R
* and C R 0 , s o P R - K V M c a n n o t s u p p o r t a g u e s t k e r n e l t h a t p r e s e r v e s
* those r e g i s t e r s a c r o s s i t s s y s t e m c a l l s .
*
* The s t a t e o f r e g i s t e r s i s a s k v m p p c _ i n t e r r u p t , e x c e p t C F A R i s n o t
* saved, R 1 3 i s n o t i n S C R A T C H 0 , a n d R 1 0 d o e s n o t c o n t a i n t h e t r a p .
* /
2021-05-28 19:07:23 +10:00
.global kvmppc_hcall
.balign IFETCH_ALIGN_BYTES
kvmppc_hcall :
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
# ifdef C O N F I G _ K V M _ B O O K 3 S _ H V _ P O S S I B L E
lbz r10 ,H S T A T E _ I N _ G U E S T ( r13 )
2021-05-28 19:07:51 +10:00
cmpwi r10 ,K V M _ G U E S T _ M O D E _ H V _ P 9
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
beq k v m p p c _ p9 _ e x i t _ h c a l l
# endif
2021-05-28 19:07:27 +10:00
ld r10 ,P A C A _ E X G E N + E X _ R 1 3 ( r13 )
SET_ S C R A T C H 0 ( r10 )
li r10 ,0 x c00
/* Now we look like kvmppc_interrupt */
li r11 ,P A C A _ E X G E N
b . L g o t _ s a v e _ a r e a
2021-05-28 19:07:23 +10:00
2021-05-28 19:07:25 +10:00
/ *
* KVM i n t e r r u p t e n t r y o c c u r s a f t e r G E N _ I N T _ E N T R Y r u n s , a n d f o l l o w s t h a t
* call c o n v e n t i o n :
*
* guest R 9 - R 1 3 , C T R , C F A R , P P R s a v e d i n P A C A E X _ x x x s a v e a r e a
* guest ( H ) D A R , ( H ) D S I S R a r e a l s o i n t h e s a v e a r e a f o r r e l e v a n t i n t e r r u p t s
* guest R 1 3 a l s o s a v e d i n S C R A T C H 0
* R1 3 = P A C A
* R1 1 = ( H ) S R R 0
* R1 2 = ( H ) S R R 1
* R9 = g u e s t C R
* PPR i s s e t t o m e d i u m
*
* With t h e a d d i t i o n f o r K V M :
* R1 0 = t r a p v e c t o r
* /
2021-05-28 19:07:21 +10:00
.global kvmppc_interrupt
.balign IFETCH_ALIGN_BYTES
kvmppc_interrupt :
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
# ifdef C O N F I G _ K V M _ B O O K 3 S _ H V _ P O S S I B L E
std r10 ,H S T A T E _ S C R A T C H 0 ( r13 )
lbz r10 ,H S T A T E _ I N _ G U E S T ( r13 )
2021-05-28 19:07:51 +10:00
cmpwi r10 ,K V M _ G U E S T _ M O D E _ H V _ P 9
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
beq k v m p p c _ p9 _ e x i t _ i n t e r r u p t
ld r10 ,H S T A T E _ S C R A T C H 0 ( r13 )
# endif
2021-05-28 19:07:25 +10:00
li r11 ,P A C A _ E X G E N
cmpdi r10 ,0 x20 0
2021-05-28 19:07:27 +10:00
bgt+ . L g o t _ s a v e _ a r e a
2021-05-28 19:07:25 +10:00
li r11 ,P A C A _ E X M C
2021-05-28 19:07:27 +10:00
beq . L g o t _ s a v e _ a r e a
2021-05-28 19:07:25 +10:00
li r11 ,P A C A _ E X N M I
2021-05-28 19:07:27 +10:00
.Lgot_save_area :
add r11 ,r11 ,r13
2021-05-28 19:07:25 +10:00
BEGIN_ F T R _ S E C T I O N
ld r12 ,E X _ C F A R ( r11 )
std r12 ,H S T A T E _ C F A R ( r13 )
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ C F A R )
ld r12 ,E X _ C T R ( r11 )
mtctr r12
BEGIN_ F T R _ S E C T I O N
ld r12 ,E X _ P P R ( r11 )
std r12 ,H S T A T E _ P P R ( r13 )
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ H A S _ P P R )
ld r12 ,E X _ R 1 2 ( r11 )
std r12 ,H S T A T E _ S C R A T C H 0 ( r13 )
sldi r12 ,r9 ,3 2
or r12 ,r12 ,r10
ld r9 ,E X _ R 9 ( r11 )
ld r10 ,E X _ R 1 0 ( r11 )
ld r11 ,E X _ R 1 1 ( r11 )
2021-05-28 19:07:21 +10:00
/ *
2021-05-28 19:07:25 +10:00
* Hcalls a n d o t h e r i n t e r r u p t s c o m e h e r e a f t e r n o r m a l i s i n g r e g i s t e r
* contents a n d s a v e l o c a t i o n s :
*
2021-05-28 19:07:21 +10:00
* R1 2 = ( g u e s t C R < < 3 2 ) | i n t e r r u p t v e c t o r
* R1 3 = P A C A
2021-05-28 19:07:25 +10:00
* guest R 1 2 s a v e d i n s h a d o w H S T A T E _ S C R A T C H 0
2021-05-28 19:07:21 +10:00
* guest R 1 3 s a v e d i n S P R N _ S C R A T C H 0
* /
std r9 ,H S T A T E _ S C R A T C H 2 ( r13 )
lbz r9 ,H S T A T E _ I N _ G U E S T ( r13 )
2021-05-28 19:07:22 +10:00
cmpwi r9 ,K V M _ G U E S T _ M O D E _ S K I P
beq- . L m a y b e _ s k i p
.Lno_skip :
# ifdef C O N F I G _ K V M _ B O O K 3 S _ H V _ P O S S I B L E
2021-05-28 19:07:21 +10:00
# ifdef C O N F I G _ K V M _ B O O K 3 S _ P R _ P O S S I B L E
cmpwi r9 ,K V M _ G U E S T _ M O D E _ G U E S T
beq k v m p p c _ i n t e r r u p t _ p r
# endif
b k v m p p c _ i n t e r r u p t _ h v
# else
b k v m p p c _ i n t e r r u p t _ p r
# endif
2021-05-28 19:07:22 +10:00
/ *
* " Skip" i n t e r r u p t s a r e p a r t o f a t r i c k K V M u s e s a w i t h h a s h g u e s t s t o l o a d
2022-05-19 00:26:29 +10:00
* the f a u l t i n g i n s t r u c t i o n i n g u e s t m e m o r y f r o m t h e h y p e r v i s o r w i t h o u t
2021-05-28 19:07:22 +10:00
* walking p a g e t a b l e s .
*
* When t h e g u e s t t a k e s a f a u l t t h a t r e q u i r e s t h e h y p e r v i s o r t o l o a d t h e
* instruction ( e . g . , M M I O e m u l a t i o n ) , K V M i s r u n n i n g i n r e a l - m o d e w i t h H V =1
* and t h e g u e s t M M U c o n t e x t l o a d e d . I t s e t s K V M _ G U E S T _ M O D E _ S K I P , a n d s e t s
* MSR[ D R ] =1 w h i l e l e a v i n g M S R [ I R ] =0 , s o i t c o n t i n u e s t o f e t c h H V i n s t r u c t i o n s
* but l o a d s a n d s t o r e s w i l l a c c e s s t h e g u e s t c o n t e x t . T h i s i s u s e d t o l o a d
* the f a u l t i n g i n s t r u c t i o n u s i n g t h e f a u l t i n g g u e s t e f f e c t i v e a d d r e s s .
*
* However t h e g u e s t c o n t e x t m a y n o t b e a b l e t o t r a n s l a t e , o r i t m a y c a u s e a
* machine c h e c k o r o t h e r i s s u e , w h i c h r e s u l t s i n a f a u l t i n t h e h o s t
* ( even w i t h K V M - H V ) .
*
* These f a u l t s c o m e h e r e b e c a u s e K V M _ G U E S T _ M O D E _ S K I P w a s s e t , s o i f t h e y
* are ( o r a r e l i k e l y ) c a u s e d b y t h a t l o a d , t h e i n s t r u c t i o n i s s k i p p e d b y
* just r e t u r n i n g w i t h t h e P C a d v a n c e d + 4 , w h e r e i t i s n o t i c e d t h e l o a d d i d
* not e x e c u t e a n d i t g o e s t o t h e s l o w p a t h w h i c h w a l k s t h e p a g e t a b l e s t o
* read g u e s t m e m o r y .
* /
.Lmaybe_skip :
cmpwi r12 ,B O O K 3 S _ I N T E R R U P T _ M A C H I N E _ C H E C K
beq 1 f
cmpwi r12 ,B O O K 3 S _ I N T E R R U P T _ D A T A _ S T O R A G E
beq 1 f
cmpwi r12 ,B O O K 3 S _ I N T E R R U P T _ D A T A _ S E G M E N T
beq 1 f
# ifdef C O N F I G _ K V M _ B O O K 3 S _ H V _ P O S S I B L E
/* HSRR interrupts get 2 added to interrupt number */
cmpwi r12 ,B O O K 3 S _ I N T E R R U P T _ H _ D A T A _ S T O R A G E | 0 x2
beq 2 f
# endif
b . L n o _ s k i p
1 : mfspr r9 ,S P R N _ S R R 0
addi r9 ,r9 ,4
mtspr S P R N _ S R R 0 ,r9
ld r12 ,H S T A T E _ S C R A T C H 0 ( r13 )
ld r9 ,H S T A T E _ S C R A T C H 2 ( r13 )
GET_ S C R A T C H 0 ( r13 )
RFI_ T O _ K E R N E L
# ifdef C O N F I G _ K V M _ B O O K 3 S _ H V _ P O S S I B L E
2 : mfspr r9 ,S P R N _ H S R R 0
addi r9 ,r9 ,4
mtspr S P R N _ H S R R 0 ,r9
ld r12 ,H S T A T E _ S C R A T C H 0 ( r13 )
ld r9 ,H S T A T E _ S C R A T C H 2 ( r13 )
GET_ S C R A T C H 0 ( r13 )
HRFI_ T O _ K E R N E L
# endif
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
# ifdef C O N F I G _ K V M _ B O O K 3 S _ H V _ P O S S I B L E
/* Stack frame offsets for kvmppc_p9_enter_guest */
# define S F S ( 1 4 4 + S T A C K _ F R A M E _ M I N _ S I Z E )
# define S T A C K _ S L O T _ N V G P R S ( S F S - 1 4 4 ) / * 1 8 g p r s * /
/ *
* void k v m p p c _ p9 _ e n t e r _ g u e s t ( s t r u c t v c p u * v c p u ) ;
*
2021-05-28 19:07:51 +10:00
* Enter t h e g u e s t o n a I S A v3 . 0 o r l a t e r s y s t e m .
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
* /
.balign IFETCH_ALIGN_BYTES
_ GLOBAL( k v m p p c _ p9 _ e n t e r _ g u e s t )
EXPORT_ S Y M B O L _ G P L ( k v m p p c _ p9 _ e n t e r _ g u e s t )
mflr r0
std r0 ,P P C _ L R _ S T K O F F ( r1 )
stdu r1 ,- S F S ( r1 )
std r1 ,H S T A T E _ H O S T _ R 1 ( r13 )
mfcr r4
stw r4 ,S F S + 8 ( r1 )
reg = 1 4
.rept 18
std r e g ,S T A C K _ S L O T _ N V G P R S + ( ( r e g - 1 4 ) * 8 ) ( r1 )
reg = r e g + 1
.endr
ld r4 ,V C P U _ L R ( r3 )
mtlr r4
ld r4 ,V C P U _ C T R ( r3 )
mtctr r4
ld r4 ,V C P U _ X E R ( r3 )
mtspr S P R N _ X E R ,r4
ld r1 ,V C P U _ C R ( r3 )
BEGIN_ F T R _ S E C T I O N
ld r4 ,V C P U _ C F A R ( r3 )
mtspr S P R N _ C F A R ,r4
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ C F A R )
BEGIN_ F T R _ S E C T I O N
ld r4 ,V C P U _ P P R ( r3 )
mtspr S P R N _ P P R ,r4
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ H A S _ P P R )
reg = 4
.rept 28
ld r e g ,_ _ V C P U _ G P R ( r e g ) ( r3 )
reg = r e g + 1
.endr
ld r4 ,V C P U _ K V M ( r3 )
lbz r4 ,K V M _ S E C U R E _ G U E S T ( r4 )
cmpdi r4 ,0
ld r4 ,V C P U _ G P R ( R 4 ) ( r3 )
bne . L r e t _ t o _ u l t r a
mtcr r1
ld r0 ,V C P U _ G P R ( R 0 ) ( r3 )
ld r1 ,V C P U _ G P R ( R 1 ) ( r3 )
ld r2 ,V C P U _ G P R ( R 2 ) ( r3 )
ld r3 ,V C P U _ G P R ( R 3 ) ( r3 )
HRFI_ T O _ G U E S T
b .
/ *
* Use U V _ R E T U R N u l t r a c a l l t o r e t u r n c o n t r o l b a c k t o t h e U l t r a v i s o r
* after p r o c e s s i n g a n h y p e r c a l l o r i n t e r r u p t t h a t w a s f o r w a r d e d
* ( a. k . a . r e f l e c t e d ) t o t h e H y p e r v i s o r .
*
* All r e g i s t e r s h a v e a l r e a d y b e e n r e l o a d e d e x c e p t t h e u c a l l r e q u i r e s :
* R0 = h c a l l r e s u l t
* R2 = S R R 1 , s o U V c a n d e t e c t a s y n t h e s i z e d i n t e r r u p t ( i f a n y )
* R3 = U V _ R E T U R N
* /
.Lret_to_ultra :
mtcr r1
ld r1 ,V C P U _ G P R ( R 1 ) ( r3 )
ld r0 ,V C P U _ G P R ( R 3 ) ( r3 )
mfspr r2 ,S P R N _ S R R 1
LOAD_ R E G _ I M M E D I A T E ( r3 , U V _ R E T U R N )
sc 2
/ *
* kvmppc_ p9 _ e x i t _ h c a l l a n d k v m p p c _ p9 _ e x i t _ i n t e r r u p t a r e b r a n c h e d t o f r o m
* above i f t h e i n t e r r u p t w a s t a k e n f o r a g u e s t t h a t w a s e n t e r e d v i a
* kvmppc_ p9 _ e n t e r _ g u e s t ( ) .
*
* The e x i t c o d e r e c o v e r s t h e h o s t s t a c k a n d v c p u p o i n t e r , s a v e s a l l g u e s t G P R s
* and C R , L R , X E R a s w e l l a s g u e s t M S R a n d N I A i n t o t h e V C P U , t h e n r e -
* establishes t h e h o s t s t a c k a n d r e g i s t e r s t o r e t u r n f r o m t h e
* kvmppc_ p9 _ e n t e r _ g u e s t ( ) f u n c t i o n , w h i c h s a v e s C T R a n d o t h e r g u e s t r e g i s t e r s
* ( SPRs a n d F P , V E C , e t c ) .
* /
.balign IFETCH_ALIGN_BYTES
kvmppc_p9_exit_hcall :
mfspr r11 ,S P R N _ S R R 0
mfspr r12 ,S P R N _ S R R 1
li r10 ,0 x c00
std r10 ,H S T A T E _ S C R A T C H 0 ( r13 )
.balign IFETCH_ALIGN_BYTES
kvmppc_p9_exit_interrupt :
/ *
2021-05-28 19:07:51 +10:00
* If s e t t o K V M _ G U E S T _ M O D E _ H V _ P 9 b u t w e ' r e s t i l l i n t h e
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
* hypervisor, t h a t m e a n s w e c a n ' t r e t u r n f r o m t h e e n t r y s t a c k .
* /
rldicl. r10 ,r12 ,6 4 - M S R _ H V _ L G ,6 3
bne- k v m p p c _ p9 _ b a d _ i n t e r r u p t
std r1 ,H S T A T E _ S C R A T C H 1 ( r13 )
std r3 ,H S T A T E _ S C R A T C H 2 ( r13 )
ld r1 ,H S T A T E _ H O S T _ R 1 ( r13 )
ld r3 ,H S T A T E _ K V M _ V C P U ( r13 )
std r9 ,V C P U _ C R ( r3 )
1 :
std r11 ,V C P U _ P C ( r3 )
std r12 ,V C P U _ M S R ( r3 )
reg = 1 4
.rept 18
std r e g ,_ _ V C P U _ G P R ( r e g ) ( r3 )
reg = r e g + 1
.endr
/* r1, r3, r9-r13 are saved to vcpu by C code */
std r0 ,V C P U _ G P R ( R 0 ) ( r3 )
std r2 ,V C P U _ G P R ( R 2 ) ( r3 )
reg = 4
.rept 5
std r e g ,_ _ V C P U _ G P R ( r e g ) ( r3 )
reg = r e g + 1
.endr
ld r2 ,P A C A T O C ( r13 )
mflr r4
std r4 ,V C P U _ L R ( r3 )
mfspr r4 ,S P R N _ X E R
std r4 ,V C P U _ X E R ( r3 )
reg = 1 4
.rept 18
ld r e g ,S T A C K _ S L O T _ N V G P R S + ( ( r e g - 1 4 ) * 8 ) ( r1 )
reg = r e g + 1
.endr
lwz r4 ,S F S + 8 ( r1 )
mtcr r4
/ *
* Flush t h e l i n k s t a c k h e r e , b e f o r e e x e c u t i n g t h e f i r s t b l r o n t h e
* way o u t o f t h e g u e s t .
*
* The l i n k s t a c k w o n ' t m a t c h c o m i n g o u t o f t h e g u e s t a n y w a y s o t h e
* only c o s t i s t h e f l u s h i t s e l f . T h e c a l l c l o b b e r s r0 .
* /
1 : nop
patch_ s i t e 1 b p a t c h _ _ c a l l _ k v m _ f l u s h _ l i n k _ s t a c k _ p9
addi r1 ,r1 ,S F S
ld r0 ,P P C _ L R _ S T K O F F ( r1 )
mtlr r0
blr
/ *
* Took a n i n t e r r u p t s o m e w h e r e r i g h t b e f o r e H R F I D t o g u e s t , s o r e g i s t e r s a r e
* in a b a d w a y . R e t u r n t h i n g s h o p e f u l l y e n o u g h t o r u n h o s t v i r t u a l c o d e a n d
* run t h e L i n u x i n t e r r u p t h a n d l e r ( S R E S E T o r M C E ) t o p r i n t s o m e t h i n g u s e f u l .
*
* We c o u l d b e r e a l l y c l e v e r a n d s a v e a l l h o s t r e g i s t e r s i n k n o w n l o c a t i o n s
* before s e t t i n g H S T A T E _ I N _ G U E S T , t h e n r e s t o r i n g t h e m a l l h e r e , a n d s e t t i n g
* return a d d r e s s t o a f i x u p t h a t s e t s t h e m u p a g a i n . B u t t h a t ' s a l o t o f
* effort f o r a s m a l l b i t o f c o d e . L o t s o f o t h e r t h i n g s t o d o f i r s t .
* /
kvmppc_p9_bad_interrupt :
2021-05-28 19:07:51 +10:00
BEGIN_ M M U _ F T R _ S E C T I O N
/ *
* Hash h o s t d o e s n ' t t r y t o r e c o v e r M M U ( r e q u i r e s h o s t S L B r e l o a d )
* /
b .
END_ M M U _ F T R _ S E C T I O N _ I F C L R ( M M U _ F T R _ T Y P E _ R A D I X )
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
/ *
* Clean u p g u e s t r e g i s t e r s t o g i v e h o s t a c h a n c e t o r u n .
* /
li r10 ,0
mtspr S P R N _ A M R ,r10
mtspr S P R N _ I A M R ,r10
mtspr S P R N _ C I A B R ,r10
mtspr S P R N _ D A W R X 0 ,r10
BEGIN_ F T R _ S E C T I O N
mtspr S P R N _ D A W R X 1 ,r10
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ D A W R 1 )
/ *
2021-11-23 19:52:17 +10:00
* Switch t o h o s t M M U m o d e ( d o n ' t h a v e t h e r e a l h o s t P I D b u t w e a r e n ' t
* going b a c k t o u s e r s p a c e ) .
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
* /
2021-11-23 19:52:17 +10:00
hwsync
isync
mtspr S P R N _ P I D ,r10
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
ld r10 , H S T A T E _ K V M _ V C P U ( r13 )
ld r10 , V C P U _ K V M ( r10 )
lwz r10 , K V M _ H O S T _ L P I D ( r10 )
mtspr S P R N _ L P I D ,r10
ld r10 , H S T A T E _ K V M _ V C P U ( r13 )
ld r10 , V C P U _ K V M ( r10 )
ld r10 , K V M _ H O S T _ L P C R ( r10 )
mtspr S P R N _ L P C R ,r10
2021-11-23 19:52:17 +10:00
isync
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
/ *
* Set G U E S T _ M O D E _ N O N E s o t h e h a n d l e r w o n ' t b r a n c h t o K V M , a n d c l e a r
* MSR_ R I i n r12 ( [ H ] S R R 1 ) s o t h e h a n d l e r w o n ' t t r y t o r e t u r n .
* /
li r10 ,K V M _ G U E S T _ M O D E _ N O N E
stb r10 ,H S T A T E _ I N _ G U E S T ( r13 )
li r10 ,M S R _ R I
andc r12 ,r12 ,r10
/ *
* Go b a c k t o i n t e r r u p t h a n d l e r . M C E a n d S R E S E T h a v e t h e i r s p e c i f i c
* PACA s a v e a r e a s o t h e y s h o u l d b e u s e d d i r e c t l y . T h e y s e t u p t h e i r
* own s t a c k . T h e o t h e r h a n d l e r s a l l u s e E X G E N . T h e y w i l l u s e t h e
* guest r1 i f i t l o o k s l i k e a k e r n e l s t a c k , s o j u s t l o a d t h e
* emergency s t a c k a n d g o t o p r o g r a m c h e c k f o r a l l o t h e r i n t e r r u p t s .
* /
ld r10 ,H S T A T E _ S C R A T C H 0 ( r13 )
cmpwi r10 ,B O O K 3 S _ I N T E R R U P T _ M A C H I N E _ C H E C K
2022-03-27 09:32:26 +02:00
beq . L c a l l _ m a c h i n e _ c h e c k _ c o m m o n
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
cmpwi r10 ,B O O K 3 S _ I N T E R R U P T _ S Y S T E M _ R E S E T
2022-03-27 09:32:26 +02:00
beq . L c a l l _ s y s t e m _ r e s e t _ c o m m o n
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
b .
2022-03-27 09:32:26 +02:00
.Lcall_machine_check_common :
b m a c h i n e _ c h e c k _ c o m m o n
.Lcall_system_reset_common :
b s y s t e m _ r e s e t _ c o m m o n
KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C
Almost all logic is moved to C, by introducing a new in_guest mode for
the P9 path that branches very early in the KVM interrupt handler to P9
exit code.
The main P9 entry and exit assembly is now only about 160 lines of low
level stack setup and register save/restore, plus a bad-interrupt
handler.
There are two motivations for this, the first is just make the code more
maintainable being in C. The second is to reduce the amount of code
running in a special KVM mode, "realmode". In quotes because with radix
it is no longer necessarily real-mode in the MMU, but it still has to be
treated specially because it may be in real-mode, and has various
important registers like PID, DEC, TB, etc set to guest. This is hostile
to the rest of Linux and can't use arbitrary kernel functionality or be
instrumented well.
This initial patch is a reasonably faithful conversion of the asm code,
but it does lack any loop to return quickly back into the guest without
switching out of realmode in the case of unimportant or easily handled
interrupts. As explained in previous changes, handling HV interrupts
very quickly in this low level realmode is not so important for P9
performance, and are important to avoid for security, observability,
debugability reasons.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210528090752.3542186-15-npiggin@gmail.com
2021-05-28 19:07:34 +10:00
# endif