2 * sys_ia32.c: Conversion between 32bit and 64bit native syscalls. Derived from sys_sparc32.c.
4 * Copyright (C) 2000 VA Linux Co
5 * Copyright (C) 2000 Don Dugger <n0ano@valinux.com>
6 * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com>
7 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
8 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
9 * Copyright (C) 2000-2003, 2005 Hewlett-Packard Co
10 * David Mosberger-Tang <davidm@hpl.hp.com>
11 * Copyright (C) 2004 Gordon Jin <gordon.jin@intel.com>
13 * These routines maintain argument size conversion between 32bit and 64bit
17 #include <linux/config.h>
18 #include <linux/kernel.h>
19 #include <linux/syscalls.h>
20 #include <linux/sysctl.h>
21 #include <linux/sched.h>
23 #include <linux/file.h>
24 #include <linux/signal.h>
25 #include <linux/resource.h>
26 #include <linux/times.h>
27 #include <linux/utsname.h>
28 #include <linux/timex.h>
29 #include <linux/smp.h>
30 #include <linux/smp_lock.h>
31 #include <linux/sem.h>
32 #include <linux/msg.h>
34 #include <linux/shm.h>
35 #include <linux/slab.h>
36 #include <linux/uio.h>
37 #include <linux/nfs_fs.h>
38 #include <linux/quota.h>
39 #include <linux/syscalls.h>
40 #include <linux/sunrpc/svc.h>
41 #include <linux/nfsd/nfsd.h>
42 #include <linux/nfsd/cache.h>
43 #include <linux/nfsd/xdr.h>
44 #include <linux/nfsd/syscall.h>
45 #include <linux/poll.h>
46 #include <linux/eventpoll.h>
47 #include <linux/personality.h>
48 #include <linux/ptrace.h>
49 #include <linux/stat.h>
50 #include <linux/ipc.h>
51 #include <linux/compat.h>
52 #include <linux/vfs.h>
53 #include <linux/mman.h>
55 #include <asm/intrinsics.h>
56 #include <asm/semaphore.h>
57 #include <asm/types.h>
58 #include <asm/uaccess.h>
59 #include <asm/unistd.h>
69 # define DBG(fmt...) printk(KERN_DEBUG fmt)
74 #define ROUND_UP(x,a) ((__typeof__(x))(((unsigned long)(x) + ((a) - 1)) & ~((a) - 1)))
76 #define OFFSET4K(a) ((a) & 0xfff)
77 #define PAGE_START(addr) ((addr) & PAGE_MASK)
78 #define MINSIGSTKSZ_IA32 2048
80 #define high2lowuid(uid) ((uid) > 65535 ? 65534 : (uid))
81 #define high2lowgid(gid) ((gid) > 65535 ? 65534 : (gid))
84 * Anything that modifies or inspects ia32 user virtual memory must hold this semaphore
87 /* XXX make per-mm: */
88 static DECLARE_MUTEX(ia32_mmap_sem);
91 sys32_execve (char __user *name, compat_uptr_t __user *argv, compat_uptr_t __user *envp,
96 unsigned long old_map_base, old_task_size, tssd;
98 filename = getname(name);
99 error = PTR_ERR(filename);
100 if (IS_ERR(filename))
103 old_map_base = current->thread.map_base;
104 old_task_size = current->thread.task_size;
105 tssd = ia64_get_kr(IA64_KR_TSSD);
107 /* we may be exec'ing a 64-bit process: reset map base, task-size, and io-base: */
108 current->thread.map_base = DEFAULT_MAP_BASE;
109 current->thread.task_size = DEFAULT_TASK_SIZE;
110 ia64_set_kr(IA64_KR_IO_BASE, current->thread.old_iob);
111 ia64_set_kr(IA64_KR_TSSD, current->thread.old_k1);
113 error = compat_do_execve(filename, argv, envp, regs);
117 /* oops, execve failed, switch back to old values... */
118 ia64_set_kr(IA64_KR_IO_BASE, IA32_IOBASE);
119 ia64_set_kr(IA64_KR_TSSD, tssd);
120 current->thread.map_base = old_map_base;
121 current->thread.task_size = old_task_size;
127 int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf)
131 if ((u64) stat->size > MAX_NON_LFS ||
132 !old_valid_dev(stat->dev) ||
133 !old_valid_dev(stat->rdev))
136 if (clear_user(ubuf, sizeof(*ubuf)))
139 err = __put_user(old_encode_dev(stat->dev), &ubuf->st_dev);
140 err |= __put_user(stat->ino, &ubuf->st_ino);
141 err |= __put_user(stat->mode, &ubuf->st_mode);
142 err |= __put_user(stat->nlink, &ubuf->st_nlink);
143 err |= __put_user(high2lowuid(stat->uid), &ubuf->st_uid);
144 err |= __put_user(high2lowgid(stat->gid), &ubuf->st_gid);
145 err |= __put_user(old_encode_dev(stat->rdev), &ubuf->st_rdev);
146 err |= __put_user(stat->size, &ubuf->st_size);
147 err |= __put_user(stat->atime.tv_sec, &ubuf->st_atime);
148 err |= __put_user(stat->atime.tv_nsec, &ubuf->st_atime_nsec);
149 err |= __put_user(stat->mtime.tv_sec, &ubuf->st_mtime);
150 err |= __put_user(stat->mtime.tv_nsec, &ubuf->st_mtime_nsec);
151 err |= __put_user(stat->ctime.tv_sec, &ubuf->st_ctime);
152 err |= __put_user(stat->ctime.tv_nsec, &ubuf->st_ctime_nsec);
153 err |= __put_user(stat->blksize, &ubuf->st_blksize);
154 err |= __put_user(stat->blocks, &ubuf->st_blocks);
158 #if PAGE_SHIFT > IA32_PAGE_SHIFT
162 get_page_prot (struct vm_area_struct *vma, unsigned long addr)
166 if (!vma || vma->vm_start > addr)
169 if (vma->vm_flags & VM_READ)
171 if (vma->vm_flags & VM_WRITE)
173 if (vma->vm_flags & VM_EXEC)
179 * Map a subpage by creating an anonymous page that contains the union of the old page and
183 mmap_subpage (struct file *file, unsigned long start, unsigned long end, int prot, int flags,
188 unsigned long ret = 0;
189 struct vm_area_struct *vma = find_vma(current->mm, start);
190 int old_prot = get_page_prot(vma, start);
192 DBG("mmap_subpage(file=%p,start=0x%lx,end=0x%lx,prot=%x,flags=%x,off=0x%llx)\n",
193 file, start, end, prot, flags, off);
196 /* Optimize the case where the old mmap and the new mmap are both anonymous */
197 if ((old_prot & PROT_WRITE) && (flags & MAP_ANONYMOUS) && !vma->vm_file) {
198 if (clear_user((void __user *) start, end - start)) {
205 page = (void *) get_zeroed_page(GFP_KERNEL);
210 copy_from_user(page, (void __user *) PAGE_START(start), PAGE_SIZE);
212 down_write(¤t->mm->mmap_sem);
214 ret = do_mmap(NULL, PAGE_START(start), PAGE_SIZE, prot | PROT_WRITE,
215 flags | MAP_FIXED | MAP_ANONYMOUS, 0);
217 up_write(¤t->mm->mmap_sem);
219 if (IS_ERR((void *) ret))
223 /* copy back the old page contents. */
224 if (offset_in_page(start))
225 copy_to_user((void __user *) PAGE_START(start), page,
226 offset_in_page(start));
227 if (offset_in_page(end))
228 copy_to_user((void __user *) end, page + offset_in_page(end),
229 PAGE_SIZE - offset_in_page(end));
232 if (!(flags & MAP_ANONYMOUS)) {
233 /* read the file contents */
234 inode = file->f_dentry->d_inode;
235 if (!inode->i_fop || !file->f_op->read
236 || ((*file->f_op->read)(file, (char __user *) start, end - start, &off) < 0))
244 if (!(prot & PROT_WRITE))
245 ret = sys_mprotect(PAGE_START(start), PAGE_SIZE, prot | old_prot);
248 free_page((unsigned long) page);
252 /* SLAB cache for partial_page structures */
253 kmem_cache_t *partial_page_cachep;
256 * init partial_page_list.
257 * return 0 means kmalloc fail.
259 struct partial_page_list*
260 ia32_init_pp_list(void)
262 struct partial_page_list *p;
264 if ((p = kmalloc(sizeof(*p), GFP_KERNEL)) == NULL)
269 atomic_set(&p->pp_count, 1);
274 * Search for the partial page with @start in partial page list @ppl.
275 * If finds the partial page, return the found partial page.
276 * Else, return 0 and provide @pprev, @rb_link, @rb_parent to
277 * be used by later __ia32_insert_pp().
279 static struct partial_page *
280 __ia32_find_pp(struct partial_page_list *ppl, unsigned int start,
281 struct partial_page **pprev, struct rb_node ***rb_link,
282 struct rb_node **rb_parent)
284 struct partial_page *pp;
285 struct rb_node **__rb_link, *__rb_parent, *rb_prev;
288 if (pp && pp->base == start)
291 __rb_link = &ppl->ppl_rb.rb_node;
292 rb_prev = __rb_parent = NULL;
295 __rb_parent = *__rb_link;
296 pp = rb_entry(__rb_parent, struct partial_page, pp_rb);
298 if (pp->base == start) {
301 } else if (pp->base < start) {
302 rb_prev = __rb_parent;
303 __rb_link = &__rb_parent->rb_right;
305 __rb_link = &__rb_parent->rb_left;
309 *rb_link = __rb_link;
310 *rb_parent = __rb_parent;
313 *pprev = rb_entry(rb_prev, struct partial_page, pp_rb);
318 * insert @pp into @ppl.
321 __ia32_insert_pp(struct partial_page_list *ppl, struct partial_page *pp,
322 struct partial_page *prev, struct rb_node **rb_link,
323 struct rb_node *rb_parent)
327 pp->next = prev->next;
332 pp->next = rb_entry(rb_parent,
333 struct partial_page, pp_rb);
339 rb_link_node(&pp->pp_rb, rb_parent, rb_link);
340 rb_insert_color(&pp->pp_rb, &ppl->ppl_rb);
346 * delete @pp from partial page list @ppl.
349 __ia32_delete_pp(struct partial_page_list *ppl, struct partial_page *pp,
350 struct partial_page *prev)
353 prev->next = pp->next;
354 if (ppl->pp_hint == pp)
357 ppl->pp_head = pp->next;
358 if (ppl->pp_hint == pp)
359 ppl->pp_hint = pp->next;
361 rb_erase(&pp->pp_rb, &ppl->ppl_rb);
362 kmem_cache_free(partial_page_cachep, pp);
365 static struct partial_page *
366 __pp_prev(struct partial_page *pp)
368 struct rb_node *prev = rb_prev(&pp->pp_rb);
370 return rb_entry(prev, struct partial_page, pp_rb);
376 * Delete partial pages with address between @start and @end.
377 * @start and @end are page aligned.
380 __ia32_delete_pp_range(unsigned int start, unsigned int end)
382 struct partial_page *pp, *prev;
383 struct rb_node **rb_link, *rb_parent;
388 pp = __ia32_find_pp(current->thread.ppl, start, &prev,
389 &rb_link, &rb_parent);
391 prev = __pp_prev(pp);
396 pp = current->thread.ppl->pp_head;
399 while (pp && pp->base < end) {
400 struct partial_page *tmp = pp->next;
401 __ia32_delete_pp(current->thread.ppl, pp, prev);
407 * Set the range between @start and @end in bitmap.
408 * @start and @end should be IA32 page aligned and in the same IA64 page.
411 __ia32_set_pp(unsigned int start, unsigned int end, int flags)
413 struct partial_page *pp, *prev;
414 struct rb_node ** rb_link, *rb_parent;
415 unsigned int pstart, start_bit, end_bit, i;
417 pstart = PAGE_START(start);
418 start_bit = (start % PAGE_SIZE) / IA32_PAGE_SIZE;
419 end_bit = (end % PAGE_SIZE) / IA32_PAGE_SIZE;
421 end_bit = PAGE_SIZE / IA32_PAGE_SIZE;
422 pp = __ia32_find_pp(current->thread.ppl, pstart, &prev,
423 &rb_link, &rb_parent);
425 for (i = start_bit; i < end_bit; i++)
426 set_bit(i, &pp->bitmap);
428 * Check: if this partial page has been set to a full page,
431 if (find_first_zero_bit(&pp->bitmap, sizeof(pp->bitmap)*8) >=
432 PAGE_SIZE/IA32_PAGE_SIZE) {
433 __ia32_delete_pp(current->thread.ppl, pp, __pp_prev(pp));
439 * MAP_FIXED may lead to overlapping mmap.
440 * In this case, the requested mmap area may already mmaped as a full
441 * page. So check vma before adding a new partial page.
443 if (flags & MAP_FIXED) {
444 struct vm_area_struct *vma = find_vma(current->mm, pstart);
445 if (vma && vma->vm_start <= pstart)
449 /* new a partial_page */
450 pp = kmem_cache_alloc(partial_page_cachep, GFP_KERNEL);
455 for (i=start_bit; i<end_bit; i++)
456 set_bit(i, &(pp->bitmap));
458 __ia32_insert_pp(current->thread.ppl, pp, prev, rb_link, rb_parent);
463 * @start and @end should be IA32 page aligned, but don't need to be in the
464 * same IA64 page. Split @start and @end to make sure they're in the same IA64
465 * page, then call __ia32_set_pp().
468 ia32_set_pp(unsigned int start, unsigned int end, int flags)
470 down_write(¤t->mm->mmap_sem);
471 if (flags & MAP_FIXED) {
473 * MAP_FIXED may lead to overlapping mmap. When this happens,
474 * a series of complete IA64 pages results in deletion of
475 * old partial pages in that range.
477 __ia32_delete_pp_range(PAGE_ALIGN(start), PAGE_START(end));
480 if (end < PAGE_ALIGN(start)) {
481 __ia32_set_pp(start, end, flags);
483 if (offset_in_page(start))
484 __ia32_set_pp(start, PAGE_ALIGN(start), flags);
485 if (offset_in_page(end))
486 __ia32_set_pp(PAGE_START(end), end, flags);
488 up_write(¤t->mm->mmap_sem);
492 * Unset the range between @start and @end in bitmap.
493 * @start and @end should be IA32 page aligned and in the same IA64 page.
494 * After doing that, if the bitmap is 0, then free the page and return 1,
496 * If not find the partial page in the list, then
497 * If the vma exists, then the full page is set to a partial page;
498 * Else return -ENOMEM.
501 __ia32_unset_pp(unsigned int start, unsigned int end)
503 struct partial_page *pp, *prev;
504 struct rb_node ** rb_link, *rb_parent;
505 unsigned int pstart, start_bit, end_bit, i;
506 struct vm_area_struct *vma;
508 pstart = PAGE_START(start);
509 start_bit = (start % PAGE_SIZE) / IA32_PAGE_SIZE;
510 end_bit = (end % PAGE_SIZE) / IA32_PAGE_SIZE;
512 end_bit = PAGE_SIZE / IA32_PAGE_SIZE;
514 pp = __ia32_find_pp(current->thread.ppl, pstart, &prev,
515 &rb_link, &rb_parent);
517 for (i = start_bit; i < end_bit; i++)
518 clear_bit(i, &pp->bitmap);
519 if (pp->bitmap == 0) {
520 __ia32_delete_pp(current->thread.ppl, pp, __pp_prev(pp));
526 vma = find_vma(current->mm, pstart);
527 if (!vma || vma->vm_start > pstart) {
531 /* new a partial_page */
532 pp = kmem_cache_alloc(partial_page_cachep, GFP_KERNEL);
537 for (i = 0; i < start_bit; i++)
538 set_bit(i, &(pp->bitmap));
539 for (i = end_bit; i < PAGE_SIZE / IA32_PAGE_SIZE; i++)
540 set_bit(i, &(pp->bitmap));
542 __ia32_insert_pp(current->thread.ppl, pp, prev, rb_link, rb_parent);
547 * Delete pp between PAGE_ALIGN(start) and PAGE_START(end) by calling
548 * __ia32_delete_pp_range(). Unset possible partial pages by calling
550 * The returned value see __ia32_unset_pp().
553 ia32_unset_pp(unsigned int *startp, unsigned int *endp)
555 unsigned int start = *startp, end = *endp;
558 down_write(¤t->mm->mmap_sem);
560 __ia32_delete_pp_range(PAGE_ALIGN(start), PAGE_START(end));
562 if (end < PAGE_ALIGN(start)) {
563 ret = __ia32_unset_pp(start, end);
565 *startp = PAGE_START(start);
566 *endp = PAGE_ALIGN(end);
569 /* to shortcut sys_munmap() in sys32_munmap() */
570 *startp = PAGE_START(start);
571 *endp = PAGE_START(end);
574 if (offset_in_page(start)) {
575 ret = __ia32_unset_pp(start, PAGE_ALIGN(start));
577 *startp = PAGE_START(start);
579 *startp = PAGE_ALIGN(start);
583 if (offset_in_page(end)) {
584 ret = __ia32_unset_pp(PAGE_START(end), end);
586 *endp = PAGE_ALIGN(end);
588 *endp = PAGE_START(end);
593 up_write(¤t->mm->mmap_sem);
598 * Compare the range between @start and @end with bitmap in partial page.
599 * @start and @end should be IA32 page aligned and in the same IA64 page.
602 __ia32_compare_pp(unsigned int start, unsigned int end)
604 struct partial_page *pp, *prev;
605 struct rb_node ** rb_link, *rb_parent;
606 unsigned int pstart, start_bit, end_bit, size;
607 unsigned int first_bit, next_zero_bit; /* the first range in bitmap */
609 pstart = PAGE_START(start);
611 pp = __ia32_find_pp(current->thread.ppl, pstart, &prev,
612 &rb_link, &rb_parent);
616 start_bit = (start % PAGE_SIZE) / IA32_PAGE_SIZE;
617 end_bit = (end % PAGE_SIZE) / IA32_PAGE_SIZE;
618 size = sizeof(pp->bitmap) * 8;
619 first_bit = find_first_bit(&pp->bitmap, size);
620 next_zero_bit = find_next_zero_bit(&pp->bitmap, size, first_bit);
621 if ((start_bit < first_bit) || (end_bit > next_zero_bit)) {
622 /* exceeds the first range in bitmap */
624 } else if ((start_bit == first_bit) && (end_bit == next_zero_bit)) {
625 first_bit = find_next_bit(&pp->bitmap, size, next_zero_bit);
626 if ((next_zero_bit < first_bit) && (first_bit < size))
627 return 1; /* has next range */
629 return 0; /* no next range */
635 * @start and @end should be IA32 page aligned, but don't need to be in the
636 * same IA64 page. Split @start and @end to make sure they're in the same IA64
637 * page, then call __ia32_compare_pp().
639 * Take this as example: the range is the 1st and 2nd 4K page.
640 * Return 0 if they fit bitmap exactly, i.e. bitmap = 00000011;
641 * Return 1 if the range doesn't cover whole bitmap, e.g. bitmap = 00001111;
642 * Return -ENOMEM if the range exceeds the bitmap, e.g. bitmap = 00000001 or
646 ia32_compare_pp(unsigned int *startp, unsigned int *endp)
648 unsigned int start = *startp, end = *endp;
651 down_write(¤t->mm->mmap_sem);
653 if (end < PAGE_ALIGN(start)) {
654 retval = __ia32_compare_pp(start, end);
656 *startp = PAGE_START(start);
657 *endp = PAGE_ALIGN(end);
660 if (offset_in_page(start)) {
661 retval = __ia32_compare_pp(start,
664 *startp = PAGE_START(start);
668 if (offset_in_page(end)) {
669 retval = __ia32_compare_pp(PAGE_START(end), end);
671 *endp = PAGE_ALIGN(end);
676 up_write(¤t->mm->mmap_sem);
681 __ia32_drop_pp_list(struct partial_page_list *ppl)
683 struct partial_page *pp = ppl->pp_head;
686 struct partial_page *next = pp->next;
687 kmem_cache_free(partial_page_cachep, pp);
695 ia32_drop_partial_page_list(struct task_struct *task)
697 struct partial_page_list* ppl = task->thread.ppl;
699 if (ppl && atomic_dec_and_test(&ppl->pp_count))
700 __ia32_drop_pp_list(ppl);
704 * Copy current->thread.ppl to ppl (already initialized).
707 __ia32_copy_pp_list(struct partial_page_list *ppl)
709 struct partial_page *pp, *tmp, *prev;
710 struct rb_node **rb_link, *rb_parent;
714 ppl->ppl_rb = RB_ROOT;
715 rb_link = &ppl->ppl_rb.rb_node;
719 for (pp = current->thread.ppl->pp_head; pp; pp = pp->next) {
720 tmp = kmem_cache_alloc(partial_page_cachep, GFP_KERNEL);
724 __ia32_insert_pp(ppl, tmp, prev, rb_link, rb_parent);
726 rb_link = &tmp->pp_rb.rb_right;
727 rb_parent = &tmp->pp_rb;
733 ia32_copy_partial_page_list(struct task_struct *p, unsigned long clone_flags)
737 if (clone_flags & CLONE_VM) {
738 atomic_inc(¤t->thread.ppl->pp_count);
739 p->thread.ppl = current->thread.ppl;
741 p->thread.ppl = ia32_init_pp_list();
744 down_write(¤t->mm->mmap_sem);
746 retval = __ia32_copy_pp_list(p->thread.ppl);
748 up_write(¤t->mm->mmap_sem);
755 emulate_mmap (struct file *file, unsigned long start, unsigned long len, int prot, int flags,
758 unsigned long tmp, end, pend, pstart, ret, is_congruent, fudge = 0;
763 pstart = PAGE_START(start);
764 pend = PAGE_ALIGN(end);
766 if (flags & MAP_FIXED) {
767 ia32_set_pp((unsigned int)start, (unsigned int)end, flags);
768 if (start > pstart) {
769 if (flags & MAP_SHARED)
771 "%s(%d): emulate_mmap() can't share head (addr=0x%lx)\n",
772 current->comm, current->pid, start);
773 ret = mmap_subpage(file, start, min(PAGE_ALIGN(start), end), prot, flags,
775 if (IS_ERR((void *) ret))
782 if (flags & MAP_SHARED)
784 "%s(%d): emulate_mmap() can't share tail (end=0x%lx)\n",
785 current->comm, current->pid, end);
786 ret = mmap_subpage(file, max(start, PAGE_START(end)), end, prot, flags,
787 (off + len) - offset_in_page(end));
788 if (IS_ERR((void *) ret))
796 * If a start address was specified, use it if the entire rounded out area
799 if (start && !pstart)
800 fudge = 1; /* handle case of mapping to range (0,PAGE_SIZE) */
801 tmp = arch_get_unmapped_area(file, pstart - fudge, pend - pstart, 0, flags);
804 start = pstart + offset_in_page(off); /* make start congruent with off */
806 pend = PAGE_ALIGN(end);
810 poff = off + (pstart - start); /* note: (pstart - start) may be negative */
811 is_congruent = (flags & MAP_ANONYMOUS) || (offset_in_page(poff) == 0);
813 if ((flags & MAP_SHARED) && !is_congruent)
814 printk(KERN_INFO "%s(%d): emulate_mmap() can't share contents of incongruent mmap "
815 "(addr=0x%lx,off=0x%llx)\n", current->comm, current->pid, start, off);
817 DBG("mmap_body: mapping [0x%lx-0x%lx) %s with poff 0x%llx\n", pstart, pend,
818 is_congruent ? "congruent" : "not congruent", poff);
820 down_write(¤t->mm->mmap_sem);
822 if (!(flags & MAP_ANONYMOUS) && is_congruent)
823 ret = do_mmap(file, pstart, pend - pstart, prot, flags | MAP_FIXED, poff);
825 ret = do_mmap(NULL, pstart, pend - pstart,
826 prot | ((flags & MAP_ANONYMOUS) ? 0 : PROT_WRITE),
827 flags | MAP_FIXED | MAP_ANONYMOUS, 0);
829 up_write(¤t->mm->mmap_sem);
831 if (IS_ERR((void *) ret))
835 /* read the file contents */
836 inode = file->f_dentry->d_inode;
837 if (!inode->i_fop || !file->f_op->read
838 || ((*file->f_op->read)(file, (char __user *) pstart, pend - pstart, &poff)
841 sys_munmap(pstart, pend - pstart);
844 if (!(prot & PROT_WRITE) && sys_mprotect(pstart, pend - pstart, prot) < 0)
848 if (!(flags & MAP_FIXED))
849 ia32_set_pp((unsigned int)start, (unsigned int)end, flags);
854 #endif /* PAGE_SHIFT > IA32_PAGE_SHIFT */
856 static inline unsigned int
857 get_prot32 (unsigned int prot)
859 if (prot & PROT_WRITE)
860 /* on x86, PROT_WRITE implies PROT_READ which implies PROT_EEC */
861 prot |= PROT_READ | PROT_WRITE | PROT_EXEC;
862 else if (prot & (PROT_READ | PROT_EXEC))
863 /* on x86, there is no distinction between PROT_READ and PROT_EXEC */
864 prot |= (PROT_READ | PROT_EXEC);
870 ia32_do_mmap (struct file *file, unsigned long addr, unsigned long len, int prot, int flags,
873 DBG("ia32_do_mmap(file=%p,addr=0x%lx,len=0x%lx,prot=%x,flags=%x,offset=0x%llx)\n",
874 file, addr, len, prot, flags, offset);
876 if (file && (!file->f_op || !file->f_op->mmap))
879 len = IA32_PAGE_ALIGN(len);
883 if (len > IA32_PAGE_OFFSET || addr > IA32_PAGE_OFFSET - len)
885 if (flags & MAP_FIXED)
891 if (OFFSET4K(offset))
894 prot = get_prot32(prot);
896 #if PAGE_SHIFT > IA32_PAGE_SHIFT
897 down(&ia32_mmap_sem);
899 addr = emulate_mmap(file, addr, len, prot, flags, offset);
903 down_write(¤t->mm->mmap_sem);
905 addr = do_mmap(file, addr, len, prot, flags, offset);
907 up_write(¤t->mm->mmap_sem);
909 DBG("ia32_do_mmap: returning 0x%lx\n", addr);
914 * Linux/i386 didn't use to be able to handle more than 4 system call parameters, so these
915 * system calls used a memory block for parameter passing..
918 struct mmap_arg_struct {
928 sys32_mmap (struct mmap_arg_struct __user *arg)
930 struct mmap_arg_struct a;
931 struct file *file = NULL;
935 if (copy_from_user(&a, arg, sizeof(a)))
938 if (OFFSET4K(a.offset))
943 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
944 if (!(flags & MAP_ANONYMOUS)) {
950 addr = ia32_do_mmap(file, a.addr, a.len, a.prot, flags, a.offset);
958 sys32_mmap2 (unsigned int addr, unsigned int len, unsigned int prot, unsigned int flags,
959 unsigned int fd, unsigned int pgoff)
961 struct file *file = NULL;
962 unsigned long retval;
964 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
965 if (!(flags & MAP_ANONYMOUS)) {
971 retval = ia32_do_mmap(file, addr, len, prot, flags,
972 (unsigned long) pgoff << IA32_PAGE_SHIFT);
980 sys32_munmap (unsigned int start, unsigned int len)
982 unsigned int end = start + len;
985 #if PAGE_SHIFT <= IA32_PAGE_SHIFT
986 ret = sys_munmap(start, end - start);
991 end = IA32_PAGE_ALIGN(end);
995 ret = ia32_unset_pp(&start, &end);
1002 down(&ia32_mmap_sem);
1004 ret = sys_munmap(start, end - start);
1011 #if PAGE_SHIFT > IA32_PAGE_SHIFT
1014 * When mprotect()ing a partial page, we set the permission to the union of the old
1015 * settings and the new settings. In other words, it's only possible to make access to a
1016 * partial page less restrictive.
1019 mprotect_subpage (unsigned long address, int new_prot)
1022 struct vm_area_struct *vma;
1024 if (new_prot == PROT_NONE)
1025 return 0; /* optimize case where nothing changes... */
1026 vma = find_vma(current->mm, address);
1027 old_prot = get_page_prot(vma, address);
1028 return sys_mprotect(address, PAGE_SIZE, new_prot | old_prot);
1031 #endif /* PAGE_SHIFT > IA32_PAGE_SHIFT */
1034 sys32_mprotect (unsigned int start, unsigned int len, int prot)
1036 unsigned int end = start + len;
1037 #if PAGE_SHIFT > IA32_PAGE_SHIFT
1041 prot = get_prot32(prot);
1043 #if PAGE_SHIFT <= IA32_PAGE_SHIFT
1044 return sys_mprotect(start, end - start, prot);
1046 if (OFFSET4K(start))
1049 end = IA32_PAGE_ALIGN(end);
1053 retval = ia32_compare_pp(&start, &end);
1058 down(&ia32_mmap_sem);
1060 if (offset_in_page(start)) {
1061 /* start address is 4KB aligned but not page aligned. */
1062 retval = mprotect_subpage(PAGE_START(start), prot);
1066 start = PAGE_ALIGN(start);
1068 goto out; /* retval is already zero... */
1071 if (offset_in_page(end)) {
1072 /* end address is 4KB aligned but not page aligned. */
1073 retval = mprotect_subpage(PAGE_START(end), prot);
1077 end = PAGE_START(end);
1079 retval = sys_mprotect(start, end - start, prot);
1088 sys32_mremap (unsigned int addr, unsigned int old_len, unsigned int new_len,
1089 unsigned int flags, unsigned int new_addr)
1093 #if PAGE_SHIFT <= IA32_PAGE_SHIFT
1094 ret = sys_mremap(addr, old_len, new_len, flags, new_addr);
1096 unsigned int old_end, new_end;
1101 old_len = IA32_PAGE_ALIGN(old_len);
1102 new_len = IA32_PAGE_ALIGN(new_len);
1103 old_end = addr + old_len;
1104 new_end = addr + new_len;
1109 if ((flags & MREMAP_FIXED) && (OFFSET4K(new_addr)))
1112 if (old_len >= new_len) {
1113 ret = sys32_munmap(addr + new_len, old_len - new_len);
1114 if (ret && old_len != new_len)
1117 if (!(flags & MREMAP_FIXED) || (new_addr == addr))
1122 addr = PAGE_START(addr);
1123 old_len = PAGE_ALIGN(old_end) - addr;
1124 new_len = PAGE_ALIGN(new_end) - addr;
1126 down(&ia32_mmap_sem);
1128 ret = sys_mremap(addr, old_len, new_len, flags, new_addr);
1132 if ((ret >= 0) && (old_len < new_len)) {
1133 /* mremap expanded successfully */
1134 ia32_set_pp(old_end, new_end, flags);
1141 sys32_pipe (int __user *fd)
1146 retval = do_pipe(fds);
1149 if (copy_to_user(fd, fds, sizeof(fds)))
1156 get_tv32 (struct timeval *o, struct compat_timeval __user *i)
1158 return (!access_ok(VERIFY_READ, i, sizeof(*i)) ||
1159 (__get_user(o->tv_sec, &i->tv_sec) | __get_user(o->tv_usec, &i->tv_usec)));
1163 put_tv32 (struct compat_timeval __user *o, struct timeval *i)
1165 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
1166 (__put_user(i->tv_sec, &o->tv_sec) | __put_user(i->tv_usec, &o->tv_usec)));
1169 asmlinkage unsigned long
1170 sys32_alarm (unsigned int seconds)
1172 struct itimerval it_new, it_old;
1173 unsigned int oldalarm;
1175 it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
1176 it_new.it_value.tv_sec = seconds;
1177 it_new.it_value.tv_usec = 0;
1178 do_setitimer(ITIMER_REAL, &it_new, &it_old);
1179 oldalarm = it_old.it_value.tv_sec;
1180 /* ehhh.. We can't return 0 if we have an alarm pending.. */
1181 /* And we'd better return too much than too little anyway */
1182 if (it_old.it_value.tv_usec)
1187 /* Translations due to time_t size differences. Which affects all
1188 sorts of things, like timeval and itimerval. */
1190 extern struct timezone sys_tz;
1193 sys32_gettimeofday (struct compat_timeval __user *tv, struct timezone __user *tz)
1197 do_gettimeofday(&ktv);
1198 if (put_tv32(tv, &ktv))
1202 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
1209 sys32_settimeofday (struct compat_timeval __user *tv, struct timezone __user *tz)
1212 struct timespec kts;
1213 struct timezone ktz;
1216 if (get_tv32(&ktv, tv))
1218 kts.tv_sec = ktv.tv_sec;
1219 kts.tv_nsec = ktv.tv_usec * 1000;
1222 if (copy_from_user(&ktz, tz, sizeof(ktz)))
1226 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
1229 struct getdents32_callback {
1230 struct compat_dirent __user *current_dir;
1231 struct compat_dirent __user *previous;
1236 struct readdir32_callback {
1237 struct old_linux32_dirent __user * dirent;
1242 filldir32 (void *__buf, const char *name, int namlen, loff_t offset, ino_t ino,
1243 unsigned int d_type)
1245 struct compat_dirent __user * dirent;
1246 struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
1247 int reclen = ROUND_UP(offsetof(struct compat_dirent, d_name) + namlen + 1, 4);
1249 buf->error = -EINVAL; /* only used if we fail.. */
1250 if (reclen > buf->count)
1252 buf->error = -EFAULT; /* only used if we fail.. */
1253 dirent = buf->previous;
1255 if (put_user(offset, &dirent->d_off))
1257 dirent = buf->current_dir;
1258 buf->previous = dirent;
1259 if (put_user(ino, &dirent->d_ino)
1260 || put_user(reclen, &dirent->d_reclen)
1261 || copy_to_user(dirent->d_name, name, namlen)
1262 || put_user(0, dirent->d_name + namlen))
1264 dirent = (struct compat_dirent __user *) ((char __user *) dirent + reclen);
1265 buf->current_dir = dirent;
1266 buf->count -= reclen;
1271 sys32_getdents (unsigned int fd, struct compat_dirent __user *dirent, unsigned int count)
1274 struct compat_dirent __user * lastdirent;
1275 struct getdents32_callback buf;
1283 buf.current_dir = dirent;
1284 buf.previous = NULL;
1288 error = vfs_readdir(file, filldir32, &buf);
1292 lastdirent = buf.previous;
1295 if (put_user(file->f_pos, &lastdirent->d_off))
1297 error = count - buf.count;
1307 fillonedir32 (void * __buf, const char * name, int namlen, loff_t offset, ino_t ino,
1308 unsigned int d_type)
1310 struct readdir32_callback * buf = (struct readdir32_callback *) __buf;
1311 struct old_linux32_dirent __user * dirent;
1316 dirent = buf->dirent;
1317 if (put_user(ino, &dirent->d_ino)
1318 || put_user(offset, &dirent->d_offset)
1319 || put_user(namlen, &dirent->d_namlen)
1320 || copy_to_user(dirent->d_name, name, namlen)
1321 || put_user(0, dirent->d_name + namlen))
1327 sys32_readdir (unsigned int fd, void __user *dirent, unsigned int count)
1331 struct readdir32_callback buf;
1339 buf.dirent = dirent;
1341 error = vfs_readdir(file, fillonedir32, &buf);
1349 struct sel_arg_struct {
1358 sys32_old_select (struct sel_arg_struct __user *arg)
1360 struct sel_arg_struct a;
1362 if (copy_from_user(&a, arg, sizeof(a)))
1364 return compat_sys_select(a.n, compat_ptr(a.inp), compat_ptr(a.outp),
1365 compat_ptr(a.exp), compat_ptr(a.tvp));
1371 #define SEMTIMEDOP 4
1382 sys32_ipc(u32 call, int first, int second, int third, u32 ptr, u32 fifth)
1386 version = call >> 16; /* hack for backward compatibility */
1392 return compat_sys_semtimedop(first, compat_ptr(ptr),
1393 second, compat_ptr(fifth));
1394 /* else fall through for normal semop() */
1396 /* struct sembuf is the same on 32 and 64bit :)) */
1397 return sys_semtimedop(first, compat_ptr(ptr), second,
1400 return sys_semget(first, second, third);
1402 return compat_sys_semctl(first, second, third, compat_ptr(ptr));
1405 return compat_sys_msgsnd(first, second, third, compat_ptr(ptr));
1407 return compat_sys_msgrcv(first, second, fifth, third, version, compat_ptr(ptr));
1409 return sys_msgget((key_t) first, second);
1411 return compat_sys_msgctl(first, second, compat_ptr(ptr));
1414 return compat_sys_shmat(first, second, third, version, compat_ptr(ptr));
1417 return sys_shmdt(compat_ptr(ptr));
1419 return sys_shmget(first, (unsigned)second, third);
1421 return compat_sys_shmctl(first, second, compat_ptr(ptr));
1430 compat_sys_wait4 (compat_pid_t pid, compat_uint_t * stat_addr, int options,
1431 struct compat_rusage *ru);
1434 sys32_waitpid (int pid, unsigned int *stat_addr, int options)
1436 return compat_sys_wait4(pid, stat_addr, options, NULL);
1440 ia32_peek (struct task_struct *child, unsigned long addr, unsigned int *val)
1445 copied = access_process_vm(child, addr, val, sizeof(*val), 0);
1446 return (copied != sizeof(ret)) ? -EIO : 0;
1450 ia32_poke (struct task_struct *child, unsigned long addr, unsigned int val)
1453 if (access_process_vm(child, addr, &val, sizeof(val), 1) != sizeof(val))
1459 * The order in which registers are stored in the ptrace regs structure
1472 #define PT_ORIG_EAX 11
1480 getreg (struct task_struct *child, int regno)
1482 struct pt_regs *child_regs;
1484 child_regs = ia64_task_regs(child);
1485 switch (regno / sizeof(int)) {
1486 case PT_EBX: return child_regs->r11;
1487 case PT_ECX: return child_regs->r9;
1488 case PT_EDX: return child_regs->r10;
1489 case PT_ESI: return child_regs->r14;
1490 case PT_EDI: return child_regs->r15;
1491 case PT_EBP: return child_regs->r13;
1492 case PT_EAX: return child_regs->r8;
1493 case PT_ORIG_EAX: return child_regs->r1; /* see dispatch_to_ia32_handler() */
1494 case PT_EIP: return child_regs->cr_iip;
1495 case PT_UESP: return child_regs->r12;
1496 case PT_EFL: return child->thread.eflag;
1497 case PT_DS: case PT_ES: case PT_FS: case PT_GS: case PT_SS:
1499 case PT_CS: return __USER_CS;
1501 printk(KERN_ERR "ia32.getreg(): unknown register %d\n", regno);
1508 putreg (struct task_struct *child, int regno, unsigned int value)
1510 struct pt_regs *child_regs;
1512 child_regs = ia64_task_regs(child);
1513 switch (regno / sizeof(int)) {
1514 case PT_EBX: child_regs->r11 = value; break;
1515 case PT_ECX: child_regs->r9 = value; break;
1516 case PT_EDX: child_regs->r10 = value; break;
1517 case PT_ESI: child_regs->r14 = value; break;
1518 case PT_EDI: child_regs->r15 = value; break;
1519 case PT_EBP: child_regs->r13 = value; break;
1520 case PT_EAX: child_regs->r8 = value; break;
1521 case PT_ORIG_EAX: child_regs->r1 = value; break;
1522 case PT_EIP: child_regs->cr_iip = value; break;
1523 case PT_UESP: child_regs->r12 = value; break;
1524 case PT_EFL: child->thread.eflag = value; break;
1525 case PT_DS: case PT_ES: case PT_FS: case PT_GS: case PT_SS:
1526 if (value != __USER_DS)
1528 "ia32.putreg: attempt to set invalid segment register %d = %x\n",
1532 if (value != __USER_CS)
1534 "ia32.putreg: attempt to to set invalid segment register %d = %x\n",
1538 printk(KERN_ERR "ia32.putreg: unknown register %d\n", regno);
1544 put_fpreg (int regno, struct _fpreg_ia32 __user *reg, struct pt_regs *ptp,
1545 struct switch_stack *swp, int tos)
1547 struct _fpreg_ia32 *f;
1550 f = (struct _fpreg_ia32 *)(((unsigned long)buf + 15) & ~15);
1551 if ((regno += tos) >= 8)
1555 ia64f2ia32f(f, &ptp->f8);
1558 ia64f2ia32f(f, &ptp->f9);
1561 ia64f2ia32f(f, &ptp->f10);
1564 ia64f2ia32f(f, &ptp->f11);
1570 ia64f2ia32f(f, &swp->f12 + (regno - 4));
1573 copy_to_user(reg, f, sizeof(*reg));
1577 get_fpreg (int regno, struct _fpreg_ia32 __user *reg, struct pt_regs *ptp,
1578 struct switch_stack *swp, int tos)
1581 if ((regno += tos) >= 8)
1585 copy_from_user(&ptp->f8, reg, sizeof(*reg));
1588 copy_from_user(&ptp->f9, reg, sizeof(*reg));
1591 copy_from_user(&ptp->f10, reg, sizeof(*reg));
1594 copy_from_user(&ptp->f11, reg, sizeof(*reg));
1600 copy_from_user(&swp->f12 + (regno - 4), reg, sizeof(*reg));
1607 save_ia32_fpstate (struct task_struct *tsk, struct ia32_user_i387_struct __user *save)
1609 struct switch_stack *swp;
1610 struct pt_regs *ptp;
1613 if (!access_ok(VERIFY_WRITE, save, sizeof(*save)))
1616 __put_user(tsk->thread.fcr & 0xffff, &save->cwd);
1617 __put_user(tsk->thread.fsr & 0xffff, &save->swd);
1618 __put_user((tsk->thread.fsr>>16) & 0xffff, &save->twd);
1619 __put_user(tsk->thread.fir, &save->fip);
1620 __put_user((tsk->thread.fir>>32) & 0xffff, &save->fcs);
1621 __put_user(tsk->thread.fdr, &save->foo);
1622 __put_user((tsk->thread.fdr>>32) & 0xffff, &save->fos);
1625 * Stack frames start with 16-bytes of temp space
1627 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1628 ptp = ia64_task_regs(tsk);
1629 tos = (tsk->thread.fsr >> 11) & 7;
1630 for (i = 0; i < 8; i++)
1631 put_fpreg(i, &save->st_space[i], ptp, swp, tos);
1636 restore_ia32_fpstate (struct task_struct *tsk, struct ia32_user_i387_struct __user *save)
1638 struct switch_stack *swp;
1639 struct pt_regs *ptp;
1641 unsigned int fsrlo, fsrhi, num32;
1643 if (!access_ok(VERIFY_READ, save, sizeof(*save)))
1646 __get_user(num32, (unsigned int __user *)&save->cwd);
1647 tsk->thread.fcr = (tsk->thread.fcr & (~0x1f3f)) | (num32 & 0x1f3f);
1648 __get_user(fsrlo, (unsigned int __user *)&save->swd);
1649 __get_user(fsrhi, (unsigned int __user *)&save->twd);
1650 num32 = (fsrhi << 16) | fsrlo;
1651 tsk->thread.fsr = (tsk->thread.fsr & (~0xffffffff)) | num32;
1652 __get_user(num32, (unsigned int __user *)&save->fip);
1653 tsk->thread.fir = (tsk->thread.fir & (~0xffffffff)) | num32;
1654 __get_user(num32, (unsigned int __user *)&save->foo);
1655 tsk->thread.fdr = (tsk->thread.fdr & (~0xffffffff)) | num32;
1658 * Stack frames start with 16-bytes of temp space
1660 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1661 ptp = ia64_task_regs(tsk);
1662 tos = (tsk->thread.fsr >> 11) & 7;
1663 for (i = 0; i < 8; i++)
1664 get_fpreg(i, &save->st_space[i], ptp, swp, tos);
1669 save_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct __user *save)
1671 struct switch_stack *swp;
1672 struct pt_regs *ptp;
1674 unsigned long mxcsr=0;
1675 unsigned long num128[2];
1677 if (!access_ok(VERIFY_WRITE, save, sizeof(*save)))
1680 __put_user(tsk->thread.fcr & 0xffff, &save->cwd);
1681 __put_user(tsk->thread.fsr & 0xffff, &save->swd);
1682 __put_user((tsk->thread.fsr>>16) & 0xffff, &save->twd);
1683 __put_user(tsk->thread.fir, &save->fip);
1684 __put_user((tsk->thread.fir>>32) & 0xffff, &save->fcs);
1685 __put_user(tsk->thread.fdr, &save->foo);
1686 __put_user((tsk->thread.fdr>>32) & 0xffff, &save->fos);
1689 * Stack frames start with 16-bytes of temp space
1691 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1692 ptp = ia64_task_regs(tsk);
1693 tos = (tsk->thread.fsr >> 11) & 7;
1694 for (i = 0; i < 8; i++)
1695 put_fpreg(i, (struct _fpreg_ia32 __user *)&save->st_space[4*i], ptp, swp, tos);
1697 mxcsr = ((tsk->thread.fcr>>32) & 0xff80) | ((tsk->thread.fsr>>32) & 0x3f);
1698 __put_user(mxcsr & 0xffff, &save->mxcsr);
1699 for (i = 0; i < 8; i++) {
1700 memcpy(&(num128[0]), &(swp->f16) + i*2, sizeof(unsigned long));
1701 memcpy(&(num128[1]), &(swp->f17) + i*2, sizeof(unsigned long));
1702 copy_to_user(&save->xmm_space[0] + 4*i, num128, sizeof(struct _xmmreg_ia32));
1708 restore_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct __user *save)
1710 struct switch_stack *swp;
1711 struct pt_regs *ptp;
1713 unsigned int fsrlo, fsrhi, num32;
1715 unsigned long num64;
1716 unsigned long num128[2];
1718 if (!access_ok(VERIFY_READ, save, sizeof(*save)))
1721 __get_user(num32, (unsigned int __user *)&save->cwd);
1722 tsk->thread.fcr = (tsk->thread.fcr & (~0x1f3f)) | (num32 & 0x1f3f);
1723 __get_user(fsrlo, (unsigned int __user *)&save->swd);
1724 __get_user(fsrhi, (unsigned int __user *)&save->twd);
1725 num32 = (fsrhi << 16) | fsrlo;
1726 tsk->thread.fsr = (tsk->thread.fsr & (~0xffffffff)) | num32;
1727 __get_user(num32, (unsigned int __user *)&save->fip);
1728 tsk->thread.fir = (tsk->thread.fir & (~0xffffffff)) | num32;
1729 __get_user(num32, (unsigned int __user *)&save->foo);
1730 tsk->thread.fdr = (tsk->thread.fdr & (~0xffffffff)) | num32;
1733 * Stack frames start with 16-bytes of temp space
1735 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1736 ptp = ia64_task_regs(tsk);
1737 tos = (tsk->thread.fsr >> 11) & 7;
1738 for (i = 0; i < 8; i++)
1739 get_fpreg(i, (struct _fpreg_ia32 __user *)&save->st_space[4*i], ptp, swp, tos);
1741 __get_user(mxcsr, (unsigned int __user *)&save->mxcsr);
1742 num64 = mxcsr & 0xff10;
1743 tsk->thread.fcr = (tsk->thread.fcr & (~0xff1000000000UL)) | (num64<<32);
1744 num64 = mxcsr & 0x3f;
1745 tsk->thread.fsr = (tsk->thread.fsr & (~0x3f00000000UL)) | (num64<<32);
1747 for (i = 0; i < 8; i++) {
1748 copy_from_user(num128, &save->xmm_space[0] + 4*i, sizeof(struct _xmmreg_ia32));
1749 memcpy(&(swp->f16) + i*2, &(num128[0]), sizeof(unsigned long));
1750 memcpy(&(swp->f17) + i*2, &(num128[1]), sizeof(unsigned long));
1756 sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data)
1758 struct task_struct *child;
1759 unsigned int value, tmp;
1763 if (request == PTRACE_TRACEME) {
1764 ret = sys_ptrace(request, pid, addr, data);
1769 read_lock(&tasklist_lock);
1770 child = find_task_by_pid(pid);
1772 get_task_struct(child);
1773 read_unlock(&tasklist_lock);
1777 if (pid == 1) /* no messing around with init! */
1780 if (request == PTRACE_ATTACH) {
1781 ret = sys_ptrace(request, pid, addr, data);
1785 ret = ptrace_check_attach(child, request == PTRACE_KILL);
1790 case PTRACE_PEEKTEXT:
1791 case PTRACE_PEEKDATA: /* read word at location addr */
1792 ret = ia32_peek(child, addr, &value);
1794 ret = put_user(value, (unsigned int __user *) compat_ptr(data));
1799 case PTRACE_POKETEXT:
1800 case PTRACE_POKEDATA: /* write the word at location addr */
1801 ret = ia32_poke(child, addr, data);
1804 case PTRACE_PEEKUSR: /* read word at addr in USER area */
1806 if ((addr & 3) || addr > 17*sizeof(int))
1809 tmp = getreg(child, addr);
1810 if (!put_user(tmp, (unsigned int __user *) compat_ptr(data)))
1814 case PTRACE_POKEUSR: /* write word at addr in USER area */
1816 if ((addr & 3) || addr > 17*sizeof(int))
1819 putreg(child, addr, data);
1823 case IA32_PTRACE_GETREGS:
1824 if (!access_ok(VERIFY_WRITE, compat_ptr(data), 17*sizeof(int))) {
1828 for (i = 0; i < (int) (17*sizeof(int)); i += sizeof(int) ) {
1829 put_user(getreg(child, i), (unsigned int __user *) compat_ptr(data));
1830 data += sizeof(int);
1835 case IA32_PTRACE_SETREGS:
1836 if (!access_ok(VERIFY_READ, compat_ptr(data), 17*sizeof(int))) {
1840 for (i = 0; i < (int) (17*sizeof(int)); i += sizeof(int) ) {
1841 get_user(tmp, (unsigned int __user *) compat_ptr(data));
1842 putreg(child, i, tmp);
1843 data += sizeof(int);
1848 case IA32_PTRACE_GETFPREGS:
1849 ret = save_ia32_fpstate(child, (struct ia32_user_i387_struct __user *)
1853 case IA32_PTRACE_GETFPXREGS:
1854 ret = save_ia32_fpxstate(child, (struct ia32_user_fxsr_struct __user *)
1858 case IA32_PTRACE_SETFPREGS:
1859 ret = restore_ia32_fpstate(child, (struct ia32_user_i387_struct __user *)
1863 case IA32_PTRACE_SETFPXREGS:
1864 ret = restore_ia32_fpxstate(child, (struct ia32_user_fxsr_struct __user *)
1868 case PTRACE_GETEVENTMSG:
1869 ret = put_user(child->ptrace_message, (unsigned int __user *) compat_ptr(data));
1872 case PTRACE_SYSCALL: /* continue, stop after next syscall */
1873 case PTRACE_CONT: /* restart after signal. */
1875 case PTRACE_SINGLESTEP: /* execute chile for one instruction */
1876 case PTRACE_DETACH: /* detach a process */
1877 ret = sys_ptrace(request, pid, addr, data);
1881 ret = ptrace_request(child, request, addr, data);
1886 put_task_struct(child);
1894 unsigned int ss_flags;
1895 unsigned int ss_size;
1899 sys32_sigaltstack (ia32_stack_t __user *uss32, ia32_stack_t __user *uoss32,
1900 long arg2, long arg3, long arg4, long arg5, long arg6,
1901 long arg7, struct pt_regs pt)
1906 mm_segment_t old_fs = get_fs();
1909 if (copy_from_user(&buf32, uss32, sizeof(ia32_stack_t)))
1911 uss.ss_sp = (void __user *) (long) buf32.ss_sp;
1912 uss.ss_flags = buf32.ss_flags;
1913 /* MINSIGSTKSZ is different for ia32 vs ia64. We lie here to pass the
1914 check and set it to the user requested value later */
1915 if ((buf32.ss_flags != SS_DISABLE) && (buf32.ss_size < MINSIGSTKSZ_IA32)) {
1919 uss.ss_size = MINSIGSTKSZ;
1922 ret = do_sigaltstack(uss32 ? (stack_t __user *) &uss : NULL,
1923 (stack_t __user *) &uoss, pt.r12);
1924 current->sas_ss_size = buf32.ss_size;
1930 buf32.ss_sp = (long __user) uoss.ss_sp;
1931 buf32.ss_flags = uoss.ss_flags;
1932 buf32.ss_size = uoss.ss_size;
1933 if (copy_to_user(uoss32, &buf32, sizeof(ia32_stack_t)))
1942 current->state = TASK_INTERRUPTIBLE;
1944 return -ERESTARTNOHAND;
1948 sys32_msync (unsigned int start, unsigned int len, int flags)
1952 if (OFFSET4K(start))
1954 addr = PAGE_START(start);
1955 return sys_msync(addr, len + (start - addr), flags);
1961 unsigned int oldval;
1962 unsigned int oldlenp;
1963 unsigned int newval;
1964 unsigned int newlen;
1965 unsigned int __unused[4];
1968 #ifdef CONFIG_SYSCTL
1970 sys32_sysctl (struct sysctl32 __user *args)
1972 struct sysctl32 a32;
1973 mm_segment_t old_fs = get_fs ();
1974 void __user *oldvalp, *newvalp;
1979 if (copy_from_user(&a32, args, sizeof(a32)))
1983 * We need to pre-validate these because we have to disable address checking
1984 * before calling do_sysctl() because of OLDLEN but we can't run the risk of the
1985 * user specifying bad addresses here. Well, since we're dealing with 32 bit
1986 * addresses, we KNOW that access_ok() will always succeed, so this is an
1987 * expensive NOP, but so what...
1989 namep = (int __user *) compat_ptr(a32.name);
1990 oldvalp = compat_ptr(a32.oldval);
1991 newvalp = compat_ptr(a32.newval);
1993 if ((oldvalp && get_user(oldlen, (int __user *) compat_ptr(a32.oldlenp)))
1994 || !access_ok(VERIFY_WRITE, namep, 0)
1995 || !access_ok(VERIFY_WRITE, oldvalp, 0)
1996 || !access_ok(VERIFY_WRITE, newvalp, 0))
2001 ret = do_sysctl(namep, a32.nlen, oldvalp, (size_t __user *) &oldlen,
2002 newvalp, (size_t) a32.newlen);
2006 if (oldvalp && put_user (oldlen, (int __user *) compat_ptr(a32.oldlenp)))
2014 sys32_newuname (struct new_utsname __user *name)
2016 int ret = sys_newuname(name);
2019 if (copy_to_user(name->machine, "i686\0\0\0", 8))
2025 sys32_getresuid16 (u16 __user *ruid, u16 __user *euid, u16 __user *suid)
2029 mm_segment_t old_fs = get_fs();
2032 ret = sys_getresuid((uid_t __user *) &a, (uid_t __user *) &b, (uid_t __user *) &c);
2035 if (put_user(a, ruid) || put_user(b, euid) || put_user(c, suid))
2041 sys32_getresgid16 (u16 __user *rgid, u16 __user *egid, u16 __user *sgid)
2045 mm_segment_t old_fs = get_fs();
2048 ret = sys_getresgid((gid_t __user *) &a, (gid_t __user *) &b, (gid_t __user *) &c);
2054 return put_user(a, rgid) | put_user(b, egid) | put_user(c, sgid);
2058 sys32_lseek (unsigned int fd, int offset, unsigned int whence)
2060 /* Sign-extension of "offset" is important here... */
2061 return sys_lseek(fd, offset, whence);
2065 groups16_to_user(short __user *grouplist, struct group_info *group_info)
2070 for (i = 0; i < group_info->ngroups; i++) {
2071 group = (short)GROUP_AT(group_info, i);
2072 if (put_user(group, grouplist+i))
2080 groups16_from_user(struct group_info *group_info, short __user *grouplist)
2085 for (i = 0; i < group_info->ngroups; i++) {
2086 if (get_user(group, grouplist+i))
2088 GROUP_AT(group_info, i) = (gid_t)group;
2095 sys32_getgroups16 (int gidsetsize, short __user *grouplist)
2102 get_group_info(current->group_info);
2103 i = current->group_info->ngroups;
2105 if (i > gidsetsize) {
2109 if (groups16_to_user(grouplist, current->group_info)) {
2115 put_group_info(current->group_info);
2120 sys32_setgroups16 (int gidsetsize, short __user *grouplist)
2122 struct group_info *group_info;
2125 if (!capable(CAP_SETGID))
2127 if ((unsigned)gidsetsize > NGROUPS_MAX)
2130 group_info = groups_alloc(gidsetsize);
2133 retval = groups16_from_user(group_info, grouplist);
2135 put_group_info(group_info);
2139 retval = set_current_groups(group_info);
2140 put_group_info(group_info);
2146 sys32_truncate64 (unsigned int path, unsigned int len_lo, unsigned int len_hi)
2148 return sys_truncate(compat_ptr(path), ((unsigned long) len_hi << 32) | len_lo);
2152 sys32_ftruncate64 (int fd, unsigned int len_lo, unsigned int len_hi)
2154 return sys_ftruncate(fd, ((unsigned long) len_hi << 32) | len_lo);
2158 putstat64 (struct stat64 __user *ubuf, struct kstat *kbuf)
2163 if (clear_user(ubuf, sizeof(*ubuf)))
2166 hdev = huge_encode_dev(kbuf->dev);
2167 err = __put_user(hdev, (u32 __user*)&ubuf->st_dev);
2168 err |= __put_user(hdev >> 32, ((u32 __user*)&ubuf->st_dev) + 1);
2169 err |= __put_user(kbuf->ino, &ubuf->__st_ino);
2170 err |= __put_user(kbuf->ino, &ubuf->st_ino_lo);
2171 err |= __put_user(kbuf->ino >> 32, &ubuf->st_ino_hi);
2172 err |= __put_user(kbuf->mode, &ubuf->st_mode);
2173 err |= __put_user(kbuf->nlink, &ubuf->st_nlink);
2174 err |= __put_user(kbuf->uid, &ubuf->st_uid);
2175 err |= __put_user(kbuf->gid, &ubuf->st_gid);
2176 hdev = huge_encode_dev(kbuf->rdev);
2177 err = __put_user(hdev, (u32 __user*)&ubuf->st_rdev);
2178 err |= __put_user(hdev >> 32, ((u32 __user*)&ubuf->st_rdev) + 1);
2179 err |= __put_user(kbuf->size, &ubuf->st_size_lo);
2180 err |= __put_user((kbuf->size >> 32), &ubuf->st_size_hi);
2181 err |= __put_user(kbuf->atime.tv_sec, &ubuf->st_atime);
2182 err |= __put_user(kbuf->atime.tv_nsec, &ubuf->st_atime_nsec);
2183 err |= __put_user(kbuf->mtime.tv_sec, &ubuf->st_mtime);
2184 err |= __put_user(kbuf->mtime.tv_nsec, &ubuf->st_mtime_nsec);
2185 err |= __put_user(kbuf->ctime.tv_sec, &ubuf->st_ctime);
2186 err |= __put_user(kbuf->ctime.tv_nsec, &ubuf->st_ctime_nsec);
2187 err |= __put_user(kbuf->blksize, &ubuf->st_blksize);
2188 err |= __put_user(kbuf->blocks, &ubuf->st_blocks);
2193 sys32_stat64 (char __user *filename, struct stat64 __user *statbuf)
2196 long ret = vfs_stat(filename, &s);
2198 ret = putstat64(statbuf, &s);
2203 sys32_lstat64 (char __user *filename, struct stat64 __user *statbuf)
2206 long ret = vfs_lstat(filename, &s);
2208 ret = putstat64(statbuf, &s);
2213 sys32_fstat64 (unsigned int fd, struct stat64 __user *statbuf)
2216 long ret = vfs_fstat(fd, &s);
2218 ret = putstat64(statbuf, &s);
2240 sys32_sysinfo (struct sysinfo32 __user *info)
2245 mm_segment_t old_fs = get_fs();
2248 ret = sys_sysinfo((struct sysinfo __user *) &s);
2250 /* Check to see if any memory value is too large for 32-bit and
2251 * scale down if needed.
2253 if ((s.totalram >> 32) || (s.totalswap >> 32)) {
2254 while (s.mem_unit < PAGE_SIZE) {
2258 s.totalram >>= bitcount;
2259 s.freeram >>= bitcount;
2260 s.sharedram >>= bitcount;
2261 s.bufferram >>= bitcount;
2262 s.totalswap >>= bitcount;
2263 s.freeswap >>= bitcount;
2264 s.totalhigh >>= bitcount;
2265 s.freehigh >>= bitcount;
2268 if (!access_ok(VERIFY_WRITE, info, sizeof(*info)))
2271 err = __put_user(s.uptime, &info->uptime);
2272 err |= __put_user(s.loads[0], &info->loads[0]);
2273 err |= __put_user(s.loads[1], &info->loads[1]);
2274 err |= __put_user(s.loads[2], &info->loads[2]);
2275 err |= __put_user(s.totalram, &info->totalram);
2276 err |= __put_user(s.freeram, &info->freeram);
2277 err |= __put_user(s.sharedram, &info->sharedram);
2278 err |= __put_user(s.bufferram, &info->bufferram);
2279 err |= __put_user(s.totalswap, &info->totalswap);
2280 err |= __put_user(s.freeswap, &info->freeswap);
2281 err |= __put_user(s.procs, &info->procs);
2282 err |= __put_user (s.totalhigh, &info->totalhigh);
2283 err |= __put_user (s.freehigh, &info->freehigh);
2284 err |= __put_user (s.mem_unit, &info->mem_unit);
2291 sys32_sched_rr_get_interval (pid_t pid, struct compat_timespec __user *interval)
2293 mm_segment_t old_fs = get_fs();
2298 ret = sys_sched_rr_get_interval(pid, (struct timespec __user *) &t);
2300 if (put_compat_timespec(&t, interval))
2306 sys32_pread (unsigned int fd, void __user *buf, unsigned int count, u32 pos_lo, u32 pos_hi)
2308 return sys_pread64(fd, buf, count, ((unsigned long) pos_hi << 32) | pos_lo);
2312 sys32_pwrite (unsigned int fd, void __user *buf, unsigned int count, u32 pos_lo, u32 pos_hi)
2314 return sys_pwrite64(fd, buf, count, ((unsigned long) pos_hi << 32) | pos_lo);
2318 sys32_sendfile (int out_fd, int in_fd, int __user *offset, unsigned int count)
2320 mm_segment_t old_fs = get_fs();
2324 if (offset && get_user(of, offset))
2328 ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *) &of : NULL, count);
2331 if (offset && put_user(of, offset))
2338 sys32_personality (unsigned int personality)
2342 if (current->personality == PER_LINUX32 && personality == PER_LINUX)
2343 personality = PER_LINUX32;
2344 ret = sys_personality(personality);
2345 if (ret == PER_LINUX32)
2350 asmlinkage unsigned long
2351 sys32_brk (unsigned int brk)
2353 unsigned long ret, obrk;
2354 struct mm_struct *mm = current->mm;
2359 clear_user(compat_ptr(ret), PAGE_ALIGN(ret) - ret);
2363 /* Structure for ia32 emulation on ia64 */
2364 struct epoll_event32
2371 sys32_epoll_ctl(int epfd, int op, int fd, struct epoll_event32 __user *event)
2373 mm_segment_t old_fs = get_fs();
2374 struct epoll_event event64;
2378 if (!access_ok(VERIFY_READ, event, sizeof(struct epoll_event32)))
2381 __get_user(event64.events, &event->events);
2382 __get_user(data_halfword, &event->data[0]);
2383 event64.data = data_halfword;
2384 __get_user(data_halfword, &event->data[1]);
2385 event64.data |= (u64)data_halfword << 32;
2388 error = sys_epoll_ctl(epfd, op, fd, (struct epoll_event __user *) &event64);
2395 sys32_epoll_wait(int epfd, struct epoll_event32 __user * events, int maxevents,
2398 struct epoll_event *events64 = NULL;
2399 mm_segment_t old_fs = get_fs();
2400 int numevents, size;
2402 int do_free_pages = 0;
2404 if (maxevents <= 0) {
2408 /* Verify that the area passed by the user is writeable */
2409 if (!access_ok(VERIFY_WRITE, events, maxevents * sizeof(struct epoll_event32)))
2413 * Allocate space for the intermediate copy. If the space needed
2414 * is large enough to cause kmalloc to fail, then try again with
2417 size = maxevents * sizeof(struct epoll_event);
2418 events64 = kmalloc(size, GFP_KERNEL);
2419 if (events64 == NULL) {
2420 events64 = (struct epoll_event *)
2421 __get_free_pages(GFP_KERNEL, get_order(size));
2422 if (events64 == NULL)
2427 /* Do the system call */
2428 set_fs(KERNEL_DS); /* copy_to/from_user should work on kernel mem*/
2429 numevents = sys_epoll_wait(epfd, (struct epoll_event __user *) events64,
2430 maxevents, timeout);
2433 /* Don't modify userspace memory if we're returning an error */
2434 if (numevents > 0) {
2435 /* Translate the 64-bit structures back into the 32-bit
2437 for (evt_idx = 0; evt_idx < numevents; evt_idx++) {
2438 __put_user(events64[evt_idx].events,
2439 &events[evt_idx].events);
2440 __put_user((u32)events64[evt_idx].data,
2441 &events[evt_idx].data[0]);
2442 __put_user((u32)(events64[evt_idx].data >> 32),
2443 &events[evt_idx].data[1]);
2448 free_pages((unsigned long) events64, get_order(size));
2455 * Get a yet unused TLS descriptor index.
2460 struct thread_struct *t = ¤t->thread;
2463 for (idx = 0; idx < GDT_ENTRY_TLS_ENTRIES; idx++)
2464 if (desc_empty(t->tls_array + idx))
2465 return idx + GDT_ENTRY_TLS_MIN;
2470 * Set a given TLS descriptor:
2473 sys32_set_thread_area (struct ia32_user_desc __user *u_info)
2475 struct thread_struct *t = ¤t->thread;
2476 struct ia32_user_desc info;
2477 struct desc_struct *desc;
2480 if (copy_from_user(&info, u_info, sizeof(info)))
2482 idx = info.entry_number;
2485 * index -1 means the kernel should try to find and allocate an empty descriptor:
2488 idx = get_free_idx();
2491 if (put_user(idx, &u_info->entry_number))
2495 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
2498 desc = t->tls_array + idx - GDT_ENTRY_TLS_MIN;
2500 cpu = smp_processor_id();
2502 if (LDT_empty(&info)) {
2506 desc->a = LDT_entry_a(&info);
2507 desc->b = LDT_entry_b(&info);
2514 * Get the current Thread-Local Storage area:
2517 #define GET_BASE(desc) ( \
2518 (((desc)->a >> 16) & 0x0000ffff) | \
2519 (((desc)->b << 16) & 0x00ff0000) | \
2520 ( (desc)->b & 0xff000000) )
2522 #define GET_LIMIT(desc) ( \
2523 ((desc)->a & 0x0ffff) | \
2524 ((desc)->b & 0xf0000) )
2526 #define GET_32BIT(desc) (((desc)->b >> 22) & 1)
2527 #define GET_CONTENTS(desc) (((desc)->b >> 10) & 3)
2528 #define GET_WRITABLE(desc) (((desc)->b >> 9) & 1)
2529 #define GET_LIMIT_PAGES(desc) (((desc)->b >> 23) & 1)
2530 #define GET_PRESENT(desc) (((desc)->b >> 15) & 1)
2531 #define GET_USEABLE(desc) (((desc)->b >> 20) & 1)
2534 sys32_get_thread_area (struct ia32_user_desc __user *u_info)
2536 struct ia32_user_desc info;
2537 struct desc_struct *desc;
2540 if (get_user(idx, &u_info->entry_number))
2542 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
2545 desc = current->thread.tls_array + idx - GDT_ENTRY_TLS_MIN;
2547 info.entry_number = idx;
2548 info.base_addr = GET_BASE(desc);
2549 info.limit = GET_LIMIT(desc);
2550 info.seg_32bit = GET_32BIT(desc);
2551 info.contents = GET_CONTENTS(desc);
2552 info.read_exec_only = !GET_WRITABLE(desc);
2553 info.limit_in_pages = GET_LIMIT_PAGES(desc);
2554 info.seg_not_present = !GET_PRESENT(desc);
2555 info.useable = GET_USEABLE(desc);
2557 if (copy_to_user(u_info, &info, sizeof(info)))
2563 sys32_timer_create(u32 clock, struct compat_sigevent __user *se32, timer_t __user *timer_id)
2571 return sys_timer_create(clock, NULL, timer_id);
2573 if (get_compat_sigevent(&se, se32))
2576 if (!access_ok(VERIFY_WRITE,timer_id,sizeof(timer_t)))
2581 err = sys_timer_create(clock, (struct sigevent __user *) &se, (timer_t __user *) &t);
2585 err = __put_user (t, timer_id);
2590 long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
2591 __u32 len_low, __u32 len_high, int advice)
2593 return sys_fadvise64_64(fd,
2594 (((u64)offset_high)<<32) | offset_low,
2595 (((u64)len_high)<<32) | len_low,
2599 #ifdef NOTYET /* UNTESTED FOR IA64 FROM HERE DOWN */
2601 asmlinkage long sys32_setreuid(compat_uid_t ruid, compat_uid_t euid)
2605 sruid = (ruid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)ruid);
2606 seuid = (euid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)euid);
2607 return sys_setreuid(sruid, seuid);
2611 sys32_setresuid(compat_uid_t ruid, compat_uid_t euid,
2614 uid_t sruid, seuid, ssuid;
2616 sruid = (ruid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)ruid);
2617 seuid = (euid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)euid);
2618 ssuid = (suid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)suid);
2619 return sys_setresuid(sruid, seuid, ssuid);
2623 sys32_setregid(compat_gid_t rgid, compat_gid_t egid)
2627 srgid = (rgid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)rgid);
2628 segid = (egid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)egid);
2629 return sys_setregid(srgid, segid);
2633 sys32_setresgid(compat_gid_t rgid, compat_gid_t egid,
2636 gid_t srgid, segid, ssgid;
2638 srgid = (rgid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)rgid);
2639 segid = (egid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)egid);
2640 ssgid = (sgid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)sgid);
2641 return sys_setresgid(srgid, segid, ssgid);
2644 /* Handle adjtimex compatibility. */
2648 s32 offset, freq, maxerror, esterror;
2649 s32 status, constant, precision, tolerance;
2650 struct compat_timeval time;
2652 s32 ppsfreq, jitter, shift, stabil;
2653 s32 jitcnt, calcnt, errcnt, stbcnt;
2654 s32 :32; s32 :32; s32 :32; s32 :32;
2655 s32 :32; s32 :32; s32 :32; s32 :32;
2656 s32 :32; s32 :32; s32 :32; s32 :32;
2659 extern int do_adjtimex(struct timex *);
2662 sys32_adjtimex(struct timex32 *utp)
2667 memset(&txc, 0, sizeof(struct timex));
2669 if(get_user(txc.modes, &utp->modes) ||
2670 __get_user(txc.offset, &utp->offset) ||
2671 __get_user(txc.freq, &utp->freq) ||
2672 __get_user(txc.maxerror, &utp->maxerror) ||
2673 __get_user(txc.esterror, &utp->esterror) ||
2674 __get_user(txc.status, &utp->status) ||
2675 __get_user(txc.constant, &utp->constant) ||
2676 __get_user(txc.precision, &utp->precision) ||
2677 __get_user(txc.tolerance, &utp->tolerance) ||
2678 __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
2679 __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
2680 __get_user(txc.tick, &utp->tick) ||
2681 __get_user(txc.ppsfreq, &utp->ppsfreq) ||
2682 __get_user(txc.jitter, &utp->jitter) ||
2683 __get_user(txc.shift, &utp->shift) ||
2684 __get_user(txc.stabil, &utp->stabil) ||
2685 __get_user(txc.jitcnt, &utp->jitcnt) ||
2686 __get_user(txc.calcnt, &utp->calcnt) ||
2687 __get_user(txc.errcnt, &utp->errcnt) ||
2688 __get_user(txc.stbcnt, &utp->stbcnt))
2691 ret = do_adjtimex(&txc);
2693 if(put_user(txc.modes, &utp->modes) ||
2694 __put_user(txc.offset, &utp->offset) ||
2695 __put_user(txc.freq, &utp->freq) ||
2696 __put_user(txc.maxerror, &utp->maxerror) ||
2697 __put_user(txc.esterror, &utp->esterror) ||
2698 __put_user(txc.status, &utp->status) ||
2699 __put_user(txc.constant, &utp->constant) ||
2700 __put_user(txc.precision, &utp->precision) ||
2701 __put_user(txc.tolerance, &utp->tolerance) ||
2702 __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
2703 __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
2704 __put_user(txc.tick, &utp->tick) ||
2705 __put_user(txc.ppsfreq, &utp->ppsfreq) ||
2706 __put_user(txc.jitter, &utp->jitter) ||
2707 __put_user(txc.shift, &utp->shift) ||
2708 __put_user(txc.stabil, &utp->stabil) ||
2709 __put_user(txc.jitcnt, &utp->jitcnt) ||
2710 __put_user(txc.calcnt, &utp->calcnt) ||
2711 __put_user(txc.errcnt, &utp->errcnt) ||
2712 __put_user(txc.stbcnt, &utp->stbcnt))