1 /* 2 * sys_parisc32.c: Conversion between 32bit and 64bit native syscalls. 3 * 4 * Copyright (C) 2000-2001 Hewlett Packard Company 5 * Copyright (C) 2000 John Marvin 6 * Copyright (C) 2001 Matthew Wilcox 7 * 8 * These routines maintain argument size conversion between 32bit and 64bit 9 * environment. Based heavily on sys_ia32.c and sys_sparc32.c. 10 */ 11 12 #include <linux/compat.h> 13 #include <linux/kernel.h> 14 #include <linux/sched.h> 15 #include <linux/fs.h> 16 #include <linux/mm.h> 17 #include <linux/file.h> 18 #include <linux/signal.h> 19 #include <linux/resource.h> 20 #include <linux/times.h> 21 #include <linux/time.h> 22 #include <linux/smp.h> 23 #include <linux/sem.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> 40 41 #include <asm/types.h> 42 #include <asm/uaccess.h> 43 #include <asm/mmu_context.h> 44 45 #include "sys32.h" 46 47 #undef DEBUG 48 49 #ifdef DEBUG 50 #define DBG(x) printk x 51 #else 52 #define DBG(x) 53 #endif 54 55 asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23, 56 int r22, int r21, int r20) 57 { 58 printk(KERN_ERR "%s(%d): Unimplemented 32 on 64 syscall #%d!\n", 59 current->comm, current->pid, r20); 60 return -ENOSYS; 61 } 62 63 asmlinkage long sys32_sched_rr_get_interval(pid_t pid, 64 struct compat_timespec __user *interval) 65 { 66 struct timespec t; 67 int ret; 68 69 KERNEL_SYSCALL(ret, sys_sched_rr_get_interval, pid, (struct timespec __user *)&t); 70 if (put_compat_timespec(&t, interval)) 71 return -EFAULT; 72 return ret; 73 } 74 75 asmlinkage int sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count) 76 { 77 mm_segment_t old_fs = get_fs(); 78 int ret; 79 off_t of; 80 81 if (offset && get_user(of, offset)) 82 return -EFAULT; 83 84 set_fs(KERNEL_DS); 85 ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL, count); 86 set_fs(old_fs); 87 88 if (offset && put_user(of, offset)) 89 return -EFAULT; 90 91 return ret; 92 } 93 94 asmlinkage int sys32_sendfile64(int out_fd, int in_fd, compat_loff_t __user *offset, s32 count) 95 { 96 mm_segment_t old_fs = get_fs(); 97 int ret; 98 loff_t lof; 99 100 if (offset && get_user(lof, offset)) 101 return -EFAULT; 102 103 set_fs(KERNEL_DS); 104 ret = sys_sendfile64(out_fd, in_fd, offset ? (loff_t __user *)&lof : NULL, count); 105 set_fs(old_fs); 106 107 if (offset && put_user(lof, offset)) 108 return -EFAULT; 109 110 return ret; 111 } 112 113 114 /* lseek() needs a wrapper because 'offset' can be negative, but the top 115 * half of the argument has been zeroed by syscall.S. 116 */ 117 118 asmlinkage int sys32_lseek(unsigned int fd, int offset, unsigned int origin) 119 { 120 return sys_lseek(fd, offset, origin); 121 } 122 123 asmlinkage long sys32_semctl(int semid, int semnum, int cmd, union semun arg) 124 { 125 union semun u; 126 127 if (cmd == SETVAL) { 128 /* Ugh. arg is a union of int,ptr,ptr,ptr, so is 8 bytes. 129 * The int should be in the first 4, but our argument 130 * frobbing has left it in the last 4. 131 */ 132 u.val = *((int *)&arg + 1); 133 return sys_semctl (semid, semnum, cmd, u); 134 } 135 return sys_semctl (semid, semnum, cmd, arg); 136 } 137 138 long sys32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char __user *buf, 139 size_t len) 140 { 141 return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low, 142 buf, len); 143 } 144 145 asmlinkage long compat_sys_fanotify_mark(int fan_fd, int flags, u32 mask_hi, 146 u32 mask_lo, int fd, 147 const char __user *pathname) 148 { 149 return sys_fanotify_mark(fan_fd, flags, ((u64)mask_hi << 32) | mask_lo, 150 fd, pathname); 151 } 152