Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * arch/xtensa/kernel/syscall.c
3 *
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
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 * Copyright (C) 2000 Silicon Graphics, Inc.
10 * Copyright (C) 1995 - 2000 by Ralf Baechle
11 *
12 * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
13 * Marc Gauthier <marc@tensilica.com, marc@alumni.uwaterloo.ca>
14 * Chris Zankel <chris@zankel.net>
15 * Kevin Chea
16 *
17 */
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>
25#include <linux/fs.h>
26#include <linux/mman.h>
27#include <linux/sched/mm.h>
28#include <linux/shm.h>
29
30syscall_t sys_call_table[] /* FIXME __cacheline_aligned */= {
31#define __SYSCALL(nr, entry) (syscall_t)entry,
32#include <asm/syscall_table.h>
33};
34
35#define COLOUR_ALIGN(addr, pgoff) \
36 ((((addr) + SHMLBA - 1) & ~(SHMLBA - 1)) + \
37 (((pgoff) << PAGE_SHIFT) & (SHMLBA - 1)))
38
39asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
40{
41 unsigned long ret;
42 long err;
43
44 err = do_shmat(shmid, shmaddr, shmflg, &ret, SHMLBA);
45 if (err)
46 return err;
47 return (long)ret;
48}
49
50asmlinkage long xtensa_fadvise64_64(int fd, int advice,
51 unsigned long long offset, unsigned long long len)
52{
53 return ksys_fadvise64_64(fd, offset, len, advice);
54}
55
56#ifdef CONFIG_MMU
57unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
58 unsigned long len, unsigned long pgoff, unsigned long flags)
59{
60 struct vm_area_struct *vmm;
61 struct vma_iterator vmi;
62
63 if (flags & MAP_FIXED) {
64 /* We do not accept a shared mapping if it would violate
65 * cache aliasing constraints.
66 */
67 if ((flags & MAP_SHARED) &&
68 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
69 return -EINVAL;
70 return addr;
71 }
72
73 if (len > TASK_SIZE)
74 return -ENOMEM;
75 if (!addr)
76 addr = TASK_UNMAPPED_BASE;
77
78 if (flags & MAP_SHARED)
79 addr = COLOUR_ALIGN(addr, pgoff);
80 else
81 addr = PAGE_ALIGN(addr);
82
83 vma_iter_init(&vmi, current->mm, addr);
84 for_each_vma(vmi, vmm) {
85 /* At this point: (addr < vmm->vm_end). */
86 if (addr + len <= vm_start_gap(vmm))
87 break;
88
89 addr = vmm->vm_end;
90 if (flags & MAP_SHARED)
91 addr = COLOUR_ALIGN(addr, pgoff);
92 }
93
94 if (TASK_SIZE - len < addr)
95 return -ENOMEM;
96
97 return addr;
98}
99#endif