2019-05-27 08:55:01 +02:00
/* SPDX-License-Identifier: GPL-2.0-or-later */
2005-09-26 16:04:21 +10:00
/ *
* FPU s u p p o r t c o d e , m o v e d h e r e f r o m h e a d . S s o t h a t i t c a n b e u s e d
* by c h i p s w h i c h u s e o t h e r h e a d - w h a t e v e r . S f i l e s .
*
2006-08-30 14:45:35 +10:00
* Copyright ( C ) 1 9 9 5 - 1 9 9 6 G a r y T h o m a s ( g d t @linuxppc.org)
* Copyright ( C ) 1 9 9 6 C o r t D o u g a n < c o r t @cs.nmt.edu>
* Copyright ( C ) 1 9 9 6 P a u l M a c k e r r a s .
* Copyright ( C ) 1 9 9 7 D a n M a l e k ( d m a l e k @jlc.net).
2005-09-26 16:04:21 +10:00
* /
2005-10-10 22:20:10 +10:00
# include < a s m / r e g . h >
2005-09-26 16:04:21 +10:00
# include < a s m / p a g e . h >
# include < a s m / m m u . h >
# include < a s m / c p u t a b l e . h >
# include < a s m / c a c h e . h >
# include < a s m / t h r e a d _ i n f o . 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 >
2010-11-18 15:06:17 +00:00
# include < a s m / p t r a c e . h >
2016-01-13 23:33:46 -05:00
# include < a s m / e x p o r t . h >
2018-07-05 16:24:57 +00:00
# include < a s m / a s m - c o m p a t . h >
2018-07-05 16:25:01 +00:00
# include < a s m / f e a t u r e - f i x u p s . h >
2005-09-26 16:04:21 +10:00
2008-06-25 14:07:18 +10:00
# ifdef C O N F I G _ V S X
2012-06-25 13:33:23 +00:00
# define _ _ R E S T _ 3 2 F P V S R S ( n ,c ,b a s e ) \
2008-06-25 14:07:18 +10:00
BEGIN_ F T R _ S E C T I O N \
b 2 f ; \
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ V S X ) ; \
REST_ 3 2 F P R S ( n ,b a s e ) ; \
b 3 f ; \
2 : REST_ 3 2 V S R S ( n ,c ,b a s e ) ; \
3 :
2012-06-25 13:33:23 +00:00
# define _ _ S A V E _ 3 2 F P V S R S ( n ,c ,b a s e ) \
2008-06-25 14:07:18 +10:00
BEGIN_ F T R _ S E C T I O N \
b 2 f ; \
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ V S X ) ; \
SAVE_ 3 2 F P R S ( n ,b a s e ) ; \
b 3 f ; \
2 : SAVE_ 3 2 V S R S ( n ,c ,b a s e ) ; \
3 :
# else
2012-06-25 13:33:23 +00:00
# define _ _ R E S T _ 3 2 F P V S R S ( n ,b ,b a s e ) R E S T _ 3 2 F P R S ( n , b a s e )
# define _ _ S A V E _ 3 2 F P V S R S ( n ,b ,b a s e ) S A V E _ 3 2 F P R S ( n , b a s e )
2008-06-25 14:07:18 +10:00
# endif
2012-06-25 13:33:23 +00:00
# define R E S T _ 3 2 F P V S R S ( n ,c ,b a s e ) _ _ R E S T _ 3 2 F P V S R S ( n ,_ _ R E G _ ## c , _ _ R E G _ # # b a s e )
# define S A V E _ 3 2 F P V S R S ( n ,c ,b a s e ) _ _ S A V E _ 3 2 F P V S R S ( n ,_ _ R E G _ ## c , _ _ R E G _ # # b a s e )
2008-06-25 14:07:18 +10:00
2013-09-10 20:21:10 +10:00
/ *
* Load s t a t e f r o m m e m o r y i n t o F P r e g i s t e r s i n c l u d i n g F P S C R .
* Assumes t h e c a l l e r h a s e n a b l e d F P i n t h e M S R .
* /
_ GLOBAL( l o a d _ f p _ s t a t e )
lfd f r0 ,F P S T A T E _ F P S C R ( r3 )
MTFSF_ L ( f r0 )
REST_ 3 2 F P V S R S ( 0 , R 4 , R 3 )
blr
2016-01-13 23:33:46 -05:00
EXPORT_ S Y M B O L ( l o a d _ f p _ s t a t e )
powerpc/64: Don't trace code that runs with the soft irq mask unreconciled
"Reconciling" in terms of interrupt handling, is to bring the soft irq
mask state in to synch with the hardware, after an interrupt causes
MSR[EE] to be cleared (while the soft mask may be enabled, and hard
irqs not marked disabled).
General kernel code should not be called while unreconciled, because
local_irq_disable, etc. manipulations can cause surprising irq traces,
and it's fragile because the soft irq code does not really expect to
be called in this situation.
When exiting from an interrupt, MSR[EE] is cleared to prevent races,
but soft irq state is enabled for the returned-to context, so this is
now an unreconciled state. restore_math is called in this state, and
that can be ftraced, and the ftrace subsystem disables local irqs.
Mark restore_math and its callees as notrace. Restore a sanity check
in the soft irq code that had to be disabled for this case, by commit
4da1f79227ad4 ("powerpc/64: Disable irq restore warning for now").
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2019-05-02 15:21:07 +10:00
_ ASM_ N O K P R O B E _ S Y M B O L ( l o a d _ f p _ s t a t e ) ; /* used by restore_math */
2013-09-10 20:21:10 +10:00
/ *
* Store F P s t a t e i n t o m e m o r y , i n c l u d i n g F P S C R
* Assumes t h e c a l l e r h a s e n a b l e d F P i n t h e M S R .
* /
_ GLOBAL( s t o r e _ f p _ s t a t e )
SAVE_ 3 2 F P V S R S ( 0 , R 4 , R 3 )
mffs f r0
stfd f r0 ,F P S T A T E _ F P S C R ( r3 )
blr
2016-01-13 23:33:46 -05:00
EXPORT_ S Y M B O L ( s t o r e _ f p _ s t a t e )
2013-09-10 20:21:10 +10:00
2005-09-26 16:04:21 +10:00
/ *
* This t a s k w a n t s t o u s e t h e F P U n o w .
* On U P , d i s a b l e F P f o r t h e t a s k w h i c h h a d t h e F P U p r e v i o u s l y ,
* and s a v e i t s f l o a t i n g - p o i n t r e g i s t e r s i n i t s t h r e a d _ s t r u c t .
* Load u p t h i s t a s k ' s F P r e g i s t e r s f r o m i t s t h r e a d _ s t r u c t ,
* enable t h e F P U f o r t h e c u r r e n t t a s k a n d r e t u r n t o t h e t a s k .
2013-10-23 09:40:02 +01:00
* Note t h a t o n 3 2 - b i t t h i s c a n o n l y u s e r e g i s t e r s t h a t w i l l b e
* restored b y f a s t _ e x c e p t i o n _ r e t u r n , i . e . r3 - r6 , r10 a n d r11 .
2005-09-26 16:04:21 +10:00
* /
2005-10-06 10:59:19 +10:00
_ GLOBAL( l o a d _ u p _ f p u )
2005-09-26 16:04:21 +10:00
mfmsr r5
ori r5 ,r5 ,M S R _ F P
2008-06-25 14:07:18 +10:00
# ifdef C O N F I G _ V S X
BEGIN_ F T R _ S E C T I O N
oris r5 ,r5 ,M S R _ V S X @h
END_ F T R _ S E C T I O N _ I F S E T ( C P U _ F T R _ V S X )
# endif
2005-09-26 16:04:21 +10:00
MTMSRD( r5 ) / * e n a b l e u s e o f f p u n o w * /
isync
/* enable use of FP after return */
2005-10-06 10:59:19 +10:00
# ifdef C O N F I G _ P P C 3 2
2021-08-18 08:47:28 +00:00
addi r5 ,r2 ,T H R E A D
2005-09-26 16:04:21 +10:00
lwz r4 ,T H R E A D _ F P E X C _ M O D E ( r5 )
ori r9 ,r9 ,M S R _ F P / * e n a b l e F P f o r c u r r e n t * /
or r9 ,r9 ,r4
2005-10-06 10:59:19 +10:00
# else
ld r4 ,P A C A C U R R E N T ( r13 )
addi r5 ,r4 ,T H R E A D / * G e t T H R E A D * /
2006-02-07 13:55:30 +11:00
lwz r4 ,T H R E A D _ F P E X C _ M O D E ( r5 )
2005-10-06 10:59:19 +10:00
ori r12 ,r12 ,M S R _ F P
or r12 ,r12 ,r4
std r12 ,_ M S R ( r1 )
2021-06-18 01:51:03 +10:00
# ifdef C O N F I G _ P P C _ B O O K 3 S _ 6 4
li r4 ,0
stb r4 ,P A C A S R R _ V A L I D ( r13 )
# endif
2005-10-06 10:59:19 +10:00
# endif
2020-06-24 09:41:39 +10:00
li r4 ,1
2016-02-29 17:53:47 +11:00
stb r4 ,T H R E A D _ L O A D _ F P ( r5 )
2013-10-23 09:40:02 +01:00
addi r10 ,r5 ,T H R E A D _ F P S T A T E
lfd f r0 ,F P S T A T E _ F P S C R ( r10 )
2006-06-10 20:18:39 +10:00
MTFSF_ L ( f r0 )
2013-10-23 09:40:02 +01:00
REST_ 3 2 F P V S R S ( 0 , R 4 , R 1 0 )
2005-09-26 16:04:21 +10:00
/* restore registers and return */
/* we haven't used ctr or xer or lr */
2008-06-25 14:07:18 +10:00
blr
2020-03-31 16:03:44 +00:00
_ ASM_ N O K P R O B E _ S Y M B O L ( l o a d _ u p _ f p u )
2005-09-26 16:04:21 +10:00
/ *
2016-02-29 17:53:49 +11:00
* save_ f p u ( t s k )
* Save t h e f l o a t i n g - p o i n t r e g i s t e r s i n i t s t h r e a d _ s t r u c t .
2005-09-26 16:04:21 +10:00
* Enables t h e F P U f o r u s e i n t h e k e r n e l o n r e t u r n .
* /
2016-02-29 17:53:49 +11:00
_ GLOBAL( s a v e _ f p u )
2005-09-26 16:04:21 +10:00
addi r3 ,r3 ,T H R E A D / * w a n t T H R E A D o f t a s k * /
2013-09-10 20:21:10 +10:00
PPC_ L L r6 ,T H R E A D _ F P S A V E A R E A ( r3 )
[PATCH] powerpc: Consolidate asm compatibility macros
This patch consolidates macros used to generate assembly for
compatibility across different CPUs or configs. A new header,
asm-powerpc/asm-compat.h contains the main compatibility macros. It
uses some preprocessor magic to make the macros suitable both for use
in .S files, and in inline asm in .c files. Headers (bitops.h,
uaccess.h, atomic.h, bug.h) which had their own such compatibility
macros are changed to use asm-compat.h.
ppc_asm.h is now for use in .S files *only*, and a #error enforces
that. As such, we're a lot more careless about namespace pollution
here than in asm-compat.h.
While we're at it, this patch adds a call to the PPC405_ERR77 macro in
futex.h which should have had it already, but didn't.
Built and booted on pSeries, Maple and iSeries (ARCH=powerpc). Built
for 32-bit powermac (ARCH=powerpc) and Walnut (ARCH=ppc).
Signed-off-by: David Gibson <dwg@au1.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-10 12:56:55 +11:00
PPC_ L L r5 ,P T _ R E G S ( r3 )
2013-09-10 20:21:10 +10:00
PPC_ L C M P I 0 ,r6 ,0
bne 2 f
2013-09-10 20:20:42 +10:00
addi r6 ,r3 ,T H R E A D _ F P S T A T E
2016-02-29 17:53:49 +11:00
2 : SAVE_ 3 2 F P V S R S ( 0 , R 4 , R 6 )
2005-09-26 16:04:21 +10:00
mffs f r0
2013-09-10 20:20:42 +10:00
stfd f r0 ,F P S T A T E _ F P S C R ( r6 )
2005-09-26 16:04:21 +10:00
blr