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 */
2005-04-16 15:20:36 -07:00
/ *
* S3 9 0 l o w - l e v e l e n t r y p o i n t s .
*
2012-07-20 11:15:04 +02:00
* Copyright I B M C o r p . 1 9 9 9 , 2 0 1 2
2005-04-16 15:20:36 -07:00
* Author( s ) : M a r t i n S c h w i d e f s k y ( s c h w i d e f s k y @de.ibm.com),
2006-09-28 16:56:37 +02:00
* Hartmut P e n n e r ( h p @de.ibm.com),
* Denis J o s e p h B a r r o w ( d j b a r r o w @de.ibm.com,barrow_dj@yahoo.com),
2005-04-16 15:20:36 -07:00
* /
2008-02-05 16:50:40 +01:00
# include < l i n u x / i n i t . h >
2011-07-24 10:48:19 +02:00
# include < l i n u x / l i n k a g e . h >
2022-02-28 11:22:12 +01:00
# include < a s m / a s m - e x t a b l e . h >
2018-03-26 15:27:36 +02:00
# include < a s m / a l t e r n a t i v e - a s m . h >
2012-09-05 13:26:11 +02:00
# include < a s m / p r o c e s s o r . h >
2005-04-16 15:20:36 -07:00
# include < a s m / c a c h e . h >
2018-02-19 11:27:09 +01:00
# include < a s m / d w a r f . h >
2005-04-16 15:20:36 -07:00
# include < a s m / e r r n o . h >
# include < a s m / p t r a c e . h >
# include < a s m / t h r e a d _ i n f o . h >
2005-09-09 20:57:26 +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 / u n i s t d . h >
# include < a s m / p a g e . h >
2012-06-04 15:05:43 +02:00
# include < a s m / s i g p . h >
2013-06-27 09:01:09 +02:00
# include < a s m / i r q . h >
s390/kernel: lazy restore fpu registers
Improve the save and restore behavior of FPU register contents to use the
vector extension within the kernel.
The kernel does not use floating-point or vector registers and, therefore,
saving and restoring the FPU register contents are performed for handling
signals or switching processes only. To prepare for using vector
instructions and vector registers within the kernel, enhance the save
behavior and implement a lazy restore at return to user space from a
system call or interrupt.
To implement the lazy restore, the save_fpu_regs() sets a CPU information
flag, CIF_FPU, to indicate that the FPU registers must be restored.
Saving and setting CIF_FPU is performed in an atomic fashion to be
interrupt-safe. When the kernel wants to use the vector extension or
wants to change the FPU register state for a task during signal handling,
the save_fpu_regs() must be called first. The CIF_FPU flag is also set at
process switch. At return to user space, the FPU state is restored. In
particular, the FPU state includes the floating-point or vector register
contents, as well as, vector-enablement and floating-point control. The
FPU state restore and clearing CIF_FPU is also performed in an atomic
fashion.
For KVM, the restore of the FPU register state is performed when restoring
the general-purpose guest registers before the SIE instructions is started.
Because the path towards the SIE instruction is interruptible, the CIF_FPU
flag must be checked again right before going into SIE. If set, the guest
registers must be reloaded again by re-entering the outer SIE loop. This
is the same behavior as if the SIE critical section is interrupted.
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
2015-06-10 12:53:42 +02:00
# include < a s m / v x - i n s n . h >
2015-10-01 17:02:48 +02:00
# include < a s m / s e t u p . h >
# include < a s m / n m i . h >
2016-01-12 13:30:03 -05:00
# include < a s m / e x p o r t . h >
2018-04-20 16:49:46 +02:00
# include < a s m / n o s p e c - i n s n . h >
2005-04-16 15:20:36 -07:00
2011-12-27 11:27:15 +01:00
_ _ PT_ R 0 = _ _ P T _ G P R S
_ _ PT_ R 1 = _ _ P T _ G P R S + 8
_ _ PT_ R 2 = _ _ P T _ G P R S + 1 6
_ _ PT_ R 3 = _ _ P T _ G P R S + 2 4
_ _ PT_ R 4 = _ _ P T _ G P R S + 3 2
_ _ PT_ R 5 = _ _ P T _ G P R S + 4 0
_ _ PT_ R 6 = _ _ P T _ G P R S + 4 8
_ _ PT_ R 7 = _ _ P T _ G P R S + 5 6
_ _ PT_ R 8 = _ _ P T _ G P R S + 6 4
_ _ PT_ R 9 = _ _ P T _ G P R S + 7 2
_ _ PT_ R 1 0 = _ _ P T _ G P R S + 8 0
_ _ PT_ R 1 1 = _ _ P T _ G P R S + 8 8
_ _ PT_ R 1 2 = _ _ P T _ G P R S + 9 6
_ _ PT_ R 1 3 = _ _ P T _ G P R S + 1 0 4
_ _ PT_ R 1 4 = _ _ P T _ G P R S + 1 1 2
_ _ PT_ R 1 5 = _ _ P T _ G P R S + 1 2 0
2005-04-16 15:20:36 -07:00
2016-11-14 14:39:16 +01:00
STACK_ S H I F T = P A G E _ S H I F T + T H R E A D _ S I Z E _ O R D E R
2005-04-16 15:20:36 -07:00
STACK_ S I Z E = 1 < < S T A C K _ S H I F T
2013-04-24 10:20:43 +02:00
STACK_ I N I T = S T A C K _ S I Z E - S T A C K _ F R A M E _ O V E R H E A D - _ _ P T _ S I Z E
2005-04-16 15:20:36 -07:00
2018-03-26 15:23:33 +02:00
_ LPP_ O F F S E T = _ _ L C _ L P P
2021-04-07 09:20:17 +02:00
.macro STBEAR address
ALTERNATIVE " " , " . i n s n s ,0 x b20 1 0 0 0 0 ,\ a d d r e s s " , 1 9 3
.endm
.macro LBEAR address
ALTERNATIVE " " , " . i n s n s ,0 x b20 0 0 0 0 0 ,\ a d d r e s s " , 1 9 3
.endm
.macro LPSWEY address,l p s w e
ALTERNATIVE " b \ l p s w e " , " . i n s n s i y ,0 x e b00 0 0 0 0 0 0 7 1 ,\ a d d r e s s ,0 " , 1 9 3
.endm
.macro MBEAR reg
ALTERNATIVE " " , _ _ s t r i n g i f y ( m v c _ _ P T _ L A S T _ B R E A K ( 8 ,\ r e g ) ,_ _ L C _ L A S T _ B R E A K ) , 1 9 3
.endm
2017-09-12 16:37:33 +02:00
.macro CHECK_STACK savearea
2006-06-29 14:58:05 +02:00
# ifdef C O N F I G _ C H E C K _ S T A C K
2017-09-12 16:37:33 +02:00
tml % r15 ,S T A C K _ S I Z E - C O N F I G _ S T A C K _ G U A R D
2011-12-27 11:27:15 +01:00
lghi % r14 ,\ s a v e a r e a
jz s t a c k _ o v e r f l o w
2006-06-29 14:58:05 +02:00
# endif
.endm
2017-09-12 16:37:33 +02:00
.macro CHECK_VMAP_STACK savearea,o k l a b e l
# ifdef C O N F I G _ V M A P _ S T A C K
lgr % r14 ,% r15
nill % r14 ,0 x10 0 0 0 - S T A C K _ S I Z E
oill % r14 ,S T A C K _ I N I T
clg % r14 ,_ _ L C _ K E R N E L _ S T A C K
je \ o k l a b e l
clg % r14 ,_ _ L C _ A S Y N C _ S T A C K
je \ o k l a b e l
2021-02-03 09:02:51 +01:00
clg % r14 ,_ _ L C _ M C C K _ S T A C K
je \ o k l a b e l
2017-09-12 16:37:33 +02:00
clg % r14 ,_ _ L C _ N O D A T _ S T A C K
je \ o k l a b e l
clg % r14 ,_ _ L C _ R E S T A R T _ S T A C K
je \ o k l a b e l
lghi % r14 ,\ s a v e a r e a
j s t a c k _ o v e r f l o w
# else
j \ o k l a b e l
# endif
.endm
2015-10-01 17:02:48 +02:00
/ *
* The T S T M S K m a c r o g e n e r a t e s a t e s t - u n d e r - m a s k i n s t r u c t i o n b y
* calculating t h e m e m o r y o f f s e t f o r t h e s p e c i f i e d m a s k v a l u e .
* Mask v a l u e c a n b e a n y c o n s t a n t . T h e m a c r o s h i f t s t h e m a s k
* value t o c a l c u l a t e t h e m e m o r y o f f s e t f o r t h e t e s t - u n d e r - m a s k
* instruction.
* /
.macro TSTMSK addr, m a s k , s i z e =8 , b y t e p o s =0
.if ( \ bytepos < \ s i z e ) & & ( \ m a s k > > 8 )
.if ( \ mask & 0 x f f )
.error " Mask e x c e e d s b y t e b o u n d a r y "
.endif
TSTMSK \ a d d r , " ( \ m a s k > > 8 ) " , \ s i z e , " ( \ b y t e p o s + 1 ) "
.exitm
.endif
.ifeq \ mask
.error " Mask m u s t n o t b e z e r o "
.endif
off = \ s i z e - \ b y t e p o s - 1
tm o f f + \ a d d r , \ m a s k
.endm
2018-01-16 07:11:45 +01:00
.macro BPOFF
2022-03-13 22:39:27 +01:00
ALTERNATIVE " " , " . i n s n r r f ,0 x b2 e 8 0 0 0 0 ,0 ,0 ,1 2 ,0 " , 8 2
2018-01-16 07:11:45 +01:00
.endm
.macro BPON
2022-03-13 22:39:27 +01:00
ALTERNATIVE " " , " . i n s n r r f ,0 x b2 e 8 0 0 0 0 ,0 ,0 ,1 3 ,0 " , 8 2
2018-01-16 07:11:45 +01:00
.endm
2018-01-16 07:36:46 +01:00
.macro BPENTER tif_ p t r ,t i f _ m a s k
2022-03-13 22:39:27 +01:00
ALTERNATIVE " T S T M S K \ t i f _ p t r ,\ t i f _ m a s k ; jz .+8; .insn rrf,0xb2e80000,0,0,13,0", \
2018-03-26 15:27:36 +02:00
" " , 8 2
2018-01-16 07:36:46 +01:00
.endm
.macro BPEXIT tif_ p t r ,t i f _ m a s k
TSTMSK \ t i f _ p t r ,\ t i f _ m a s k
2022-03-13 22:39:27 +01:00
ALTERNATIVE " j z . + 8 ; .insn rrf,0xb2e80000,0,0,12,0", \
" jnz . + 8 ; .insn rrf,0xb2e80000,0,0,13,0", 82
2018-01-16 07:36:46 +01:00
.endm
2021-06-18 08:17:16 +02:00
/ *
* The C H K S T G m a c r o j u m p s t o t h e p r o v i d e d l a b e l i n c a s e t h e
* machine c h e c k i n t e r r u p t i o n c o d e r e p o r t s o n e o f u n r e c o v e r a b l e
* storage e r r o r s :
* - Storage e r r o r u n c o r r e c t e d
* - Storage k e y e r r o r u n c o r r e c t e d
* - Storage d e g r a d a t i o n w i t h F a i l i n g - s t o r a g e - a d d r e s s v a l i d i t y
* /
.macro CHKSTG errlabel
TSTMSK _ _ L C _ M C C K _ C O D E ,( M C C K _ C O D E _ S T G _ E R R O R | M C C K _ C O D E _ S T G _ K E Y _ E R R O R )
jnz \ e r r l a b e l
TSTMSK _ _ L C _ M C C K _ C O D E ,M C C K _ C O D E _ S T G _ D E G R A D
2021-08-27 13:45:14 +02:00
jz . L o k l a b e l \ @
2021-06-18 08:17:16 +02:00
TSTMSK _ _ L C _ M C C K _ C O D E ,M C C K _ C O D E _ S T G _ F A I L _ A D D R
jnz \ e r r l a b e l
2021-08-27 13:45:14 +02:00
.Loklabel \ @:
2021-06-18 08:17:16 +02:00
.endm
2021-06-07 12:01:49 +02:00
# if I S _ E N A B L E D ( C O N F I G _ K V M )
/ *
* The O U T S I D E m a c r o j u m p s t o t h e p r o v i d e d l a b e l i n c a s e t h e v a l u e
* in t h e p r o v i d e d r e g i s t e r i s o u t s i d e o f t h e p r o v i d e d r a n g e . T h e
* macro i s u s e f u l f o r c h e c k i n g w h e t h e r a P S W s t o r e d i n a r e g i s t e r
* pair p o i n t s i n s i d e o r o u t s i d e o f a b l o c k o f i n s t r u c t i o n s .
* @reg: register to check
* @start: start of the range
* @end: end of the range
* @outside_label: jump here if @reg is outside of [@start..@end)
* /
.macro OUTSIDE reg,s t a r t ,e n d ,o u t s i d e _ l a b e l
lgr % r14 ,\ r e g
larl % r13 ,\ s t a r t
slgr % r14 ,% r13
lghi % r13 ,\ e n d - \ s t a r t
clgr % r14 ,% r13
jhe \ o u t s i d e _ l a b e l
.endm
2021-06-18 08:17:13 +02:00
.macro SIEEXIT
lg % r9 ,_ _ S F _ S I E _ C O N T R O L ( % r15 ) # g e t c o n t r o l b l o c k p o i n t e r
ni _ _ S I E _ P R O G 0 C + 3 ( % r9 ) ,0 x f e # n o l o n g e r i n S I E
lctlg % c1 ,% c1 ,_ _ L C _ K E R N E L _ A S C E # l o a d p r i m a r y a s c e
larl % r9 ,s i e _ e x i t # s k i p f o r w a r d t o s i e _ e x i t
.endm
2021-06-07 12:01:49 +02:00
# endif
2018-04-20 16:49:46 +02:00
GEN_ B R _ T H U N K % r14
2018-01-26 12:46:47 +01:00
2011-01-05 12:47:25 +01:00
.section .kprobes .text , " ax"
2016-06-30 12:40:25 +02:00
.Ldummy :
/ *
2020-11-21 11:14:56 +01:00
* This n o p e x i s t s o n l y i n o r d e r t o a v o i d t h a t _ _ b p o n s t a r t s a t
2016-06-30 12:40:25 +02:00
* the b e g i n n i n g o f t h e k p r o b e s t e x t s e c t i o n . I n t h a t c a s e w e w o u l d
* have s e v e r a l s y m b o l s a t t h e s a m e a d d r e s s . E . g . o b j d u m p w o u l d t a k e
* an a r b i t r a r y s y m b o l n a m e w h e n d i s a s s e m b l i n g t h i s c o d e .
2020-11-21 11:14:56 +01:00
* With t h e a d d e d n o p i n b e t w e e n t h e _ _ b p o n s y m b o l i s u n i q u e
2016-06-30 12:40:25 +02:00
* again.
* /
nop 0
2011-01-05 12:47:25 +01:00
2018-01-16 07:11:45 +01:00
ENTRY( _ _ b p o n )
.globl __bpon
BPON
2018-04-20 16:49:46 +02:00
BR_ E X % r14
2019-01-17 10:02:22 +01:00
ENDPROC( _ _ b p o n )
2018-01-16 07:11:45 +01:00
2005-04-16 15:20:36 -07:00
/ *
* Scheduler r e s u m e f u n c t i o n , c a l l e d b y s w i t c h _ t o
* gpr2 = ( t a s k _ s t r u c t * ) p r e v
* gpr3 = ( t a s k _ s t r u c t * ) n e x t
* Returns :
* gpr2 = p r e v
* /
2011-07-24 10:48:19 +02:00
ENTRY( _ _ s w i t c h _ t o )
2012-05-15 09:20:06 +02:00
stmg % r6 ,% r15 ,_ _ S F _ G P R S ( % r15 ) # s t o r e g p r s o f p r e v t a s k
2017-11-16 14:54:04 +01:00
lghi % r4 ,_ _ T A S K _ s t a c k
lghi % r1 ,_ _ T A S K _ t h r e a d
2018-10-26 15:29:59 +02:00
llill % r5 ,S T A C K _ I N I T
2017-11-16 14:54:04 +01:00
stg % r15 ,_ _ T H R E A D _ k s p ( % r1 ,% r2 ) # s t o r e k e r n e l s t a c k o f p r e v
2018-10-26 15:29:59 +02:00
lg % r15 ,0 ( % r4 ,% r3 ) # s t a r t o f k e r n e l s t a c k o f n e x t
agr % r15 ,% r5 # e n d o f k e r n e l s t a c k o f n e x t
2012-05-15 09:20:06 +02:00
stg % r3 ,_ _ L C _ C U R R E N T # s t o r e t a s k s t r u c t o f n e x t
stg % r15 ,_ _ L C _ K E R N E L _ S T A C K # s t o r e e n d o f k e r n e l s t a c k
2017-11-16 14:54:04 +01:00
lg % r15 ,_ _ T H R E A D _ k s p ( % r1 ,% r3 ) # l o a d k e r n e l s t a c k o f n e x t
aghi % r3 ,_ _ T A S K _ p i d
mvc _ _ L C _ C U R R E N T _ P I D ( 4 ,% r0 ) ,0 ( % r3 ) # s t o r e p i d o f n e x t
2014-04-15 12:55:07 +02:00
lmg % r6 ,% r15 ,_ _ S F _ G P R S ( % r15 ) # l o a d g p r s o f n e x t t a s k
2022-02-25 10:39:02 +01:00
ALTERNATIVE " " , " l p p _ L P P _ O F F S E T " , 4 0
2018-04-20 16:49:46 +02:00
BR_ E X % r14
2019-01-17 10:02:22 +01:00
ENDPROC( _ _ s w i t c h _ t o )
2005-04-16 15:20:36 -07:00
2015-06-22 17:26:40 +02:00
# if I S _ E N A B L E D ( C O N F I G _ K V M )
/ *
* sie6 4 a c a l l i n g c o n v e n t i o n :
* % r2 p o i n t e r t o s i e c o n t r o l b l o c k
* % r3 g u e s t r e g i s t e r s a v e a r e a
* /
ENTRY( s i e 6 4 a )
stmg % r6 ,% r14 ,_ _ S F _ G P R S ( % r15 ) # s a v e k e r n e l r e g i s t e r s
2018-01-16 07:36:46 +01:00
lg % r12 ,_ _ L C _ C U R R E N T
2018-03-20 13:33:43 +01:00
stg % r2 ,_ _ S F _ S I E _ C O N T R O L ( % r15 ) # s a v e c o n t r o l b l o c k p o i n t e r
stg % r3 ,_ _ S F _ S I E _ S A V E A R E A ( % r15 ) # s a v e g u e s t r e g i s t e r s a v e a r e a
xc _ _ S F _ S I E _ R E A S O N ( 8 ,% r15 ) ,_ _ S F _ S I E _ R E A S O N ( % r15 ) # r e a s o n c o d e = 0
mvc _ _ S F _ S I E _ F L A G S ( 8 ,% r15 ) ,_ _ T I _ f l a g s ( % r12 ) # c o p y t h r e a d f l a g s
2015-06-22 17:26:40 +02:00
lmg % r0 ,% r13 ,0 ( % r3 ) # l o a d g u e s t g p r s 0 - 1 3
lg % r14 ,_ _ L C _ G M A P # g e t g m a p p o i n t e r
ltgr % r14 ,% r14
jz . L s i e _ g m a p
lctlg % c1 ,% c1 ,_ _ G M A P _ A S C E ( % r14 ) # l o a d p r i m a r y a s c e
.Lsie_gmap :
2018-03-20 13:33:43 +01:00
lg % r14 ,_ _ S F _ S I E _ C O N T R O L ( % r15 ) # g e t c o n t r o l b l o c k p o i n t e r
2015-06-22 17:26:40 +02:00
oi _ _ S I E _ P R O G 0 C + 3 ( % r14 ) ,1 # w e a r e g o i n g i n t o S I E n o w
tm _ _ S I E _ P R O G 2 0 + 3 ( % r14 ) ,3 # l a s t e x i t . . .
jnz . L s i e _ s k i p
2015-10-01 17:02:48 +02:00
TSTMSK _ _ L C _ C P U _ F L A G S ,_ C I F _ F P U
2015-06-22 17:26:40 +02:00
jo . L s i e _ s k i p # e x i t i f f p / v x r e g s c h a n g e d
2018-03-20 13:33:43 +01:00
BPEXIT _ _ S F _ S I E _ F L A G S ( % r15 ) ,( _ T I F _ I S O L A T E _ B P | _ T I F _ I S O L A T E _ B P _ G U E S T )
2017-06-07 11:30:42 +02:00
.Lsie_entry :
2015-06-22 17:26:40 +02:00
sie 0 ( % r14 )
2018-01-16 07:11:45 +01:00
BPOFF
2018-03-20 13:33:43 +01:00
BPENTER _ _ S F _ S I E _ F L A G S ( % r15 ) ,( _ T I F _ I S O L A T E _ B P | _ T I F _ I S O L A T E _ B P _ G U E S T )
2015-06-22 17:26:40 +02:00
.Lsie_skip :
ni _ _ S I E _ P R O G 0 C + 3 ( % r14 ) ,0 x f e # n o l o n g e r i n S I E
2020-11-16 08:06:40 +01:00
lctlg % c1 ,% c1 ,_ _ L C _ K E R N E L _ A S C E # l o a d p r i m a r y a s c e
2015-06-22 17:26:40 +02:00
.Lsie_done :
# some p r o g r a m c h e c k s a r e s u p p r e s s i n g . C c o d e ( e . g . d o _ p r o t e c t i o n _ e x c e p t i o n )
2017-05-15 14:11:03 +02:00
# will r e w i n d t h e P S W b y t h e I L C , w h i c h i s o f t e n 4 b y t e s i n c a s e o f S I E . T h e r e
# are s o m e c o r n e r c a s e s ( e . g . r u n t i m e i n s t r u m e n t a t i o n ) w h e r e I L C i s u n p r e d i c t a b l e .
# Other i n s t r u c t i o n s b e t w e e n s i e 6 4 a a n d . L s i e _ d o n e s h o u l d n o t c a u s e p r o g r a m
# interrupts. S o l e t s u s e 3 n o p s a s a l a n d i n g p a d f o r a l l p o s s i b l e r e w i n d s .
.Lrewind_pad6 :
nopr 7
.Lrewind_pad4 :
nopr 7
.Lrewind_pad2 :
nopr 7
2015-06-22 17:26:40 +02:00
.globl sie_exit
sie_exit :
2018-03-20 13:33:43 +01:00
lg % r14 ,_ _ S F _ S I E _ S A V E A R E A ( % r15 ) # l o a d g u e s t r e g i s t e r s a v e a r e a
2015-06-22 17:26:40 +02:00
stmg % r0 ,% r13 ,0 ( % r14 ) # s a v e g u e s t g p r s 0 - 1 3
2018-01-16 13:27:30 +01:00
xgr % r0 ,% r0 # c l e a r g u e s t r e g i s t e r s t o
xgr % r1 ,% r1 # p r e v e n t s p e c u l a t i v e u s e
xgr % r3 ,% r3
xgr % r4 ,% r4
xgr % r5 ,% r5
2015-06-22 17:26:40 +02:00
lmg % r6 ,% r14 ,_ _ S F _ G P R S ( % r15 ) # r e s t o r e k e r n e l r e g i s t e r s
2018-03-20 13:33:43 +01:00
lg % r2 ,_ _ S F _ S I E _ R E A S O N ( % r15 ) # r e t u r n e x i t r e a s o n c o d e
2018-04-20 16:49:46 +02:00
BR_ E X % r14
2015-06-22 17:26:40 +02:00
.Lsie_fault :
lghi % r14 ,- E F A U L T
2018-03-20 13:33:43 +01:00
stg % r14 ,_ _ S F _ S I E _ R E A S O N ( % r15 ) # s e t e x i t r e a s o n c o d e
2015-06-22 17:26:40 +02:00
j s i e _ e x i t
2017-05-15 14:11:03 +02:00
EX_ T A B L E ( . L r e w i n d _ p a d6 ,. L s i e _ f a u l t )
EX_ T A B L E ( . L r e w i n d _ p a d4 ,. L s i e _ f a u l t )
EX_ T A B L E ( . L r e w i n d _ p a d2 ,. L s i e _ f a u l t )
2015-06-22 17:26:40 +02:00
EX_ T A B L E ( s i e _ e x i t ,. L s i e _ f a u l t )
2019-01-17 10:02:22 +01:00
ENDPROC( s i e 6 4 a )
2016-01-12 13:30:03 -05:00
EXPORT_ S Y M B O L ( s i e 6 4 a )
EXPORT_ S Y M B O L ( s i e _ e x i t )
2015-06-22 17:26:40 +02:00
# endif
2005-04-16 15:20:36 -07:00
/ *
* SVC i n t e r r u p t h a n d l e r r o u t i n e . S y s t e m c a l l s a r e s y n c h r o n o u s e v e n t s a n d
2020-07-07 14:07:53 +02:00
* are e n t e r e d w i t h i n t e r r u p t s d i s a b l e d .
2005-04-16 15:20:36 -07:00
* /
2011-07-24 10:48:19 +02:00
ENTRY( s y s t e m _ c a l l )
2020-11-21 11:14:56 +01:00
stpt _ _ L C _ S Y S _ E N T E R _ T I M E R
2011-12-27 11:27:15 +01:00
stmg % r8 ,% r15 ,_ _ L C _ S A V E _ A R E A _ S Y N C
2018-01-16 07:11:45 +01:00
BPOFF
2020-11-21 11:14:56 +01:00
lghi % r14 ,0
2014-12-03 17:00:08 +01:00
.Lsysc_per :
2021-04-07 09:20:17 +02:00
STBEAR _ _ L C _ L A S T _ B R E A K
2020-11-16 08:06:40 +01:00
lctlg % c1 ,% c1 ,_ _ L C _ K E R N E L _ A S C E
2020-11-21 11:14:56 +01:00
lg % r12 ,_ _ L C _ C U R R E N T
2011-12-27 11:27:15 +01:00
lg % r15 ,_ _ L C _ K E R N E L _ S T A C K
2020-12-04 17:56:57 +01:00
xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 )
2020-11-21 11:14:56 +01:00
stmg % r0 ,% r7 ,S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ R 0 ( % r15 )
BPENTER _ _ T I _ f l a g s ( % r12 ) ,_ T I F _ I S O L A T E _ B P
2018-03-05 19:18:47 +00:00
# clear u s e r c o n t r o l l e d r e g i s t e r t o p r e v e n t s p e c u l a t i v e u s e
xgr % r0 ,% r0
2020-11-21 11:14:56 +01:00
xgr % r1 ,% r1
xgr % r4 ,% r4
xgr % r5 ,% r5
xgr % r6 ,% r6
xgr % r7 ,% r7
xgr % r8 ,% r8
xgr % r9 ,% r9
xgr % r10 ,% r10
xgr % r11 ,% r11
la % r2 ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 ) # p o i n t e r t o p t _ r e g s
2021-05-05 22:01:09 +02:00
mvc _ _ P T _ R 8 ( 6 4 ,% r2 ) ,_ _ L C _ S A V E _ A R E A _ S Y N C
2021-04-07 09:20:17 +02:00
MBEAR % r2
2020-11-21 11:14:56 +01:00
lgr % r3 ,% r14
brasl % r14 ,_ _ d o _ s y s c a l l
2020-11-16 08:06:40 +01:00
lctlg % c1 ,% c1 ,_ _ L C _ U S E R _ A S C E
2020-11-21 11:14:56 +01:00
mvc _ _ L C _ R E T U R N _ P S W ( 1 6 ) ,S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ P S W ( % r15 )
BPEXIT _ _ T I _ f l a g s ( % r12 ) ,_ T I F _ I S O L A T E _ B P
2021-04-07 09:20:17 +02:00
LBEAR S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ L A S T _ B R E A K ( % r15 )
2020-11-21 11:14:56 +01:00
lmg % r0 ,% r15 ,S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ R 0 ( % r15 )
2011-12-27 11:27:15 +01:00
stpt _ _ L C _ E X I T _ T I M E R
2021-04-07 09:20:17 +02:00
LPSWEY _ _ L C _ R E T U R N _ P S W ,_ _ L C _ R E T U R N _ L P S W E
2019-01-17 10:02:22 +01:00
ENDPROC( s y s t e m _ c a l l )
2005-04-16 15:20:36 -07:00
#
# a n e w p r o c e s s e x i t s t h e k e r n e l w i t h r e t _ f r o m _ f o r k
#
2011-07-24 10:48:19 +02:00
ENTRY( r e t _ f r o m _ f o r k )
2020-11-21 11:14:56 +01:00
lgr % r3 ,% r11
brasl % r14 ,_ _ r e t _ f r o m _ f o r k
lctlg % c1 ,% c1 ,_ _ L C _ U S E R _ A S C E
mvc _ _ L C _ R E T U R N _ P S W ( 1 6 ) ,S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ P S W ( % r15 )
BPEXIT _ _ T I _ f l a g s ( % r12 ) ,_ T I F _ I S O L A T E _ B P
2021-04-07 09:20:17 +02:00
LBEAR S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ L A S T _ B R E A K ( % r15 )
2020-11-21 11:14:56 +01:00
lmg % r0 ,% r15 ,S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ R 0 ( % r15 )
stpt _ _ L C _ E X I T _ T I M E R
2021-04-07 09:20:17 +02:00
LPSWEY _ _ L C _ R E T U R N _ P S W ,_ _ L C _ R E T U R N _ L P S W E
2019-01-17 10:02:22 +01:00
ENDPROC( r e t _ f r o m _ f o r k )
2005-04-16 15:20:36 -07:00
/ *
* Program c h e c k h a n d l e r r o u t i n e
* /
2011-07-24 10:48:19 +02:00
ENTRY( p g m _ c h e c k _ h a n d l e r )
2020-11-21 11:14:56 +01:00
stpt _ _ L C _ S Y S _ E N T E R _ T I M E R
2018-01-16 07:11:45 +01:00
BPOFF
2011-12-27 11:27:15 +01:00
stmg % r8 ,% r15 ,_ _ L C _ S A V E _ A R E A _ S Y N C
2020-11-21 11:14:56 +01:00
lg % r12 ,_ _ L C _ C U R R E N T
lghi % r10 ,0
2011-12-27 11:27:15 +01:00
lmg % r8 ,% r9 ,_ _ L C _ P G M _ O L D _ P S W
2020-11-16 08:06:40 +01:00
tmhh % r8 ,0 x00 0 1 # c o m i n g f r o m u s e r s p a c e ?
jno . L p g m _ s k i p _ a s c e
lctlg % c1 ,% c1 ,_ _ L C _ K E R N E L _ A S C E
2020-11-21 11:14:56 +01:00
j 3 f # - > f a u l t i n u s e r s p a c e
2020-11-16 08:06:40 +01:00
.Lpgm_skip_asce :
2015-06-22 17:26:40 +02:00
# if I S _ E N A B L E D ( C O N F I G _ K V M )
2017-10-05 08:29:47 +02:00
# cleanup c r i t i c a l s e c t i o n f o r p r o g r a m c h e c k s i n s i e 6 4 a
2021-06-07 12:01:49 +02:00
OUTSIDE % r9 ,. L s i e _ g m a p ,. L s i e _ d o n e ,1 f
2021-06-18 08:17:13 +02:00
SIEEXIT
2020-11-21 11:14:56 +01:00
lghi % r10 ,_ P I F _ G U E S T _ F A U L T
2015-06-22 17:26:40 +02:00
# endif
2020-01-22 13:38:22 +01:00
1 : tmhh % r8 ,0 x40 0 0 # P E R b i t s e t i n o l d P S W ?
jnz 2 f # - > e n a b l e d , c a n ' t b e a d o u b l e f a u l t
2011-12-27 11:27:15 +01:00
tm _ _ L C _ P G M _ I L C + 3 ,0 x80 # c h e c k f o r p e r e x c e p t i o n
2014-12-03 17:00:08 +01:00
jnz . L p g m _ s v c p e r # - > s i n g l e s t e p p e d s v c
2020-01-22 13:38:22 +01:00
2 : CHECK_ S T A C K _ _ L C _ S A V E _ A R E A _ S Y N C
2013-04-24 10:20:43 +02:00
aghi % r15 ,- ( S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ S I Z E )
2020-11-21 11:14:56 +01:00
# CHECK_ V M A P _ S T A C K b r a n c h e s t o s t a c k _ o v e r f l o w o r 4 f
CHECK_ V M A P _ S T A C K _ _ L C _ S A V E _ A R E A _ S Y N C ,4 f
3 : BPENTER _ _ T I _ f l a g s ( % r12 ) ,_ T I F _ I S O L A T E _ B P
2011-12-27 11:27:15 +01:00
lg % r15 ,_ _ L C _ K E R N E L _ S T A C K
2020-11-21 11:14:56 +01:00
4 : la % r11 ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 )
stg % r10 ,_ _ P T _ F L A G S ( % r11 )
xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 )
2011-12-27 11:27:15 +01:00
stmg % r0 ,% r7 ,_ _ P T _ R 0 ( % r11 )
2020-11-21 11:14:56 +01:00
mvc _ _ P T _ R 8 ( 6 4 ,% r11 ) ,_ _ L C _ S A V E _ A R E A _ S Y N C
2021-04-07 09:20:17 +02:00
mvc _ _ P T _ L A S T _ B R E A K ( 8 ,% r11 ) ,_ _ L C _ P G M _ L A S T _ B R E A K
2020-11-21 11:14:56 +01:00
stmg % r8 ,% r9 ,_ _ P T _ P S W ( % r11 )
2018-01-16 13:27:30 +01:00
# clear u s e r c o n t r o l l e d r e g i s t e r s t o p r e v e n t s p e c u l a t i v e u s e
xgr % r0 ,% r0
xgr % r1 ,% r1
xgr % r3 ,% r3
xgr % r4 ,% r4
xgr % r5 ,% r5
xgr % r6 ,% r6
xgr % r7 ,% r7
2020-11-21 11:14:56 +01:00
lgr % r2 ,% r11
brasl % r14 ,_ _ d o _ p g m _ c h e c k
tmhh % r8 ,0 x00 0 1 # r e t u r n i n g t o u s e r s p a c e ?
jno . L p g m _ e x i t _ k e r n e l
lctlg % c1 ,% c1 ,_ _ L C _ U S E R _ A S C E
BPEXIT _ _ T I _ f l a g s ( % r12 ) ,_ T I F _ I S O L A T E _ B P
2020-11-11 18:46:26 +01:00
stpt _ _ L C _ E X I T _ T I M E R
2020-11-21 11:14:56 +01:00
.Lpgm_exit_kernel :
mvc _ _ L C _ R E T U R N _ P S W ( 1 6 ) ,S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ P S W ( % r15 )
2021-04-07 09:20:17 +02:00
LBEAR S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ L A S T _ B R E A K ( % r15 )
2020-11-21 11:14:56 +01:00
lmg % r0 ,% r15 ,S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ R 0 ( % r15 )
2021-04-07 09:20:17 +02:00
LPSWEY _ _ L C _ R E T U R N _ P S W ,_ _ L C _ R E T U R N _ L P S W E
2005-04-16 15:20:36 -07:00
2006-09-20 15:58:39 +02:00
#
2011-12-27 11:27:15 +01:00
# single s t e p p e d s y s t e m c a l l
2006-09-20 15:58:39 +02:00
#
2014-12-03 17:00:08 +01:00
.Lpgm_svcper :
2011-12-27 11:27:15 +01:00
mvc _ _ L C _ R E T U R N _ P S W ( 8 ) ,_ _ L C _ S V C _ N E W _ P S W
2014-12-03 17:00:08 +01:00
larl % r14 ,. L s y s c _ p e r
2011-12-27 11:27:15 +01:00
stg % r14 ,_ _ L C _ R E T U R N _ P S W + 8
2020-11-21 11:14:56 +01:00
lghi % r14 ,1
2021-04-07 09:20:17 +02:00
LBEAR _ _ L C _ P G M _ L A S T _ B R E A K
LPSWEY _ _ L C _ R E T U R N _ P S W ,_ _ L C _ R E T U R N _ L P S W E # b r a n c h t o . L s y s c _ p e r
2019-01-17 10:02:22 +01:00
ENDPROC( p g m _ c h e c k _ h a n d l e r )
2006-09-20 15:58:39 +02:00
2005-04-16 15:20:36 -07:00
/ *
2020-11-21 11:14:56 +01:00
* Interrupt h a n d l e r m a c r o u s e d f o r e x t e r n a l a n d I O i n t e r r u p t s .
2005-04-16 15:20:36 -07:00
* /
2020-11-21 11:14:56 +01:00
.macro INT_HANDLER name,l c _ o l d _ p s w ,h a n d l e r
ENTRY( \ n a m e )
2022-02-25 10:38:23 +01:00
stckf _ _ L C _ I N T _ C L O C K
2020-11-21 11:14:56 +01:00
stpt _ _ L C _ S Y S _ E N T E R _ T I M E R
2021-04-07 09:20:17 +02:00
STBEAR _ _ L C _ L A S T _ B R E A K
2018-01-16 07:11:45 +01:00
BPOFF
2011-12-27 11:27:15 +01:00
stmg % r8 ,% r15 ,_ _ L C _ S A V E _ A R E A _ A S Y N C
2016-11-08 11:08:26 +01:00
lg % r12 ,_ _ L C _ C U R R E N T
2020-11-21 11:14:56 +01:00
lmg % r8 ,% r9 ,\ l c _ o l d _ p s w
2021-01-28 13:06:05 +01:00
tmhh % r8 ,0 x00 0 1 # i n t e r r u p t i n g f r o m u s e r ?
jnz 1 f
# if I S _ E N A B L E D ( C O N F I G _ K V M )
2021-06-07 12:01:49 +02:00
OUTSIDE % r9 ,. L s i e _ g m a p ,. L s i e _ d o n e ,0 f
2021-06-18 08:17:13 +02:00
BPENTER _ _ S F _ S I E _ F L A G S ( % r15 ) ,( _ T I F _ I S O L A T E _ B P | _ T I F _ I S O L A T E _ B P _ G U E S T )
SIEEXIT
2021-01-28 13:06:05 +01:00
# endif
0 : CHECK_ S T A C K _ _ L C _ S A V E _ A R E A _ A S Y N C
aghi % r15 ,- ( S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ S I Z E )
j 2 f
1 : BPENTER _ _ T I _ f l a g s ( % r12 ) ,_ T I F _ I S O L A T E _ B P
lctlg % c1 ,% c1 ,_ _ L C _ K E R N E L _ A S C E
lg % r15 ,_ _ L C _ K E R N E L _ S T A C K
2021-04-09 00:13:18 +02:00
2 : xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 )
la % r11 ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 )
2011-12-27 11:27:15 +01:00
stmg % r0 ,% r7 ,_ _ P T _ R 0 ( % r11 )
2018-01-16 13:27:30 +01:00
# clear u s e r c o n t r o l l e d r e g i s t e r s t o p r e v e n t s p e c u l a t i v e u s e
xgr % r0 ,% r0
xgr % r1 ,% r1
xgr % r3 ,% r3
xgr % r4 ,% r4
xgr % r5 ,% r5
xgr % r6 ,% r6
xgr % r7 ,% r7
xgr % r10 ,% r10
2021-06-11 16:08:18 +02:00
xc _ _ P T _ F L A G S ( 8 ,% r11 ) ,_ _ P T _ F L A G S ( % r11 )
2011-12-27 11:27:15 +01:00
mvc _ _ P T _ R 8 ( 6 4 ,% r11 ) ,_ _ L C _ S A V E _ A R E A _ A S Y N C
2021-04-07 09:20:17 +02:00
MBEAR % r11
2011-12-27 11:27:15 +01:00
stmg % r8 ,% r9 ,_ _ P T _ P S W ( % r11 )
2022-05-03 14:59:16 +02:00
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
2020-11-21 11:14:56 +01:00
brasl % r14 ,\ h a n d l e r
2011-12-27 11:27:15 +01:00
mvc _ _ L C _ R E T U R N _ P S W ( 1 6 ) ,_ _ P T _ P S W ( % r11 )
2020-11-21 11:14:56 +01:00
tmhh % r8 ,0 x00 0 1 # r e t u r n i n g t o u s e r ?
jno 2 f
2020-11-16 08:06:40 +01:00
lctlg % c1 ,% c1 ,_ _ L C _ U S E R _ A S C E
2018-01-16 07:36:46 +01:00
BPEXIT _ _ T I _ f l a g s ( % r12 ) ,_ T I F _ I S O L A T E _ B P
2011-12-27 11:27:15 +01:00
stpt _ _ L C _ E X I T _ T I M E R
2021-04-07 09:20:17 +02:00
2 : LBEAR _ _ P T _ L A S T _ B R E A K ( % r11 )
lmg % r0 ,% r15 ,_ _ P T _ R 0 ( % r11 )
LPSWEY _ _ L C _ R E T U R N _ P S W ,_ _ L C _ R E T U R N _ L P S W E
2020-11-21 11:14:56 +01:00
ENDPROC( \ n a m e )
.endm
2016-01-26 14:10:34 +01:00
2020-11-21 11:14:56 +01:00
INT_ H A N D L E R e x t _ i n t _ h a n d l e r ,_ _ L C _ E X T _ O L D _ P S W ,d o _ e x t _ i r q
INT_ H A N D L E R i o _ i n t _ h a n d l e r ,_ _ L C _ I O _ O L D _ P S W ,d o _ i o _ i r q
2005-04-16 15:20:36 -07:00
2012-03-11 11:59:27 -04:00
/ *
2020-02-20 12:09:36 +01:00
* Load i d l e P S W .
2012-03-11 11:59:27 -04:00
* /
ENTRY( p s w _ i d l e )
2021-04-09 00:15:21 +02:00
stg % r14 ,( _ _ S F _ G P R S + 8 * 8 ) ( % r15 )
2012-07-20 11:15:08 +02:00
stg % r3 ,_ _ S F _ E M P T Y ( % r15 )
2020-11-21 11:14:56 +01:00
larl % r1 ,p s w _ i d l e _ e x i t
2012-03-11 11:59:27 -04:00
stg % r1 ,_ _ S F _ E M P T Y + 8 ( % r15 )
2015-09-18 16:41:36 +02:00
larl % r1 ,s m p _ c p u _ m t i d
llgf % r1 ,0 ( % r1 )
ltgr % r1 ,% r1
jz . L p s w _ i d l e _ s t c c t m
2020-11-21 11:14:56 +01:00
.insn rsy,0 x e b00 0 0 0 0 0 0 1 7 ,% r1 ,5 ,_ _ M T _ C Y C L E S _ E N T E R ( % r2 )
2015-09-18 16:41:36 +02:00
.Lpsw_idle_stcctm :
2015-11-19 11:09:45 +01:00
oi _ _ L C _ C P U _ F L A G S + 7 ,_ C I F _ E N A B L E D _ W A I T
2018-01-16 07:11:45 +01:00
BPON
2022-02-25 10:38:23 +01:00
stckf _ _ C L O C K _ I D L E _ E N T E R ( % r2 )
2012-07-20 11:15:08 +02:00
stpt _ _ T I M E R _ I D L E _ E N T E R ( % r2 )
2012-03-11 11:59:27 -04:00
lpswe _ _ S F _ E M P T Y ( % r15 )
2020-11-21 11:14:56 +01:00
.globl psw_idle_exit
psw_idle_exit :
2018-04-20 16:49:46 +02:00
BR_ E X % r14
2019-01-17 10:02:22 +01:00
ENDPROC( p s w _ i d l e )
2012-03-11 11:59:27 -04:00
2005-04-16 15:20:36 -07:00
/ *
* Machine c h e c k h a n d l e r r o u t i n e s
* /
2011-07-24 10:48:19 +02:00
ENTRY( m c c k _ i n t _ h a n d l e r )
2022-02-25 10:38:23 +01:00
stckf _ _ L C _ M C C K _ C L O C K
2018-01-16 07:11:45 +01:00
BPOFF
2017-10-12 13:24:48 +02:00
la % r1 ,4 0 9 5 # v a l i d a t e r 1
spt _ _ L C _ C P U _ T I M E R _ S A V E _ A R E A - 4 0 9 5 ( % r1 ) # v a l i d a t e c p u t i m e r
2021-04-07 09:20:17 +02:00
LBEAR _ _ L C _ L A S T _ B R E A K _ S A V E _ A R E A - 4 0 9 5 ( % r1 ) # v a l i d a t e b e a r
2017-10-12 13:24:48 +02:00
lmg % r0 ,% r15 ,_ _ L C _ G P R E G S _ S A V E _ A R E A - 4 0 9 5 ( % r1 ) # v a l i d a t e g p r s
2016-11-08 11:08:26 +01:00
lg % r12 ,_ _ L C _ C U R R E N T
2011-12-27 11:27:15 +01:00
lmg % r8 ,% r9 ,_ _ L C _ M C K _ O L D _ P S W
2015-10-01 17:02:48 +02:00
TSTMSK _ _ L C _ M C C K _ C O D E ,M C C K _ C O D E _ S Y S T E M _ D A M A G E
2014-12-03 17:00:08 +01:00
jo . L m c c k _ p a n i c # y e s - > r e s t o f m c c k c o d e i n v a l i d
2017-10-12 13:24:48 +02:00
TSTMSK _ _ L C _ M C C K _ C O D E ,M C C K _ C O D E _ C R _ V A L I D
jno . L m c c k _ p a n i c # c o n t r o l r e g i s t e r s i n v a l i d - > p a n i c
la % r14 ,4 0 9 5
lctlg % c0 ,% c15 ,_ _ L C _ C R E G S _ S A V E _ A R E A - 4 0 9 5 ( % r14 ) # v a l i d a t e c t l r e g s
ptlb
2021-06-18 08:17:18 +02:00
lghi % r14 ,_ _ L C _ C P U _ T I M E R _ S A V E _ A R E A
2011-12-27 11:27:15 +01:00
mvc _ _ L C _ M C C K _ E N T E R _ T I M E R ( 8 ) ,0 ( % r14 )
2015-10-01 17:02:48 +02:00
TSTMSK _ _ L C _ M C C K _ C O D E ,M C C K _ C O D E _ C P U _ T I M E R _ V A L I D
2011-12-27 11:27:15 +01:00
jo 3 f
2020-11-21 11:14:56 +01:00
la % r14 ,_ _ L C _ S Y S _ E N T E R _ T I M E R
clc 0 ( 8 ,% r14 ) ,_ _ L C _ E X I T _ T I M E R
2011-12-27 11:27:15 +01:00
jl 1 f
2006-06-29 14:58:05 +02:00
la % r14 ,_ _ L C _ E X I T _ T I M E R
2011-12-27 11:27:15 +01:00
1 : clc 0 ( 8 ,% r14 ) ,_ _ L C _ L A S T _ U P D A T E _ T I M E R
jl 2 f
2006-06-29 14:58:05 +02:00
la % r14 ,_ _ L C _ L A S T _ U P D A T E _ T I M E R
2011-12-27 11:27:15 +01:00
2 : spt 0 ( % r14 )
2010-05-17 10:00:03 +02:00
mvc _ _ L C _ M C C K _ E N T E R _ T I M E R ( 8 ) ,0 ( % r14 )
2017-10-12 13:24:48 +02:00
3 : TSTMSK _ _ L C _ M C C K _ C O D E ,M C C K _ C O D E _ P S W _ M W P _ V A L I D
jno . L m c c k _ p a n i c
tmhh % r8 ,0 x00 0 1 # i n t e r r u p t i n g f r o m u s e r ?
2021-06-18 08:17:16 +02:00
jnz 6 f
2017-10-12 13:24:48 +02:00
TSTMSK _ _ L C _ M C C K _ C O D E ,M C C K _ C O D E _ P S W _ I A _ V A L I D
jno . L m c c k _ p a n i c
2021-01-28 13:06:05 +01:00
# if I S _ E N A B L E D ( C O N F I G _ K V M )
2021-06-18 08:17:16 +02:00
OUTSIDE % r9 ,. L s i e _ g m a p ,. L s i e _ d o n e ,6 f
OUTSIDE % r9 ,. L s i e _ e n t r y ,. L s i e _ s k i p ,4 f
2021-05-17 08:18:13 +02:00
oi _ _ L C _ C P U _ F L A G S + 7 , _ C I F _ M C C K _ G U E S T
2021-06-18 08:17:16 +02:00
j 5 f
4 : CHKSTG . L m c c k _ p a n i c
5 : larl % r14 ,. L s t o s m _ t m p
stosm 0 ( % r14 ) ,0 x04 # t u r n d a t o n , k e e p i r q s o f f
BPENTER _ _ S F _ S I E _ F L A G S ( % r15 ) ,( _ T I F _ I S O L A T E _ B P | _ T I F _ I S O L A T E _ B P _ G U E S T )
2021-06-18 08:17:13 +02:00
SIEEXIT
2021-02-03 09:02:51 +01:00
j . L m c c k _ s t a c k
2021-06-22 19:06:18 +02:00
# endif
2021-06-18 08:17:16 +02:00
6 : CHKSTG . L m c c k _ p a n i c
larl % r14 ,. L s t o s m _ t m p
stosm 0 ( % r14 ) ,0 x04 # t u r n d a t o n , k e e p i r q s o f f
tmhh % r8 ,0 x00 0 1 # i n t e r r u p t i n g f r o m u s e r ?
jz . L m c c k _ s t a c k
2021-01-28 13:06:05 +01:00
BPENTER _ _ T I _ f l a g s ( % r12 ) ,_ T I F _ I S O L A T E _ B P
2021-02-03 09:02:51 +01:00
.Lmcck_stack :
lg % r15 ,_ _ L C _ M C C K _ S T A C K
la % r11 ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 )
2021-02-03 09:16:45 +01:00
stctg % c1 ,% c1 ,_ _ P T _ C R 1 ( % r11 )
2021-01-28 13:06:05 +01:00
lctlg % c1 ,% c1 ,_ _ L C _ K E R N E L _ A S C E
xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 )
2013-02-28 16:28:41 +01:00
lghi % r14 ,_ _ L C _ G P R E G S _ S A V E _ A R E A + 6 4
stmg % r0 ,% r7 ,_ _ P T _ R 0 ( % r11 )
2018-01-16 13:27:30 +01:00
# clear u s e r c o n t r o l l e d r e g i s t e r s t o p r e v e n t s p e c u l a t i v e u s e
xgr % r0 ,% r0
xgr % r1 ,% r1
xgr % r3 ,% r3
xgr % r4 ,% r4
xgr % r5 ,% r5
xgr % r6 ,% r6
xgr % r7 ,% r7
xgr % r10 ,% r10
2013-02-28 16:28:41 +01:00
mvc _ _ P T _ R 8 ( 6 4 ,% r11 ) ,0 ( % r14 )
2011-12-27 11:27:15 +01:00
stmg % r8 ,% r9 ,_ _ P T _ P S W ( % r11 )
2014-04-15 12:55:07 +02:00
xc _ _ P T _ F L A G S ( 8 ,% r11 ) ,_ _ P T _ F L A G S ( % r11 )
2011-12-27 11:27:15 +01:00
xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 )
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
2005-06-25 14:55:30 -07:00
brasl % r14 ,s39 0 _ d o _ m a c h i n e _ c h e c k
2020-02-20 12:09:36 +01:00
cghi % r2 ,0
je . L m c c k _ r e t u r n
2005-06-25 14:55:30 -07:00
lg % r1 ,_ _ L C _ K E R N E L _ S T A C K # s w i t c h t o k e r n e l s t a c k
2011-12-27 11:27:15 +01:00
mvc S T A C K _ F R A M E _ O V E R H E A D ( _ _ P T _ S I Z E ,% r1 ) ,0 ( % r11 )
xc _ _ S F _ B A C K C H A I N ( 8 ,% r1 ) ,_ _ S F _ B A C K C H A I N ( % r1 )
la % r11 ,S T A C K _ F R A M E _ O V E R H E A D ( % r1 )
2005-06-25 14:55:30 -07:00
lgr % r15 ,% r1
brasl % r14 ,s39 0 _ h a n d l e _ m c c k
2014-12-03 17:00:08 +01:00
.Lmcck_return :
2020-11-16 08:06:40 +01:00
lctlg % c1 ,% c1 ,_ _ P T _ C R 1 ( % r11 )
2011-12-27 11:27:15 +01:00
lmg % r0 ,% r10 ,_ _ P T _ R 0 ( % r11 )
mvc _ _ L C _ R E T U R N _ M C C K _ P S W ( 1 6 ) ,_ _ P T _ P S W ( % r11 ) # m o v e r e t u r n P S W
2006-06-29 14:58:05 +02:00
tm _ _ L C _ R E T U R N _ M C C K _ P S W + 1 ,0 x01 # r e t u r n i n g t o u s e r ?
jno 0 f
2018-01-16 07:36:46 +01:00
BPEXIT _ _ T I _ f l a g s ( % r12 ) ,_ T I F _ I S O L A T E _ B P
2006-06-29 14:58:05 +02:00
stpt _ _ L C _ E X I T _ T I M E R
2021-04-07 09:20:17 +02:00
0 : ALTERNATIVE " " , _ _ s t r i n g i f y ( l g h i % r12 ,_ _ L C _ L A S T _ B R E A K _ S A V E _ A R E A ) ,1 9 3
LBEAR 0 ( % r12 )
lmg % r11 ,% r15 ,_ _ P T _ R 1 1 ( % r11 )
LPSWEY _ _ L C _ R E T U R N _ M C C K _ P S W ,_ _ L C _ R E T U R N _ M C C K _ L P S W E
2011-12-27 11:27:15 +01:00
2014-12-03 17:00:08 +01:00
.Lmcck_panic :
2021-06-18 08:17:15 +02:00
/ *
* Iterate o v e r a l l p o s s i b l e C P U a d d r e s s e s i n t h e r a n g e 0 . . 0 x f f f f
* and s t o p e a c h C P U u s i n g s i g n a l p r o c e s s o r . U s e c o m p a r e a n d s w a p
* to a l l o w j u s t o n e C P U - s t o p p e r a n d p r e v e n t c o n c u r r e n t C P U s f r o m
* stopping e a c h o t h e r w h i l e l e a v i n g t h e o t h e r s r u n n i n g .
* /
lhi % r5 ,0
lhi % r6 ,1
larl % r7 ,. L s t o p _ l o c k
cs % r5 ,% r6 ,0 ( % r7 ) # s i n g l e C P U - s t o p p e r o n l y
jnz 4 f
larl % r7 ,. L t h i s _ c p u
stap 0 ( % r7 ) # t h i s C P U a d d r e s s
lh % r4 ,0 ( % r7 )
nilh % r4 ,0
lhi % r0 ,1
sll % r0 ,1 6 # C P U c o u n t e r
lhi % r3 ,0 # n e x t C P U a d d r e s s
0 : cr % r3 ,% r4
je 2 f
1 : sigp % r1 ,% r3 ,S I G P _ S T O P # s t o p n e x t C P U
brc S I G P _ C C _ B U S Y ,1 b
2 : ahi % r3 ,1
brct % r0 ,0 b
3 : sigp % r1 ,% r4 ,S I G P _ S T O P # s t o p t h i s C P U
brc S I G P _ C C _ B U S Y ,3 b
4 : j 4 b
2019-01-17 10:02:22 +01:00
ENDPROC( m c c k _ i n t _ h a n d l e r )
2005-04-16 15:20:36 -07:00
2012-03-11 11:59:26 -04:00
ENTRY( r e s t a r t _ i n t _ h a n d l e r )
2022-02-25 10:39:02 +01:00
ALTERNATIVE " " , " l p p _ L P P _ O F F S E T " , 4 0
2018-03-26 15:23:33 +02:00
stg % r15 ,_ _ L C _ S A V E _ A R E A _ R E S T A R T
2021-08-24 15:30:21 +02:00
TSTMSK _ _ L C _ R E S T A R T _ F L A G S ,R E S T A R T _ F L A G _ C T L R E G S ,4
jz 0 f
la % r15 ,4 0 9 5
lctlg % c0 ,% c15 ,_ _ L C _ C R E G S _ S A V E _ A R E A - 4 0 9 5 ( % r15 )
0 : larl % r15 ,. L s t o s m _ t m p
stosm 0 ( % r15 ) ,0 x04 # t u r n d a t o n , k e e p i r q s o f f
2012-03-11 11:59:26 -04:00
lg % r15 ,_ _ L C _ R E S T A R T _ S T A C K
2017-09-12 16:37:33 +02:00
xc S T A C K _ F R A M E _ O V E R H E A D ( _ _ P T _ S I Z E ,% r15 ) ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 )
stmg % r0 ,% r14 ,S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ R 0 ( % r15 )
mvc S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ R 1 5 ( 8 ,% r15 ) ,_ _ L C _ S A V E _ A R E A _ R E S T A R T
mvc S T A C K _ F R A M E _ O V E R H E A D + _ _ P T _ P S W ( 1 6 ,% r15 ) ,_ _ L C _ R S T _ O L D _ P S W
2012-03-11 11:59:26 -04:00
xc 0 ( S T A C K _ F R A M E _ O V E R H E A D ,% r15 ) ,0 ( % r15 )
2012-06-05 09:59:52 +02:00
lg % r1 ,_ _ L C _ R E S T A R T _ F N # l o a d f n , p a r m & s o u r c e c p u
lg % r2 ,_ _ L C _ R E S T A R T _ D A T A
2021-08-24 15:30:21 +02:00
lgf % r3 ,_ _ L C _ R E S T A R T _ S O U R C E
2012-03-11 11:59:26 -04:00
ltgr % r3 ,% r3 # t e s t s o u r c e c p u a d d r e s s
jm 1 f # n e g a t i v e - > s k i p s o u r c e s t o p
2012-06-04 15:05:43 +02:00
0 : sigp % r4 ,% r3 ,S I G P _ S E N S E # s i g p s e n s e t o s o u r c e c p u
2012-03-11 11:59:26 -04:00
brc 1 0 ,0 b # w a i t f o r s t a t u s s t o r e d
1 : basr % r14 ,% r1 # c a l l f u n c t i o n
stap _ _ S F _ E M P T Y ( % r15 ) # s t o r e c p u a d d r e s s
llgh % r3 ,_ _ S F _ E M P T Y ( % r15 )
2012-06-04 15:05:43 +02:00
2 : sigp % r4 ,% r3 ,S I G P _ S T O P # s i g p s t o p t o c u r r e n t c p u
2012-03-11 11:59:26 -04:00
brc 2 ,2 b
3 : j 3 b
2019-01-17 10:02:22 +01:00
ENDPROC( r e s t a r t _ i n t _ h a n d l e r )
2011-08-03 16:44:19 +02:00
2011-01-05 12:47:25 +01:00
.section .kprobes .text , " ax"
2017-09-12 16:37:33 +02:00
# if d e f i n e d ( C O N F I G _ C H E C K _ S T A C K ) | | d e f i n e d ( C O N F I G _ V M A P _ S T A C K )
2005-04-16 15:20:36 -07:00
/ *
* The s y n c h r o n o u s o r t h e a s y n c h r o n o u s s t a c k o v e r f l o w e d . W e a r e d e a d .
* No n e e d t o p r o p e r l y s a v e t h e r e g i s t e r s , w e a r e g o i n g t o p a n i c a n y w a y .
* Setup a p t _ r e g s s o t h a t s h o w _ t r a c e c a n p r o v i d e a g o o d c a l l t r a c e .
* /
2019-01-17 10:02:22 +01:00
ENTRY( s t a c k _ o v e r f l o w )
2017-09-12 16:37:33 +02:00
lg % r15 ,_ _ L C _ N O D A T _ S T A C K # c h a n g e t o p a n i c s t a c k
2013-04-24 10:20:43 +02:00
la % r11 ,S T A C K _ F R A M E _ O V E R H E A D ( % r15 )
2011-12-27 11:27:15 +01:00
stmg % r0 ,% r7 ,_ _ P T _ R 0 ( % r11 )
stmg % r8 ,% r9 ,_ _ P T _ P S W ( % r11 )
mvc _ _ P T _ R 8 ( 6 4 ,% r11 ) ,0 ( % r14 )
stg % r10 ,_ _ P T _ O R I G _ G P R 2 ( % r11 ) # s t o r e l a s t b r e a k t o o r i g _ g p r 2
xc _ _ S F _ B A C K C H A I N ( 8 ,% r15 ) ,_ _ S F _ B A C K C H A I N ( % r15 )
lgr % r2 ,% r11 # p a s s p o i n t e r t o p t _ r e g s
2005-04-16 15:20:36 -07:00
jg k e r n e l _ s t a c k _ o v e r f l o w
2019-01-17 10:02:22 +01:00
ENDPROC( s t a c k _ o v e r f l o w )
2005-04-16 15:20:36 -07:00
# endif
2021-06-18 08:17:15 +02:00
.section .data , " aw"
.align 4
.Lstop_lock : .long 0
.Lthis_cpu : .short 0
2021-06-18 08:17:16 +02:00
.Lstosm_tmp : .byte 0
2015-02-13 14:44:29 +01:00
.section .rodata , " a"
2019-02-03 21:36:13 +01:00
# define S Y S C A L L ( e s a m e ,e m u ) . q u a d _ _ s39 0 x _ ## e s a m e
2009-06-12 10:26:47 +02:00
.globl sys_call_table
2005-04-16 15:20:36 -07:00
sys_call_table :
2017-12-11 14:47:27 +01:00
# include " a s m / s y s c a l l _ t a b l e . h "
2005-04-16 15:20:36 -07:00
# undef S Y S C A L L
2006-01-06 00:19:28 -08:00
# ifdef C O N F I G _ C O M P A T
2005-04-16 15:20:36 -07:00
2019-02-03 21:36:13 +01:00
# define S Y S C A L L ( e s a m e ,e m u ) . q u a d _ _ s39 0 _ ## e m u
2013-04-24 12:58:39 +02:00
.globl sys_call_table_emu
2005-04-16 15:20:36 -07:00
sys_call_table_emu :
2017-12-11 14:47:27 +01:00
# include " a s m / s y s c a l l _ t a b l e . h "
2005-04-16 15:20:36 -07:00
# undef S Y S C A L L
# endif