Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * sys_ppc32.c: Conversion between 32bit and 64bit native syscalls. |
| 3 | * |
| 4 | * Copyright (C) 2001 IBM |
| 5 | * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) |
| 6 | * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) |
| 7 | * |
| 8 | * These routines maintain argument size conversion between 32bit and 64bit |
| 9 | * environment. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License |
| 13 | * as published by the Free Software Foundation; either version |
| 14 | * 2 of the License, or (at your option) any later version. |
| 15 | */ |
| 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/kernel.h> |
| 18 | #include <linux/sched.h> |
| 19 | #include <linux/fs.h> |
| 20 | #include <linux/mm.h> |
| 21 | #include <linux/file.h> |
| 22 | #include <linux/signal.h> |
| 23 | #include <linux/resource.h> |
| 24 | #include <linux/times.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <linux/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/sem.h> |
| 27 | #include <linux/msg.h> |
| 28 | #include <linux/shm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <linux/poll.h> |
| 30 | #include <linux/personality.h> |
| 31 | #include <linux/stat.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <linux/mman.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <linux/in.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <linux/syscalls.h> |
| 35 | #include <linux/unistd.h> |
| 36 | #include <linux/sysctl.h> |
| 37 | #include <linux/binfmts.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | #include <linux/security.h> |
| 39 | #include <linux/compat.h> |
| 40 | #include <linux/ptrace.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #include <linux/elf.h> |
Adrian Bunk | cba4fbb | 2007-10-16 23:29:24 -0700 | [diff] [blame] | 42 | #include <linux/ipc.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 43 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <asm/ptrace.h> |
| 46 | #include <asm/types.h> |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 47 | #include <linux/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #include <asm/unistd.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #include <asm/time.h> |
| 50 | #include <asm/mmu_context.h> |
Stephen Rothwell | d387899 | 2005-09-28 02:50:25 +1000 | [diff] [blame] | 51 | #include <asm/ppc-pci.h> |
Arnd Bergmann | 369cf4b | 2006-11-27 19:18:59 +0100 | [diff] [blame] | 52 | #include <asm/syscalls.h> |
David Howells | ae3a197 | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 53 | #include <asm/switch_to.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
Stephen Rothwell | b09a491 | 2005-10-18 14:51:57 +1000 | [diff] [blame] | 55 | unsigned long compat_sys_mmap2(unsigned long addr, size_t len, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | unsigned long prot, unsigned long flags, |
| 57 | unsigned long fd, unsigned long pgoff) |
| 58 | { |
| 59 | /* This should remain 12 even if PAGE_SIZE changes */ |
| 60 | return sys_mmap(addr, len, prot, flags, fd, pgoff << 12); |
| 61 | } |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | /* |
| 64 | * long long munging: |
| 65 | * The 32 bit ABI passes long longs in an odd even register pair. |
| 66 | */ |
| 67 | |
Stephen Rothwell | b09a491 | 2005-10-18 14:51:57 +1000 | [diff] [blame] | 68 | compat_ssize_t compat_sys_pread64(unsigned int fd, char __user *ubuf, compat_size_t count, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | u32 reg6, u32 poshi, u32 poslo) |
| 70 | { |
Dominik Brodowski | 36028d5 | 2018-03-19 17:38:31 +0100 | [diff] [blame] | 71 | return ksys_pread64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | } |
| 73 | |
David Howells | c788732 | 2010-08-11 11:26:22 +0100 | [diff] [blame] | 74 | compat_ssize_t compat_sys_pwrite64(unsigned int fd, const char __user *ubuf, compat_size_t count, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | u32 reg6, u32 poshi, u32 poslo) |
| 76 | { |
Dominik Brodowski | 36028d5 | 2018-03-19 17:38:31 +0100 | [diff] [blame] | 77 | return ksys_pwrite64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Stephen Rothwell | b09a491 | 2005-10-18 14:51:57 +1000 | [diff] [blame] | 80 | compat_ssize_t compat_sys_readahead(int fd, u32 r4, u32 offhi, u32 offlo, u32 count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | { |
Dominik Brodowski | c7b95d5 | 2018-03-19 17:51:36 +0100 | [diff] [blame] | 82 | return ksys_readahead(fd, ((loff_t)offhi << 32) | offlo, count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | } |
| 84 | |
Stephen Rothwell | b09a491 | 2005-10-18 14:51:57 +1000 | [diff] [blame] | 85 | asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | unsigned long high, unsigned long low) |
| 87 | { |
Dominik Brodowski | df260e2 | 2018-03-19 17:32:11 +0100 | [diff] [blame] | 88 | return ksys_truncate(path, (high << 32) | low); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Amit Arora | 97ac735 | 2007-07-17 21:42:44 -0400 | [diff] [blame] | 91 | asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo, |
| 92 | u32 lenhi, u32 lenlo) |
| 93 | { |
Dominik Brodowski | edf292c | 2018-03-19 17:46:32 +0100 | [diff] [blame] | 94 | return ksys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo, |
Amit Arora | 97ac735 | 2007-07-17 21:42:44 -0400 | [diff] [blame] | 95 | ((loff_t)lenhi << 32) | lenlo); |
| 96 | } |
| 97 | |
Stephen Rothwell | b09a491 | 2005-10-18 14:51:57 +1000 | [diff] [blame] | 98 | asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long high, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | unsigned long low) |
| 100 | { |
Dominik Brodowski | 411d947 | 2018-03-11 11:34:54 +0100 | [diff] [blame] | 101 | return ksys_ftruncate(fd, (high << 32) | low); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | } |
| 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low, |
| 105 | size_t len, int advice) |
| 106 | { |
Dominik Brodowski | 9d5b7c9 | 2018-03-11 11:34:45 +0100 | [diff] [blame] | 107 | return ksys_fadvise64_64(fd, (u64)offset_high << 32 | offset_low, len, |
| 108 | advice); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | } |
| 110 | |
David Woodhouse | edd5cd4 | 2007-06-27 14:10:09 -0700 | [diff] [blame] | 111 | asmlinkage long compat_sys_sync_file_range2(int fd, unsigned int flags, |
| 112 | unsigned offset_hi, unsigned offset_lo, |
| 113 | unsigned nbytes_hi, unsigned nbytes_lo) |
| 114 | { |
| 115 | loff_t offset = ((loff_t)offset_hi << 32) | offset_lo; |
| 116 | loff_t nbytes = ((loff_t)nbytes_hi << 32) | nbytes_lo; |
| 117 | |
Dominik Brodowski | 806cbae | 2018-03-11 11:34:47 +0100 | [diff] [blame] | 118 | return ksys_sync_file_range(fd, offset, nbytes, flags); |
David Woodhouse | edd5cd4 | 2007-06-27 14:10:09 -0700 | [diff] [blame] | 119 | } |