Path: blob/master/arch/powerpc/platforms/cell/spufs/syscalls.c
26498 views
// SPDX-License-Identifier: GPL-2.01#include <linux/file.h>2#include <linux/fs.h>3#include <linux/export.h>4#include <linux/mount.h>5#include <linux/namei.h>6#include <linux/slab.h>78#include <linux/uaccess.h>910#include "spufs.h"1112/**13* sys_spu_run - run code loaded into an SPU14*15* @unpc: next program counter for the SPU16* @ustatus: status of the SPU17*18* This system call transfers the control of execution of a19* user space thread to an SPU. It will return when the20* SPU has finished executing or when it hits an error21* condition and it will be interrupted if a signal needs22* to be delivered to a handler in user space.23*24* The next program counter is set to the passed value25* before the SPU starts fetching code and the user space26* pointer gets updated with the new value when returning27* from kernel space.28*29* The status value returned from spu_run reflects the30* value of the spu_status register after the SPU has stopped.31*32*/33static long do_spu_run(struct file *filp,34__u32 __user *unpc,35__u32 __user *ustatus)36{37long ret;38struct spufs_inode_info *i;39u32 npc, status;4041ret = -EFAULT;42if (get_user(npc, unpc))43goto out;4445/* check if this file was created by spu_create */46ret = -EINVAL;47if (filp->f_op != &spufs_context_fops)48goto out;4950i = SPUFS_I(file_inode(filp));51ret = spufs_run_spu(i->i_ctx, &npc, &status);5253if (put_user(npc, unpc))54ret = -EFAULT;5556if (ustatus && put_user(status, ustatus))57ret = -EFAULT;58out:59return ret;60}6162static long do_spu_create(const char __user *pathname, unsigned int flags,63umode_t mode, struct file *neighbor)64{65struct path path;66struct dentry *dentry;67int ret;6869dentry = user_path_create(AT_FDCWD, pathname, &path, LOOKUP_DIRECTORY);70ret = PTR_ERR(dentry);71if (!IS_ERR(dentry)) {72ret = spufs_create(&path, dentry, flags, mode, neighbor);73done_path_create(&path, dentry);74}7576return ret;77}7879struct spufs_calls spufs_calls = {80.create_thread = do_spu_create,81.spu_run = do_spu_run,82.notify_spus_active = do_notify_spus_active,83.owner = THIS_MODULE,84#ifdef CONFIG_COREDUMP85.coredump_extra_notes_size = spufs_coredump_extra_notes_size,86.coredump_extra_notes_write = spufs_coredump_extra_notes_write,87#endif88};899091