syscall.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 <[email protected], [email protected]>
  13. * Marc Gauthier <[email protected], [email protected]>
  14. * Chris Zankel <[email protected]>
  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. syscall_t sys_call_table[] /* FIXME __cacheline_aligned */= {
  30. #define __SYSCALL(nr, entry) (syscall_t)entry,
  31. #include <asm/syscall_table.h>
  32. };
  33. #define COLOUR_ALIGN(addr, pgoff) \
  34. ((((addr) + SHMLBA - 1) & ~(SHMLBA - 1)) + \
  35. (((pgoff) << PAGE_SHIFT) & (SHMLBA - 1)))
  36. asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
  37. {
  38. unsigned long ret;
  39. long err;
  40. err = do_shmat(shmid, shmaddr, shmflg, &ret, SHMLBA);
  41. if (err)
  42. return err;
  43. return (long)ret;
  44. }
  45. asmlinkage long xtensa_fadvise64_64(int fd, int advice,
  46. unsigned long long offset, unsigned long long len)
  47. {
  48. return ksys_fadvise64_64(fd, offset, len, advice);
  49. }
  50. #ifdef CONFIG_MMU
  51. unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
  52. unsigned long len, unsigned long pgoff, unsigned long flags)
  53. {
  54. struct vm_area_struct *vmm;
  55. struct vma_iterator vmi;
  56. if (flags & MAP_FIXED) {
  57. /* We do not accept a shared mapping if it would violate
  58. * cache aliasing constraints.
  59. */
  60. if ((flags & MAP_SHARED) &&
  61. ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
  62. return -EINVAL;
  63. return addr;
  64. }
  65. if (len > TASK_SIZE)
  66. return -ENOMEM;
  67. if (!addr)
  68. addr = TASK_UNMAPPED_BASE;
  69. if (flags & MAP_SHARED)
  70. addr = COLOUR_ALIGN(addr, pgoff);
  71. else
  72. addr = PAGE_ALIGN(addr);
  73. vma_iter_init(&vmi, current->mm, addr);
  74. for_each_vma(vmi, vmm) {
  75. /* At this point: (addr < vmm->vm_end). */
  76. if (addr + len <= vm_start_gap(vmm))
  77. break;
  78. addr = vmm->vm_end;
  79. if (flags & MAP_SHARED)
  80. addr = COLOUR_ALIGN(addr, pgoff);
  81. }
  82. if (TASK_SIZE - len < addr)
  83. return -ENOMEM;
  84. return addr;
  85. }
  86. #endif