2 * arch/xtensa/kernel/syscall.c
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 * Copyright (C) 2000 Silicon Graphics, Inc.
10 * Copyright (C) 1995 - 2000 by Ralf Baechle
18 #include <linux/uaccess.h>
19 #include <asm/syscall.h>
20 #include <linux/linkage.h>
21 #include <linux/stringify.h>
22 #include <linux/errno.h>
23 #include <linux/syscalls.h>
24 #include <linux/file.h>
26 #include <linux/mman.h>
27 #include <linux/sched/mm.h>
28 #include <linux/shm.h>
30 syscall_t sys_call_table[] /* FIXME __cacheline_aligned */= {
31 #define __SYSCALL(nr, entry) (syscall_t)entry,
32 #include <asm/syscall_table.h>
35 #define COLOUR_ALIGN(addr, pgoff) \
36 ((((addr) + SHMLBA - 1) & ~(SHMLBA - 1)) + \
37 (((pgoff) << PAGE_SHIFT) & (SHMLBA - 1)))
39 asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
44 err = do_shmat(shmid, shmaddr, shmflg, &ret, SHMLBA);
50 asmlinkage long xtensa_fadvise64_64(int fd, int advice,
51 unsigned long long offset, unsigned long long len)
53 return ksys_fadvise64_64(fd, offset, len, advice);
57 unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
58 unsigned long len, unsigned long pgoff, unsigned long flags)
60 struct vm_area_struct *vmm;
62 if (flags & MAP_FIXED) {
63 /* We do not accept a shared mapping if it would violate
64 * cache aliasing constraints.
66 if ((flags & MAP_SHARED) &&
67 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
75 addr = TASK_UNMAPPED_BASE;
77 if (flags & MAP_SHARED)
78 addr = COLOUR_ALIGN(addr, pgoff);
80 addr = PAGE_ALIGN(addr);
82 for (vmm = find_vma(current->mm, addr); ; vmm = vmm->vm_next) {
83 /* At this point: (!vmm || addr < vmm->vm_end). */
84 if (TASK_SIZE - len < addr)
86 if (!vmm || addr + len <= vm_start_gap(vmm))
89 if (flags & MAP_SHARED)
90 addr = COLOUR_ALIGN(addr, pgoff);