x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub
[linux/fpc-iii.git] / arch / parisc / kernel / sys_parisc.c
blob0d3a9d4927b58009bfe0c4dc4114585409ddd2f5
2 /*
3 * PARISC specific syscalls
5 * Copyright (C) 1999-2003 Matthew Wilcox <willy at parisc-linux.org>
6 * Copyright (C) 2000-2003 Paul Bame <bame at parisc-linux.org>
7 * Copyright (C) 2001 Thomas Bogendoerfer <tsbogend at parisc-linux.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <asm/uaccess.h>
26 #include <linux/file.h>
27 #include <linux/fs.h>
28 #include <linux/linkage.h>
29 #include <linux/mm.h>
30 #include <linux/mman.h>
31 #include <linux/shm.h>
32 #include <linux/syscalls.h>
33 #include <linux/utsname.h>
34 #include <linux/personality.h>
36 static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
38 struct vm_unmapped_area_info info;
40 info.flags = 0;
41 info.length = len;
42 info.low_limit = PAGE_ALIGN(addr);
43 info.high_limit = TASK_SIZE;
44 info.align_mask = 0;
45 info.align_offset = 0;
46 return vm_unmapped_area(&info);
50 * We need to know the offset to use. Old scheme was to look for
51 * existing mapping and use the same offset. New scheme is to use the
52 * address of the kernel data structure as the seed for the offset.
53 * We'll see how that works...
55 * The mapping is cacheline aligned, so there's no information in the bottom
56 * few bits of the address. We're looking for 10 bits (4MB / 4k), so let's
57 * drop the bottom 8 bits and use bits 8-17.
59 static int get_offset(struct address_space *mapping)
61 return (unsigned long) mapping >> 8;
64 static unsigned long shared_align_offset(struct file *filp, unsigned long pgoff)
66 struct address_space *mapping = filp ? filp->f_mapping : NULL;
68 return (get_offset(mapping) + pgoff) << PAGE_SHIFT;
71 static unsigned long get_shared_area(struct file *filp, unsigned long addr,
72 unsigned long len, unsigned long pgoff)
74 struct vm_unmapped_area_info info;
76 info.flags = 0;
77 info.length = len;
78 info.low_limit = PAGE_ALIGN(addr);
79 info.high_limit = TASK_SIZE;
80 info.align_mask = PAGE_MASK & (SHMLBA - 1);
81 info.align_offset = shared_align_offset(filp, pgoff);
82 return vm_unmapped_area(&info);
85 unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
86 unsigned long len, unsigned long pgoff, unsigned long flags)
88 if (len > TASK_SIZE)
89 return -ENOMEM;
90 if (flags & MAP_FIXED) {
91 if ((flags & MAP_SHARED) &&
92 (addr - shared_align_offset(filp, pgoff)) & (SHMLBA - 1))
93 return -EINVAL;
94 return addr;
96 if (!addr)
97 addr = TASK_UNMAPPED_BASE;
99 if (filp || (flags & MAP_SHARED))
100 addr = get_shared_area(filp, addr, len, pgoff);
101 else
102 addr = get_unshared_area(addr, len);
104 return addr;
107 asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len,
108 unsigned long prot, unsigned long flags, unsigned long fd,
109 unsigned long pgoff)
111 /* Make sure the shift for mmap2 is constant (12), no matter what PAGE_SIZE
112 we have. */
113 return sys_mmap_pgoff(addr, len, prot, flags, fd,
114 pgoff >> (PAGE_SHIFT - 12));
117 asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
118 unsigned long prot, unsigned long flags, unsigned long fd,
119 unsigned long offset)
121 if (!(offset & ~PAGE_MASK)) {
122 return sys_mmap_pgoff(addr, len, prot, flags, fd,
123 offset >> PAGE_SHIFT);
124 } else {
125 return -EINVAL;
129 /* Fucking broken ABI */
131 #ifdef CONFIG_64BIT
132 asmlinkage long parisc_truncate64(const char __user * path,
133 unsigned int high, unsigned int low)
135 return sys_truncate(path, (long)high << 32 | low);
138 asmlinkage long parisc_ftruncate64(unsigned int fd,
139 unsigned int high, unsigned int low)
141 return sys_ftruncate(fd, (long)high << 32 | low);
144 /* stubs for the benefit of the syscall_table since truncate64 and truncate
145 * are identical on LP64 */
146 asmlinkage long sys_truncate64(const char __user * path, unsigned long length)
148 return sys_truncate(path, length);
150 asmlinkage long sys_ftruncate64(unsigned int fd, unsigned long length)
152 return sys_ftruncate(fd, length);
154 asmlinkage long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg)
156 return sys_fcntl(fd, cmd, arg);
158 #else
160 asmlinkage long parisc_truncate64(const char __user * path,
161 unsigned int high, unsigned int low)
163 return sys_truncate64(path, (loff_t)high << 32 | low);
166 asmlinkage long parisc_ftruncate64(unsigned int fd,
167 unsigned int high, unsigned int low)
169 return sys_ftruncate64(fd, (loff_t)high << 32 | low);
171 #endif
173 asmlinkage ssize_t parisc_pread64(unsigned int fd, char __user *buf, size_t count,
174 unsigned int high, unsigned int low)
176 return sys_pread64(fd, buf, count, (loff_t)high << 32 | low);
179 asmlinkage ssize_t parisc_pwrite64(unsigned int fd, const char __user *buf,
180 size_t count, unsigned int high, unsigned int low)
182 return sys_pwrite64(fd, buf, count, (loff_t)high << 32 | low);
185 asmlinkage ssize_t parisc_readahead(int fd, unsigned int high, unsigned int low,
186 size_t count)
188 return sys_readahead(fd, (loff_t)high << 32 | low, count);
191 asmlinkage long parisc_fadvise64_64(int fd,
192 unsigned int high_off, unsigned int low_off,
193 unsigned int high_len, unsigned int low_len, int advice)
195 return sys_fadvise64_64(fd, (loff_t)high_off << 32 | low_off,
196 (loff_t)high_len << 32 | low_len, advice);
199 asmlinkage long parisc_sync_file_range(int fd,
200 u32 hi_off, u32 lo_off, u32 hi_nbytes, u32 lo_nbytes,
201 unsigned int flags)
203 return sys_sync_file_range(fd, (loff_t)hi_off << 32 | lo_off,
204 (loff_t)hi_nbytes << 32 | lo_nbytes, flags);
207 asmlinkage long parisc_fallocate(int fd, int mode, u32 offhi, u32 offlo,
208 u32 lenhi, u32 lenlo)
210 return sys_fallocate(fd, mode, ((u64)offhi << 32) | offlo,
211 ((u64)lenhi << 32) | lenlo);
214 asmlinkage unsigned long sys_alloc_hugepages(int key, unsigned long addr, unsigned long len, int prot, int flag)
216 return -ENOMEM;
219 asmlinkage int sys_free_hugepages(unsigned long addr)
221 return -EINVAL;
224 long parisc_personality(unsigned long personality)
226 long err;
228 if (personality(current->personality) == PER_LINUX32
229 && personality(personality) == PER_LINUX)
230 personality = (personality & ~PER_MASK) | PER_LINUX32;
232 err = sys_personality(personality);
233 if (personality(err) == PER_LINUX32)
234 err = (err & ~PER_MASK) | PER_LINUX;
236 return err;