]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - arch/x86_64/kernel/sys_x86_64.c
2 * linux/arch/x86_64/kernel/sys_x86_64.c
5 #include <linux/errno.h>
6 #include <linux/sched.h>
7 #include <linux/syscalls.h>
10 #include <linux/smp_lock.h>
11 #include <linux/sem.h>
12 #include <linux/msg.h>
13 #include <linux/shm.h>
14 #include <linux/stat.h>
15 #include <linux/mman.h>
16 #include <linux/file.h>
17 #include <linux/utsname.h>
18 #include <linux/personality.h>
20 #include <asm/uaccess.h>
24 * sys_pipe() is the normal C calling standard for creating
25 * a pipe. It's not the way Unix traditionally does this, though.
27 asmlinkage
long sys_pipe(int __user
*fildes
)
34 if (copy_to_user(fildes
, fd
, 2*sizeof(int)))
40 asmlinkage
long sys_mmap(unsigned long addr
, unsigned long len
, unsigned long prot
, unsigned long flags
,
41 unsigned long fd
, unsigned long off
)
52 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
53 if (!(flags
& MAP_ANONYMOUS
)) {
58 down_write(¤t
->mm
->mmap_sem
);
59 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, off
>> PAGE_SHIFT
);
60 up_write(¤t
->mm
->mmap_sem
);
68 static void find_start_end(unsigned long flags
, unsigned long *begin
,
71 if (!test_thread_flag(TIF_IA32
) && (flags
& MAP_32BIT
)) {
72 /* This is usually used needed to map code in small
73 model, so it needs to be in the first 31bit. Limit
74 it to that. This means we need to move the
75 unmapped base down for this case. This can give
76 conflicts with the heap, but we assume that glibc
77 malloc knows how to fall back to mmap. Give it 1GB
78 of playground for now. -AK */
82 *begin
= TASK_UNMAPPED_BASE
;
88 arch_get_unmapped_area(struct file
*filp
, unsigned long addr
,
89 unsigned long len
, unsigned long pgoff
, unsigned long flags
)
91 struct mm_struct
*mm
= current
->mm
;
92 struct vm_area_struct
*vma
;
93 unsigned long start_addr
;
94 unsigned long begin
, end
;
96 find_start_end(flags
, &begin
, &end
);
102 addr
= PAGE_ALIGN(addr
);
103 vma
= find_vma(mm
, addr
);
104 if (end
- len
>= addr
&&
105 (!vma
|| addr
+ len
<= vma
->vm_start
))
108 if (((flags
& MAP_32BIT
) || test_thread_flag(TIF_IA32
))
109 && len
<= mm
->cached_hole_size
) {
110 mm
->cached_hole_size
= 0;
111 mm
->free_area_cache
= begin
;
113 addr
= mm
->free_area_cache
;
119 for (vma
= find_vma(mm
, addr
); ; vma
= vma
->vm_next
) {
120 /* At this point: (!vma || addr < vma->vm_end). */
121 if (end
- len
< addr
) {
123 * Start a new search - just in case we missed
126 if (start_addr
!= begin
) {
127 start_addr
= addr
= begin
;
128 mm
->cached_hole_size
= 0;
133 if (!vma
|| addr
+ len
<= vma
->vm_start
) {
135 * Remember the place where we stopped the search:
137 mm
->free_area_cache
= addr
+ len
;
140 if (addr
+ mm
->cached_hole_size
< vma
->vm_start
)
141 mm
->cached_hole_size
= vma
->vm_start
- addr
;
147 asmlinkage
long sys_uname(struct new_utsname __user
* name
)
151 err
= copy_to_user(name
, &system_utsname
, sizeof (*name
));
153 if (personality(current
->personality
) == PER_LINUX32
)
154 err
|= copy_to_user(&name
->machine
, "i686", 5);
155 return err
? -EFAULT
: 0;
158 asmlinkage
long sys_time64(long __user
* tloc
)
163 do_gettimeofday(&now
);
166 if (put_user(i
,tloc
))