2012-03-05 11:49:32 +00:00
|
|
|
/*
|
|
|
|
* Based on arch/arm/kernel/sys_arm.c
|
|
|
|
*
|
|
|
|
* Copyright (C) People who wrote linux/arch/i386/kernel/sys_i386.c
|
|
|
|
* Copyright (C) 1995, 1996 Russell King.
|
|
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/compat.h>
|
|
|
|
#include <linux/personality.h>
|
|
|
|
#include <linux/sched.h>
|
2017-02-03 22:47:37 +00:00
|
|
|
#include <linux/sched/signal.h>
|
2012-03-05 11:49:32 +00:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/syscalls.h>
|
|
|
|
#include <linux/uaccess.h>
|
|
|
|
|
|
|
|
#include <asm/cacheflush.h>
|
2018-02-01 22:13:37 +00:00
|
|
|
#include <asm/system_misc.h>
|
2014-01-30 17:56:56 +00:00
|
|
|
#include <asm/unistd.h>
|
2012-03-05 11:49:32 +00:00
|
|
|
|
2014-12-01 10:53:08 +00:00
|
|
|
static long
|
|
|
|
__do_compat_cache_op(unsigned long start, unsigned long end)
|
2012-03-05 11:49:32 +00:00
|
|
|
{
|
2014-12-01 10:53:08 +00:00
|
|
|
long ret;
|
2012-03-05 11:49:32 +00:00
|
|
|
|
2014-12-01 10:53:08 +00:00
|
|
|
do {
|
|
|
|
unsigned long chunk = min(PAGE_SIZE, end - start);
|
2012-03-05 11:49:32 +00:00
|
|
|
|
2014-12-01 10:53:08 +00:00
|
|
|
if (fatal_signal_pending(current))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ret = __flush_cache_user_range(start, start + chunk);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
cond_resched();
|
|
|
|
start += chunk;
|
|
|
|
} while (start < end);
|
|
|
|
|
|
|
|
return 0;
|
2012-03-05 11:49:32 +00:00
|
|
|
}
|
|
|
|
|
2014-12-01 10:53:08 +00:00
|
|
|
static inline long
|
|
|
|
do_compat_cache_op(unsigned long start, unsigned long end, int flags)
|
|
|
|
{
|
|
|
|
if (end < start || flags)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2018-02-19 13:38:00 +00:00
|
|
|
if (!access_ok(VERIFY_READ, (const void __user *)start, end - start))
|
2014-12-01 10:53:08 +00:00
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
return __do_compat_cache_op(start, end);
|
|
|
|
}
|
2012-03-05 11:49:32 +00:00
|
|
|
/*
|
|
|
|
* Handle all unrecognised system calls.
|
|
|
|
*/
|
|
|
|
long compat_arm_syscall(struct pt_regs *regs)
|
|
|
|
{
|
2018-02-01 22:13:37 +00:00
|
|
|
siginfo_t info;
|
2012-03-05 11:49:32 +00:00
|
|
|
unsigned int no = regs->regs[7];
|
|
|
|
|
|
|
|
switch (no) {
|
|
|
|
/*
|
|
|
|
* Flush a region from virtual address 'r0' to virtual address 'r1'
|
|
|
|
* _exclusive_. There is no alignment requirement on either address;
|
|
|
|
* user space does not need to know the hardware cache layout.
|
|
|
|
*
|
|
|
|
* r2 contains flags. It should ALWAYS be passed as ZERO until it
|
|
|
|
* is defined to be something else. For now we ignore it, but may
|
|
|
|
* the fires of hell burn in your belly if you break this rule. ;)
|
|
|
|
*
|
|
|
|
* (at a later date, we may want to allow this call to not flush
|
|
|
|
* various aspects of the cache. Passing '0' will guarantee that
|
|
|
|
* everything necessary gets flushed to maintain consistency in
|
|
|
|
* the specified region).
|
|
|
|
*/
|
|
|
|
case __ARM_NR_compat_cacheflush:
|
2014-12-01 10:53:08 +00:00
|
|
|
return do_compat_cache_op(regs->regs[0], regs->regs[1], regs->regs[2]);
|
2012-03-05 11:49:32 +00:00
|
|
|
|
|
|
|
case __ARM_NR_compat_set_tls:
|
|
|
|
current->thread.tp_value = regs->regs[0];
|
2014-09-11 13:38:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Protect against register corruption from context switch.
|
|
|
|
* See comment in tls_thread_flush.
|
|
|
|
*/
|
|
|
|
barrier();
|
2016-09-08 12:55:38 +00:00
|
|
|
write_sysreg(regs->regs[0], tpidrro_el0);
|
2012-03-05 11:49:32 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
2018-02-01 22:13:37 +00:00
|
|
|
/*
|
|
|
|
* Calls 9f00xx..9f07ff are defined to return -ENOSYS
|
|
|
|
* if not implemented, rather than raising SIGILL. This
|
|
|
|
* way the calling program can gracefully determine whether
|
|
|
|
* a feature is supported.
|
|
|
|
*/
|
|
|
|
if ((no & 0xffff) <= 0x7ff)
|
|
|
|
return -ENOSYS;
|
|
|
|
break;
|
2012-03-05 11:49:32 +00:00
|
|
|
}
|
2018-02-01 22:13:37 +00:00
|
|
|
|
|
|
|
info.si_signo = SIGILL;
|
|
|
|
info.si_errno = 0;
|
|
|
|
info.si_code = ILL_ILLTRP;
|
|
|
|
info.si_addr = (void __user *)instruction_pointer(regs) -
|
|
|
|
(compat_thumb_mode(regs) ? 2 : 4);
|
|
|
|
|
|
|
|
arm64_notify_die("Oops - bad compat syscall(2)", regs, &info, no);
|
|
|
|
return 0;
|
2012-03-05 11:49:32 +00:00
|
|
|
}
|