]> git.ipfire.org Git - thirdparty/kernel/stable.git/blame - arch/powerpc/platforms/cell/spu_callbacks.c
treewide: Add SPDX license identifier for missed files
[thirdparty/kernel/stable.git] / arch / powerpc / platforms / cell / spu_callbacks.c
CommitLineData
457c8996 1// SPDX-License-Identifier: GPL-2.0-only
2dd14934
AB
2/*
3 * System call callback functions for SPUs
4 */
5
c70d4ca5 6#undef DEBUG
2dd14934
AB
7
8#include <linux/kallsyms.h>
4b16f8e2 9#include <linux/export.h>
2dd14934
AB
10#include <linux/syscalls.h>
11
12#include <asm/spu.h>
13#include <asm/syscalls.h>
14#include <asm/unistd.h>
15
16/*
17 * This table defines the system calls that an SPU can call.
18 * It is currently a subset of the 64 bit powerpc system calls,
19 * with the exact semantics.
20 *
21 * The reasons for disabling some of the system calls are:
22 * 1. They interact with the way SPU syscalls are handled
23 * and we can't let them execute ever:
24 * restart_syscall, exit, for, execve, ptrace, ...
25 * 2. They are deprecated and replaced by other means:
26 * uselib, pciconfig_*, sysfs, ...
27 * 3. They are somewhat interacting with the system in a way
28 * we don't want an SPU to:
29 * reboot, init_module, mount, kexec_load
30 * 4. They are optional and we can't rely on them being
31 * linked into the kernel. Unfortunately, the cond_syscall
32 * helper does not work here as it does not add the necessary
33 * opd symbols:
34 * mbind, mq_open, ipc, ...
35 */
36
1238819a 37static void *spu_syscall_table[] = {
6b1200fa 38#define __SYSCALL(nr, entry) entry,
ab66dcc7
FK
39#include <asm/syscall_table_spu.h>
40#undef __SYSCALL
2dd14934
AB
41};
42
43long spu_sys_callback(struct spu_syscall_block *s)
44{
45 long (*syscall)(u64 a1, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6);
46
23b2527d 47 if (s->nr_ret >= ARRAY_SIZE(spu_syscall_table)) {
fe333321 48 pr_debug("%s: invalid syscall #%lld", __func__, s->nr_ret);
2dd14934
AB
49 return -ENOSYS;
50 }
51
b471f554
DW
52 syscall = spu_syscall_table[s->nr_ret];
53
03743716
JP
54 pr_debug("SPU-syscall "
55 "%pSR:syscall%lld(%llx, %llx, %llx, %llx, %llx, %llx)\n",
56 syscall,
57 s->nr_ret,
58 s->parm[0], s->parm[1], s->parm[2],
59 s->parm[3], s->parm[4], s->parm[5]);
2dd14934
AB
60
61 return syscall(s->parm[0], s->parm[1], s->parm[2],
62 s->parm[3], s->parm[4], s->parm[5]);
63}
64EXPORT_SYMBOL_GPL(spu_sys_callback);