mirror of
https://github.com/torvalds/linux.git
synced 2024-12-28 22:02:28 +00:00
8640de0dee
Cause syscall handlers to be typed as follows when called indirectly throughout the kernel. This is to allow for better type checking. typedef long (*syscall_fn)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); Since both 32 and 64-bit abis allow for at least the first six machine-word length parameters to a function to be passed by registers, even handlers which admit fewer than six parameters may be viewed as having the above type. Coercing syscalls to syscall_fn requires a cast to void* to avoid -Wcast-function-type. Fixup comparisons in VDSO to avoid pointer-integer comparison. Introduce explicit cast on systems with SPUs. Signed-off-by: Rohan McLure <rmclure@linux.ibm.com> Reviewed-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20220921065605.1051927-19-rmclure@linux.ibm.com
65 lines
1.8 KiB
C
65 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* System call callback functions for SPUs
|
|
*/
|
|
|
|
#undef DEBUG
|
|
|
|
#include <linux/kallsyms.h>
|
|
#include <linux/export.h>
|
|
#include <linux/syscalls.h>
|
|
|
|
#include <asm/spu.h>
|
|
#include <asm/syscalls.h>
|
|
#include <asm/unistd.h>
|
|
|
|
/*
|
|
* This table defines the system calls that an SPU can call.
|
|
* It is currently a subset of the 64 bit powerpc system calls,
|
|
* with the exact semantics.
|
|
*
|
|
* The reasons for disabling some of the system calls are:
|
|
* 1. They interact with the way SPU syscalls are handled
|
|
* and we can't let them execute ever:
|
|
* restart_syscall, exit, for, execve, ptrace, ...
|
|
* 2. They are deprecated and replaced by other means:
|
|
* uselib, pciconfig_*, sysfs, ...
|
|
* 3. They are somewhat interacting with the system in a way
|
|
* we don't want an SPU to:
|
|
* reboot, init_module, mount, kexec_load
|
|
* 4. They are optional and we can't rely on them being
|
|
* linked into the kernel. Unfortunately, the cond_syscall
|
|
* helper does not work here as it does not add the necessary
|
|
* opd symbols:
|
|
* mbind, mq_open, ipc, ...
|
|
*/
|
|
|
|
static const syscall_fn spu_syscall_table[] = {
|
|
#define __SYSCALL_WITH_COMPAT(nr, entry, compat) __SYSCALL(nr, entry)
|
|
#define __SYSCALL(nr, entry) [nr] = (void *) entry,
|
|
#include <asm/syscall_table_spu.h>
|
|
};
|
|
|
|
long spu_sys_callback(struct spu_syscall_block *s)
|
|
{
|
|
syscall_fn syscall;
|
|
|
|
if (s->nr_ret >= ARRAY_SIZE(spu_syscall_table)) {
|
|
pr_debug("%s: invalid syscall #%lld", __func__, s->nr_ret);
|
|
return -ENOSYS;
|
|
}
|
|
|
|
syscall = spu_syscall_table[s->nr_ret];
|
|
|
|
pr_debug("SPU-syscall "
|
|
"%pSR:syscall%lld(%llx, %llx, %llx, %llx, %llx, %llx)\n",
|
|
syscall,
|
|
s->nr_ret,
|
|
s->parm[0], s->parm[1], s->parm[2],
|
|
s->parm[3], s->parm[4], s->parm[5]);
|
|
|
|
return syscall(s->parm[0], s->parm[1], s->parm[2],
|
|
s->parm[3], s->parm[4], s->parm[5]);
|
|
}
|
|
EXPORT_SYMBOL_GPL(spu_sys_callback);
|