1
2
3
4
5
6
7
8
9#include <linux/errno.h>
10#include <linux/fs.h>
11#include <linux/mm.h>
12#include <linux/mman.h>
13#include <linux/sched.h>
14#include <linux/sched/mm.h>
15#include <linux/sched/task_stack.h>
16#include <linux/shm.h>
17#include <linux/file.h>
18#include <linux/smp.h>
19#include <linux/syscalls.h>
20#include <linux/highuid.h>
21#include <linux/hugetlb.h>
22
23#include <asm/shmparam.h>
24#include <linux/uaccess.h>
25
26unsigned long
27arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len,
28 unsigned long pgoff, unsigned long flags)
29{
30 long map_shared = (flags & MAP_SHARED);
31 unsigned long align_mask = 0;
32 struct mm_struct *mm = current->mm;
33 struct vm_unmapped_area_info info;
34
35 if (len > RGN_MAP_LIMIT)
36 return -ENOMEM;
37
38
39 if (flags & MAP_FIXED) {
40 if (is_hugepage_only_range(mm, addr, len))
41 return -EINVAL;
42 return addr;
43 }
44
45#ifdef CONFIG_HUGETLB_PAGE
46 if (REGION_NUMBER(addr) == RGN_HPAGE)
47 addr = 0;
48#endif
49 if (!addr)
50 addr = TASK_UNMAPPED_BASE;
51
52 if (map_shared && (TASK_SIZE > 0xfffffffful))
53
54
55
56
57
58
59 align_mask = PAGE_MASK & (SHMLBA - 1);
60
61 info.flags = 0;
62 info.length = len;
63 info.low_limit = addr;
64 info.high_limit = TASK_SIZE;
65 info.align_mask = align_mask;
66 info.align_offset = 0;
67 return vm_unmapped_area(&info);
68}
69
70asmlinkage long
71ia64_getpriority (int which, int who)
72{
73 long prio;
74
75 prio = sys_getpriority(which, who);
76 if (prio >= 0) {
77 force_successful_syscall_return();
78 prio = 20 - prio;
79 }
80 return prio;
81}
82
83
84asmlinkage unsigned long
85sys_getpagesize (void)
86{
87 return PAGE_SIZE;
88}
89
90asmlinkage unsigned long
91ia64_brk (unsigned long brk)
92{
93 unsigned long retval = sys_brk(brk);
94 force_successful_syscall_return();
95 return retval;
96}
97
98
99
100
101
102asmlinkage long
103sys_ia64_pipe (void)
104{
105 struct pt_regs *regs = task_pt_regs(current);
106 int fd[2];
107 int retval;
108
109 retval = do_pipe_flags(fd, 0);
110 if (retval)
111 goto out;
112 retval = fd[0];
113 regs->r9 = fd[1];
114 out:
115 return retval;
116}
117
118int ia64_mmap_check(unsigned long addr, unsigned long len,
119 unsigned long flags)
120{
121 unsigned long roff;
122
123
124
125
126
127
128 roff = REGION_OFFSET(addr);
129 if ((len > RGN_MAP_LIMIT) || (roff > (RGN_MAP_LIMIT - len)))
130 return -EINVAL;
131 return 0;
132}
133
134
135
136
137
138
139asmlinkage unsigned long
140sys_mmap2 (unsigned long addr, unsigned long len, int prot, int flags, int fd, long pgoff)
141{
142 addr = ksys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
143 if (!IS_ERR((void *) addr))
144 force_successful_syscall_return();
145 return addr;
146}
147
148asmlinkage unsigned long
149sys_mmap (unsigned long addr, unsigned long len, int prot, int flags, int fd, long off)
150{
151 if (offset_in_page(off) != 0)
152 return -EINVAL;
153
154 addr = ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
155 if (!IS_ERR((void *) addr))
156 force_successful_syscall_return();
157 return addr;
158}
159
160asmlinkage unsigned long
161ia64_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags,
162 unsigned long new_addr)
163{
164 addr = sys_mremap(addr, old_len, new_len, flags, new_addr);
165 if (!IS_ERR((void *) addr))
166 force_successful_syscall_return();
167 return addr;
168}
169
170#ifndef CONFIG_PCI
171
172asmlinkage long
173sys_pciconfig_read (unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len,
174 void *buf)
175{
176 return -ENOSYS;
177}
178
179asmlinkage long
180sys_pciconfig_write (unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len,
181 void *buf)
182{
183 return -ENOSYS;
184}
185
186#endif
187