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 17:07:57 +03:00
// SPDX-License-Identifier: GPL-2.0
2005-04-17 02:20:36 +04:00
/*
2009-03-26 17:23:52 +03:00
* This file handles the architecture dependent parts of process handling .
2005-04-17 02:20:36 +04:00
*
2012-07-20 13:15:04 +04:00
* Copyright IBM Corp . 1999 , 2009
2009-03-26 17:23:52 +03:00
* Author ( s ) : Martin Schwidefsky < schwidefsky @ de . ibm . com > ,
* Hartmut Penner < hp @ de . ibm . com > ,
* Denis Joseph Barrow ,
2005-04-17 02:20:36 +04:00
*/
2016-05-07 13:15:34 +03:00
# include <linux/elf-randomize.h>
2005-04-17 02:20:36 +04:00
# include <linux/compiler.h>
# include <linux/cpu.h>
# include <linux/sched.h>
2017-02-08 20:51:35 +03:00
# include <linux/sched/debug.h>
2017-02-08 20:51:36 +03:00
# include <linux/sched/task.h>
2017-02-08 20:51:37 +03:00
# include <linux/sched/task_stack.h>
2005-04-17 02:20:36 +04:00
# include <linux/kernel.h>
# include <linux/mm.h>
2011-10-30 18:17:13 +04:00
# include <linux/elfcore.h>
2005-04-17 02:20:36 +04:00
# include <linux/smp.h>
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
# include <linux/slab.h>
2005-04-17 02:20:36 +04:00
# include <linux/interrupt.h>
2008-04-17 09:46:25 +04:00
# include <linux/tick.h>
2011-01-12 11:55:28 +03:00
# include <linux/personality.h>
2009-01-14 16:14:36 +03:00
# include <linux/syscalls.h>
2009-09-23 00:58:42 +04:00
# include <linux/compat.h>
2011-01-05 14:47:25 +03:00
# include <linux/kprobes.h>
2011-01-12 11:55:28 +03:00
# include <linux/random.h>
2017-02-09 23:20:23 +03:00
# include <linux/export.h>
2015-09-29 18:53:22 +03:00
# include <linux/init_task.h>
2018-04-20 11:21:21 +03:00
# include <asm/cpu_mf.h>
2005-04-17 02:20:36 +04:00
# include <asm/io.h>
# include <asm/processor.h>
2012-07-20 13:15:08 +04:00
# include <asm/vtimer.h>
2012-09-14 15:45:24 +04:00
# include <asm/exec.h>
2005-04-17 02:20:36 +04:00
# include <asm/irq.h>
2009-03-26 17:24:01 +03:00
# include <asm/nmi.h>
2011-01-05 14:48:09 +03:00
# include <asm/smp.h>
2019-01-28 10:33:08 +03:00
# include <asm/stacktrace.h>
2012-03-28 21:30:02 +04:00
# include <asm/switch_to.h>
2012-07-31 12:52:05 +04:00
# include <asm/runtime_instr.h>
2008-04-17 09:46:26 +04:00
# include "entry.h"
2005-04-17 02:20:36 +04:00
2006-09-28 18:56:43 +04:00
asmlinkage void ret_from_fork ( void ) asm ( " ret_from_fork " ) ;
2005-04-17 02:20:36 +04:00
2014-10-22 14:42:38 +04:00
extern void kernel_thread_starter ( void ) ;
2005-04-17 02:20:36 +04:00
void flush_thread ( void )
{
}
2018-04-20 11:21:21 +03:00
void arch_setup_new_exec ( void )
{
if ( S390_lowcore . current_pid ! = current - > pid ) {
S390_lowcore . current_pid = current - > pid ;
if ( test_facility ( 40 ) )
lpp ( & S390_lowcore . lpp ) ;
}
}
2015-02-09 18:47:00 +03:00
void arch_release_task_struct ( struct task_struct * tsk )
{
2017-09-11 12:24:22 +03:00
runtime_instr_release ( tsk ) ;
2017-09-11 12:24:23 +03:00
guarded_storage_release ( tsk ) ;
2015-06-11 17:57:20 +03:00
}
int arch_dup_task_struct ( struct task_struct * dst , struct task_struct * src )
{
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 13:53:42 +03:00
/*
* Save the floating - point or vector register state of the current
2015-09-29 11:04:41 +03:00
* task and set the CIF_FPU flag to lazy restore the FPU register
* state when returning to user space .
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 13:53:42 +03:00
*/
2015-06-29 17:43:06 +03:00
save_fpu_regs ( ) ;
2015-09-29 11:04:41 +03:00
2016-04-01 16:42:15 +03:00
memcpy ( dst , src , arch_task_struct_size ) ;
dst - > thread . fpu . regs = dst - > thread . fpu . fprs ;
2015-06-11 17:57:20 +03:00
return 0 ;
2015-02-09 18:47:00 +03:00
}
2017-02-20 11:38:42 +03:00
int copy_thread_tls ( unsigned long clone_flags , unsigned long new_stackp ,
unsigned long arg , struct task_struct * p , unsigned long tls )
2005-04-17 02:20:36 +04:00
{
2009-03-26 17:23:52 +03:00
struct fake_frame
{
struct stack_frame sf ;
struct pt_regs childregs ;
} * frame ;
frame = container_of ( task_pt_regs ( p ) , struct fake_frame , childregs ) ;
p - > thread . ksp = ( unsigned long ) frame ;
2012-09-22 04:48:32 +04:00
/* Save access registers to new thread structure. */
save_access_regs ( & p - > thread . acrs [ 0 ] ) ;
/* start new process with ar4 pointing to the correct address space */
p - > thread . mm_segment = get_fs ( ) ;
/* Don't copy debug registers */
memset ( & p - > thread . per_user , 0 , sizeof ( p - > thread . per_user ) ) ;
memset ( & p - > thread . per_event , 0 , sizeof ( p - > thread . per_event ) ) ;
clear_tsk_thread_flag ( p , TIF_SINGLE_STEP ) ;
s390: fix transactional execution control register handling
Dan Horák reported the following crash related to transactional execution:
User process fault: interruption code 0013 ilc:3 in libpthread-2.26.so[3ff93c00000+1b000]
CPU: 2 PID: 1 Comm: /init Not tainted 4.13.4-300.fc27.s390x #1
Hardware name: IBM 2827 H43 400 (z/VM 6.4.0)
task: 00000000fafc8000 task.stack: 00000000fafc4000
User PSW : 0705200180000000 000003ff93c14e70
R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:1 AS:0 CC:2 PM:0 RI:0 EA:3
User GPRS: 0000000000000077 000003ff00000000 000003ff93144d48 000003ff93144d5e
0000000000000000 0000000000000002 0000000000000000 000003ff00000000
0000000000000000 0000000000000418 0000000000000000 000003ffcc9fe770
000003ff93d28f50 000003ff9310acf0 000003ff92b0319a 000003ffcc9fe6d0
User Code: 000003ff93c14e62: 60e0b030 std %f14,48(%r11)
000003ff93c14e66: 60f0b038 std %f15,56(%r11)
#000003ff93c14e6a: e5600000ff0e tbegin 0,65294
>000003ff93c14e70: a7740006 brc 7,3ff93c14e7c
000003ff93c14e74: a7080000 lhi %r0,0
000003ff93c14e78: a7f40023 brc 15,3ff93c14ebe
000003ff93c14e7c: b2220000 ipm %r0
000003ff93c14e80: 8800001c srl %r0,28
There are several bugs with control register handling with respect to
transactional execution:
- on task switch update_per_regs() is only called if the next task has
an mm (is not a kernel thread). This however is incorrect. This
breaks e.g. for user mode helper handling, where the kernel creates
a kernel thread and then execve's a user space program. Control
register contents related to transactional execution won't be
updated on execve. If the previous task ran with transactional
execution disabled then the new task will also run with
transactional execution disabled, which is incorrect. Therefore call
update_per_regs() unconditionally within switch_to().
- on startup the transactional execution facility is not enabled for
the idle thread. This is not really a bug, but an inconsistency to
other facilities. Therefore enable the facility if it is available.
- on fork the new thread's per_flags field is not cleared. This means
that a child process inherits the PER_FLAG_NO_TE flag. This flag can
be set with a ptrace request to disable transactional execution for
the current process. It should not be inherited by new child
processes in order to be consistent with the handling of all other
PER related debugging options. Therefore clear the per_flags field in
copy_thread_tls().
Reported-and-tested-by: Dan Horák <dan@danny.cz>
Fixes: d35339a42dd1 ("s390: add support for transactional memory")
Cc: <stable@vger.kernel.org> # v3.7+
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2017-11-09 14:29:34 +03:00
p - > thread . per_flags = 0 ;
2012-09-22 04:48:32 +04:00
/* Initialize per thread user and system timer values */
2016-11-08 14:15:59 +03:00
p - > thread . user_timer = 0 ;
2017-03-01 11:18:34 +03:00
p - > thread . guest_timer = 0 ;
2016-11-08 14:15:59 +03:00
p - > thread . system_timer = 0 ;
2017-03-01 11:18:34 +03:00
p - > thread . hardirq_timer = 0 ;
p - > thread . softirq_timer = 0 ;
2005-04-17 02:20:36 +04:00
2012-09-22 04:48:32 +04:00
frame - > sf . back_chain = 0 ;
2009-03-26 17:23:52 +03:00
/* new return point is ret_from_fork */
frame - > sf . gprs [ 8 ] = ( unsigned long ) ret_from_fork ;
/* fake return stack for resume(), don't go back to schedule */
frame - > sf . gprs [ 9 ] = ( unsigned long ) frame ;
2005-04-17 02:20:36 +04:00
2012-09-22 04:48:32 +04:00
/* Store access registers to kernel stack of new process. */
2012-10-22 00:44:27 +04:00
if ( unlikely ( p - > flags & PF_KTHREAD ) ) {
2012-09-22 04:48:32 +04:00
/* kernel thread */
memset ( & frame - > childregs , 0 , sizeof ( struct pt_regs ) ) ;
2013-09-24 11:14:56 +04:00
frame - > childregs . psw . mask = PSW_KERNEL_BITS | PSW_MASK_DAT |
2012-09-22 04:48:32 +04:00
PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK ;
2016-01-18 14:49:44 +03:00
frame - > childregs . psw . addr =
2012-09-22 04:48:32 +04:00
( unsigned long ) kernel_thread_starter ;
frame - > childregs . gprs [ 9 ] = new_stackp ; /* function */
frame - > childregs . gprs [ 10 ] = arg ;
frame - > childregs . gprs [ 11 ] = ( unsigned long ) do_exit ;
frame - > childregs . orig_gpr2 = - 1 ;
return 0 ;
}
2012-10-22 00:44:27 +04:00
frame - > childregs = * current_pt_regs ( ) ;
2012-09-22 04:48:32 +04:00
frame - > childregs . gprs [ 2 ] = 0 ; /* child returns 0 on fork. */
2014-04-15 14:55:07 +04:00
frame - > childregs . flags = 0 ;
2012-10-22 00:44:27 +04:00
if ( new_stackp )
frame - > childregs . gprs [ 15 ] = new_stackp ;
2005-04-17 02:20:36 +04:00
2012-07-31 12:52:05 +04:00
/* Don't copy runtime instrumentation info */
p - > thread . ri_cb = NULL ;
frame - > childregs . psw . mask & = ~ PSW_MASK_RI ;
2016-01-26 16:10:34 +03:00
/* Don't copy guarded storage control block */
p - > thread . gs_cb = NULL ;
p - > thread . gs_bc_cb = NULL ;
2012-07-31 12:52:05 +04:00
2005-04-17 02:20:36 +04:00
/* Set a new TLS ? */
if ( clone_flags & CLONE_SETTLS ) {
2009-06-12 12:26:25 +04:00
if ( is_compat_task ( ) ) {
2012-10-22 00:44:27 +04:00
p - > thread . acrs [ 0 ] = ( unsigned int ) tls ;
2005-04-17 02:20:36 +04:00
} else {
2012-10-22 00:44:27 +04:00
p - > thread . acrs [ 0 ] = ( unsigned int ) ( tls > > 32 ) ;
p - > thread . acrs [ 1 ] = ( unsigned int ) tls ;
2005-04-17 02:20:36 +04:00
}
}
2009-03-26 17:23:52 +03:00
return 0 ;
2005-04-17 02:20:36 +04:00
}
2007-04-27 18:01:40 +04:00
asmlinkage void execve_tail ( void )
{
2015-06-11 16:33:54 +03:00
current - > thread . fpu . fpc = 0 ;
2015-07-06 16:02:37 +03:00
asm volatile ( " sfpc %0 " : : " d " ( 0 ) ) ;
2005-04-17 02:20:36 +04:00
}
/*
* fill in the FPU structure for a core dump .
*/
int dump_fpu ( struct pt_regs * regs , s390_fp_regs * fpregs )
{
2015-06-29 17:43:06 +03:00
save_fpu_regs ( ) ;
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 13:53:42 +03:00
fpregs - > fpc = current - > thread . fpu . fpc ;
fpregs - > pad = 0 ;
2015-09-29 11:04:41 +03:00
if ( MACHINE_HAS_VX )
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 13:53:42 +03:00
convert_vx_to_fp ( ( freg_t * ) & fpregs - > fprs ,
current - > thread . fpu . vxrs ) ;
else
memcpy ( & fpregs - > fprs , current - > thread . fpu . fprs ,
sizeof ( fpregs - > fprs ) ) ;
2005-04-17 02:20:36 +04:00
return 1 ;
}
2009-03-26 17:24:04 +03:00
EXPORT_SYMBOL ( dump_fpu ) ;
2005-04-17 02:20:36 +04:00
unsigned long get_wchan ( struct task_struct * p )
{
struct stack_frame * sf , * low , * high ;
unsigned long return_address ;
int count ;
2006-01-12 12:05:50 +03:00
if ( ! p | | p = = current | | p - > state = = TASK_RUNNING | | ! task_stack_page ( p ) )
2005-04-17 02:20:36 +04:00
return 0 ;
2019-08-13 21:11:08 +03:00
if ( ! try_get_task_stack ( p ) )
return 0 ;
2006-01-12 12:05:50 +03:00
low = task_stack_page ( p ) ;
high = ( struct stack_frame * ) task_pt_regs ( p ) ;
2016-01-18 15:12:19 +03:00
sf = ( struct stack_frame * ) p - > thread . ksp ;
2019-08-13 21:11:08 +03:00
if ( sf < = low | | sf > high ) {
return_address = 0 ;
goto out ;
}
2005-04-17 02:20:36 +04:00
for ( count = 0 ; count < 16 ; count + + ) {
2019-08-13 20:23:51 +03:00
sf = ( struct stack_frame * ) READ_ONCE_NOCHECK ( sf - > back_chain ) ;
2019-08-13 21:11:08 +03:00
if ( sf < = low | | sf > high ) {
return_address = 0 ;
goto out ;
}
2019-08-13 20:23:51 +03:00
return_address = READ_ONCE_NOCHECK ( sf - > gprs [ 8 ] ) ;
2005-04-17 02:20:36 +04:00
if ( ! in_sched_functions ( return_address ) )
2019-08-13 21:11:08 +03:00
goto out ;
2005-04-17 02:20:36 +04:00
}
2019-08-13 21:11:08 +03:00
out :
put_task_stack ( p ) ;
return return_address ;
2005-04-17 02:20:36 +04:00
}
2011-01-12 11:55:28 +03:00
unsigned long arch_align_stack ( unsigned long sp )
{
if ( ! ( current - > personality & ADDR_NO_RANDOMIZE ) & & randomize_va_space )
sp - = get_random_int ( ) & ~ PAGE_MASK ;
return sp & ~ 0xf ;
}
2011-01-12 11:55:30 +03:00
static inline unsigned long brk_rnd ( void )
{
2015-11-10 14:30:28 +03:00
return ( get_random_int ( ) & BRK_RND_MASK ) < < PAGE_SHIFT ;
2011-01-12 11:55:30 +03:00
}
unsigned long arch_randomize_brk ( struct mm_struct * mm )
{
2013-12-17 16:41:31 +04:00
unsigned long ret ;
2011-01-12 11:55:30 +03:00
2013-12-17 16:41:31 +04:00
ret = PAGE_ALIGN ( mm - > brk + brk_rnd ( ) ) ;
return ( ret > mm - > brk ) ? ret : mm - > brk ;
2011-01-12 11:55:30 +03:00
}
2017-02-17 10:13:28 +03:00
void set_fs_fixup ( void )
{
struct pt_regs * regs = current_pt_regs ( ) ;
static bool warned ;
set_fs ( USER_DS ) ;
if ( warned )
return ;
WARN ( 1 , " Unbalanced set_fs - int code: 0x%x \n " , regs - > int_code ) ;
show_registers ( regs ) ;
warned = true ;
}