License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 15:07:57 +01:00
/* SPDX-License-Identifier: GPL-2.0 */
2007-08-02 00:19:14 -07:00
/ * arch/ s p a r c / k e r n e l / e n t r y . S : S p a r c t r a p l o w - l e v e l e n t r y p o i n t s .
2005-04-16 15:20:36 -07:00
*
2007-08-02 00:19:14 -07:00
* Copyright ( C ) 1 9 9 5 , 2 0 0 7 D a v i d S . M i l l e r ( d a v e m @davemloft.net)
2005-04-16 15:20:36 -07:00
* Copyright ( C ) 1 9 9 6 E d d i e C . D o s t ( e c d @skynet.be)
* Copyright ( C ) 1 9 9 6 M i g u e l d e I c a z a ( m i g u e l @nuclecu.unam.mx)
* Copyright ( C ) 1 9 9 6 - 1 9 9 9 J a k u b J e l i n e k ( j j @sunsite.mff.cuni.cz)
* Copyright ( C ) 1 9 9 7 A n t o n B l a n c h a r d ( a n t o n @progsoc.uts.edu.au)
* /
2023-08-20 08:33:48 +09:00
# include < l i n u x / e x p o r t . h >
2012-05-13 23:09:04 -07:00
# include < l i n u x / l i n k a g e . h >
2005-04-16 15:20:36 -07:00
# include < l i n u x / e r r n o . h >
2020-06-08 21:32:42 -07:00
# include < l i n u x / p g t a b l e . h >
2005-04-16 15:20:36 -07:00
# include < a s m / h e a d . h >
# include < a s m / a s i . h >
# include < a s m / s m p . h >
# include < a s m / c o n t r e g s . h >
# include < a s m / p t r a c e . h >
2005-09-09 20:35:55 +02:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-16 15:20:36 -07:00
# include < a s m / p s r . h >
# include < a s m / v a d d r s . h >
# include < a s m / p a g e . h >
# include < a s m / w i n m a c r o . h >
# include < a s m / s i g n a l . h >
# include < a s m / o b i o . h >
# include < a s m / m x c c . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / p a r a m . h >
2006-11-05 16:51:03 -08:00
# include < a s m / u n i s t d . h >
2005-04-16 15:20:36 -07:00
# include < a s m / a s m m a c r o . h >
# define c u r p t r g 6
/* These are just handy. */
# define _ S V s a v e % s p , - S T A C K F R A M E _ S Z , % s p
# define _ R S r e s t o r e
# define F L U S H _ A L L _ K E R N E L _ W I N D O W S \
_ SV; _SV; _SV; _SV; _SV; _SV; _SV; \
_ RS; _RS; _RS; _RS; _RS; _RS; _RS;
.text
2008-04-29 02:38:50 -07:00
# ifdef C O N F I G _ K G D B
.align 4
.globl arch_kgdb_breakpoint
.type arch_ k g d b _ b r e a k p o i n t ,#f u n c t i o n
arch_kgdb_breakpoint :
ta 0 x7 d
retl
nop
.size arch_ k g d b _ b r e a k p o i n t ,. - a r c h _ k g d b _ b r e a k p o i n t
2005-04-16 15:20:36 -07:00
# endif
2007-08-02 00:19:14 -07:00
# if d e f i n e d ( C O N F I G _ B L K _ D E V _ F D ) | | d e f i n e d ( C O N F I G _ B L K _ D E V _ F D _ M O D U L E )
2005-04-16 15:20:36 -07:00
.align 4
.globl floppy_hardint
floppy_hardint :
/ *
* This c o d e c a n n o t t o u c h r e g i s t e r s % l 0 % l 1 a n d % l 2
* because S A V E _ A L L d e p e n d s o n t h e i r v a l u e s . I t d e p e n d s
* on % l 3 a l s o , b u t w e r e g e n e r a t e i t b e f o r e a c a l l .
* Other r e g i s t e r s a r e :
* % l3 - - b a s e a d d r e s s o f f d c r e g i s t e r s
* % l4 - - p d m a _ v a d d r
* % l5 - - s c r a t c h f o r l d / s t a d d r e s s
* % l6 - - p d m a _ s i z e
* % l7 - - s c r a t c h [ f l o p p y b y t e , l d / s t a d d r e s s , a u x . d a t a ]
* /
/* Do we have work to do? */
sethi % h i ( d o i n g _ p d m a ) , % l 7
ld [ % l 7 + % l o ( d o i n g _ p d m a ) ] , % l 7
cmp % l 7 , 0
be f l o p p y _ d o s o f t i n t
nop
/* Load fdc register base */
sethi % h i ( f d c _ s t a t u s ) , % l 3
ld [ % l 3 + % l o ( f d c _ s t a t u s ) ] , % l 3
/* Setup register addresses */
sethi % h i ( p d m a _ v a d d r ) , % l 5 ! t r a n s f e r b u f f e r
ld [ % l 5 + % l o ( p d m a _ v a d d r ) ] , % l 4
sethi % h i ( p d m a _ s i z e ) , % l 5 ! b y t e s t o g o
ld [ % l 5 + % l o ( p d m a _ s i z e ) ] , % l 6
next_byte :
ldub [ % l 3 ] , % l 7
andcc % l 7 , 0 x80 , % g 0 ! D o e s f i f o s t i l l h a v e d a t a
bz f l o p p y _ f i f o _ e m p t i e d ! f i f o h a s b e e n e m p t i e d . . .
andcc % l 7 , 0 x20 , % g 0 ! i n n o n - d m a m o d e s t i l l ?
bz f l o p p y _ o v e r r u n ! n o p e , o v e r r u n
andcc % l 7 , 0 x40 , % g 0 ! 0 =write 1 =read
bz f l o p p y _ w r i t e
sub % l 6 , 0 x1 , % l 6
/* Ok, actually read this byte */
ldub [ % l 3 + 1 ] , % l 7
orcc % g 0 , % l 6 , % g 0
stb % l 7 , [ % l 4 ]
bne n e x t _ b y t e
add % l 4 , 0 x1 , % l 4
b f l o p p y _ t d o n e
nop
floppy_write :
/* Ok, actually write this byte */
ldub [ % l 4 ] , % l 7
orcc % g 0 , % l 6 , % g 0
stb % l 7 , [ % l 3 + 1 ]
bne n e x t _ b y t e
add % l 4 , 0 x1 , % l 4
/* fall through... */
floppy_tdone :
sethi % h i ( p d m a _ v a d d r ) , % l 5
st % l 4 , [ % l 5 + % l o ( p d m a _ v a d d r ) ]
sethi % h i ( p d m a _ s i z e ) , % l 5
st % l 6 , [ % l 5 + % l o ( p d m a _ s i z e ) ]
/* Flip terminal count pin */
set a u x i o _ r e g i s t e r , % l 7
ld [ % l 7 ] , % l 7
2012-05-11 20:59:57 -07:00
ldub [ % l 7 ] , % l 5
2005-04-16 15:20:36 -07:00
or % l 5 , 0 x c2 , % l 5
stb % l 5 , [ % l 7 ]
andn % l 5 , 0 x02 , % l 5
2 :
/* Kill some time so the bits set */
WRITE_ P A U S E
WRITE_ P A U S E
stb % l 5 , [ % l 7 ]
/* Prevent recursion */
sethi % h i ( d o i n g _ p d m a ) , % l 7
b f l o p p y _ d o s o f t i n t
st % g 0 , [ % l 7 + % l o ( d o i n g _ p d m a ) ]
/ * We e m p t i e d t h e F I F O , b u t w e h a v e n ' t r e a d e v e r y t h i n g
* as o f y e t . S t o r e t h e c u r r e n t t r a n s f e r a d d r e s s a n d
* bytes l e f t t o r e a d s o w e c a n c o n t i n u e w h e n t h e n e x t
* fast I R Q c o m e s i n .
* /
floppy_fifo_emptied :
sethi % h i ( p d m a _ v a d d r ) , % l 5
st % l 4 , [ % l 5 + % l o ( p d m a _ v a d d r ) ]
sethi % h i ( p d m a _ s i z e ) , % l 7
st % l 6 , [ % l 7 + % l o ( p d m a _ s i z e ) ]
/* Restore condition codes */
wr % l 0 , 0 x0 , % p s r
WRITE_ P A U S E
jmp % l 1
rett % l 2
floppy_overrun :
sethi % h i ( p d m a _ v a d d r ) , % l 5
st % l 4 , [ % l 5 + % l o ( p d m a _ v a d d r ) ]
sethi % h i ( p d m a _ s i z e ) , % l 5
st % l 6 , [ % l 5 + % l o ( p d m a _ s i z e ) ]
/* Prevent recursion */
sethi % h i ( d o i n g _ p d m a ) , % l 7
st % g 0 , [ % l 7 + % l o ( d o i n g _ p d m a ) ]
/* fall through... */
floppy_dosoftint :
rd % w i m , % l 3
SAVE_ A L L
/* Set all IRQs off. */
or % l 0 , P S R _ P I L , % l 4
wr % l 4 , 0 x0 , % p s r
WRITE_ P A U S E
wr % l 4 , P S R _ E T , % p s r
WRITE_ P A U S E
mov 1 1 , % o 0 ! f l o p p y i r q l e v e l ( u n u s e d a n y w a y )
mov % g 0 , % o 1 ! d e v i d i s n o t u s e d i n f a s t i n t e r r u p t s
call s p a r c _ f l o p p y _ i r q
add % s p , S T A C K F R A M E _ S Z , % o 2 ! s t r u c t p t _ r e g s * r e g s
RESTORE_ A L L
# endif / * ( C O N F I G _ B L K _ D E V _ F D ) * /
/* Bad trap handler */
.globl bad_trap_handler
bad_trap_handler :
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r
WRITE_ P A U S E
add % s p , S T A C K F R A M E _ S Z , % o 0 ! p t _ r e g s
call d o _ h w _ i n t e r r u p t
mov % l 7 , % o 1 ! t r a p n u m b e r
RESTORE_ A L L
/ * For n o w a l l I R Q ' s n o t r e g i s t e r e d g e t s e n t h e r e . h a n d l e r _ i r q ( ) w i l l
* see i f a r o u t i n e i s r e g i s t e r e d t o h a n d l e t h i s i n t e r r u p t a n d i f n o t
* it w i l l s a y s o o n t h e c o n s o l e .
* /
.align 4
.globl real_ i r q _ e n t r y , p a t c h _ h a n d l e r _ i r q
real_irq_entry :
SAVE_ A L L
# ifdef C O N F I G _ S M P
.globl patchme_maybe_smp_msg
2011-06-09 02:54:08 +00:00
cmp % l 7 , 1 1
2005-04-16 15:20:36 -07:00
patchme_maybe_smp_msg :
bgu m a y b e _ s m p4 m _ m s g
nop
# endif
real_irq_continue :
or % l 0 , P S R _ P I L , % g 2
wr % g 2 , 0 x0 , % p s r
WRITE_ P A U S E
wr % g 2 , P S R _ E T , % p s r
WRITE_ P A U S E
mov % l 7 , % o 0 ! i r q l e v e l
patch_handler_irq :
call h a n d l e r _ i r q
add % s p , S T A C K F R A M E _ S Z , % o 1 ! p t _ r e g s p t r
or % l 0 , P S R _ P I L , % g 2 ! r e s t o r e P I L a f t e r h a n d l e r _ i r q
wr % g 2 , P S R _ E T , % p s r ! k e e p E T u p
WRITE_ P A U S E
RESTORE_ A L L
# ifdef C O N F I G _ S M P
/* SMP per-cpu ticker interrupts are handled specially. */
smp4m_ticker :
bne r e a l _ i r q _ c o n t i n u e + 4
or % l 0 , P S R _ P I L , % g 2
wr % g 2 , 0 x0 , % p s r
WRITE_ P A U S E
wr % g 2 , P S R _ E T , % p s r
WRITE_ P A U S E
call s m p4 m _ p e r c p u _ t i m e r _ i n t e r r u p t
add % s p , S T A C K F R A M E _ S Z , % o 0
wr % l 0 , P S R _ E T , % p s r
WRITE_ P A U S E
RESTORE_ A L L
2012-05-19 21:22:11 -07:00
# define G E T _ P R O C E S S O R 4 M _ I D ( r e g ) \
rd % t b r , % r e g ; \
srl % r e g , 1 2 , % r e g ; \
and % r e g , 3 , % r e g ;
2005-04-16 15:20:36 -07:00
/ * Here i s w h e r e w e c h e c k f o r p o s s i b l e S M P I P I p a s s e d t o u s
* on s o m e l e v e l o t h e r t h a n 1 5 w h i c h i s t h e N M I a n d o n l y u s e d
* for c r o s s c a l l s . T h a t h a s a s e p a r a t e e n t r y p o i n t b e l o w .
2011-05-02 00:08:53 +00:00
*
* IPIs a r e s e n t o n L e v e l 1 2 , 1 3 a n d 1 4 . S e e I R Q _ I P I _ * .
2005-04-16 15:20:36 -07:00
* /
maybe_smp4m_msg :
GET_ P R O C E S S O R 4 M _ I D ( o 3 )
2008-09-19 21:17:43 -07:00
sethi % h i ( s u n 4 m _ i r q _ p e r c p u ) , % l 5
sll % o 3 , 2 , % o 3
or % l 5 , % l o ( s u n 4 m _ i r q _ p e r c p u ) , % o 5
2011-05-02 00:08:53 +00:00
sethi % h i ( 0 x70 0 0 0 0 0 0 ) , % o 2 ! C h e c k a l l s o f t - I R Q s
2005-04-16 15:20:36 -07:00
ld [ % o 5 + % o 3 ] , % o 1
2008-09-19 21:17:43 -07:00
ld [ % o 1 + 0 x00 ] , % o 3 ! s u n 4 m _ i r q _ p e r c p u [ c p u ] - > p e n d i n g
andcc % o 3 , % o 2 , % g 0
2005-04-16 15:20:36 -07:00
be,a s m p4 m _ t i c k e r
cmp % l 7 , 1 4
2011-05-02 00:08:53 +00:00
/* Soft-IRQ IPI */
st % o 2 , [ % o 1 + 0 x04 ] ! s u n 4 m _ i r q _ p e r c p u [ c p u ] - > c l e a r =0x70000000
2005-04-16 15:20:36 -07:00
WRITE_ P A U S E
2008-09-19 21:17:43 -07:00
ld [ % o 1 + 0 x00 ] , % g 0 ! s u n 4 m _ i r q _ p e r c p u [ c p u ] - > p e n d i n g
2005-04-16 15:20:36 -07:00
WRITE_ P A U S E
or % l 0 , P S R _ P I L , % l 4
wr % l 4 , 0 x0 , % p s r
WRITE_ P A U S E
wr % l 4 , P S R _ E T , % p s r
WRITE_ P A U S E
2011-07-16 10:45:12 -07:00
srl % o 3 , 2 8 , % o 2 ! s h i f t f o r s i m p l e r c h e c k s b e l o w
2011-05-02 00:08:53 +00:00
maybe_smp4m_msg_check_single :
andcc % o 2 , 0 x1 , % g 0
beq,a m a y b e _ s m p4 m _ m s g _ c h e c k _ m a s k
andcc % o 2 , 0 x2 , % g 0
call s m p _ c a l l _ f u n c t i o n _ s i n g l e _ i n t e r r u p t
2005-04-16 15:20:36 -07:00
nop
2011-05-02 00:08:53 +00:00
andcc % o 2 , 0 x2 , % g 0
maybe_smp4m_msg_check_mask :
beq,a m a y b e _ s m p4 m _ m s g _ c h e c k _ r e s c h e d
andcc % o 2 , 0 x4 , % g 0
call s m p _ c a l l _ f u n c t i o n _ i n t e r r u p t
nop
andcc % o 2 , 0 x4 , % g 0
maybe_smp4m_msg_check_resched :
/* rescheduling is done in RESTORE_ALL regardless, but incr stats */
beq,a m a y b e _ s m p4 m _ m s g _ o u t
nop
call s m p _ r e s c h e d _ i n t e r r u p t
nop
maybe_smp4m_msg_out :
2005-04-16 15:20:36 -07:00
RESTORE_ A L L
.align 4
2012-05-11 21:23:05 -07:00
.globl linux_trap_ipi15_sun4m
linux_trap_ipi15_sun4m :
2005-04-16 15:20:36 -07:00
SAVE_ A L L
sethi % h i ( 0 x80 0 0 0 0 0 0 ) , % o 2
GET_ P R O C E S S O R 4 M _ I D ( o 0 )
2008-09-19 21:17:43 -07:00
sethi % h i ( s u n 4 m _ i r q _ p e r c p u ) , % l 5
or % l 5 , % l o ( s u n 4 m _ i r q _ p e r c p u ) , % o 5
sll % o 0 , 2 , % o 0
ld [ % o 5 + % o 0 ] , % o 5
ld [ % o 5 + 0 x00 ] , % o 3 ! s u n 4 m _ i r q _ p e r c p u [ c p u ] - > p e n d i n g
2005-04-16 15:20:36 -07:00
andcc % o 3 , % o 2 , % g 0
2012-05-11 21:23:05 -07:00
be s u n 4 m _ n m i _ e r r o r ! M u s t b e a n N M I a s y n c m e m o r y e r r o r
2008-09-19 21:17:43 -07:00
st % o 2 , [ % o 5 + 0 x04 ] ! s u n 4 m _ i r q _ p e r c p u [ c p u ] - > c l e a r =0x80000000
2005-04-16 15:20:36 -07:00
WRITE_ P A U S E
2008-09-19 21:17:43 -07:00
ld [ % o 5 + 0 x00 ] , % g 0 ! s u n 4 m _ i r q _ p e r c p u [ c p u ] - > p e n d i n g
2005-04-16 15:20:36 -07:00
WRITE_ P A U S E
or % l 0 , P S R _ P I L , % l 4
wr % l 4 , 0 x0 , % p s r
WRITE_ P A U S E
wr % l 4 , P S R _ E T , % p s r
WRITE_ P A U S E
call s m p4 m _ c r o s s _ c a l l _ i r q
nop
b r e t _ t r a p _ l o c k l e s s _ i p i
clr % l 6
.globl smp4d_ticker
/* SMP per-cpu ticker interrupts are handled specially. */
smp4d_ticker :
SAVE_ A L L
or % l 0 , P S R _ P I L , % g 2
sethi % h i ( C C _ I C L R ) , % o 0
sethi % h i ( 1 < < 1 4 ) , % o 1
or % o 0 , % l o ( C C _ I C L R ) , % o 0
stha % o 1 , [ % o 0 ] A S I _ M _ M X C C / * C l e a r P I L 1 4 i n M X C C ' s I C L R * /
wr % g 2 , 0 x0 , % p s r
WRITE_ P A U S E
wr % g 2 , P S R _ E T , % p s r
WRITE_ P A U S E
call s m p4 d _ p e r c p u _ t i m e r _ i n t e r r u p t
add % s p , S T A C K F R A M E _ S Z , % o 0
wr % l 0 , P S R _ E T , % p s r
WRITE_ P A U S E
RESTORE_ A L L
.align 4
.globl linux_trap_ipi15_sun4d
linux_trap_ipi15_sun4d :
SAVE_ A L L
sethi % h i ( C C _ B A S E ) , % o 4
sethi % h i ( M X C C _ E R R _ M E | M X C C _ E R R _ P E W | M X C C _ E R R _ A S E | M X C C _ E R R _ P E E ) , % o 2
or % o 4 , ( C C _ E R E G - C C _ B A S E ) , % o 0
ldda [ % o 0 ] A S I _ M _ M X C C , % o 0
andcc % o 0 , % o 2 , % g 0
bne 1 f
sethi % h i ( B B _ S T A T 2 ) , % o 2
lduba [ % o 2 ] A S I _ M _ C T L , % o 2
andcc % o 2 , B B _ S T A T 2 _ M A S K , % g 0
bne 2 f
or % o 4 , ( C C _ I C L R - C C _ B A S E ) , % o 0
sethi % h i ( 1 < < 1 5 ) , % o 1
stha % o 1 , [ % o 0 ] A S I _ M _ M X C C / * C l e a r P I L 1 5 i n M X C C ' s I C L R * /
or % l 0 , P S R _ P I L , % l 4
wr % l 4 , 0 x0 , % p s r
WRITE_ P A U S E
wr % l 4 , P S R _ E T , % p s r
WRITE_ P A U S E
call s m p4 d _ c r o s s _ c a l l _ i r q
nop
b r e t _ t r a p _ l o c k l e s s _ i p i
clr % l 6
1 : /* MXCC error */
2 : /* BB error */
/* Disable PIL 15 */
set C C _ I M S K , % l 4
lduha [ % l 4 ] A S I _ M _ M X C C , % l 5
sethi % h i ( 1 < < 1 5 ) , % l 7
or % l 5 , % l 7 , % l 5
stha % l 5 , [ % l 4 ] A S I _ M _ M X C C
/* FIXME */
1 : b,a 1 b
2011-05-02 00:08:52 +00:00
.globl smpleon_ipi
.extern leon_ipi_interrupt
/* SMP per-cpu IPI interrupts are handled specially. */
smpleon_ipi :
SAVE_ A L L
or % l 0 , P S R _ P I L , % g 2
wr % g 2 , 0 x0 , % p s r
WRITE_ P A U S E
wr % g 2 , P S R _ E T , % p s r
WRITE_ P A U S E
call l e o n s m p _ i p i _ i n t e r r u p t
add % s p , S T A C K F R A M E _ S Z , % o 1 ! p t _ r e g s
wr % l 0 , P S R _ E T , % p s r
WRITE_ P A U S E
RESTORE_ A L L
2009-08-31 22:08:13 +00:00
.align 4
.globl linux_trap_ipi15_leon
linux_trap_ipi15_leon :
SAVE_ A L L
or % l 0 , P S R _ P I L , % l 4
wr % l 4 , 0 x0 , % p s r
WRITE_ P A U S E
wr % l 4 , P S R _ E T , % p s r
WRITE_ P A U S E
call l e o n _ c r o s s _ c a l l _ i r q
nop
b r e t _ t r a p _ l o c k l e s s _ i p i
clr % l 6
2005-04-16 15:20:36 -07:00
# endif / * C O N F I G _ S M P * /
/ * This r o u t i n e h a n d l e s i l l e g a l i n s t r u c t i o n s a n d p r i v i l e g e d
* instruction a t t e m p t s f r o m u s e r c o d e .
* /
.align 4
.globl bad_instruction
bad_instruction :
sethi % h i ( 0 x c1 f80 0 0 0 ) , % l 4
ld [ % l 1 ] , % l 5
sethi % h i ( 0 x81 d80 0 0 0 ) , % l 7
and % l 5 , % l 4 , % l 5
cmp % l 5 , % l 7
be 1 f
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r ! r e - e n a b l e t r a p s
WRITE_ P A U S E
add % s p , S T A C K F R A M E _ S Z , % o 0
mov % l 1 , % o 1
mov % l 2 , % o 2
call d o _ i l l e g a l _ i n s t r u c t i o n
mov % l 0 , % o 3
RESTORE_ A L L
1 : /* unimplemented flush - just skip */
jmpl % l 2 , % g 0
rett % l 2 + 4
.align 4
.globl priv_instruction
priv_instruction :
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r
WRITE_ P A U S E
add % s p , S T A C K F R A M E _ S Z , % o 0
mov % l 1 , % o 1
mov % l 2 , % o 2
call d o _ p r i v _ i n s t r u c t i o n
mov % l 0 , % o 3
RESTORE_ A L L
/* This routine handles unaligned data accesses. */
.align 4
.globl mna_handler
mna_handler :
andcc % l 0 , P S R _ P S , % g 0
be m n a _ f r o m u s e r
nop
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r
WRITE_ P A U S E
ld [ % l 1 ] , % o 1
call k e r n e l _ u n a l i g n e d _ t r a p
add % s p , S T A C K F R A M E _ S Z , % o 0
RESTORE_ A L L
mna_fromuser :
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r ! r e - e n a b l e t r a p s
WRITE_ P A U S E
ld [ % l 1 ] , % o 1
call u s e r _ u n a l i g n e d _ t r a p
add % s p , S T A C K F R A M E _ S Z , % o 0
RESTORE_ A L L
/* This routine handles floating point disabled traps. */
.align 4
.globl fpd_trap_handler
fpd_trap_handler :
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r ! r e - e n a b l e t r a p s
WRITE_ P A U S E
add % s p , S T A C K F R A M E _ S Z , % o 0
mov % l 1 , % o 1
mov % l 2 , % o 2
call d o _ f p d _ t r a p
mov % l 0 , % o 3
RESTORE_ A L L
/* This routine handles Floating Point Exceptions. */
.align 4
.globl fpe_trap_handler
fpe_trap_handler :
set f p s a v e _ m a g i c , % l 5
cmp % l 1 , % l 5
be 1 f
sethi % h i ( f p s a v e ) , % l 5
or % l 5 , % l o ( f p s a v e ) , % l 5
cmp % l 1 , % l 5
bne 2 f
sethi % h i ( f p s a v e _ c a t c h2 ) , % l 5
or % l 5 , % l o ( f p s a v e _ c a t c h2 ) , % l 5
wr % l 0 , 0 x0 , % p s r
WRITE_ P A U S E
jmp % l 5
rett % l 5 + 4
1 :
sethi % h i ( f p s a v e _ c a t c h ) , % l 5
or % l 5 , % l o ( f p s a v e _ c a t c h ) , % l 5
wr % l 0 , 0 x0 , % p s r
WRITE_ P A U S E
jmp % l 5
rett % l 5 + 4
2 :
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r ! r e - e n a b l e t r a p s
WRITE_ P A U S E
add % s p , S T A C K F R A M E _ S Z , % o 0
mov % l 1 , % o 1
mov % l 2 , % o 2
call d o _ f p e _ t r a p
mov % l 0 , % o 3
RESTORE_ A L L
/* This routine handles Tag Overflow Exceptions. */
.align 4
.globl do_tag_overflow
do_tag_overflow :
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r ! r e - e n a b l e t r a p s
WRITE_ P A U S E
add % s p , S T A C K F R A M E _ S Z , % o 0
mov % l 1 , % o 1
mov % l 2 , % o 2
call h a n d l e _ t a g _ o v e r f l o w
mov % l 0 , % o 3
RESTORE_ A L L
/* This routine handles Watchpoint Exceptions. */
.align 4
.globl do_watchpoint
do_watchpoint :
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r ! r e - e n a b l e t r a p s
WRITE_ P A U S E
add % s p , S T A C K F R A M E _ S Z , % o 0
mov % l 1 , % o 1
mov % l 2 , % o 2
call h a n d l e _ w a t c h p o i n t
mov % l 0 , % o 3
RESTORE_ A L L
/* This routine handles Register Access Exceptions. */
.align 4
.globl do_reg_access
do_reg_access :
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r ! r e - e n a b l e t r a p s
WRITE_ P A U S E
add % s p , S T A C K F R A M E _ S Z , % o 0
mov % l 1 , % o 1
mov % l 2 , % o 2
call h a n d l e _ r e g _ a c c e s s
mov % l 0 , % o 3
RESTORE_ A L L
/* This routine handles Co-Processor Disabled Exceptions. */
.align 4
.globl do_cp_disabled
do_cp_disabled :
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r ! r e - e n a b l e t r a p s
WRITE_ P A U S E
add % s p , S T A C K F R A M E _ S Z , % o 0
mov % l 1 , % o 1
mov % l 2 , % o 2
call h a n d l e _ c p _ d i s a b l e d
mov % l 0 , % o 3
RESTORE_ A L L
/* This routine handles Co-Processor Exceptions. */
.align 4
.globl do_cp_exception
do_cp_exception :
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r ! r e - e n a b l e t r a p s
WRITE_ P A U S E
add % s p , S T A C K F R A M E _ S Z , % o 0
mov % l 1 , % o 1
mov % l 2 , % o 2
call h a n d l e _ c p _ e x c e p t i o n
mov % l 0 , % o 3
RESTORE_ A L L
/* This routine handles Hardware Divide By Zero Exceptions. */
.align 4
.globl do_hw_divzero
do_hw_divzero :
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r ! r e - e n a b l e t r a p s
WRITE_ P A U S E
add % s p , S T A C K F R A M E _ S Z , % o 0
mov % l 1 , % o 1
mov % l 2 , % o 2
call h a n d l e _ h w _ d i v z e r o
mov % l 0 , % o 3
RESTORE_ A L L
.align 4
.globl do_flush_windows
do_flush_windows :
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r
WRITE_ P A U S E
andcc % l 0 , P S R _ P S , % g 0
bne d f w _ k e r n e l
nop
call f l u s h _ u s e r _ w i n d o w s
nop
/* Advance over the trap instruction. */
ld [ % s p + S T A C K F R A M E _ S Z + P T _ N P C ] , % l 1
add % l 1 , 0 x4 , % l 2
st % l 1 , [ % s p + S T A C K F R A M E _ S Z + P T _ P C ]
st % l 2 , [ % s p + S T A C K F R A M E _ S Z + P T _ N P C ]
RESTORE_ A L L
.globl flush_patch_one
/* We get these for debugging routines using __builtin_return_address() */
dfw_kernel :
flush_patch_one :
FLUSH_ A L L _ K E R N E L _ W I N D O W S
/* Advance over the trap instruction. */
ld [ % s p + S T A C K F R A M E _ S Z + P T _ N P C ] , % l 1
add % l 1 , 0 x4 , % l 2
st % l 1 , [ % s p + S T A C K F R A M E _ S Z + P T _ P C ]
st % l 2 , [ % s p + S T A C K F R A M E _ S Z + P T _ N P C ]
RESTORE_ A L L
/ * The g e t c c s o f t w a r e t r a p . T h e u s e r w a n t s t h e c o n d i t i o n c o d e s f r o m
* the % p s r i n r e g i s t e r % g 1 .
* /
.align 4
.globl getcc_trap_handler
getcc_trap_handler :
srl % l 0 , 2 0 , % g 1 ! g i v e u s e r
and % g 1 , 0 x f , % g 1 ! o n l y I C C b i t s i n % p s r
jmp % l 2 ! a d v a n c e o v e r t r a p i n s t r u c t i o n
rett % l 2 + 0 x4 ! l i k e t h i s . . .
/ * The s e t c c s o f t w a r e t r a p . T h e u s e r h a s c o n d i t i o n c o d e s i n % g 1
* that i t w o u l d l i k e p l a c e d i n t h e % p s r . B e c a r e f u l n o t t o f l i p
* any u n i n t e n t i o n a l b i t s !
* /
.align 4
.globl setcc_trap_handler
setcc_trap_handler :
sll % g 1 , 0 x14 , % l 4
set P S R _ I C C , % l 5
andn % l 0 , % l 5 , % l 0 ! c l e a r I C C b i t s i n % p s r
and % l 4 , % l 5 , % l 4 ! c l e a r n o n - I C C b i t s i n u s e r v a l u e
or % l 4 , % l 0 , % l 4 ! o r t h e m i n . . . m i x m i x m i x
wr % l 4 , 0 x0 , % p s r ! s e t n e w % p s r
WRITE_ P A U S E ! T I s c u m b a g s . . .
jmp % l 2 ! a d v a n c e o v e r t r a p i n s t r u c t i o n
rett % l 2 + 0 x4 ! l i k e t h i s . . .
2012-05-11 21:23:05 -07:00
sun4m_nmi_error :
/* NMI async memory error handling. */
sethi % h i ( 0 x80 0 0 0 0 0 0 ) , % l 4
sethi % h i ( s u n 4 m _ i r q _ g l o b a l ) , % o 5
ld [ % o 5 + % l o ( s u n 4 m _ i r q _ g l o b a l ) ] , % l 5
st % l 4 , [ % l 5 + 0 x0 c ] ! s u n 4 m _ i r q _ g l o b a l - > m a s k _ s e t =0x80000000
WRITE_ P A U S E
ld [ % l 5 + 0 x00 ] , % g 0 ! s u n 4 m _ i r q _ g l o b a l - > p e n d i n g
WRITE_ P A U S E
or % l 0 , P S R _ P I L , % l 4
wr % l 4 , 0 x0 , % p s r
WRITE_ P A U S E
wr % l 4 , P S R _ E T , % p s r
WRITE_ P A U S E
call s u n 4 m _ n m i
nop
st % l 4 , [ % l 5 + 0 x08 ] ! s u n 4 m _ i r q _ g l o b a l - > m a s k _ c l e a r =0x80000000
WRITE_ P A U S E
ld [ % l 5 + 0 x00 ] , % g 0 ! s u n 4 m _ i r q _ g l o b a l - > p e n d i n g
WRITE_ P A U S E
RESTORE_ A L L
2012-05-11 11:35:04 +00:00
# ifndef C O N F I G _ S M P
2005-04-16 15:20:36 -07:00
.align 4
2012-05-11 21:23:05 -07:00
.globl linux_trap_ipi15_sun4m
linux_trap_ipi15_sun4m :
2005-04-16 15:20:36 -07:00
SAVE_ A L L
2012-05-11 21:23:05 -07:00
ba s u n 4 m _ n m i _ e r r o r
nop
2012-05-11 11:35:04 +00:00
# endif / * C O N F I G _ S M P * /
2005-04-16 15:20:36 -07:00
.align 4
.globl srmmu_fault
srmmu_fault :
mov 0 x40 0 , % l 5
mov 0 x30 0 , % l 4
2012-05-25 21:20:16 +00:00
LEON_ P I ( l d a [ % l 5 ] A S I _ L E O N _ M M U R E G S , % l 6 ) ! r e a d s f a r f i r s t
SUN_ P I _ ( l d a [ % l 5 ] A S I _ M _ M M U R E G S , % l 6 ) ! r e a d s f a r f i r s t
LEON_ P I ( l d a [ % l 4 ] A S I _ L E O N _ M M U R E G S , % l 5 ) ! r e a d s f s r l a s t
SUN_ P I _ ( l d a [ % l 4 ] A S I _ M _ M M U R E G S , % l 5 ) ! r e a d s f s r l a s t
2005-04-16 15:20:36 -07:00
andn % l 6 , 0 x f f f , % l 6
srl % l 5 , 6 , % l 5 ! a n d e n c o d e a l l i n f o i n t o l 7
and % l 5 , 2 , % l 5
or % l 5 , % l 6 , % l 6
or % l 6 , % l 7 , % l 7 ! l 7 = [ a d d r ,w r i t e ,t x t f a u l t ]
SAVE_ A L L
mov % l 7 , % o 1
mov % l 7 , % o 2
and % o 1 , 1 , % o 1 ! a r g 2 = t e x t _ f a u l t p
mov % l 7 , % o 3
and % o 2 , 2 , % o 2 ! a r g 3 = w r i t e p
andn % o 3 , 0 x f f f , % o 3 ! a r g 4 = f a u l t i n g a d d r e s s
wr % l 0 , P S R _ E T , % p s r
WRITE_ P A U S E
call d o _ s p a r c _ f a u l t
add % s p , S T A C K F R A M E _ S Z , % o 0 ! a r g 1 = p t _ r e g s p t r
RESTORE_ A L L
.align 4
2008-04-20 02:14:23 -07:00
sunos_execv :
2012-09-29 14:49:48 -04:00
.globl sunos_execv
b s y s _ e x e c v e
clr % i 2
2008-04-20 02:14:23 -07:00
2005-04-16 15:20:36 -07:00
.align 4
.globl sys_sigstack
sys_sigstack :
mov % o 7 , % l 5
mov % f p , % o 2
call d o _ s y s _ s i g s t a c k
mov % l 5 , % o 7
.align 4
.globl sys_sigreturn
sys_sigreturn :
call d o _ s i g r e t u r n
add % s p , S T A C K F R A M E _ S Z , % o 0
ld [ % c u r p t r + T I _ F L A G S ] , % l 5
andcc % l 5 , _ T I F _ S Y S C A L L _ T R A C E , % g 0
be 1 f
nop
call s y s c a l l _ t r a c e
2013-07-26 01:17:15 +04:00
mov 1 , % o 1
2005-04-16 15:20:36 -07:00
1 :
/ * We d o n ' t w a n t t o m u c k w i t h u s e r r e g i s t e r s l i k e a
* normal s y s c a l l , j u s t r e t u r n .
* /
RESTORE_ A L L
.align 4
.globl sys_rt_sigreturn
sys_rt_sigreturn :
call d o _ r t _ s i g r e t u r n
add % s p , S T A C K F R A M E _ S Z , % o 0
ld [ % c u r p t r + T I _ F L A G S ] , % l 5
andcc % l 5 , _ T I F _ S Y S C A L L _ T R A C E , % g 0
be 1 f
nop
2008-07-27 03:13:13 -07:00
add % s p , S T A C K F R A M E _ S Z , % o 0
2005-04-16 15:20:36 -07:00
call s y s c a l l _ t r a c e
2008-07-27 03:13:13 -07:00
mov 1 , % o 1
2005-04-16 15:20:36 -07:00
1 :
/* We are returning to a signal handler. */
RESTORE_ A L L
/ * Now t h a t w e h a v e a r e a l s y s _ c l o n e , s y s _ f o r k ( ) i s
* implemented i n t e r m s o f i t . O u r _ r e a l _ i m p l e m e n t a t i o n
* of S u n O S v f o r k ( ) w i l l u s e s y s _ v f o r k ( ) .
*
* XXX T h e s e t h r e e s h o u l d b e c o n s o l i d a t e d i n t o m o s t l y s h a r e d
* XXX c o d e j u s t l i k e o n s p a r c64 . . . - D a v e M
* /
.align 4
.globl sys_ f o r k , f l u s h _ p a t c h _ t w o
sys_fork :
mov % o 7 , % l 5
flush_patch_two :
FLUSH_ A L L _ K E R N E L _ W I N D O W S ;
ld [ % c u r p t r + T I _ T A S K ] , % o 4
rd % p s r , % g 4
WRITE_ P A U S E
rd % w i m , % g 5
WRITE_ P A U S E
std % g 4 , [ % o 4 + A O F F _ t a s k _ t h r e a d + A O F F _ t h r e a d _ f o r k _ k p s r ]
2020-05-12 19:15:26 +02:00
add % s p , S T A C K F R A M E _ S Z , % o 0
call s p a r c _ f o r k
2005-04-16 15:20:36 -07:00
mov % l 5 , % o 7
/* Whee, kernel threads! */
.globl sys_ c l o n e , f l u s h _ p a t c h _ t h r e e
sys_clone :
mov % o 7 , % l 5
flush_patch_three :
FLUSH_ A L L _ K E R N E L _ W I N D O W S ;
ld [ % c u r p t r + T I _ T A S K ] , % o 4
rd % p s r , % g 4
WRITE_ P A U S E
rd % w i m , % g 5
WRITE_ P A U S E
std % g 4 , [ % o 4 + A O F F _ t a s k _ t h r e a d + A O F F _ t h r e a d _ f o r k _ k p s r ]
2020-05-12 19:15:26 +02:00
add % s p , S T A C K F R A M E _ S Z , % o 0
call s p a r c _ c l o n e
2005-04-16 15:20:36 -07:00
mov % l 5 , % o 7
/* Whee, real vfork! */
.globl sys_ v f o r k , f l u s h _ p a t c h _ f o u r
sys_vfork :
flush_patch_four :
FLUSH_ A L L _ K E R N E L _ W I N D O W S ;
ld [ % c u r p t r + T I _ T A S K ] , % o 4
rd % p s r , % g 4
WRITE_ P A U S E
rd % w i m , % g 5
WRITE_ P A U S E
std % g 4 , [ % o 4 + A O F F _ t a s k _ t h r e a d + A O F F _ t h r e a d _ f o r k _ k p s r ]
2020-05-12 19:15:26 +02:00
sethi % h i ( s p a r c _ v f o r k ) , % l 1
jmpl % l 1 + % l o ( s p a r c _ v f o r k ) , % g 0
add % s p , S T A C K F R A M E _ S Z , % o 0
2005-04-16 15:20:36 -07:00
.align 4
linux_sparc_ni_syscall :
sethi % h i ( s y s _ n i _ s y s c a l l ) , % l 7
2012-09-27 08:51:20 -04:00
b d o _ s y s c a l l
2005-04-16 15:20:36 -07:00
or % l 7 , % l o ( s y s _ n i _ s y s c a l l ) , % l 7
linux_syscall_trace :
2008-07-27 03:13:13 -07:00
add % s p , S T A C K F R A M E _ S Z , % o 0
2005-04-16 15:20:36 -07:00
call s y s c a l l _ t r a c e
2008-07-27 03:13:13 -07:00
mov 0 , % o 1
cmp % o 0 , 0
bne 3 f
mov - E N O S Y S , % o 0
2016-01-18 06:32:30 -05:00
/* Syscall tracing can modify the registers. */
ld [ % s p + S T A C K F R A M E _ S Z + P T _ G 1 ] , % g 1
sethi % h i ( s y s _ c a l l _ t a b l e ) , % l 7
ld [ % s p + S T A C K F R A M E _ S Z + P T _ I 0 ] , % i 0
or % l 7 , % l o ( s y s _ c a l l _ t a b l e ) , % l 7
ld [ % s p + S T A C K F R A M E _ S Z + P T _ I 1 ] , % i 1
ld [ % s p + S T A C K F R A M E _ S Z + P T _ I 2 ] , % i 2
ld [ % s p + S T A C K F R A M E _ S Z + P T _ I 3 ] , % i 3
ld [ % s p + S T A C K F R A M E _ S Z + P T _ I 4 ] , % i 4
ld [ % s p + S T A C K F R A M E _ S Z + P T _ I 5 ] , % i 5
cmp % g 1 , N R _ s y s c a l l s
bgeu 3 f
mov - E N O S Y S , % o 0
sll % g 1 , 2 , % l 4
2005-04-16 15:20:36 -07:00
mov % i 0 , % o 0
2016-01-18 06:32:30 -05:00
ld [ % l 7 + % l 4 ] , % l 7
2005-04-16 15:20:36 -07:00
mov % i 1 , % o 1
mov % i 2 , % o 2
mov % i 3 , % o 3
b 2 f
mov % i 4 , % o 4
.globl ret_from_fork
ret_from_fork :
call s c h e d u l e _ t a i l
2011-03-31 00:52:38 -07:00
ld [ % g 3 + T I _ T A S K ] , % o 0
2005-04-16 15:20:36 -07:00
b r e t _ s y s _ c a l l
ld [ % s p + S T A C K F R A M E _ S Z + P T _ I 0 ] , % o 0
2012-09-27 15:21:21 -04:00
.globl ret_from_kernel_thread
ret_from_kernel_thread :
call s c h e d u l e _ t a i l
ld [ % g 3 + T I _ T A S K ] , % o 0
ld [ % s p + S T A C K F R A M E _ S Z + P T _ G 1 ] , % l 0
call % l 0
ld [ % s p + S T A C K F R A M E _ S Z + P T _ G 2 ] , % o 0
2012-09-28 14:20:01 -04:00
rd % p s r , % l 1
ld [ % s p + S T A C K F R A M E _ S Z + P T _ P S R ] , % l 0
andn % l 0 , P S R _ C W P , % l 0
nop
and % l 1 , P S R _ C W P , % l 1
or % l 0 , % l 1 , % l 0
st % l 0 , [ % s p + S T A C K F R A M E _ S Z + P T _ P S R ]
b r e t _ s y s _ c a l l
mov 0 , % o 0
2012-09-27 15:21:21 -04:00
2008-04-20 02:14:23 -07:00
/* Linux native system calls enter here... */
2005-04-16 15:20:36 -07:00
.align 4
.globl linux_sparc_syscall
linux_sparc_syscall :
sparc: Fix debugger syscall restart interactions.
So, forever, we've had this ptrace_signal_deliver implementation
which tries to handle all of the nasties that can occur when the
debugger looks at a process about to take a signal. It's meant
to address all of these issues inside of the kernel so that the
debugger need not be mindful of such things.
Problem is, this doesn't work.
The idea was that we should do the syscall restart business first, so
that the debugger captures that state. Otherwise, if the debugger for
example saves the child's state, makes the child execute something
else, then restores the saved state, we won't handle the syscall
restart properly because we lose the "we're in a syscall" state.
The code here worked for most cases, but if the debugger actually
passes the signal through to the child unaltered, it's possible that
we would do a syscall restart when we shouldn't have.
In particular this breaks the case of debugging a process under a gdb
which is being debugged by yet another gdb. gdb uses sigsuspend
to wait for SIGCHLD of the inferior, but if gdb itself is being
debugged by a top-level gdb we get a ptrace_stop(). The top-level gdb
does a PTRACE_CONT with SIGCHLD to let the inferior gdb see the
signal. But ptrace_signal_deliver() assumed the debugger would cancel
out the signal and therefore did a syscall restart, because the return
error was ERESTARTNOHAND.
Fix this by simply making ptrace_signal_deliver() a nop, and providing
a way for the debugger to control system call restarting properly:
1) Report a "in syscall" software bit in regs->{tstate,psr}.
It is set early on in trap entry to a system call and is fully
visible to the debugger via ptrace() and regsets.
2) Test this bit right before doing a syscall restart. We have
to do a final recheck right after get_signal_to_deliver() in
case the debugger cleared the bit during ptrace_stop().
3) Clear the bit in trap return so we don't accidently try to set
that bit in the real register.
As a result we also get a ptrace_{is,clear}_syscall() for sparc32 just
like sparc64 has.
M68K has this same exact bug, and is now the only other user of the
ptrace_signal_deliver hook. It needs to be fixed in the same exact
way as sparc.
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-05-11 02:07:19 -07:00
sethi % h i ( P S R _ S Y S C A L L ) , % l 4
or % l 0 , % l 4 , % l 0
2005-04-16 15:20:36 -07:00
/* Direct access to user regs, must faster. */
2009-12-11 00:44:47 -08:00
cmp % g 1 , N R _ s y s c a l l s
2005-04-16 15:20:36 -07:00
bgeu l i n u x _ s p a r c _ n i _ s y s c a l l
sll % g 1 , 2 , % l 4
ld [ % l 7 + % l 4 ] , % l 7
2012-09-27 08:51:20 -04:00
do_syscall :
2005-04-16 15:20:36 -07:00
SAVE_ A L L _ H E A D
rd % w i m , % l 3
wr % l 0 , P S R _ E T , % p s r
mov % i 0 , % o 0
mov % i 1 , % o 1
mov % i 2 , % o 2
ld [ % c u r p t r + T I _ F L A G S ] , % l 5
mov % i 3 , % o 3
andcc % l 5 , _ T I F _ S Y S C A L L _ T R A C E , % g 0
mov % i 4 , % o 4
bne l i n u x _ s y s c a l l _ t r a c e
2021-02-04 17:23:41 +01:00
mov % i 0 , % l 6
2005-04-16 15:20:36 -07:00
2 :
call % l 7
mov % i 5 , % o 5
2008-07-27 03:13:13 -07:00
3 :
2005-04-16 15:20:36 -07:00
st % o 0 , [ % s p + S T A C K F R A M E _ S Z + P T _ I 0 ]
ret_sys_call :
2021-02-04 17:23:41 +01:00
ld [ % c u r p t r + T I _ F L A G S ] , % l 5
2005-04-16 15:20:36 -07:00
cmp % o 0 , - E R E S T A R T _ R E S T A R T B L O C K
ld [ % s p + S T A C K F R A M E _ S Z + P T _ P S R ] , % g 3
set P S R _ C , % g 2
bgeu 1 f
2021-02-04 17:23:41 +01:00
andcc % l 5 , _ T I F _ S Y S C A L L _ T R A C E , % g 0
2005-04-16 15:20:36 -07:00
/* System call success, clear Carry condition code. */
andn % g 3 , % g 2 , % g 3
st % g 3 , [ % s p + S T A C K F R A M E _ S Z + P T _ P S R ]
bne l i n u x _ s y s c a l l _ t r a c e 2
ld [ % s p + S T A C K F R A M E _ S Z + P T _ N P C ] , % l 1 / * p c = n p c * /
add % l 1 , 0 x4 , % l 2 / * n p c = n p c + 4 * /
st % l 1 , [ % s p + S T A C K F R A M E _ S Z + P T _ P C ]
b r e t _ t r a p _ e n t r y
st % l 2 , [ % s p + S T A C K F R A M E _ S Z + P T _ N P C ]
1 :
/ * System c a l l f a i l u r e , s e t C a r r y c o n d i t i o n c o d e .
* Also, g e t a b s ( e r r n o ) t o r e t u r n t o t h e p r o c e s s .
* /
sub % g 0 , % o 0 , % o 0
or % g 3 , % g 2 , % g 3
st % o 0 , [ % s p + S T A C K F R A M E _ S Z + P T _ I 0 ]
st % g 3 , [ % s p + S T A C K F R A M E _ S Z + P T _ P S R ]
bne l i n u x _ s y s c a l l _ t r a c e 2
ld [ % s p + S T A C K F R A M E _ S Z + P T _ N P C ] , % l 1 / * p c = n p c * /
add % l 1 , 0 x4 , % l 2 / * n p c = n p c + 4 * /
st % l 1 , [ % s p + S T A C K F R A M E _ S Z + P T _ P C ]
b r e t _ t r a p _ e n t r y
st % l 2 , [ % s p + S T A C K F R A M E _ S Z + P T _ N P C ]
linux_syscall_trace2 :
2008-07-27 03:13:13 -07:00
add % s p , S T A C K F R A M E _ S Z , % o 0
mov 1 , % o 1
2005-04-16 15:20:36 -07:00
call s y s c a l l _ t r a c e
add % l 1 , 0 x4 , % l 2 / * n p c = n p c + 4 * /
st % l 1 , [ % s p + S T A C K F R A M E _ S Z + P T _ P C ]
b r e t _ t r a p _ e n t r y
st % l 2 , [ % s p + S T A C K F R A M E _ S Z + P T _ N P C ]
/ * Saving a n d r e s t o r i n g t h e F P U s t a t e i s b e s t d o n e f r o m l o w l e v e l c o d e .
*
* void f p s a v e ( u n s i g n e d l o n g * f p r e g s , u n s i g n e d l o n g * f s r ,
* void * f p q u e u e , u n s i g n e d l o n g * f p q d e p t h )
* /
.globl fpsave
fpsave :
st % f s r , [ % o 1 ] ! t h i s c a n t r a p o n u s i f f p u i s i n b o g o n s t a t e
ld [ % o 1 ] , % g 1
set 0 x20 0 0 , % g 4
andcc % g 1 , % g 4 , % g 0
be 2 f
mov 0 , % g 2
/* We have an fpqueue to save. */
1 :
std % f q , [ % o 2 ]
fpsave_magic :
st % f s r , [ % o 1 ]
ld [ % o 1 ] , % g 3
andcc % g 3 , % g 4 , % g 0
add % g 2 , 1 , % g 2
bne 1 b
add % o 2 , 8 , % o 2
2 :
st % g 2 , [ % o 3 ]
std % f0 , [ % o 0 + 0 x00 ]
std % f2 , [ % o 0 + 0 x08 ]
std % f4 , [ % o 0 + 0 x10 ]
std % f6 , [ % o 0 + 0 x18 ]
std % f8 , [ % o 0 + 0 x20 ]
std % f10 , [ % o 0 + 0 x28 ]
std % f12 , [ % o 0 + 0 x30 ]
std % f14 , [ % o 0 + 0 x38 ]
std % f16 , [ % o 0 + 0 x40 ]
std % f18 , [ % o 0 + 0 x48 ]
std % f20 , [ % o 0 + 0 x50 ]
std % f22 , [ % o 0 + 0 x58 ]
std % f24 , [ % o 0 + 0 x60 ]
std % f26 , [ % o 0 + 0 x68 ]
std % f28 , [ % o 0 + 0 x70 ]
retl
std % f30 , [ % o 0 + 0 x78 ]
/ * Thanks f o r T h e o D e r a a d t a n d t h e a u t h o r s o f t h e S p r i t e / n e t b s d / o p e n b s d
* code f o r p o i n t i n g o u t t h i s p o s s i b l e d e a d l o c k , w h i l e w e s a v e s t a t e
* above w e c o u l d t r a p o n t h e f s r s t o r e s o o u r l o w l e v e l f p u t r a p
* code h a s t o k n o w h o w t o d e a l w i t h t h i s .
* /
fpsave_catch :
b f p s a v e _ m a g i c + 4
st % f s r , [ % o 1 ]
fpsave_catch2 :
b f p s a v e + 4
st % f s r , [ % o 1 ]
/* void fpload(unsigned long *fpregs, unsigned long *fsr); */
.globl fpload
fpload :
ldd [ % o 0 + 0 x00 ] , % f0
ldd [ % o 0 + 0 x08 ] , % f2
ldd [ % o 0 + 0 x10 ] , % f4
ldd [ % o 0 + 0 x18 ] , % f6
ldd [ % o 0 + 0 x20 ] , % f8
ldd [ % o 0 + 0 x28 ] , % f10
ldd [ % o 0 + 0 x30 ] , % f12
ldd [ % o 0 + 0 x38 ] , % f14
ldd [ % o 0 + 0 x40 ] , % f16
ldd [ % o 0 + 0 x48 ] , % f18
ldd [ % o 0 + 0 x50 ] , % f20
ldd [ % o 0 + 0 x58 ] , % f22
ldd [ % o 0 + 0 x60 ] , % f24
ldd [ % o 0 + 0 x68 ] , % f26
ldd [ % o 0 + 0 x70 ] , % f28
ldd [ % o 0 + 0 x78 ] , % f30
ld [ % o 1 ] , % f s r
retl
nop
/ * _ _ ndelay a n d _ _ u d e l a y t a k e t w o a r g u m e n t s :
* 0 - nsecs o r u s e c s t o d e l a y
* 1 - per_ c p u u d e l a y _ v a l ( l o o p s p e r j i f f y )
*
* Note t h a t n d e l a y g i v e s H Z t i m e s h i g h e r r e s o l u t i o n b u t h a s a 1 0 m s
* limit. u d e l a y c a n h a n d l e u p t o 1 s .
* /
.globl __ndelay
__ndelay :
save % s p , - S T A C K F R A M E _ S Z , % s p
2012-05-15 11:23:01 -07:00
mov % i 0 , % o 0 ! r o u n d m u l t i p l i e r u p s o l a r g e n s o k
mov 0 x1 a e , % o 1 ! 2 * * 3 2 / ( 1 0 0 0 0 0 0 0 0 0 / H Z )
umul % o 0 , % o 1 , % o 0
rd % y , % o 1
mov % i 1 , % o 1 ! u d e l a y _ v a l
umul % o 0 , % o 1 , % o 0
rd % y , % o 1
2005-04-16 15:20:36 -07:00
ba d e l a y _ c o n t i n u e
mov % o 1 , % o 0 ! > > 3 2 l a t e r f o r b e t t e r r e s o l u t i o n
.globl __udelay
__udelay :
save % s p , - S T A C K F R A M E _ S Z , % s p
mov % i 0 , % o 0
2007-07-21 19:17:41 -07:00
sethi % h i ( 0 x10 c7 ) , % o 1 ! r o u n d m u l t i p l i e r u p s o l a r g e u s o k
2012-05-15 11:23:01 -07:00
or % o 1 , % l o ( 0 x10 c7 ) , % o 1 ! 2 * * 3 2 / 1 0 0 0 0 0 0
umul % o 0 , % o 1 , % o 0
rd % y , % o 1
mov % i 1 , % o 1 ! u d e l a y _ v a l
umul % o 0 , % o 1 , % o 0
rd % y , % o 1
2007-07-21 19:17:41 -07:00
sethi % h i ( 0 x02 8 f4 b62 ) , % l 0 ! A d d i n r o u n d i n g c o n s t a n t * 2 * * 3 2 ,
or % g 0 , % l o ( 0 x02 8 f4 b62 ) , % l 0
addcc % o 0 , % l 0 , % o 0 ! 2 * * 3 2 * 0 . 0 0 9 9 9 9
bcs,a 3 f
add % o 1 , 0 x01 , % o 1
3 :
2012-05-15 11:23:01 -07:00
mov H Z , % o 0 ! > > 3 2 e a r l i e r f o r w i d e r r a n g e
umul % o 0 , % o 1 , % o 0
rd % y , % o 1
2005-04-16 15:20:36 -07:00
delay_continue :
cmp % o 0 , 0 x0
1 :
bne 1 b
subcc % o 0 , 1 , % o 0
ret
restore
2016-01-16 21:39:30 -05:00
EXPORT_ S Y M B O L ( _ _ u d e l a y )
EXPORT_ S Y M B O L ( _ _ n d e l a y )
2005-04-16 15:20:36 -07:00
/* Handle a software breakpoint */
/* We have to inform parent that child has stopped */
.align 4
.globl breakpoint_trap
breakpoint_trap :
rd % w i m ,% l 3
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r
WRITE_ P A U S E
st % i 0 , [ % s p + S T A C K F R A M E _ S Z + P T _ G 0 ] ! f o r r e s t a r t i n g s y s c a l l s
call s p a r c _ b r e a k p o i n t
add % s p , S T A C K F R A M E _ S Z , % o 0
RESTORE_ A L L
2008-04-29 02:38:50 -07:00
# ifdef C O N F I G _ K G D B
2016-04-22 19:41:03 +02:00
ENTRY( k g d b _ t r a p _ l o w )
2008-04-29 02:38:50 -07:00
rd % w i m ,% l 3
SAVE_ A L L
wr % l 0 , P S R _ E T , % p s r
WRITE_ P A U S E
2016-04-22 19:41:03 +02:00
mov % l 7 , % o 0 ! t r a p _ l e v e l
2008-04-29 02:38:50 -07:00
call k g d b _ t r a p
2016-04-22 19:41:03 +02:00
add % s p , S T A C K F R A M E _ S Z , % o 1 ! s t r u c t p t _ r e g s * r e g s
2008-04-29 02:38:50 -07:00
RESTORE_ A L L
2016-04-22 19:41:03 +02:00
ENDPROC( k g d b _ t r a p _ l o w )
2008-04-29 02:38:50 -07:00
# endif
2005-04-16 15:20:36 -07:00
.align 4
2008-06-05 11:40:58 -07:00
.globl flush_patch_exception
2005-04-16 15:20:36 -07:00
flush_patch_exception :
FLUSH_ A L L _ K E R N E L _ W I N D O W S ;
ldd [ % o 0 ] , % o 6
jmpl % o 7 + 0 x c , % g 0 ! s e e a s m - s p a r c / p r o c e s s o r . h
mov 1 , % g 1 ! s i g n a l E F A U L T c o n d i t i o n
.align 4
.globl kill_ u s e r _ w i n d o w s , k u w _ p a t c h1 _ 7 w i n
.globl kuw_patch1
kuw_patch1_7win : sll % o 3 , 6 , % o 3
/ * No m a t t e r h o w m u c h o v e r h e a d t h i s r o u t i n e h a s i n t h e w o r s t
2016-03-04 11:21:18 -08:00
* case s c e n a r i o , i t i s s e v e r a l t i m e s b e t t e r t h a n t a k i n g t h e
2005-04-16 15:20:36 -07:00
* traps w i t h t h e o l d m e t h o d o f j u s t d o i n g f l u s h _ u s e r _ w i n d o w s ( ) .
* /
kill_user_windows :
ld [ % g 6 + T I _ U W I N M A S K ] , % o 0 ! g e t c u r r e n t u m a s k
orcc % g 0 , % o 0 , % g 0 ! i f n o b i t s s e t , w e a r e d o n e
be 3 f ! n o t h i n g t o d o
rd % p s r , % o 5 ! m u s t c l e a r i n t e r r u p t s
or % o 5 , P S R _ P I L , % o 4 ! o r e l s e t h a t c o u l d c h a n g e
wr % o 4 , 0 x0 , % p s r ! t h e u w i n m a s k s t a t e
WRITE_ P A U S E ! b u r n t h e m c y c l e s
1 :
ld [ % g 6 + T I _ U W I N M A S K ] , % o 0 ! g e t c o n s i s t e n t s t a t e
orcc % g 0 , % o 0 , % g 0 ! d i d a n i n t e r r u p t c o m e i n ?
be 4 f ! y e p , w e a r e d o n e
rd % w i m , % o 3 ! g e t c u r r e n t w i m
srl % o 3 , 1 , % o 4 ! s i m u l a t e a s a v e
kuw_patch1 :
sll % o 3 , 7 , % o 3 ! c o m p u t e n e x t w i m
or % o 4 , % o 3 , % o 3 ! r e s u l t
andncc % o 0 , % o 3 , % o 0 ! c l e a n t h i s b i t i n u m a s k
bne k u w _ p a t c h1 ! n o t d o n e y e t
srl % o 3 , 1 , % o 4 ! b e g i n a n o t h e r s a v e s i m u l a t i o n
wr % o 3 , 0 x0 , % w i m ! s e t t h e n e w w i m
st % g 0 , [ % g 6 + T I _ U W I N M A S K ] ! c l e a r u w i n m a s k
4 :
wr % o 5 , 0 x0 , % p s r ! r e - e n a b l e i n t e r r u p t s
WRITE_ P A U S E ! b u r n b a b y b u r n
3 :
retl ! r e t u r n
st % g 0 , [ % g 6 + T I _ W _ S A V E D ] ! n o w i n d o w s s a v e d
.align 4
.globl restore_current
restore_current :
LOAD_ C U R R E N T ( g 6 , o 0 )
retl
nop
2011-05-23 21:04:46 +00:00
# ifdef C O N F I G _ P C I C _ P C I
2005-04-16 15:20:36 -07:00
# include < a s m / p c i c . h >
.align 4
.globl linux_trap_ipi15_pcic
linux_trap_ipi15_pcic :
rd % w i m , % l 3
SAVE_ A L L
/ *
* First d e a c t i v a t e N M I
* or w e c a n n o t d r o p E T , c a n n o t g e t w i n d o w s p i l l t r a p s .
* The b u s y l o o p i s n e c e s s a r y b e c a u s e t h e P I O e r r o r
* sometimes d o e s n o t g o a w a y q u i c k l y a n d w e t r a p a g a i n .
* /
sethi % h i ( p c i c _ r e g s ) , % o 1
ld [ % o 1 + % l o ( p c i c _ r e g s ) ] , % o 2
! Get p e n d i n g s t a t u s f o r p r i n t o u t s l a t e r .
ld [ % o 2 + P C I _ S Y S _ I N T _ P E N D I N G ] , % o 0
mov P C I _ S Y S _ I N T _ P E N D I N G _ C L E A R _ A L L , % o 1
stb % o 1 , [ % o 2 + P C I _ S Y S _ I N T _ P E N D I N G _ C L E A R ]
1 :
ld [ % o 2 + P C I _ S Y S _ I N T _ P E N D I N G ] , % o 1
andcc % o 1 , ( ( P C I _ S Y S _ I N T _ P E N D I N G _ P I O | P C I _ S Y S _ I N T _ P E N D I N G _ P C I ) > > 2 4 ) , % g 0
bne 1 b
nop
or % l 0 , P S R _ P I L , % l 4
wr % l 4 , 0 x0 , % p s r
WRITE_ P A U S E
wr % l 4 , P S R _ E T , % p s r
WRITE_ P A U S E
call p c i c _ n m i
add % s p , S T A C K F R A M E _ S Z , % o 1 ! s t r u c t p t _ r e g s * r e g s
RESTORE_ A L L
.globl pcic_nmi_trap_patch
pcic_nmi_trap_patch :
sethi % h i ( l i n u x _ t r a p _ i p i 1 5 _ p c i c ) , % l 3
jmpl % l 3 + % l o ( l i n u x _ t r a p _ i p i 1 5 _ p c i c ) , % g 0
rd % p s r , % l 0
.word 0
2011-05-23 21:04:46 +00:00
# endif / * C O N F I G _ P C I C _ P C I * /
2005-04-16 15:20:36 -07:00
2008-04-29 02:38:50 -07:00
.globl flushw_all
flushw_all :
save % s p , - 0 x40 , % s p
save % s p , - 0 x40 , % s p
save % s p , - 0 x40 , % s p
save % s p , - 0 x40 , % s p
save % s p , - 0 x40 , % s p
save % s p , - 0 x40 , % s p
save % s p , - 0 x40 , % s p
restore
restore
restore
restore
restore
restore
ret
restore
2012-05-13 23:09:04 -07:00
# ifdef C O N F I G _ S M P
ENTRY( h a r d _ s m p _ p r o c e s s o r _ i d )
661 : rd % t b r , % g 1
srl % g 1 , 1 2 , % o 0
and % o 0 , 3 , % o 0
.section .cpuid_patch , " ax"
/* Instruction location. */
.word 661b
/* SUN4D implementation. */
lda [ % g 0 ] A S I _ M _ V I K I N G _ T M P 1 , % o 0
nop
nop
/* LEON implementation. */
rd % a s r17 , % o 0
srl % o 0 , 0 x1 c , % o 0
nop
.previous
retl
nop
ENDPROC( h a r d _ s m p _ p r o c e s s o r _ i d )
# endif
2005-04-16 15:20:36 -07:00
/* End of entry.S */