Path: blob/master/arch/parisc/kernel/sys_parisc32.c
10817 views
/*1* sys_parisc32.c: Conversion between 32bit and 64bit native syscalls.2*3* Copyright (C) 2000-2001 Hewlett Packard Company4* Copyright (C) 2000 John Marvin5* Copyright (C) 2001 Matthew Wilcox6*7* These routines maintain argument size conversion between 32bit and 64bit8* environment. Based heavily on sys_ia32.c and sys_sparc32.c.9*/1011#include <linux/compat.h>12#include <linux/kernel.h>13#include <linux/sched.h>14#include <linux/fs.h>15#include <linux/mm.h>16#include <linux/file.h>17#include <linux/signal.h>18#include <linux/resource.h>19#include <linux/times.h>20#include <linux/time.h>21#include <linux/smp.h>22#include <linux/sem.h>23#include <linux/msg.h>24#include <linux/shm.h>25#include <linux/slab.h>26#include <linux/uio.h>27#include <linux/ncp_fs.h>28#include <linux/poll.h>29#include <linux/personality.h>30#include <linux/stat.h>31#include <linux/highmem.h>32#include <linux/highuid.h>33#include <linux/mman.h>34#include <linux/binfmts.h>35#include <linux/namei.h>36#include <linux/vfs.h>37#include <linux/ptrace.h>38#include <linux/swap.h>39#include <linux/syscalls.h>4041#include <asm/types.h>42#include <asm/uaccess.h>43#include <asm/mmu_context.h>4445#include "sys32.h"4647#undef DEBUG4849#ifdef DEBUG50#define DBG(x) printk x51#else52#define DBG(x)53#endif5455/*56* sys32_execve() executes a new program.57*/5859asmlinkage int sys32_execve(struct pt_regs *regs)60{61int error;62char *filename;6364DBG(("sys32_execve(%p) r26 = 0x%lx\n", regs, regs->gr[26]));65filename = getname((const char __user *) regs->gr[26]);66error = PTR_ERR(filename);67if (IS_ERR(filename))68goto out;69error = compat_do_execve(filename, compat_ptr(regs->gr[25]),70compat_ptr(regs->gr[24]), regs);71putname(filename);72out:7374return error;75}7677asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23,78int r22, int r21, int r20)79{80printk(KERN_ERR "%s(%d): Unimplemented 32 on 64 syscall #%d!\n",81current->comm, current->pid, r20);82return -ENOSYS;83}8485asmlinkage long sys32_sched_rr_get_interval(pid_t pid,86struct compat_timespec __user *interval)87{88struct timespec t;89int ret;9091KERNEL_SYSCALL(ret, sys_sched_rr_get_interval, pid, (struct timespec __user *)&t);92if (put_compat_timespec(&t, interval))93return -EFAULT;94return ret;95}9697struct msgbuf32 {98int mtype;99char mtext[1];100};101102asmlinkage long sys32_msgsnd(int msqid,103struct msgbuf32 __user *umsgp32,104size_t msgsz, int msgflg)105{106struct msgbuf *mb;107struct msgbuf32 mb32;108int err;109110if ((mb = kmalloc(msgsz + sizeof *mb + 4, GFP_KERNEL)) == NULL)111return -ENOMEM;112113err = get_user(mb32.mtype, &umsgp32->mtype);114mb->mtype = mb32.mtype;115err |= copy_from_user(mb->mtext, &umsgp32->mtext, msgsz);116117if (err)118err = -EFAULT;119else120KERNEL_SYSCALL(err, sys_msgsnd, msqid, (struct msgbuf __user *)mb, msgsz, msgflg);121122kfree(mb);123return err;124}125126asmlinkage long sys32_msgrcv(int msqid,127struct msgbuf32 __user *umsgp32,128size_t msgsz, long msgtyp, int msgflg)129{130struct msgbuf *mb;131struct msgbuf32 mb32;132int err, len;133134if ((mb = kmalloc(msgsz + sizeof *mb + 4, GFP_KERNEL)) == NULL)135return -ENOMEM;136137KERNEL_SYSCALL(err, sys_msgrcv, msqid, (struct msgbuf __user *)mb, msgsz, msgtyp, msgflg);138139if (err >= 0) {140len = err;141mb32.mtype = mb->mtype;142err = put_user(mb32.mtype, &umsgp32->mtype);143err |= copy_to_user(&umsgp32->mtext, mb->mtext, len);144if (err)145err = -EFAULT;146else147err = len;148}149150kfree(mb);151return err;152}153154asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count)155{156mm_segment_t old_fs = get_fs();157int ret;158off_t of;159160if (offset && get_user(of, offset))161return -EFAULT;162163set_fs(KERNEL_DS);164ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL, count);165set_fs(old_fs);166167if (offset && put_user(of, offset))168return -EFAULT;169170return ret;171}172173asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t __user *offset, s32 count)174{175mm_segment_t old_fs = get_fs();176int ret;177loff_t lof;178179if (offset && get_user(lof, offset))180return -EFAULT;181182set_fs(KERNEL_DS);183ret = sys_sendfile64(out_fd, in_fd, offset ? (loff_t __user *)&lof : NULL, count);184set_fs(old_fs);185186if (offset && put_user(lof, offset))187return -EFAULT;188189return ret;190}191192193/* lseek() needs a wrapper because 'offset' can be negative, but the top194* half of the argument has been zeroed by syscall.S.195*/196197asmlinkage int sys32_lseek(unsigned int fd, int offset, unsigned int origin)198{199return sys_lseek(fd, offset, origin);200}201202asmlinkage long sys32_semctl(int semid, int semnum, int cmd, union semun arg)203{204union semun u;205206if (cmd == SETVAL) {207/* Ugh. arg is a union of int,ptr,ptr,ptr, so is 8 bytes.208* The int should be in the first 4, but our argument209* frobbing has left it in the last 4.210*/211u.val = *((int *)&arg + 1);212return sys_semctl (semid, semnum, cmd, u);213}214return sys_semctl (semid, semnum, cmd, arg);215}216217long sys32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char __user *buf,218size_t len)219{220return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low,221buf, len);222}223224asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,225u32 lenhi, u32 lenlo)226{227return sys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,228((loff_t)lenhi << 32) | lenlo);229}230231asmlinkage long compat_sys_fanotify_mark(int fan_fd, int flags, u32 mask_hi,232u32 mask_lo, int fd,233const char __user *pathname)234{235return sys_fanotify_mark(fan_fd, flags, ((u64)mask_hi << 32) | mask_lo,236fd, pathname);237}238239240