]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/ia64/kernel/sys_ia64.c
Merge tag 'efi-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi into...
[mirror_ubuntu-artful-kernel.git] / arch / ia64 / kernel / sys_ia64.c
CommitLineData
1da177e4
LT
1/*
2 * This file contains various system calls that have different calling
3 * conventions on different platforms.
4 *
5 * Copyright (C) 1999-2000, 2002-2003, 2005 Hewlett-Packard Co
6 * David Mosberger-Tang <davidm@hpl.hp.com>
7 */
1da177e4
LT
8#include <linux/errno.h>
9#include <linux/fs.h>
10#include <linux/mm.h>
11#include <linux/mman.h>
12#include <linux/sched.h>
01042607 13#include <linux/sched/mm.h>
68db0cf1 14#include <linux/sched/task_stack.h>
1da177e4
LT
15#include <linux/shm.h>
16#include <linux/file.h> /* doh, must come after sched.h... */
17#include <linux/smp.h>
1da177e4
LT
18#include <linux/syscalls.h>
19#include <linux/highuid.h>
20#include <linux/hugetlb.h>
21
22#include <asm/shmparam.h>
7c0f6ba6 23#include <linux/uaccess.h>
1da177e4
LT
24
25unsigned long
26arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len,
27 unsigned long pgoff, unsigned long flags)
28{
29 long map_shared = (flags & MAP_SHARED);
f53f2325 30 unsigned long align_mask = 0;
1da177e4 31 struct mm_struct *mm = current->mm;
f53f2325 32 struct vm_unmapped_area_info info;
1da177e4
LT
33
34 if (len > RGN_MAP_LIMIT)
35 return -ENOMEM;
36
afa37394
BH
37 /* handle fixed mapping: prevent overlap with huge pages */
38 if (flags & MAP_FIXED) {
39 if (is_hugepage_only_range(mm, addr, len))
40 return -EINVAL;
41 return addr;
42 }
43
1da177e4 44#ifdef CONFIG_HUGETLB_PAGE
0a41e250 45 if (REGION_NUMBER(addr) == RGN_HPAGE)
1da177e4
LT
46 addr = 0;
47#endif
48 if (!addr)
f53f2325 49 addr = TASK_UNMAPPED_BASE;
1da177e4
LT
50
51 if (map_shared && (TASK_SIZE > 0xfffffffful))
52 /*
53 * For 64-bit tasks, align shared segments to 1MB to avoid potential
54 * performance penalty due to virtual aliasing (see ASDM). For 32-bit
55 * tasks, we prefer to avoid exhausting the address space too quickly by
56 * limiting alignment to a single page.
57 */
f53f2325 58 align_mask = PAGE_MASK & (SHMLBA - 1);
1da177e4 59
f53f2325
ML
60 info.flags = 0;
61 info.length = len;
62 info.low_limit = addr;
63 info.high_limit = TASK_SIZE;
64 info.align_mask = align_mask;
65 info.align_offset = 0;
66 return vm_unmapped_area(&info);
1da177e4
LT
67}
68
69asmlinkage long
70ia64_getpriority (int which, int who)
71{
72 long prio;
73
74 prio = sys_getpriority(which, who);
75 if (prio >= 0) {
76 force_successful_syscall_return();
77 prio = 20 - prio;
78 }
79 return prio;
80}
81
82/* XXX obsolete, but leave it here until the old libc is gone... */
83asmlinkage unsigned long
84sys_getpagesize (void)
85{
86 return PAGE_SIZE;
87}
88
1da177e4
LT
89asmlinkage unsigned long
90ia64_brk (unsigned long brk)
91{
bb52d669 92 unsigned long retval = sys_brk(brk);
1da177e4
LT
93 force_successful_syscall_return();
94 return retval;
95}
96
97/*
98 * On IA-64, we return the two file descriptors in ret0 and ret1 (r8
99 * and r9) as this is faster than doing a copy_to_user().
100 */
101asmlinkage long
1134723e 102sys_ia64_pipe (void)
1da177e4 103{
6450578f 104 struct pt_regs *regs = task_pt_regs(current);
1da177e4
LT
105 int fd[2];
106 int retval;
107
ed8cae8b 108 retval = do_pipe_flags(fd, 0);
1da177e4
LT
109 if (retval)
110 goto out;
111 retval = fd[0];
112 regs->r9 = fd[1];
113 out:
114 return retval;
115}
116
3a459756
KK
117int ia64_mmap_check(unsigned long addr, unsigned long len,
118 unsigned long flags)
119{
120 unsigned long roff;
121
122 /*
123 * Don't permit mappings into unmapped space, the virtual page table
124 * of a region, or across a region boundary. Note: RGN_MAP_LIMIT is
125 * equal to 2^n-PAGE_SIZE (for some integer n <= 61) and len > 0.
126 */
127 roff = REGION_OFFSET(addr);
128 if ((len > RGN_MAP_LIMIT) || (roff > (RGN_MAP_LIMIT - len)))
129 return -EINVAL;
130 return 0;
131}
132
1da177e4
LT
133/*
134 * mmap2() is like mmap() except that the offset is expressed in units
135 * of PAGE_SIZE (instead of bytes). This allows to mmap2() (pieces
136 * of) files that are larger than the address space of the CPU.
137 */
138asmlinkage unsigned long
139sys_mmap2 (unsigned long addr, unsigned long len, int prot, int flags, int fd, long pgoff)
140{
f8b72560 141 addr = sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
1da177e4
LT
142 if (!IS_ERR((void *) addr))
143 force_successful_syscall_return();
144 return addr;
145}
146
147asmlinkage unsigned long
148sys_mmap (unsigned long addr, unsigned long len, int prot, int flags, int fd, long off)
149{
150 if (offset_in_page(off) != 0)
151 return -EINVAL;
152
f8b72560 153 addr = sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
1da177e4
LT
154 if (!IS_ERR((void *) addr))
155 force_successful_syscall_return();
156 return addr;
157}
158
159asmlinkage unsigned long
160ia64_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags,
161 unsigned long new_addr)
162{
657bec85
AV
163 addr = sys_mremap(addr, old_len, new_len, flags, new_addr);
164 if (!IS_ERR((void *) addr))
165 force_successful_syscall_return();
1da177e4
LT
166 return addr;
167}
168
169#ifndef CONFIG_PCI
170
171asmlinkage long
172sys_pciconfig_read (unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len,
173 void *buf)
174{
175 return -ENOSYS;
176}
177
178asmlinkage long
179sys_pciconfig_write (unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len,
180 void *buf)
181{
182 return -ENOSYS;
183}
184
185#endif /* CONFIG_PCI */