sys_ia64.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * This file contains various system calls that have different calling
  3. * conventions on different platforms.
  4. *
  5. * Copyright (C) 1999-2000, 2002-2003, 2005 Hewlett-Packard Co
  6. * David Mosberger-Tang <davidm@hpl.hp.com>
  7. */
  8. #include <linux/errno.h>
  9. #include <linux/fs.h>
  10. #include <linux/mm.h>
  11. #include <linux/mman.h>
  12. #include <linux/sched.h>
  13. #include <linux/sched/mm.h>
  14. #include <linux/sched/task_stack.h>
  15. #include <linux/shm.h>
  16. #include <linux/file.h> /* doh, must come after sched.h... */
  17. #include <linux/smp.h>
  18. #include <linux/syscalls.h>
  19. #include <linux/highuid.h>
  20. #include <linux/hugetlb.h>
  21. #include <asm/shmparam.h>
  22. #include <linux/uaccess.h>
  23. unsigned long
  24. arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len,
  25. unsigned long pgoff, unsigned long flags)
  26. {
  27. long map_shared = (flags & MAP_SHARED);
  28. unsigned long align_mask = 0;
  29. struct mm_struct *mm = current->mm;
  30. struct vm_unmapped_area_info info;
  31. if (len > RGN_MAP_LIMIT)
  32. return -ENOMEM;
  33. /* handle fixed mapping: prevent overlap with huge pages */
  34. if (flags & MAP_FIXED) {
  35. if (is_hugepage_only_range(mm, addr, len))
  36. return -EINVAL;
  37. return addr;
  38. }
  39. #ifdef CONFIG_HUGETLB_PAGE
  40. if (REGION_NUMBER(addr) == RGN_HPAGE)
  41. addr = 0;
  42. #endif
  43. if (!addr)
  44. addr = TASK_UNMAPPED_BASE;
  45. if (map_shared && (TASK_SIZE > 0xfffffffful))
  46. /*
  47. * For 64-bit tasks, align shared segments to 1MB to avoid potential
  48. * performance penalty due to virtual aliasing (see ASDM). For 32-bit
  49. * tasks, we prefer to avoid exhausting the address space too quickly by
  50. * limiting alignment to a single page.
  51. */
  52. align_mask = PAGE_MASK & (SHMLBA - 1);
  53. info.flags = 0;
  54. info.length = len;
  55. info.low_limit = addr;
  56. info.high_limit = TASK_SIZE;
  57. info.align_mask = align_mask;
  58. info.align_offset = 0;
  59. return vm_unmapped_area(&info);
  60. }
  61. asmlinkage long
  62. ia64_getpriority (int which, int who)
  63. {
  64. long prio;
  65. prio = sys_getpriority(which, who);
  66. if (prio >= 0) {
  67. force_successful_syscall_return();
  68. prio = 20 - prio;
  69. }
  70. return prio;
  71. }
  72. /* XXX obsolete, but leave it here until the old libc is gone... */
  73. asmlinkage unsigned long
  74. sys_getpagesize (void)
  75. {
  76. return PAGE_SIZE;
  77. }
  78. asmlinkage unsigned long
  79. ia64_brk (unsigned long brk)
  80. {
  81. unsigned long retval = sys_brk(brk);
  82. force_successful_syscall_return();
  83. return retval;
  84. }
  85. /*
  86. * On IA-64, we return the two file descriptors in ret0 and ret1 (r8
  87. * and r9) as this is faster than doing a copy_to_user().
  88. */
  89. asmlinkage long
  90. sys_ia64_pipe (void)
  91. {
  92. struct pt_regs *regs = task_pt_regs(current);
  93. int fd[2];
  94. int retval;
  95. retval = do_pipe_flags(fd, 0);
  96. if (retval)
  97. goto out;
  98. retval = fd[0];
  99. regs->r9 = fd[1];
  100. out:
  101. return retval;
  102. }
  103. int ia64_mmap_check(unsigned long addr, unsigned long len,
  104. unsigned long flags)
  105. {
  106. unsigned long roff;
  107. /*
  108. * Don't permit mappings into unmapped space, the virtual page table
  109. * of a region, or across a region boundary. Note: RGN_MAP_LIMIT is
  110. * equal to 2^n-PAGE_SIZE (for some integer n <= 61) and len > 0.
  111. */
  112. roff = REGION_OFFSET(addr);
  113. if ((len > RGN_MAP_LIMIT) || (roff > (RGN_MAP_LIMIT - len)))
  114. return -EINVAL;
  115. return 0;
  116. }
  117. /*
  118. * mmap2() is like mmap() except that the offset is expressed in units
  119. * of PAGE_SIZE (instead of bytes). This allows to mmap2() (pieces
  120. * of) files that are larger than the address space of the CPU.
  121. */
  122. asmlinkage unsigned long
  123. sys_mmap2 (unsigned long addr, unsigned long len, int prot, int flags, int fd, long pgoff)
  124. {
  125. addr = sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff);
  126. if (!IS_ERR((void *) addr))
  127. force_successful_syscall_return();
  128. return addr;
  129. }
  130. asmlinkage unsigned long
  131. sys_mmap (unsigned long addr, unsigned long len, int prot, int flags, int fd, long off)
  132. {
  133. if (offset_in_page(off) != 0)
  134. return -EINVAL;
  135. addr = sys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
  136. if (!IS_ERR((void *) addr))
  137. force_successful_syscall_return();
  138. return addr;
  139. }
  140. asmlinkage unsigned long
  141. ia64_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags,
  142. unsigned long new_addr)
  143. {
  144. addr = sys_mremap(addr, old_len, new_len, flags, new_addr);
  145. if (!IS_ERR((void *) addr))
  146. force_successful_syscall_return();
  147. return addr;
  148. }
  149. #ifndef CONFIG_PCI
  150. asmlinkage long
  151. sys_pciconfig_read (unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len,
  152. void *buf)
  153. {
  154. return -ENOSYS;
  155. }
  156. asmlinkage long
  157. sys_pciconfig_write (unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len,
  158. void *buf)
  159. {
  160. return -ENOSYS;
  161. }
  162. #endif /* CONFIG_PCI */