blob: eca69bb8ef5f48dd503dc986a9157444c86abc1e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/time.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/sem.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/shm.h>
25#include <linux/slab.h>
26#include <linux/uio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/ncp_fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#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
Linus Torvalds1da177e2005-04-16 15:20:36 -070055asmlinkage 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
Helge Dellerf03d70a2013-02-19 22:55:17 +010063/* Note: it is necessary to treat out_fd and in_fd as unsigned ints, with the
64 * corresponding cast to a signed int to insure that the proper conversion
65 * (sign extension) between the register representation of a signed int (msr in
66 * 32-bit mode) and the register representation of a signed int (msr in 64-bit
67 * mode) is performed.
68 */
69asmlinkage long sys32_sendfile(u32 out_fd, u32 in_fd,
70 compat_off_t __user *offset, compat_size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
Helge Dellerf03d70a2013-02-19 22:55:17 +010072 return compat_sys_sendfile((int)out_fd, (int)in_fd, offset, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073}
74
Helge Dellerf03d70a2013-02-19 22:55:17 +010075asmlinkage long sys32_sendfile64(u32 out_fd, u32 in_fd,
76 compat_loff_t __user *offset, compat_size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -070077{
Helge Dellerf03d70a2013-02-19 22:55:17 +010078 return sys_sendfile64((int)out_fd, (int)in_fd,
79 (loff_t __user *)offset, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080}
81
82
Linus Torvalds1da177e2005-04-16 15:20:36 -070083/* lseek() needs a wrapper because 'offset' can be negative, but the top
84 * half of the argument has been zeroed by syscall.S.
85 */
86
87asmlinkage int sys32_lseek(unsigned int fd, int offset, unsigned int origin)
88{
89 return sys_lseek(fd, offset, origin);
90}
91
92asmlinkage long sys32_semctl(int semid, int semnum, int cmd, union semun arg)
93{
94 union semun u;
95
96 if (cmd == SETVAL) {
97 /* Ugh. arg is a union of int,ptr,ptr,ptr, so is 8 bytes.
98 * The int should be in the first 4, but our argument
99 * frobbing has left it in the last 4.
100 */
101 u.val = *((int *)&arg + 1);
102 return sys_semctl (semid, semnum, cmd, u);
103 }
104 return sys_semctl (semid, semnum, cmd, arg);
105}
106
107long sys32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char __user *buf,
108 size_t len)
109{
110 return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low,
111 buf, len);
112}
Kyle McMartin2cfc5be2007-09-28 13:25:59 -0400113
James Bottomley18240742011-04-15 08:55:44 -0700114asmlinkage long compat_sys_fanotify_mark(int fan_fd, int flags, u32 mask_hi,
115 u32 mask_lo, int fd,
116 const char __user *pathname)
117{
118 return sys_fanotify_mark(fan_fd, flags, ((u64)mask_hi << 32) | mask_lo,
119 fd, pathname);
120}