sys_ia64.c 4.4 KB

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