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 21:07:57 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2008-08-20 15:36:07 +07:00
|
|
|
#ifndef _ASM_ARM_FUTEX_H
|
|
|
|
#define _ASM_ARM_FUTEX_H
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
2011-04-29 00:43:01 +07:00
|
|
|
#include <linux/futex.h>
|
|
|
|
#include <linux/uaccess.h>
|
|
|
|
#include <asm/errno.h>
|
|
|
|
|
|
|
|
#define __futex_atomic_ex_table(err_reg) \
|
|
|
|
"3:\n" \
|
|
|
|
" .pushsection __ex_table,\"a\"\n" \
|
|
|
|
" .align 3\n" \
|
|
|
|
" .long 1b, 4f, 2b, 4f\n" \
|
|
|
|
" .popsection\n" \
|
2015-03-24 16:41:09 +07:00
|
|
|
" .pushsection .text.fixup,\"ax\"\n" \
|
2012-06-15 22:49:58 +07:00
|
|
|
" .align 2\n" \
|
2011-04-29 00:43:01 +07:00
|
|
|
"4: mov %0, " err_reg "\n" \
|
|
|
|
" b 3b\n" \
|
|
|
|
" .popsection"
|
|
|
|
|
2008-08-20 15:36:07 +07:00
|
|
|
#ifdef CONFIG_SMP
|
[PATCH] FUTEX_WAKE_OP: pthread_cond_signal() speedup
ATM pthread_cond_signal is unnecessarily slow, because it wakes one waiter
(which at least on UP usually means an immediate context switch to one of
the waiter threads). This waiter wakes up and after a few instructions it
attempts to acquire the cv internal lock, but that lock is still held by
the thread calling pthread_cond_signal. So it goes to sleep and eventually
the signalling thread is scheduled in, unlocks the internal lock and wakes
the waiter again.
Now, before 2003-09-21 NPTL was using FUTEX_REQUEUE in pthread_cond_signal
to avoid this performance issue, but it was removed when locks were
redesigned to the 3 state scheme (unlocked, locked uncontended, locked
contended).
Following scenario shows why simply using FUTEX_REQUEUE in
pthread_cond_signal together with using lll_mutex_unlock_force in place of
lll_mutex_unlock is not enough and probably why it has been disabled at
that time:
The number is value in cv->__data.__lock.
thr1 thr2 thr3
0 pthread_cond_wait
1 lll_mutex_lock (cv->__data.__lock)
0 lll_mutex_unlock (cv->__data.__lock)
0 lll_futex_wait (&cv->__data.__futex, futexval)
0 pthread_cond_signal
1 lll_mutex_lock (cv->__data.__lock)
1 pthread_cond_signal
2 lll_mutex_lock (cv->__data.__lock)
2 lll_futex_wait (&cv->__data.__lock, 2)
2 lll_futex_requeue (&cv->__data.__futex, 0, 1, &cv->__data.__lock)
# FUTEX_REQUEUE, not FUTEX_CMP_REQUEUE
2 lll_mutex_unlock_force (cv->__data.__lock)
0 cv->__data.__lock = 0
0 lll_futex_wake (&cv->__data.__lock, 1)
1 lll_mutex_lock (cv->__data.__lock)
0 lll_mutex_unlock (cv->__data.__lock)
# Here, lll_mutex_unlock doesn't know there are threads waiting
# on the internal cv's lock
Now, I believe it is possible to use FUTEX_REQUEUE in pthread_cond_signal,
but it will cost us not one, but 2 extra syscalls and, what's worse, one of
these extra syscalls will be done for every single waiting loop in
pthread_cond_*wait.
We would need to use lll_mutex_unlock_force in pthread_cond_signal after
requeue and lll_mutex_cond_lock in pthread_cond_*wait after lll_futex_wait.
Another alternative is to do the unlocking pthread_cond_signal needs to do
(the lock can't be unlocked before lll_futex_wake, as that is racy) in the
kernel.
I have implemented both variants, futex-requeue-glibc.patch is the first
one and futex-wake_op{,-glibc}.patch is the unlocking inside of the kernel.
The kernel interface allows userland to specify how exactly an unlocking
operation should look like (some atomic arithmetic operation with optional
constant argument and comparison of the previous futex value with another
constant).
It has been implemented just for ppc*, x86_64 and i?86, for other
architectures I'm including just a stub header which can be used as a
starting point by maintainers to write support for their arches and ATM
will just return -ENOSYS for FUTEX_WAKE_OP. The requeue patch has been
(lightly) tested just on x86_64, the wake_op patch on ppc64 kernel running
32-bit and 64-bit NPTL and x86_64 kernel running 32-bit and 64-bit NPTL.
With the following benchmark on UP x86-64 I get:
for i in nptl-orig nptl-requeue nptl-wake_op; do echo time elf/ld.so --library-path .:$i /tmp/bench; \
for j in 1 2; do echo ( time elf/ld.so --library-path .:$i /tmp/bench ) 2>&1; done; done
time elf/ld.so --library-path .:nptl-orig /tmp/bench
real 0m0.655s user 0m0.253s sys 0m0.403s
real 0m0.657s user 0m0.269s sys 0m0.388s
time elf/ld.so --library-path .:nptl-requeue /tmp/bench
real 0m0.496s user 0m0.225s sys 0m0.271s
real 0m0.531s user 0m0.242s sys 0m0.288s
time elf/ld.so --library-path .:nptl-wake_op /tmp/bench
real 0m0.380s user 0m0.176s sys 0m0.204s
real 0m0.382s user 0m0.175s sys 0m0.207s
The benchmark is at:
http://sourceware.org/ml/libc-alpha/2005-03/txt00001.txt
Older futex-requeue-glibc.patch version is at:
http://sourceware.org/ml/libc-alpha/2005-03/txt00002.txt
Older futex-wake_op-glibc.patch version is at:
http://sourceware.org/ml/libc-alpha/2005-03/txt00003.txt
Will post a new version (just x86-64 fixes so that the patch
applies against pthread_cond_signal.S) to libc-hacker ml soon.
Attached is the kernel FUTEX_WAKE_OP patch as well as a simple-minded
testcase that will not test the atomicity of the operation, but at least
check if the threads that should have been woken up are woken up and
whether the arithmetic operation in the kernel gave the expected results.
Acked-by: Ingo Molnar <mingo@redhat.com>
Cc: Ulrich Drepper <drepper@redhat.com>
Cc: Jamie Lokier <jamie@shareable.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-07 05:16:25 +07:00
|
|
|
|
2011-09-23 20:34:12 +07:00
|
|
|
#define __futex_atomic_op(insn, ret, oldval, tmp, uaddr, oparg) \
|
2015-08-19 17:02:28 +07:00
|
|
|
({ \
|
|
|
|
unsigned int __ua_flags; \
|
2011-04-29 00:43:01 +07:00
|
|
|
smp_mb(); \
|
2014-02-21 23:01:48 +07:00
|
|
|
prefetchw(uaddr); \
|
2015-08-19 17:02:28 +07:00
|
|
|
__ua_flags = uaccess_save_and_enable(); \
|
2011-04-29 00:43:01 +07:00
|
|
|
__asm__ __volatile__( \
|
2011-09-23 20:34:12 +07:00
|
|
|
"1: ldrex %1, [%3]\n" \
|
2011-04-29 00:43:01 +07:00
|
|
|
" " insn "\n" \
|
2011-09-23 20:34:12 +07:00
|
|
|
"2: strex %2, %0, [%3]\n" \
|
|
|
|
" teq %2, #0\n" \
|
2011-04-29 00:43:01 +07:00
|
|
|
" bne 1b\n" \
|
|
|
|
" mov %0, #0\n" \
|
2011-09-23 20:34:12 +07:00
|
|
|
__futex_atomic_ex_table("%5") \
|
|
|
|
: "=&r" (ret), "=&r" (oldval), "=&r" (tmp) \
|
2011-04-29 00:43:01 +07:00
|
|
|
: "r" (uaddr), "r" (oparg), "Ir" (-EFAULT) \
|
2015-08-19 17:02:28 +07:00
|
|
|
: "cc", "memory"); \
|
|
|
|
uaccess_restore(__ua_flags); \
|
|
|
|
})
|
2011-04-29 00:43:01 +07:00
|
|
|
|
|
|
|
static inline int
|
|
|
|
futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
|
|
|
|
u32 oldval, u32 newval)
|
|
|
|
{
|
2015-08-19 17:02:28 +07:00
|
|
|
unsigned int __ua_flags;
|
2011-04-29 00:43:01 +07:00
|
|
|
int ret;
|
|
|
|
u32 val;
|
|
|
|
|
Remove 'type' argument from access_ok() function
Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument
of the user address range verification function since we got rid of the
old racy i386-only code to walk page tables by hand.
It existed because the original 80386 would not honor the write protect
bit when in kernel mode, so you had to do COW by hand before doing any
user access. But we haven't supported that in a long time, and these
days the 'type' argument is a purely historical artifact.
A discussion about extending 'user_access_begin()' to do the range
checking resulted this patch, because there is no way we're going to
move the old VERIFY_xyz interface to that model. And it's best done at
the end of the merge window when I've done most of my merges, so let's
just get this done once and for all.
This patch was mostly done with a sed-script, with manual fix-ups for
the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form.
There were a couple of notable cases:
- csky still had the old "verify_area()" name as an alias.
- the iter_iov code had magical hardcoded knowledge of the actual
values of VERIFY_{READ,WRITE} (not that they mattered, since nothing
really used it)
- microblaze used the type argument for a debug printout
but other than those oddities this should be a total no-op patch.
I tried to fix up all architectures, did fairly extensive grepping for
access_ok() uses, and the changes are trivial, but I may have missed
something. Any missed conversion should be trivially fixable, though.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-01-04 09:57:57 +07:00
|
|
|
if (!access_ok(uaddr, sizeof(u32)))
|
2011-04-29 00:43:01 +07:00
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
smp_mb();
|
2014-02-21 23:01:48 +07:00
|
|
|
/* Prefetching cannot fault */
|
|
|
|
prefetchw(uaddr);
|
2015-08-19 17:02:28 +07:00
|
|
|
__ua_flags = uaccess_save_and_enable();
|
2011-04-29 00:43:01 +07:00
|
|
|
__asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
|
|
|
|
"1: ldrex %1, [%4]\n"
|
|
|
|
" teq %1, %2\n"
|
|
|
|
" ite eq @ explicit IT needed for the 2b label\n"
|
|
|
|
"2: strexeq %0, %3, [%4]\n"
|
|
|
|
" movne %0, #0\n"
|
|
|
|
" teq %0, #0\n"
|
|
|
|
" bne 1b\n"
|
|
|
|
__futex_atomic_ex_table("%5")
|
|
|
|
: "=&r" (ret), "=&r" (val)
|
|
|
|
: "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
|
|
|
|
: "cc", "memory");
|
2015-08-19 17:02:28 +07:00
|
|
|
uaccess_restore(__ua_flags);
|
2011-04-29 00:43:01 +07:00
|
|
|
smp_mb();
|
|
|
|
|
|
|
|
*uval = val;
|
|
|
|
return ret;
|
|
|
|
}
|
[PATCH] FUTEX_WAKE_OP: pthread_cond_signal() speedup
ATM pthread_cond_signal is unnecessarily slow, because it wakes one waiter
(which at least on UP usually means an immediate context switch to one of
the waiter threads). This waiter wakes up and after a few instructions it
attempts to acquire the cv internal lock, but that lock is still held by
the thread calling pthread_cond_signal. So it goes to sleep and eventually
the signalling thread is scheduled in, unlocks the internal lock and wakes
the waiter again.
Now, before 2003-09-21 NPTL was using FUTEX_REQUEUE in pthread_cond_signal
to avoid this performance issue, but it was removed when locks were
redesigned to the 3 state scheme (unlocked, locked uncontended, locked
contended).
Following scenario shows why simply using FUTEX_REQUEUE in
pthread_cond_signal together with using lll_mutex_unlock_force in place of
lll_mutex_unlock is not enough and probably why it has been disabled at
that time:
The number is value in cv->__data.__lock.
thr1 thr2 thr3
0 pthread_cond_wait
1 lll_mutex_lock (cv->__data.__lock)
0 lll_mutex_unlock (cv->__data.__lock)
0 lll_futex_wait (&cv->__data.__futex, futexval)
0 pthread_cond_signal
1 lll_mutex_lock (cv->__data.__lock)
1 pthread_cond_signal
2 lll_mutex_lock (cv->__data.__lock)
2 lll_futex_wait (&cv->__data.__lock, 2)
2 lll_futex_requeue (&cv->__data.__futex, 0, 1, &cv->__data.__lock)
# FUTEX_REQUEUE, not FUTEX_CMP_REQUEUE
2 lll_mutex_unlock_force (cv->__data.__lock)
0 cv->__data.__lock = 0
0 lll_futex_wake (&cv->__data.__lock, 1)
1 lll_mutex_lock (cv->__data.__lock)
0 lll_mutex_unlock (cv->__data.__lock)
# Here, lll_mutex_unlock doesn't know there are threads waiting
# on the internal cv's lock
Now, I believe it is possible to use FUTEX_REQUEUE in pthread_cond_signal,
but it will cost us not one, but 2 extra syscalls and, what's worse, one of
these extra syscalls will be done for every single waiting loop in
pthread_cond_*wait.
We would need to use lll_mutex_unlock_force in pthread_cond_signal after
requeue and lll_mutex_cond_lock in pthread_cond_*wait after lll_futex_wait.
Another alternative is to do the unlocking pthread_cond_signal needs to do
(the lock can't be unlocked before lll_futex_wake, as that is racy) in the
kernel.
I have implemented both variants, futex-requeue-glibc.patch is the first
one and futex-wake_op{,-glibc}.patch is the unlocking inside of the kernel.
The kernel interface allows userland to specify how exactly an unlocking
operation should look like (some atomic arithmetic operation with optional
constant argument and comparison of the previous futex value with another
constant).
It has been implemented just for ppc*, x86_64 and i?86, for other
architectures I'm including just a stub header which can be used as a
starting point by maintainers to write support for their arches and ATM
will just return -ENOSYS for FUTEX_WAKE_OP. The requeue patch has been
(lightly) tested just on x86_64, the wake_op patch on ppc64 kernel running
32-bit and 64-bit NPTL and x86_64 kernel running 32-bit and 64-bit NPTL.
With the following benchmark on UP x86-64 I get:
for i in nptl-orig nptl-requeue nptl-wake_op; do echo time elf/ld.so --library-path .:$i /tmp/bench; \
for j in 1 2; do echo ( time elf/ld.so --library-path .:$i /tmp/bench ) 2>&1; done; done
time elf/ld.so --library-path .:nptl-orig /tmp/bench
real 0m0.655s user 0m0.253s sys 0m0.403s
real 0m0.657s user 0m0.269s sys 0m0.388s
time elf/ld.so --library-path .:nptl-requeue /tmp/bench
real 0m0.496s user 0m0.225s sys 0m0.271s
real 0m0.531s user 0m0.242s sys 0m0.288s
time elf/ld.so --library-path .:nptl-wake_op /tmp/bench
real 0m0.380s user 0m0.176s sys 0m0.204s
real 0m0.382s user 0m0.175s sys 0m0.207s
The benchmark is at:
http://sourceware.org/ml/libc-alpha/2005-03/txt00001.txt
Older futex-requeue-glibc.patch version is at:
http://sourceware.org/ml/libc-alpha/2005-03/txt00002.txt
Older futex-wake_op-glibc.patch version is at:
http://sourceware.org/ml/libc-alpha/2005-03/txt00003.txt
Will post a new version (just x86-64 fixes so that the patch
applies against pthread_cond_signal.S) to libc-hacker ml soon.
Attached is the kernel FUTEX_WAKE_OP patch as well as a simple-minded
testcase that will not test the atomicity of the operation, but at least
check if the threads that should have been woken up are woken up and
whether the arithmetic operation in the kernel gave the expected results.
Acked-by: Ingo Molnar <mingo@redhat.com>
Cc: Ulrich Drepper <drepper@redhat.com>
Cc: Jamie Lokier <jamie@shareable.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-07 05:16:25 +07:00
|
|
|
|
2008-08-20 15:36:07 +07:00
|
|
|
#else /* !SMP, we can work around lack of atomic ops by disabling preemption */
|
|
|
|
|
|
|
|
#include <linux/preempt.h>
|
2010-09-13 22:03:21 +07:00
|
|
|
#include <asm/domain.h>
|
2008-08-20 15:36:07 +07:00
|
|
|
|
2011-09-23 20:34:12 +07:00
|
|
|
#define __futex_atomic_op(insn, ret, oldval, tmp, uaddr, oparg) \
|
2015-08-19 17:02:28 +07:00
|
|
|
({ \
|
|
|
|
unsigned int __ua_flags = uaccess_save_and_enable(); \
|
2008-08-20 15:36:07 +07:00
|
|
|
__asm__ __volatile__( \
|
2012-01-25 17:38:13 +07:00
|
|
|
"1: " TUSER(ldr) " %1, [%3]\n" \
|
2008-08-20 15:36:07 +07:00
|
|
|
" " insn "\n" \
|
2012-01-25 17:38:13 +07:00
|
|
|
"2: " TUSER(str) " %0, [%3]\n" \
|
2008-08-20 15:36:07 +07:00
|
|
|
" mov %0, #0\n" \
|
2011-09-23 20:34:12 +07:00
|
|
|
__futex_atomic_ex_table("%5") \
|
|
|
|
: "=&r" (ret), "=&r" (oldval), "=&r" (tmp) \
|
2008-08-20 15:36:07 +07:00
|
|
|
: "r" (uaddr), "r" (oparg), "Ir" (-EFAULT) \
|
2015-08-19 17:02:28 +07:00
|
|
|
: "cc", "memory"); \
|
|
|
|
uaccess_restore(__ua_flags); \
|
|
|
|
})
|
2008-08-20 15:36:07 +07:00
|
|
|
|
2011-04-29 00:43:01 +07:00
|
|
|
static inline int
|
|
|
|
futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
|
|
|
|
u32 oldval, u32 newval)
|
|
|
|
{
|
2015-08-19 17:02:28 +07:00
|
|
|
unsigned int __ua_flags;
|
2011-04-29 00:43:01 +07:00
|
|
|
int ret = 0;
|
|
|
|
u32 val;
|
|
|
|
|
Remove 'type' argument from access_ok() function
Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument
of the user address range verification function since we got rid of the
old racy i386-only code to walk page tables by hand.
It existed because the original 80386 would not honor the write protect
bit when in kernel mode, so you had to do COW by hand before doing any
user access. But we haven't supported that in a long time, and these
days the 'type' argument is a purely historical artifact.
A discussion about extending 'user_access_begin()' to do the range
checking resulted this patch, because there is no way we're going to
move the old VERIFY_xyz interface to that model. And it's best done at
the end of the merge window when I've done most of my merges, so let's
just get this done once and for all.
This patch was mostly done with a sed-script, with manual fix-ups for
the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form.
There were a couple of notable cases:
- csky still had the old "verify_area()" name as an alias.
- the iter_iov code had magical hardcoded knowledge of the actual
values of VERIFY_{READ,WRITE} (not that they mattered, since nothing
really used it)
- microblaze used the type argument for a debug printout
but other than those oddities this should be a total no-op patch.
I tried to fix up all architectures, did fairly extensive grepping for
access_ok() uses, and the changes are trivial, but I may have missed
something. Any missed conversion should be trivially fixable, though.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-01-04 09:57:57 +07:00
|
|
|
if (!access_ok(uaddr, sizeof(u32)))
|
2011-04-29 00:43:01 +07:00
|
|
|
return -EFAULT;
|
|
|
|
|
2015-05-11 22:52:15 +07:00
|
|
|
preempt_disable();
|
2015-08-19 17:02:28 +07:00
|
|
|
__ua_flags = uaccess_save_and_enable();
|
2011-04-29 00:43:01 +07:00
|
|
|
__asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
|
2012-01-25 17:38:13 +07:00
|
|
|
"1: " TUSER(ldr) " %1, [%4]\n"
|
2011-04-29 00:43:01 +07:00
|
|
|
" teq %1, %2\n"
|
|
|
|
" it eq @ explicit IT needed for the 2b label\n"
|
2012-01-25 17:38:13 +07:00
|
|
|
"2: " TUSER(streq) " %3, [%4]\n"
|
2011-04-29 00:43:01 +07:00
|
|
|
__futex_atomic_ex_table("%5")
|
|
|
|
: "+r" (ret), "=&r" (val)
|
|
|
|
: "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
|
|
|
|
: "cc", "memory");
|
2015-08-19 17:02:28 +07:00
|
|
|
uaccess_restore(__ua_flags);
|
2011-04-29 00:43:01 +07:00
|
|
|
|
|
|
|
*uval = val;
|
2015-05-11 22:52:15 +07:00
|
|
|
preempt_enable();
|
|
|
|
|
2011-04-29 00:43:01 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* !SMP */
|
|
|
|
|
2008-08-20 15:36:07 +07:00
|
|
|
static inline int
|
2017-08-24 14:31:05 +07:00
|
|
|
arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr)
|
2008-08-20 15:36:07 +07:00
|
|
|
{
|
2011-09-23 20:34:12 +07:00
|
|
|
int oldval = 0, ret, tmp;
|
2008-08-20 15:36:07 +07:00
|
|
|
|
2015-05-11 22:52:16 +07:00
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
preempt_disable();
|
|
|
|
#endif
|
|
|
|
pagefault_disable();
|
2008-08-20 15:36:07 +07:00
|
|
|
|
|
|
|
switch (op) {
|
|
|
|
case FUTEX_OP_SET:
|
2011-09-23 20:34:12 +07:00
|
|
|
__futex_atomic_op("mov %0, %4", ret, oldval, tmp, uaddr, oparg);
|
2008-08-20 15:36:07 +07:00
|
|
|
break;
|
|
|
|
case FUTEX_OP_ADD:
|
2011-09-23 20:34:12 +07:00
|
|
|
__futex_atomic_op("add %0, %1, %4", ret, oldval, tmp, uaddr, oparg);
|
2008-08-20 15:36:07 +07:00
|
|
|
break;
|
|
|
|
case FUTEX_OP_OR:
|
2011-09-23 20:34:12 +07:00
|
|
|
__futex_atomic_op("orr %0, %1, %4", ret, oldval, tmp, uaddr, oparg);
|
2008-08-20 15:36:07 +07:00
|
|
|
break;
|
|
|
|
case FUTEX_OP_ANDN:
|
2011-09-23 20:34:12 +07:00
|
|
|
__futex_atomic_op("and %0, %1, %4", ret, oldval, tmp, uaddr, ~oparg);
|
2008-08-20 15:36:07 +07:00
|
|
|
break;
|
|
|
|
case FUTEX_OP_XOR:
|
2011-09-23 20:34:12 +07:00
|
|
|
__futex_atomic_op("eor %0, %1, %4", ret, oldval, tmp, uaddr, oparg);
|
2008-08-20 15:36:07 +07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2015-05-11 22:52:16 +07:00
|
|
|
pagefault_enable();
|
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
preempt_enable();
|
|
|
|
#endif
|
2008-08-20 15:36:07 +07:00
|
|
|
|
2017-08-24 14:31:05 +07:00
|
|
|
if (!ret)
|
|
|
|
*oval = oldval;
|
|
|
|
|
2008-08-20 15:36:07 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
#endif /* _ASM_ARM_FUTEX_H */
|