[PATCH] spufs: allow SPU code to do syscalls
An SPU does not have a way to implement system calls
itself, but it can create intercepts to the kernel.
This patch uses the method defined by the JSRE interface
for C99 host library calls from an SPU to implement
Linux system calls. It uses the reserved SPU stop code
0x2104 for this, using the structure layout and syscall
numbers for ppc64-linux.
I'm still undecided wether it is better to have a list
of allowed syscalls or a list of forbidden syscalls,
since we can't allow an SPU to call all syscalls that
are defined for ppc64-linux.
This patch implements the easier choice of them, with a
blacklist that only prevents an SPU from calling anything
that interacts with its own execution, e.g fork, execve,
clone, vfork, exit, spu_run and spu_create and everything
that deals with signals.
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-03-23 07:00:09 +08:00
|
|
|
/*
|
|
|
|
* System call callback functions for SPUs
|
|
|
|
*/
|
|
|
|
|
2007-09-19 12:38:12 +08:00
|
|
|
#undef DEBUG
|
[PATCH] spufs: allow SPU code to do syscalls
An SPU does not have a way to implement system calls
itself, but it can create intercepts to the kernel.
This patch uses the method defined by the JSRE interface
for C99 host library calls from an SPU to implement
Linux system calls. It uses the reserved SPU stop code
0x2104 for this, using the structure layout and syscall
numbers for ppc64-linux.
I'm still undecided wether it is better to have a list
of allowed syscalls or a list of forbidden syscalls,
since we can't allow an SPU to call all syscalls that
are defined for ppc64-linux.
This patch implements the easier choice of them, with a
blacklist that only prevents an SPU from calling anything
that interacts with its own execution, e.g fork, execve,
clone, vfork, exit, spu_run and spu_create and everything
that deals with signals.
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-03-23 07:00:09 +08:00
|
|
|
|
|
|
|
#include <linux/kallsyms.h>
|
2011-07-23 06:24:23 +08:00
|
|
|
#include <linux/export.h>
|
[PATCH] spufs: allow SPU code to do syscalls
An SPU does not have a way to implement system calls
itself, but it can create intercepts to the kernel.
This patch uses the method defined by the JSRE interface
for C99 host library calls from an SPU to implement
Linux system calls. It uses the reserved SPU stop code
0x2104 for this, using the structure layout and syscall
numbers for ppc64-linux.
I'm still undecided wether it is better to have a list
of allowed syscalls or a list of forbidden syscalls,
since we can't allow an SPU to call all syscalls that
are defined for ppc64-linux.
This patch implements the easier choice of them, with a
blacklist that only prevents an SPU from calling anything
that interacts with its own execution, e.g fork, execve,
clone, vfork, exit, spu_run and spu_create and everything
that deals with signals.
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-03-23 07:00:09 +08:00
|
|
|
#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, ...
|
|
|
|
*/
|
|
|
|
|
2007-09-19 12:38:12 +08:00
|
|
|
static void *spu_syscall_table[] = {
|
2006-06-20 04:45:04 +08:00
|
|
|
#define SYSCALL(func) sys_ni_syscall,
|
|
|
|
#define COMPAT_SYS(func) sys_ni_syscall,
|
|
|
|
#define PPC_SYS(func) sys_ni_syscall,
|
|
|
|
#define OLDSYS(func) sys_ni_syscall,
|
|
|
|
#define SYS32ONLY(func) sys_ni_syscall,
|
powerpc: Add a proper syscall for switching endianness
We currently have a "special" syscall for switching endianness. This is
syscall number 0x1ebe, which is handled explicitly in the 64-bit syscall
exception entry.
That has a few problems, firstly the syscall number is outside of the
usual range, which confuses various tools. For example strace doesn't
recognise the syscall at all.
Secondly it's handled explicitly as a special case in the syscall
exception entry, which is complicated enough without it.
As a first step toward removing the special syscall, we need to add a
regular syscall that implements the same functionality.
The logic is simple, it simply toggles the MSR_LE bit in the userspace
MSR. This is the same as the special syscall, with the caveat that the
special syscall clobbers fewer registers.
This version clobbers r9-r12, XER, CTR, and CR0-1,5-7.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2015-03-28 18:35:16 +08:00
|
|
|
#define PPC64ONLY(func) sys_ni_syscall,
|
2006-06-20 04:45:04 +08:00
|
|
|
#define SYSX(f, f3264, f32) sys_ni_syscall,
|
|
|
|
|
|
|
|
#define SYSCALL_SPU(func) sys_##func,
|
|
|
|
#define COMPAT_SYS_SPU(func) sys_##func,
|
|
|
|
#define PPC_SYS_SPU(func) ppc_##func,
|
|
|
|
#define SYSX_SPU(f, f3264, f32) f,
|
|
|
|
|
|
|
|
#include <asm/systbl.h>
|
[PATCH] spufs: allow SPU code to do syscalls
An SPU does not have a way to implement system calls
itself, but it can create intercepts to the kernel.
This patch uses the method defined by the JSRE interface
for C99 host library calls from an SPU to implement
Linux system calls. It uses the reserved SPU stop code
0x2104 for this, using the structure layout and syscall
numbers for ppc64-linux.
I'm still undecided wether it is better to have a list
of allowed syscalls or a list of forbidden syscalls,
since we can't allow an SPU to call all syscalls that
are defined for ppc64-linux.
This patch implements the easier choice of them, with a
blacklist that only prevents an SPU from calling anything
that interacts with its own execution, e.g fork, execve,
clone, vfork, exit, spu_run and spu_create and everything
that deals with signals.
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-03-23 07:00:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
long spu_sys_callback(struct spu_syscall_block *s)
|
|
|
|
{
|
|
|
|
long (*syscall)(u64 a1, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6);
|
|
|
|
|
2006-04-18 21:24:16 +08:00
|
|
|
if (s->nr_ret >= ARRAY_SIZE(spu_syscall_table)) {
|
2009-01-06 22:26:03 +08:00
|
|
|
pr_debug("%s: invalid syscall #%lld", __func__, s->nr_ret);
|
[PATCH] spufs: allow SPU code to do syscalls
An SPU does not have a way to implement system calls
itself, but it can create intercepts to the kernel.
This patch uses the method defined by the JSRE interface
for C99 host library calls from an SPU to implement
Linux system calls. It uses the reserved SPU stop code
0x2104 for this, using the structure layout and syscall
numbers for ppc64-linux.
I'm still undecided wether it is better to have a list
of allowed syscalls or a list of forbidden syscalls,
since we can't allow an SPU to call all syscalls that
are defined for ppc64-linux.
This patch implements the easier choice of them, with a
blacklist that only prevents an SPU from calling anything
that interacts with its own execution, e.g fork, execve,
clone, vfork, exit, spu_run and spu_create and everything
that deals with signals.
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-03-23 07:00:09 +08:00
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2006-05-23 22:46:39 +08:00
|
|
|
syscall = spu_syscall_table[s->nr_ret];
|
|
|
|
|
2012-12-12 16:19:00 +08:00
|
|
|
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]);
|
[PATCH] spufs: allow SPU code to do syscalls
An SPU does not have a way to implement system calls
itself, but it can create intercepts to the kernel.
This patch uses the method defined by the JSRE interface
for C99 host library calls from an SPU to implement
Linux system calls. It uses the reserved SPU stop code
0x2104 for this, using the structure layout and syscall
numbers for ppc64-linux.
I'm still undecided wether it is better to have a list
of allowed syscalls or a list of forbidden syscalls,
since we can't allow an SPU to call all syscalls that
are defined for ppc64-linux.
This patch implements the easier choice of them, with a
blacklist that only prevents an SPU from calling anything
that interacts with its own execution, e.g fork, execve,
clone, vfork, exit, spu_run and spu_create and everything
that deals with signals.
Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2006-03-23 07:00:09 +08:00
|
|
|
|
|
|
|
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);
|