2005-04-17 02:20:36 +04:00
/ *
* This f i l e i s s u b j e c t t o t h e t e r m s a n d c o n d i t i o n s o f t h e G N U G e n e r a l P u b l i c
* License. S e e t h e f i l e " C O P Y I N G " i n t h e m a i n d i r e c t o r y o f t h i s a r c h i v e
* for m o r e d e t a i l s .
*
* Copyright ( C ) 1 9 9 4 - 2 0 0 0 , 2 0 0 1 , 2 0 0 3 R a l f B a e c h l e
* Copyright ( C ) 1 9 9 9 , 2 0 0 0 S i l i c o n G r a p h i c s , I n c .
* Copyright ( C ) 2 0 0 1 M I P S T e c h n o l o g i e s , I n c .
* /
# include < a s m / a s m . h >
# include < a s m / a s m m a c r o . h >
2015-03-03 21:48:49 +03:00
# include < a s m / c o m p i l e r . h >
2017-03-04 02:26:05 +03:00
# include < a s m / i r q f l a g s . h >
2005-04-17 02:20:36 +04:00
# include < a s m / r e g d e f . h >
# include < a s m / m i p s r e g s . h >
# include < a s m / s t a c k f r a m e . h >
# include < a s m / i s a d e p . h >
# include < a s m / t h r e a d _ i n f o . h >
2019-10-15 22:17:59 +03:00
# ifndef C O N F I G _ P R E E M P T I O N
2005-04-17 02:20:36 +04:00
# define r e s u m e _ k e r n e l r e s t o r e _ a l l
2007-02-13 16:50:18 +03:00
# else
# define _ _ r e t _ f r o m _ i r q r e t _ f r o m _ e x c e p t i o n
2005-04-17 02:20:36 +04:00
# endif
.text
.align 5
2019-10-15 22:17:59 +03:00
# ifndef C O N F I G _ P R E E M P T I O N
2005-04-17 02:20:36 +04:00
FEXPORT( r e t _ f r o m _ e x c e p t i o n )
2007-02-13 16:50:18 +03:00
local_ i r q _ d i s a b l e # p r e e m p t s t o p
b _ _ r e t _ f r o m _ i r q
2006-10-08 20:24:23 +04:00
# endif
2007-02-13 16:50:18 +03:00
FEXPORT( r e t _ f r o m _ i r q )
LONG_ S s0 , T I _ R E G S ( $ 2 8 )
FEXPORT( _ _ r e t _ f r o m _ i r q )
2012-04-05 22:37:34 +04:00
/ *
* We c a n b e c o m i n g h e r e f r o m a s y s c a l l d o n e i n t h e k e r n e l s p a c e ,
* e. g . a f a i l e d k e r n e l _ e x e c v e ( ) .
* /
resume_userspace_check :
2005-04-17 02:20:36 +04:00
LONG_ L t 0 , P T _ S T A T U S ( s p ) # r e t u r n i n g t o k e r n e l m o d e ?
andi t 0 , t 0 , K U _ U S E R
beqz t 0 , r e s u m e _ k e r n e l
2004-12-10 15:56:33 +03:00
resume_userspace :
local_ i r q _ d i s a b l e # m a k e s u r e w e d o n t m i s s a n
2005-04-17 02:20:36 +04:00
# interrupt s e t t i n g n e e d _ r e s c h e d
# between s a m p l i n g a n d r e t u r n
LONG_ L a2 , T I _ F L A G S ( $ 2 8 ) # c u r r e n t - > w o r k
2004-12-10 15:56:33 +03:00
andi t 0 , a2 , _ T I F _ W O R K _ M A S K # ( i g n o r i n g s y s c a l l _ t r a c e )
bnez t 0 , w o r k _ p e n d i n g
2005-04-17 02:20:36 +04:00
j r e s t o r e _ a l l
2019-10-15 22:17:59 +03:00
# ifdef C O N F I G _ P R E E M P T I O N
2004-12-10 15:56:33 +03:00
resume_kernel :
2005-02-07 05:54:29 +03:00
local_ i r q _ d i s a b l e
2005-04-17 02:20:36 +04:00
lw t 0 , T I _ P R E _ C O U N T ( $ 2 8 )
bnez t 0 , r e s t o r e _ a l l
LONG_ L t 0 , T I _ F L A G S ( $ 2 8 )
andi t 1 , t 0 , _ T I F _ N E E D _ R E S C H E D
beqz t 1 , r e s t o r e _ a l l
LONG_ L t 0 , P T _ S T A T U S ( s p ) # I n t e r r u p t s o f f ?
andi t 0 , 1
beqz t 0 , r e s t o r e _ a l l
2019-03-15 19:31:33 +03:00
PTR_ L A r a , r e s t o r e _ a l l
j p r e e m p t _ s c h e d u l e _ i r q
2005-04-17 02:20:36 +04:00
# endif
2012-10-10 00:27:45 +04:00
FEXPORT( r e t _ f r o m _ k e r n e l _ t h r e a d )
jal s c h e d u l e _ t a i l # a 0 = s t r u c t t a s k _ s t r u c t * p r e v
move a0 , s1
jal s0
2012-10-12 00:01:20 +04:00
j s y s c a l l _ e x i t
2012-10-10 00:27:45 +04:00
2005-04-17 02:20:36 +04:00
FEXPORT( r e t _ f r o m _ f o r k )
2006-07-03 11:25:41 +04:00
jal s c h e d u l e _ t a i l # a 0 = s t r u c t t a s k _ s t r u c t * p r e v
2005-04-17 02:20:36 +04:00
FEXPORT( s y s c a l l _ e x i t )
2018-06-14 20:20:54 +03:00
# ifdef C O N F I G _ D E B U G _ R S E Q
move a0 , s p
jal r s e q _ s y s c a l l
# endif
2005-04-17 02:20:36 +04:00
local_ i r q _ d i s a b l e # m a k e s u r e n e e d _ r e s c h e d a n d
# signals d o n t c h a n g e b e t w e e n
# sampling a n d r e t u r n
LONG_ L a2 , T I _ F L A G S ( $ 2 8 ) # c u r r e n t - > w o r k
li t 0 , _ T I F _ A L L W O R K _ M A S K
and t 0 , a2 , t 0
bnez t 0 , s y s c a l l _ e x i t _ w o r k
2012-05-06 00:11:35 +04:00
restore_all : # restore f u l l f r a m e
2005-04-17 02:20:36 +04:00
.set noat
RESTORE_ T E M P
RESTORE_ A T
RESTORE_ S T A T I C
2012-05-06 00:11:35 +04:00
restore_partial : # restore p a r t i a l f r a m e
2006-07-07 17:07:18 +04:00
# ifdef C O N F I G _ T R A C E _ I R Q F L A G S
SAVE_ S T A T I C
SAVE_ A T
SAVE_ T E M P
LONG_ L v0 , P T _ S T A T U S ( s p )
2022-02-22 12:04:28 +03:00
# if d e f i n e d ( C O N F I G _ C P U _ R 3 0 0 0 )
2007-03-26 17:47:06 +04:00
and v0 , S T 0 _ I E P
# else
and v0 , S T 0 _ I E
# endif
2006-07-07 17:07:18 +04:00
beqz v0 , 1 f
jal t r a c e _ h a r d i r q s _ o n
b 2 f
1 : jal t r a c e _ h a r d i r q s _ o f f
2 :
RESTORE_ T E M P
RESTORE_ A T
RESTORE_ S T A T I C
# endif
2005-04-17 02:20:36 +04:00
RESTORE_ S O M E
RESTORE_ S P _ A N D _ R E T
.set at
2004-12-10 15:56:33 +03:00
work_pending :
andi t 0 , a2 , _ T I F _ N E E D _ R E S C H E D # a 2 i s p r e l o a d e d w i t h T I _ F L A G S
2005-04-17 02:20:36 +04:00
beqz t 0 , w o r k _ n o t i f y s i g
work_resched :
2017-03-04 02:26:05 +03:00
TRACE_ I R Q S _ O F F
2005-04-17 02:20:36 +04:00
jal s c h e d u l e
2004-12-10 15:56:33 +03:00
local_ i r q _ d i s a b l e # m a k e s u r e n e e d _ r e s c h e d a n d
2005-04-17 02:20:36 +04:00
# signals d o n t c h a n g e b e t w e e n
# sampling a n d r e t u r n
LONG_ L a2 , T I _ F L A G S ( $ 2 8 )
andi t 0 , a2 , _ T I F _ W O R K _ M A S K # i s t h e r e a n y w o r k t o b e d o n e
# other t h a n s y s c a l l t r a c i n g ?
beqz t 0 , r e s t o r e _ a l l
andi t 0 , a2 , _ T I F _ N E E D _ R E S C H E D
bnez t 0 , w o r k _ r e s c h e d
work_notifysig : # deal w i t h p e n d i n g s i g n a l s a n d
# notify- r e s u m e r e q u e s t s
move a0 , s p
li a1 , 0
jal d o _ n o t i f y _ r e s u m e # a 2 a l r e a d y l o a d e d
2012-04-05 22:37:34 +04:00
j r e s u m e _ u s e r s p a c e _ c h e c k
2005-04-17 02:20:36 +04:00
2012-05-06 00:11:35 +04:00
FEXPORT( s y s c a l l _ e x i t _ p a r t i a l )
2018-06-14 20:20:54 +03:00
# ifdef C O N F I G _ D E B U G _ R S E Q
move a0 , s p
jal r s e q _ s y s c a l l
# endif
2012-05-06 00:11:35 +04:00
local_ i r q _ d i s a b l e # m a k e s u r e n e e d _ r e s c h e d d o e s n ' t
# change b e t w e e n a n d r e t u r n
LONG_ L a2 , T I _ F L A G S ( $ 2 8 ) # c u r r e n t - > w o r k
li t 0 , _ T I F _ A L L W O R K _ M A S K
and t 0 , a2
beqz t 0 , r e s t o r e _ p a r t i a l
2005-04-17 02:20:36 +04:00
SAVE_ S T A T I C
2004-12-10 15:56:33 +03:00
syscall_exit_work :
2012-05-03 05:45:12 +04:00
LONG_ L t 0 , P T _ S T A T U S ( s p ) # r e t u r n i n g t o k e r n e l m o d e ?
andi t 0 , t 0 , K U _ U S E R
beqz t 0 , r e s u m e _ k e r n e l
2011-05-19 12:21:28 +04:00
li t 0 , _ T I F _ W O R K _ S Y S C A L L _ E X I T
2004-12-10 15:56:33 +03:00
and t 0 , a2 # a 2 i s p r e l o a d e d w i t h T I _ F L A G S
beqz t 0 , w o r k _ p e n d i n g # t r a c e b i t s e t ?
2011-05-19 12:21:29 +04:00
local_ i r q _ e n a b l e # c o u l d l e t s y s c a l l _ t r a c e _ l e a v e ( )
2005-04-17 02:20:36 +04:00
# call s c h e d u l e ( ) i n s t e a d
2017-03-04 02:26:05 +03:00
TRACE_ I R Q S _ O N
2005-04-17 02:20:36 +04:00
move a0 , s p
2011-05-19 12:21:29 +04:00
jal s y s c a l l _ t r a c e _ l e a v e
2005-04-17 02:20:36 +04:00
b r e s u m e _ u s e r s p a c e
2006-04-05 12:45:45 +04:00
mips: Add MIPS Release 5 support
There are five MIPS32/64 architecture releases currently available:
from 1 to 6 except fourth one, which was intentionally skipped.
Three of them can be called as major: 1st, 2nd and 6th, that not only
have some system level alterations, but also introduced significant
core/ISA level updates. The rest of the MIPS architecture releases are
minor.
Even though they don't have as much ISA/system/core level changes
as the major ones with respect to the previous releases, they still
provide a set of updates (I'd say they were intended to be the
intermediate releases before a major one) that might be useful for the
kernel and user-level code, when activated by the kernel or compiler.
In particular the following features were introduced or ended up being
available at/after MIPS32/64 Release 5 architecture:
+ the last release of the misaligned memory access instructions,
+ virtualisation - VZ ASE - is optional component of the arch,
+ SIMD - MSA ASE - is optional component of the arch,
+ DSP ASE is optional component of the arch,
+ CP0.Status.FR=1 for CP1.FIR.F64=1 (pure 64-bit FPU general registers)
must be available if FPU is implemented,
+ CP1.FIR.Has2008 support is required so CP1.FCSR.{ABS2008,NAN2008} bits
are available.
+ UFR/UNFR aliases to access CP0.Status.FR from user-space by means of
ctc1/cfc1 instructions (enabled by CP0.Config5.UFR),
+ CP0.COnfig5.LLB=1 and eretnc instruction are implemented to without
accidentally clearing LL-bit when returning from an interrupt,
exception, or error trap,
+ XPA feature together with extended versions of CPx registers is
introduced, which needs to have mfhc0/mthc0 instructions available.
So due to these changes GNU GCC provides an extended instructions set
support for MIPS32/64 Release 5 by default like eretnc/mfhc0/mthc0. Even
though the architecture alteration isn't that big, it still worth to be
taken into account by the kernel software. Finally we can't deny that
some optimization/limitations might be found in future and implemented
on some level in kernel or compiler. In this case having even
intermediate MIPS architecture releases support would be more than
useful.
So the most of the changes provided by this commit can be split into
either compile- or runtime configs related. The compile-time related
changes are caused by adding the new CONFIG_CPU_MIPS32_R5/CONFIG_CPU_MIPSR5
configs and concern the code activating MIPSR2 or MIPSR6 already
implemented features (like eretnc/LLbit, mthc0/mfhc0). In addition
CPU_HAS_MSA can be now freely enabled for MIPS32/64 release 5 based
platforms as this is done for CPU_MIPS32_R6 CPUs. The runtime changes
concerns the features which are handled with respect to the MIPS ISA
revision detected at run-time by means of CP0.Config.{AT,AR} bits. Alas
these fields can be used to detect either r1 or r2 or r6 releases.
But since we know which CPUs in fact support the R5 arch, we can manually
set MIPS_CPU_ISA_M32R5/MIPS_CPU_ISA_M64R5 bit of c->isa_level and then
use cpu_has_mips32r5/cpu_has_mips64r5 where it's appropriate.
Since XPA/EVA provide too complex alterationss and to have them used with
MIPS32 Release 2 charged kernels (for compatibility with current platform
configs) they are left to be setup as a separate kernel configs.
Co-developed-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
2020-05-21 17:07:14 +03:00
# if d e f i n e d ( C O N F I G _ C P U _ M I P S R 2 ) | | d e f i n e d ( C O N F I G _ C P U _ M I P S R 5 ) | | \
defined( C O N F I G _ C P U _ M I P S R 6 ) | | d e f i n e d ( C O N F I G _ M I P S _ M T )
2006-04-05 12:45:45 +04:00
/ *
* MIPS3 2 R 2 I n s t r u c t i o n H a z a r d B a r r i e r - m u s t b e c a l l e d
*
* For C c o d e u s e t h e i n l i n e v e r s i o n n a m e d i n s t r u c t i o n _ h a z a r d ( ) .
* /
LEAF( m i p s _ i h b )
2015-03-03 21:48:49 +03:00
.set MIPS_ISA_LEVEL_RAW
2006-04-05 12:45:45 +04:00
jr. h b r a
nop
END( m i p s _ i h b )
mips: Add MIPS Release 5 support
There are five MIPS32/64 architecture releases currently available:
from 1 to 6 except fourth one, which was intentionally skipped.
Three of them can be called as major: 1st, 2nd and 6th, that not only
have some system level alterations, but also introduced significant
core/ISA level updates. The rest of the MIPS architecture releases are
minor.
Even though they don't have as much ISA/system/core level changes
as the major ones with respect to the previous releases, they still
provide a set of updates (I'd say they were intended to be the
intermediate releases before a major one) that might be useful for the
kernel and user-level code, when activated by the kernel or compiler.
In particular the following features were introduced or ended up being
available at/after MIPS32/64 Release 5 architecture:
+ the last release of the misaligned memory access instructions,
+ virtualisation - VZ ASE - is optional component of the arch,
+ SIMD - MSA ASE - is optional component of the arch,
+ DSP ASE is optional component of the arch,
+ CP0.Status.FR=1 for CP1.FIR.F64=1 (pure 64-bit FPU general registers)
must be available if FPU is implemented,
+ CP1.FIR.Has2008 support is required so CP1.FCSR.{ABS2008,NAN2008} bits
are available.
+ UFR/UNFR aliases to access CP0.Status.FR from user-space by means of
ctc1/cfc1 instructions (enabled by CP0.Config5.UFR),
+ CP0.COnfig5.LLB=1 and eretnc instruction are implemented to without
accidentally clearing LL-bit when returning from an interrupt,
exception, or error trap,
+ XPA feature together with extended versions of CPx registers is
introduced, which needs to have mfhc0/mthc0 instructions available.
So due to these changes GNU GCC provides an extended instructions set
support for MIPS32/64 Release 5 by default like eretnc/mfhc0/mthc0. Even
though the architecture alteration isn't that big, it still worth to be
taken into account by the kernel software. Finally we can't deny that
some optimization/limitations might be found in future and implemented
on some level in kernel or compiler. In this case having even
intermediate MIPS architecture releases support would be more than
useful.
So the most of the changes provided by this commit can be split into
either compile- or runtime configs related. The compile-time related
changes are caused by adding the new CONFIG_CPU_MIPS32_R5/CONFIG_CPU_MIPSR5
configs and concern the code activating MIPSR2 or MIPSR6 already
implemented features (like eretnc/LLbit, mthc0/mfhc0). In addition
CPU_HAS_MSA can be now freely enabled for MIPS32/64 release 5 based
platforms as this is done for CPU_MIPS32_R6 CPUs. The runtime changes
concerns the features which are handled with respect to the MIPS ISA
revision detected at run-time by means of CP0.Config.{AT,AR} bits. Alas
these fields can be used to detect either r1 or r2 or r6 releases.
But since we know which CPUs in fact support the R5 arch, we can manually
set MIPS_CPU_ISA_M32R5/MIPS_CPU_ISA_M64R5 bit of c->isa_level and then
use cpu_has_mips32r5/cpu_has_mips64r5 where it's appropriate.
Since XPA/EVA provide too complex alterationss and to have them used with
MIPS32 Release 2 charged kernels (for compatibility with current platform
configs) they are left to be setup as a separate kernel configs.
Co-developed-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
2020-05-21 17:07:14 +03:00
# endif / * C O N F I G _ C P U _ M I P S R 2 - C O N F I G _ C P U _ M I P S R 6 o r C O N F I G _ M I P S _ M T * /