2019-05-27 09:55:21 +03:00
/* SPDX-License-Identifier: GPL-2.0-only */
2018-05-23 10:01:47 +03:00
/ *
*
* Derived f r o m b o o k 3 s _ h v _ r m h a n d l e r s . S , w h i c h i s :
*
* Copyright 2 0 1 1 P a u l M a c k e r r a s , I B M C o r p . < p a u l u s @au1.ibm.com>
* /
# include < a s m / r e g . h >
# include < a s m / p p c _ a s m . h >
# include < a s m / a s m - o f f s e t s . h >
# include < a s m / e x p o r t . h >
# include < a s m / t m . h >
# include < a s m / c p u t a b l e . h >
# ifdef C O N F I G _ P P C _ T R A N S A C T I O N A L _ M E M
# define V C P U _ G P R S _ T M ( r e g ) ( ( ( r e g ) * U L O N G _ S I Z E ) + V C P U _ G P R _ T M )
/ *
* Save t r a n s a c t i o n a l s t a t e a n d T M - r e l a t e d r e g i s t e r s .
2018-05-23 10:01:48 +03:00
* Called w i t h :
* - r3 p o i n t i n g t o t h e v c p u s t r u c t
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
* - r4 c o n t a i n i n g t h e M S R w i t h c u r r e n t T S b i t s :
2018-05-23 10:01:48 +03:00
* ( For H V K V M , i t i s V C P U _ M S R ; For PR KVM, it is host MSR).
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
* - r5 c o n t a i n i n g a f l a g i n d i c a t i n g t h a t n o n - v o l a t i l e r e g i s t e r s
* must b e p r e s e r v e d .
* If r5 = = 0 , t h i s c a n m o d i f y a l l c h e c k p o i n t e d r e g i s t e r s , b u t
* restores r1 , r2 b e f o r e e x i t . I f r5 ! = 0 , t h i s r e s t o r e s t h e
* MSR T M / F P / V E C / V S X b i t s t o t h e i r s t a t e o n e n t r y .
2018-05-23 10:01:47 +03:00
* /
2018-05-23 10:01:50 +03:00
_ GLOBAL( _ _ k v m p p c _ s a v e _ t m )
2018-05-23 10:01:47 +03:00
mflr r0
std r0 , P P C _ L R _ S T K O F F ( r1 )
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
stdu r1 , - S W I T C H _ F R A M E _ S I Z E ( r1 )
mr r9 , r3
cmpdi c r7 , r5 , 0
2018-05-23 10:01:47 +03:00
/* Turn on TM. */
mfmsr r8
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
mr r10 , r8
2018-05-23 10:01:47 +03:00
li r0 , 1
rldimi r8 , r0 , M S R _ T M _ L G , 6 3 - M S R _ T M _ L G
2018-05-23 10:01:49 +03:00
ori r8 , r8 , M S R _ F P
oris r8 , r8 , ( M S R _ V E C | M S R _ V S X ) @h
2018-05-23 10:01:47 +03:00
mtmsrd r8
2018-05-23 10:01:48 +03:00
rldicl. r4 , r4 , 6 4 - M S R _ T S _ S _ L G , 6 2
2018-05-23 10:01:47 +03:00
beq 1 f / * T M n o t a c t i v e i n g u e s t . * /
2018-05-23 10:01:48 +03:00
std r1 , H S T A T E _ S C R A T C H 2 ( r13 )
std r3 , H S T A T E _ S C R A T C H 1 ( r13 )
2018-05-23 10:01:47 +03:00
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
/* Save CR on the stack - even if r5 == 0 we need to get cr7 back. */
mfcr r6
SAVE_ G P R ( 6 , r1 )
/* Save DSCR so we can restore it to avoid running with user value */
mfspr r7 , S P R N _ D S C R
SAVE_ G P R ( 7 , r1 )
/ *
* We a r e g o i n g t o d o t r e c l a i m . , w h i c h w i l l m o d i f y a l l c h e c k p o i n t e d
* registers. S a v e t h e n o n - v o l a t i l e r e g i s t e r s o n t h e s t a c k i f
* preservation o f n o n - v o l a t i l e s t a t e h a s b e e n r e q u e s t e d .
* /
beq c r7 , 3 f
SAVE_ N V G P R S ( r1 )
/* MSR[TS] will be 0 (non-transactional) once we do treclaim. */
li r0 , 0
rldimi r10 , r0 , M S R _ T S _ S _ L G , 6 3 - M S R _ T S _ T _ L G
SAVE_ G P R ( 1 0 , r1 ) / * f i n a l M S R v a l u e * /
3 :
2018-05-23 10:01:47 +03: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
BEGIN_ F T R _ S E C T I O N
/* Emulation of the treclaim instruction needs TEXASR before treclaim */
mfspr r6 , S P R N _ T E X A S R
2018-05-23 10:01:48 +03:00
std r6 , V C P U _ O R I G _ T E X A S R ( r3 )
2018-05-23 10:01:47 +03:00
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ P 9 _ T M _ H V _ A S S I S T )
# endif
/* Clear the MSR RI since r1, r13 are all going to be foobar. */
li r5 , 0
mtmsrd r5 , 1
2018-05-23 10:01:48 +03:00
li r3 , T M _ C A U S E _ K V M _ R E S C H E D
2018-05-23 10:01:47 +03:00
/* All GPRs are volatile at this point. */
TRECLAIM( R 3 )
/* Temporarily store r13 and r9 so we have some regs to play with */
SET_ S C R A T C H 0 ( r13 )
GET_ P A C A ( r13 )
std r9 , P A C A T M S C R A T C H ( r13 )
2018-05-23 10:01:48 +03:00
ld r9 , H S T A T E _ S C R A T C H 1 ( r13 )
2018-05-23 10:01:47 +03:00
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
/* Save away PPR soon so we don't run with user value. */
std r0 , V C P U _ G P R S _ T M ( 0 ) ( r9 )
mfspr r0 , S P R N _ P P R
2018-05-23 10:01:47 +03:00
HMT_ M E D I U M
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
/* Reload stack pointer. */
std r1 , V C P U _ G P R S _ T M ( 1 ) ( r9 )
ld r1 , H S T A T E _ S C R A T C H 2 ( r13 )
/* Set MSR RI now we have r1 and r13 back. */
std r2 , V C P U _ G P R S _ T M ( 2 ) ( r9 )
li r2 , M S R _ R I
mtmsrd r2 , 1
/* Reload TOC pointer. */
ld r2 , P A C A T O C ( r13 )
/* Save all but r0-r2, r9 & r13 */
reg = 3
2018-05-23 10:01:47 +03:00
.rept 29
.if ( reg ! = 9 ) & & ( r e g ! = 1 3 )
std r e g , V C P U _ G P R S _ T M ( r e g ) ( r9 )
.endif
reg = r e g + 1
.endr
/* ... now save r13 */
GET_ S C R A T C H 0 ( r4 )
std r4 , V C P U _ G P R S _ T M ( 1 3 ) ( r9 )
/* ... and save r9 */
ld r4 , P A C A T M S C R A T C H ( r13 )
std r4 , V C P U _ G P R S _ T M ( 9 ) ( r9 )
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
/* Restore host DSCR and CR values, after saving guest values */
mfcr r6
mfspr r7 , S P R N _ D S C R
stw r6 , V C P U _ C R _ T M ( r9 )
std r7 , V C P U _ D S C R _ T M ( r9 )
REST_ G P R ( 6 , r1 )
REST_ G P R ( 7 , r1 )
mtcr r6
mtspr S P R N _ D S C R , r7
2018-05-23 10:01:47 +03:00
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
/* Save away checkpointed SPRs. */
std r0 , V C P U _ P P R _ T M ( r9 )
2018-05-23 10:01:47 +03:00
mflr r5
mfctr r7
mfspr r8 , S P R N _ A M R
mfspr r10 , S P R N _ T A R
mfxer r11
std r5 , V C P U _ L R _ T M ( r9 )
std r7 , V C P U _ C T R _ T M ( r9 )
std r8 , V C P U _ A M R _ T M ( r9 )
std r10 , V C P U _ T A R _ T M ( r9 )
std r11 , V C P U _ X E R _ T M ( r9 )
/* Save FP/VSX. */
addi r3 , r9 , V C P U _ F P R S _ T M
bl s t o r e _ f p _ s t a t e
addi r3 , r9 , V C P U _ V R S _ T M
bl s t o r e _ v r _ s t a t e
mfspr r6 , S P R N _ V R S A V E
stw r6 , V C P U _ V R S A V E _ T M ( r9 )
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
/* Restore non-volatile registers if requested to */
beq c r7 , 1 f
REST_ N V G P R S ( r1 )
REST_ G P R ( 1 0 , r1 )
2018-05-23 10:01:47 +03:00
1 :
/ *
* We n e e d t o s a v e t h e s e S P R s a f t e r t h e t r e c l a i m s o t h a t t h e s o f t w a r e
* error c o d e i s r e c o r d e d c o r r e c t l y i n t h e T E X A S R . A l s o t h e u s e r m a y
* change t h e s e o u t s i d e o f a t r a n s a c t i o n , s o t h e y m u s t a l w a y s b e
* context s w i t c h e d .
* /
mfspr r7 , S P R N _ T E X A S R
std r7 , V C P U _ T E X A S R ( r9 )
mfspr r5 , S P R N _ T F H A R
mfspr r6 , S P R N _ T F I A R
std r5 , V C P U _ T F H A R ( r9 )
std r6 , V C P U _ T F I A R ( r9 )
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
/* Restore MSR state if requested */
beq c r7 , 2 f
mtmsrd r10 , 0
2 :
addi r1 , r1 , S W I T C H _ F R A M E _ S I Z E
2018-05-23 10:01:47 +03:00
ld r0 , P P C _ L R _ S T K O F F ( r1 )
mtlr r0
blr
2018-05-23 10:01:50 +03:00
/ *
* _ kvmppc_ s a v e _ t m _ p r ( ) i s a w r a p p e r a r o u n d _ _ k v m p p c _ s a v e _ t m ( ) , s o t h a t i t c a n
* be i n v o k e d f r o m C f u n c t i o n b y P R K V M o n l y .
* /
_ GLOBAL( _ k v m p p c _ s a v e _ t m _ p r )
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
mflr r0
std r0 , P P C _ L R _ S T K O F F ( r1 )
stdu r1 , - P P C _ M I N _ S T K F R M ( r1 )
2018-05-23 10:01:50 +03:00
2018-05-23 10:02:07 +03:00
mfspr r8 , S P R N _ T A R
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
std r8 , P P C _ M I N _ S T K F R M - 8 ( r1 )
2018-05-23 10:02:07 +03:00
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
li r5 , 1 / * p r e s e r v e n o n - v o l a t i l e r e g i s t e r s * /
2018-05-23 10:01:50 +03:00
bl _ _ k v m p p c _ s a v e _ t m
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
ld r8 , P P C _ M I N _ S T K F R M - 8 ( r1 )
2018-05-23 10:02:07 +03:00
mtspr S P R N _ T A R , r8
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
addi r1 , r1 , P P C _ M I N _ S T K F R M
ld r0 , P P C _ L R _ S T K O F F ( r1 )
mtlr r0
2018-05-23 10:01:50 +03:00
blr
EXPORT_ S Y M B O L _ G P L ( _ k v m p p c _ s a v e _ t m _ p r ) ;
2018-05-23 10:01:47 +03:00
/ *
* Restore t r a n s a c t i o n a l s t a t e a n d T M - r e l a t e d r e g i s t e r s .
2018-05-23 10:01:48 +03:00
* Called w i t h :
* - r3 p o i n t i n g t o t h e v c p u s t r u c t .
* - r4 i s t h e g u e s t M S R w i t h d e s i r e d T S b i t s :
* For H V K V M , i t i s V C P U _ M S R
* For P R K V M , i t i s p r o v i d e d b y c a l l e r
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
* - r5 c o n t a i n i n g a f l a g i n d i c a t i n g t h a t n o n - v o l a t i l e r e g i s t e r s
* must b e p r e s e r v e d .
* If r5 = = 0 , t h i s p o t e n t i a l l y m o d i f i e s a l l c h e c k p o i n t e d r e g i s t e r s , b u t
* restores r1 , r2 f r o m t h e P A C A b e f o r e e x i t .
* If r5 ! = 0 , t h i s r e s t o r e s t h e M S R T M / F P / V E C / V S X b i t s t o t h e i r s t a t e o n e n t r y .
2018-05-23 10:01:47 +03:00
* /
2018-05-23 10:01:50 +03:00
_ GLOBAL( _ _ k v m p p c _ r e s t o r e _ t m )
2018-05-23 10:01:47 +03:00
mflr r0
std r0 , P P C _ L R _ S T K O F F ( r1 )
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
cmpdi c r7 , r5 , 0
2018-05-23 10:01:47 +03:00
/* Turn on TM/FP/VSX/VMX so we can restore them. */
mfmsr r5
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
mr r10 , r5
2018-05-23 10:01:47 +03:00
li r6 , M S R _ T M > > 3 2
sldi r6 , r6 , 3 2
or r5 , r5 , r6
ori r5 , r5 , M S R _ F P
oris r5 , r5 , ( M S R _ V E C | M S R _ V S X ) @h
mtmsrd r5
/ *
* The u s e r m a y c h a n g e t h e s e o u t s i d e o f a t r a n s a c t i o n , s o t h e y m u s t
* always b e c o n t e x t s w i t c h e d .
* /
2018-05-23 10:01:48 +03:00
ld r5 , V C P U _ T F H A R ( r3 )
ld r6 , V C P U _ T F I A R ( r3 )
ld r7 , V C P U _ T E X A S R ( r3 )
2018-05-23 10:01:47 +03:00
mtspr S P R N _ T F H A R , r5
mtspr S P R N _ T F I A R , r6
mtspr S P R N _ T E X A S R , r7
2018-05-23 10:01:48 +03:00
mr r5 , r4
2018-05-23 10:01:47 +03:00
rldicl. r5 , r5 , 6 4 - M S R _ T S _ S _ L G , 6 2
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
beq 9 f / * T M n o t a c t i v e i n g u e s t * /
2018-05-23 10:01:47 +03:00
/ * Make s u r e t h e f a i l u r e s u m m a r y i s s e t , o t h e r w i s e w e ' l l p r o g r a m c h e c k
* when w e t r e c h k p t . I t ' s p o s s i b l e t h a t t h i s m i g h t h a v e b e e n n o t s e t
* on a k v m p p c _ s e t _ o n e _ r e g ( ) c a l l b u t w e s h o u l d n ' t l e t t h i s c r a s h t h e
* host.
* /
oris r7 , r7 , ( T E X A S R _ F S ) @h
mtspr S P R N _ T E X A S R , r7
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
/ *
* Make a s t a c k f r a m e a n d s a v e n o n - v o l a t i l e r e g i s t e r s i f r e q u e s t e d .
* /
stdu r1 , - S W I T C H _ F R A M E _ S I Z E ( r1 )
std r1 , H S T A T E _ S C R A T C H 2 ( r13 )
mfcr r6
mfspr r7 , S P R N _ D S C R
SAVE_ G P R ( 2 , r1 )
SAVE_ G P R ( 6 , r1 )
SAVE_ G P R ( 7 , r1 )
beq c r7 , 4 f
SAVE_ N V G P R S ( r1 )
/* MSR[TS] will be 1 (suspended) once we do trechkpt */
li r0 , 1
rldimi r10 , r0 , M S R _ T S _ S _ L G , 6 3 - M S R _ T S _ T _ L G
SAVE_ G P R ( 1 0 , r1 ) / * f i n a l M S R v a l u e * /
4 :
2018-05-23 10:01:47 +03:00
/ *
* We n e e d t o l o a d u p t h e c h e c k p o i n t e d s t a t e f o r t h e g u e s t .
* We n e e d t o d o t h i s e a r l y a s i t w i l l b l o w a w a y a n y G P R s , V S R s a n d
* some S P R s .
* /
2018-05-23 10:01:48 +03:00
mr r31 , r3
2018-05-23 10:01:47 +03:00
addi r3 , r31 , V C P U _ F P R S _ T M
bl l o a d _ f p _ s t a t e
addi r3 , r31 , V C P U _ V R S _ T M
bl l o a d _ v r _ s t a t e
2018-05-23 10:01:48 +03:00
mr r3 , r31
lwz r7 , V C P U _ V R S A V E _ T M ( r3 )
2018-05-23 10:01:47 +03:00
mtspr S P R N _ V R S A V E , r7
2018-05-23 10:01:48 +03:00
ld r5 , V C P U _ L R _ T M ( r3 )
lwz r6 , V C P U _ C R _ T M ( r3 )
ld r7 , V C P U _ C T R _ T M ( r3 )
ld r8 , V C P U _ A M R _ T M ( r3 )
ld r9 , V C P U _ T A R _ T M ( r3 )
ld r10 , V C P U _ X E R _ T M ( r3 )
2018-05-23 10:01:47 +03:00
mtlr r5
mtcr r6
mtctr r7
mtspr S P R N _ A M R , r8
mtspr S P R N _ T A R , r9
mtxer r10
/ *
* Load u p P P R a n d D S C R v a l u e s b u t d o n ' t p u t t h e m i n t h e a c t u a l S P R s
* till t h e l a s t m o m e n t t o a v o i d r u n n i n g w i t h u s e r s p a c e P P R a n d D S C R f o r
* too l o n g .
* /
2018-05-23 10:01:48 +03:00
ld r29 , V C P U _ D S C R _ T M ( r3 )
ld r30 , V C P U _ P P R _ T M ( r3 )
2018-05-23 10:01:47 +03:00
/* Clear the MSR RI since r1, r13 are all going to be foobar. */
li r5 , 0
mtmsrd r5 , 1
/* Load GPRs r0-r28 */
reg = 0
.rept 29
ld r e g , V C P U _ G P R S _ T M ( r e g ) ( r31 )
reg = r e g + 1
.endr
mtspr S P R N _ D S C R , r29
mtspr S P R N _ P P R , r30
/* Load final GPRs */
ld 2 9 , V C P U _ G P R S _ T M ( 2 9 ) ( r31 )
ld 3 0 , V C P U _ G P R S _ T M ( 3 0 ) ( r31 )
ld 3 1 , V C P U _ G P R S _ T M ( 3 1 ) ( r31 )
/* TM checkpointed state is now setup. All GPRs are now volatile. */
TRECHKPT
/* Now let's get back the state we need. */
HMT_ M E D I U M
GET_ P A C A ( r13 )
2018-05-23 10:01:48 +03:00
ld r1 , H S T A T E _ S C R A T C H 2 ( r13 )
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
REST_ G P R ( 7 , r1 )
mtspr S P R N _ D S C R , r7
2018-05-23 10:01:47 +03:00
/* Set the MSR RI since we have our registers back. */
li r5 , M S R _ R I
mtmsrd r5 , 1
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
/* Restore TOC pointer and CR */
REST_ G P R ( 2 , r1 )
REST_ G P R ( 6 , r1 )
mtcr r6
/* Restore non-volatile registers if requested to. */
beq c r7 , 5 f
REST_ G P R ( 1 0 , r1 )
REST_ N V G P R S ( r1 )
5 : addi r1 , r1 , S W I T C H _ F R A M E _ S I Z E
2018-05-23 10:01:47 +03:00
ld r0 , P P C _ L R _ S T K O F F ( r1 )
mtlr r0
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
9 : /* Restore MSR bits if requested */
beqlr c r7
mtmsrd r10 , 0
2018-05-23 10:01:47 +03:00
blr
2018-05-23 10:01:50 +03:00
/ *
* _ kvmppc_ r e s t o r e _ t m _ p r ( ) i s a w r a p p e r a r o u n d _ _ k v m p p c _ r e s t o r e _ t m ( ) , s o t h a t i t
* can b e i n v o k e d f r o m C f u n c t i o n b y P R K V M o n l y .
* /
_ GLOBAL( _ k v m p p c _ r e s t o r e _ t m _ p r )
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
mflr r0
std r0 , P P C _ L R _ S T K O F F ( r1 )
stdu r1 , - P P C _ M I N _ S T K F R M ( r1 )
2018-05-23 10:01:50 +03:00
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
/* save TAR so that it can be recovered later */
2018-05-23 10:02:07 +03:00
mfspr r8 , S P R N _ T A R
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
std r8 , P P C _ M I N _ S T K F R M - 8 ( r1 )
2018-05-23 10:02:07 +03:00
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
li r5 , 1
2018-05-23 10:01:50 +03:00
bl _ _ k v m p p c _ r e s t o r e _ t m
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
ld r8 , P P C _ M I N _ S T K F R M - 8 ( r1 )
2018-05-23 10:02:07 +03:00
mtspr S P R N _ T A R , r8
KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable
This adds a parameter to __kvmppc_save_tm and __kvmppc_restore_tm
which allows the caller to indicate whether it wants the nonvolatile
register state to be preserved across the call, as required by the C
calling conventions. This parameter being non-zero also causes the
MSR bits that enable TM, FP, VMX and VSX to be preserved. The
condition register and DSCR are now always preserved.
With this, kvmppc_save_tm_hv and kvmppc_restore_tm_hv can be called
from C code provided the 3rd parameter is non-zero. So that these
functions can be called from modules, they now include code to set
the TOC pointer (r2) on entry, as they can call other built-in C
functions which will assume the TOC to have been set.
Also, the fake suspend code in kvmppc_save_tm_hv is modified here to
assume that treclaim in fake-suspend state does not modify any registers,
which is the case on POWER9. This enables the code to be simplified
quite a bit.
_kvmppc_save_tm_pr and _kvmppc_restore_tm_pr become much simpler with
this change, since they now only need to save and restore TAR and pass
1 for the 3rd argument to __kvmppc_{save,restore}_tm.
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-10-08 08:30:53 +03:00
addi r1 , r1 , P P C _ M I N _ S T K F R M
ld r0 , P P C _ L R _ S T K O F F ( r1 )
mtlr r0
2018-05-23 10:01:50 +03:00
blr
EXPORT_ S Y M B O L _ G P L ( _ k v m p p c _ r e s t o r e _ t m _ p r ) ;
2018-05-23 10:01:47 +03:00
# endif / * C O N F I G _ P P C _ T R A N S A C T I O N A L _ M E M * /