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/capability.h>
52 #include <linux/compat.h>
53 #include <linux/vfs.h>
54 #include <linux/mman.h>
55 #include <linux/mutex.h>
57 #include <asm/intrinsics.h>
58 #include <asm/types.h>
59 #include <asm/uaccess.h>
60 #include <asm/unistd.h>
70 # define DBG(fmt...) printk(KERN_DEBUG fmt)
75 #define ROUND_UP(x,a) ((__typeof__(x))(((unsigned long)(x) + ((a) - 1)) & ~((a) - 1)))
77 #define OFFSET4K(a) ((a) & 0xfff)
78 #define PAGE_START(addr) ((addr) & PAGE_MASK)
79 #define MINSIGSTKSZ_IA32 2048
81 #define high2lowuid(uid) ((uid) > 65535 ? 65534 : (uid))
82 #define high2lowgid(gid) ((gid) > 65535 ? 65534 : (gid))
85 * Anything that modifies or inspects ia32 user virtual memory must hold this semaphore
88 /* XXX make per-mm: */
89 static DEFINE_MUTEX(ia32_mmap_mutex);
92 sys32_execve (char __user *name, compat_uptr_t __user *argv, compat_uptr_t __user *envp,
97 unsigned long old_map_base, old_task_size, tssd;
99 filename = getname(name);
100 error = PTR_ERR(filename);
101 if (IS_ERR(filename))
104 old_map_base = current->thread.map_base;
105 old_task_size = current->thread.task_size;
106 tssd = ia64_get_kr(IA64_KR_TSSD);
108 /* we may be exec'ing a 64-bit process: reset map base, task-size, and io-base: */
109 current->thread.map_base = DEFAULT_MAP_BASE;
110 current->thread.task_size = DEFAULT_TASK_SIZE;
111 ia64_set_kr(IA64_KR_IO_BASE, current->thread.old_iob);
112 ia64_set_kr(IA64_KR_TSSD, current->thread.old_k1);
114 error = compat_do_execve(filename, argv, envp, regs);
118 /* oops, execve failed, switch back to old values... */
119 ia64_set_kr(IA64_KR_IO_BASE, IA32_IOBASE);
120 ia64_set_kr(IA64_KR_TSSD, tssd);
121 current->thread.map_base = old_map_base;
122 current->thread.task_size = old_task_size;
128 int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf)
132 if ((u64) stat->size > MAX_NON_LFS ||
133 !old_valid_dev(stat->dev) ||
134 !old_valid_dev(stat->rdev))
137 if (clear_user(ubuf, sizeof(*ubuf)))
140 err = __put_user(old_encode_dev(stat->dev), &ubuf->st_dev);
141 err |= __put_user(stat->ino, &ubuf->st_ino);
142 err |= __put_user(stat->mode, &ubuf->st_mode);
143 err |= __put_user(stat->nlink, &ubuf->st_nlink);
144 err |= __put_user(high2lowuid(stat->uid), &ubuf->st_uid);
145 err |= __put_user(high2lowgid(stat->gid), &ubuf->st_gid);
146 err |= __put_user(old_encode_dev(stat->rdev), &ubuf->st_rdev);
147 err |= __put_user(stat->size, &ubuf->st_size);
148 err |= __put_user(stat->atime.tv_sec, &ubuf->st_atime);
149 err |= __put_user(stat->atime.tv_nsec, &ubuf->st_atime_nsec);
150 err |= __put_user(stat->mtime.tv_sec, &ubuf->st_mtime);
151 err |= __put_user(stat->mtime.tv_nsec, &ubuf->st_mtime_nsec);
152 err |= __put_user(stat->ctime.tv_sec, &ubuf->st_ctime);
153 err |= __put_user(stat->ctime.tv_nsec, &ubuf->st_ctime_nsec);
154 err |= __put_user(stat->blksize, &ubuf->st_blksize);
155 err |= __put_user(stat->blocks, &ubuf->st_blocks);
159 #if PAGE_SHIFT > IA32_PAGE_SHIFT
163 get_page_prot (struct vm_area_struct *vma, unsigned long addr)
167 if (!vma || vma->vm_start > addr)
170 if (vma->vm_flags & VM_READ)
172 if (vma->vm_flags & VM_WRITE)
174 if (vma->vm_flags & VM_EXEC)
180 * Map a subpage by creating an anonymous page that contains the union of the old page and
184 mmap_subpage (struct file *file, unsigned long start, unsigned long end, int prot, int flags,
189 unsigned long ret = 0;
190 struct vm_area_struct *vma = find_vma(current->mm, start);
191 int old_prot = get_page_prot(vma, start);
193 DBG("mmap_subpage(file=%p,start=0x%lx,end=0x%lx,prot=%x,flags=%x,off=0x%llx)\n",
194 file, start, end, prot, flags, off);
197 /* Optimize the case where the old mmap and the new mmap are both anonymous */
198 if ((old_prot & PROT_WRITE) && (flags & MAP_ANONYMOUS) && !vma->vm_file) {
199 if (clear_user((void __user *) start, end - start)) {
206 page = (void *) get_zeroed_page(GFP_KERNEL);
211 copy_from_user(page, (void __user *) PAGE_START(start), PAGE_SIZE);
213 down_write(¤t->mm->mmap_sem);
215 ret = do_mmap(NULL, PAGE_START(start), PAGE_SIZE, prot | PROT_WRITE,
216 flags | MAP_FIXED | MAP_ANONYMOUS, 0);
218 up_write(¤t->mm->mmap_sem);
220 if (IS_ERR((void *) ret))
224 /* copy back the old page contents. */
225 if (offset_in_page(start))
226 copy_to_user((void __user *) PAGE_START(start), page,
227 offset_in_page(start));
228 if (offset_in_page(end))
229 copy_to_user((void __user *) end, page + offset_in_page(end),
230 PAGE_SIZE - offset_in_page(end));
233 if (!(flags & MAP_ANONYMOUS)) {
234 /* read the file contents */
235 inode = file->f_dentry->d_inode;
236 if (!inode->i_fop || !file->f_op->read
237 || ((*file->f_op->read)(file, (char __user *) start, end - start, &off) < 0))
245 if (!(prot & PROT_WRITE))
246 ret = sys_mprotect(PAGE_START(start), PAGE_SIZE, prot | old_prot);
249 free_page((unsigned long) page);
253 /* SLAB cache for partial_page structures */
254 kmem_cache_t *partial_page_cachep;
257 * init partial_page_list.
258 * return 0 means kmalloc fail.
260 struct partial_page_list*
261 ia32_init_pp_list(void)
263 struct partial_page_list *p;
265 if ((p = kmalloc(sizeof(*p), GFP_KERNEL)) == NULL)
270 atomic_set(&p->pp_count, 1);
275 * Search for the partial page with @start in partial page list @ppl.
276 * If finds the partial page, return the found partial page.
277 * Else, return 0 and provide @pprev, @rb_link, @rb_parent to
278 * be used by later __ia32_insert_pp().
280 static struct partial_page *
281 __ia32_find_pp(struct partial_page_list *ppl, unsigned int start,
282 struct partial_page **pprev, struct rb_node ***rb_link,
283 struct rb_node **rb_parent)
285 struct partial_page *pp;
286 struct rb_node **__rb_link, *__rb_parent, *rb_prev;
289 if (pp && pp->base == start)
292 __rb_link = &ppl->ppl_rb.rb_node;
293 rb_prev = __rb_parent = NULL;
296 __rb_parent = *__rb_link;
297 pp = rb_entry(__rb_parent, struct partial_page, pp_rb);
299 if (pp->base == start) {
302 } else if (pp->base < start) {
303 rb_prev = __rb_parent;
304 __rb_link = &__rb_parent->rb_right;
306 __rb_link = &__rb_parent->rb_left;
310 *rb_link = __rb_link;
311 *rb_parent = __rb_parent;
314 *pprev = rb_entry(rb_prev, struct partial_page, pp_rb);
319 * insert @pp into @ppl.
322 __ia32_insert_pp(struct partial_page_list *ppl, struct partial_page *pp,
323 struct partial_page *prev, struct rb_node **rb_link,
324 struct rb_node *rb_parent)
328 pp->next = prev->next;
333 pp->next = rb_entry(rb_parent,
334 struct partial_page, pp_rb);
340 rb_link_node(&pp->pp_rb, rb_parent, rb_link);
341 rb_insert_color(&pp->pp_rb, &ppl->ppl_rb);
347 * delete @pp from partial page list @ppl.
350 __ia32_delete_pp(struct partial_page_list *ppl, struct partial_page *pp,
351 struct partial_page *prev)
354 prev->next = pp->next;
355 if (ppl->pp_hint == pp)
358 ppl->pp_head = pp->next;
359 if (ppl->pp_hint == pp)
360 ppl->pp_hint = pp->next;
362 rb_erase(&pp->pp_rb, &ppl->ppl_rb);
363 kmem_cache_free(partial_page_cachep, pp);
366 static struct partial_page *
367 __pp_prev(struct partial_page *pp)
369 struct rb_node *prev = rb_prev(&pp->pp_rb);
371 return rb_entry(prev, struct partial_page, pp_rb);
377 * Delete partial pages with address between @start and @end.
378 * @start and @end are page aligned.
381 __ia32_delete_pp_range(unsigned int start, unsigned int end)
383 struct partial_page *pp, *prev;
384 struct rb_node **rb_link, *rb_parent;
389 pp = __ia32_find_pp(current->thread.ppl, start, &prev,
390 &rb_link, &rb_parent);
392 prev = __pp_prev(pp);
397 pp = current->thread.ppl->pp_head;
400 while (pp && pp->base < end) {
401 struct partial_page *tmp = pp->next;
402 __ia32_delete_pp(current->thread.ppl, pp, prev);
408 * Set the range between @start and @end in bitmap.
409 * @start and @end should be IA32 page aligned and in the same IA64 page.
412 __ia32_set_pp(unsigned int start, unsigned int end, int flags)
414 struct partial_page *pp, *prev;
415 struct rb_node ** rb_link, *rb_parent;
416 unsigned int pstart, start_bit, end_bit, i;
418 pstart = PAGE_START(start);
419 start_bit = (start % PAGE_SIZE) / IA32_PAGE_SIZE;
420 end_bit = (end % PAGE_SIZE) / IA32_PAGE_SIZE;
422 end_bit = PAGE_SIZE / IA32_PAGE_SIZE;
423 pp = __ia32_find_pp(current->thread.ppl, pstart, &prev,
424 &rb_link, &rb_parent);
426 for (i = start_bit; i < end_bit; i++)
427 set_bit(i, &pp->bitmap);
429 * Check: if this partial page has been set to a full page,
432 if (find_first_zero_bit(&pp->bitmap, sizeof(pp->bitmap)*8) >=
433 PAGE_SIZE/IA32_PAGE_SIZE) {
434 __ia32_delete_pp(current->thread.ppl, pp, __pp_prev(pp));
440 * MAP_FIXED may lead to overlapping mmap.
441 * In this case, the requested mmap area may already mmaped as a full
442 * page. So check vma before adding a new partial page.
444 if (flags & MAP_FIXED) {
445 struct vm_area_struct *vma = find_vma(current->mm, pstart);
446 if (vma && vma->vm_start <= pstart)
450 /* new a partial_page */
451 pp = kmem_cache_alloc(partial_page_cachep, GFP_KERNEL);
456 for (i=start_bit; i<end_bit; i++)
457 set_bit(i, &(pp->bitmap));
459 __ia32_insert_pp(current->thread.ppl, pp, prev, rb_link, rb_parent);
464 * @start and @end should be IA32 page aligned, but don't need to be in the
465 * same IA64 page. Split @start and @end to make sure they're in the same IA64
466 * page, then call __ia32_set_pp().
469 ia32_set_pp(unsigned int start, unsigned int end, int flags)
471 down_write(¤t->mm->mmap_sem);
472 if (flags & MAP_FIXED) {
474 * MAP_FIXED may lead to overlapping mmap. When this happens,
475 * a series of complete IA64 pages results in deletion of
476 * old partial pages in that range.
478 __ia32_delete_pp_range(PAGE_ALIGN(start), PAGE_START(end));
481 if (end < PAGE_ALIGN(start)) {
482 __ia32_set_pp(start, end, flags);
484 if (offset_in_page(start))
485 __ia32_set_pp(start, PAGE_ALIGN(start), flags);
486 if (offset_in_page(end))
487 __ia32_set_pp(PAGE_START(end), end, flags);
489 up_write(¤t->mm->mmap_sem);
493 * Unset the range between @start and @end in bitmap.
494 * @start and @end should be IA32 page aligned and in the same IA64 page.
495 * After doing that, if the bitmap is 0, then free the page and return 1,
497 * If not find the partial page in the list, then
498 * If the vma exists, then the full page is set to a partial page;
499 * Else return -ENOMEM.
502 __ia32_unset_pp(unsigned int start, unsigned int end)
504 struct partial_page *pp, *prev;
505 struct rb_node ** rb_link, *rb_parent;
506 unsigned int pstart, start_bit, end_bit, i;
507 struct vm_area_struct *vma;
509 pstart = PAGE_START(start);
510 start_bit = (start % PAGE_SIZE) / IA32_PAGE_SIZE;
511 end_bit = (end % PAGE_SIZE) / IA32_PAGE_SIZE;
513 end_bit = PAGE_SIZE / IA32_PAGE_SIZE;
515 pp = __ia32_find_pp(current->thread.ppl, pstart, &prev,
516 &rb_link, &rb_parent);
518 for (i = start_bit; i < end_bit; i++)
519 clear_bit(i, &pp->bitmap);
520 if (pp->bitmap == 0) {
521 __ia32_delete_pp(current->thread.ppl, pp, __pp_prev(pp));
527 vma = find_vma(current->mm, pstart);
528 if (!vma || vma->vm_start > pstart) {
532 /* new a partial_page */
533 pp = kmem_cache_alloc(partial_page_cachep, GFP_KERNEL);
538 for (i = 0; i < start_bit; i++)
539 set_bit(i, &(pp->bitmap));
540 for (i = end_bit; i < PAGE_SIZE / IA32_PAGE_SIZE; i++)
541 set_bit(i, &(pp->bitmap));
543 __ia32_insert_pp(current->thread.ppl, pp, prev, rb_link, rb_parent);
548 * Delete pp between PAGE_ALIGN(start) and PAGE_START(end) by calling
549 * __ia32_delete_pp_range(). Unset possible partial pages by calling
551 * The returned value see __ia32_unset_pp().
554 ia32_unset_pp(unsigned int *startp, unsigned int *endp)
556 unsigned int start = *startp, end = *endp;
559 down_write(¤t->mm->mmap_sem);
561 __ia32_delete_pp_range(PAGE_ALIGN(start), PAGE_START(end));
563 if (end < PAGE_ALIGN(start)) {
564 ret = __ia32_unset_pp(start, end);
566 *startp = PAGE_START(start);
567 *endp = PAGE_ALIGN(end);
570 /* to shortcut sys_munmap() in sys32_munmap() */
571 *startp = PAGE_START(start);
572 *endp = PAGE_START(end);
575 if (offset_in_page(start)) {
576 ret = __ia32_unset_pp(start, PAGE_ALIGN(start));
578 *startp = PAGE_START(start);
580 *startp = PAGE_ALIGN(start);
584 if (offset_in_page(end)) {
585 ret = __ia32_unset_pp(PAGE_START(end), end);
587 *endp = PAGE_ALIGN(end);
589 *endp = PAGE_START(end);
594 up_write(¤t->mm->mmap_sem);
599 * Compare the range between @start and @end with bitmap in partial page.
600 * @start and @end should be IA32 page aligned and in the same IA64 page.
603 __ia32_compare_pp(unsigned int start, unsigned int end)
605 struct partial_page *pp, *prev;
606 struct rb_node ** rb_link, *rb_parent;
607 unsigned int pstart, start_bit, end_bit, size;
608 unsigned int first_bit, next_zero_bit; /* the first range in bitmap */
610 pstart = PAGE_START(start);
612 pp = __ia32_find_pp(current->thread.ppl, pstart, &prev,
613 &rb_link, &rb_parent);
617 start_bit = (start % PAGE_SIZE) / IA32_PAGE_SIZE;
618 end_bit = (end % PAGE_SIZE) / IA32_PAGE_SIZE;
619 size = sizeof(pp->bitmap) * 8;
620 first_bit = find_first_bit(&pp->bitmap, size);
621 next_zero_bit = find_next_zero_bit(&pp->bitmap, size, first_bit);
622 if ((start_bit < first_bit) || (end_bit > next_zero_bit)) {
623 /* exceeds the first range in bitmap */
625 } else if ((start_bit == first_bit) && (end_bit == next_zero_bit)) {
626 first_bit = find_next_bit(&pp->bitmap, size, next_zero_bit);
627 if ((next_zero_bit < first_bit) && (first_bit < size))
628 return 1; /* has next range */
630 return 0; /* no next range */
636 * @start and @end should be IA32 page aligned, but don't need to be in the
637 * same IA64 page. Split @start and @end to make sure they're in the same IA64
638 * page, then call __ia32_compare_pp().
640 * Take this as example: the range is the 1st and 2nd 4K page.
641 * Return 0 if they fit bitmap exactly, i.e. bitmap = 00000011;
642 * Return 1 if the range doesn't cover whole bitmap, e.g. bitmap = 00001111;
643 * Return -ENOMEM if the range exceeds the bitmap, e.g. bitmap = 00000001 or
647 ia32_compare_pp(unsigned int *startp, unsigned int *endp)
649 unsigned int start = *startp, end = *endp;
652 down_write(¤t->mm->mmap_sem);
654 if (end < PAGE_ALIGN(start)) {
655 retval = __ia32_compare_pp(start, end);
657 *startp = PAGE_START(start);
658 *endp = PAGE_ALIGN(end);
661 if (offset_in_page(start)) {
662 retval = __ia32_compare_pp(start,
665 *startp = PAGE_START(start);
669 if (offset_in_page(end)) {
670 retval = __ia32_compare_pp(PAGE_START(end), end);
672 *endp = PAGE_ALIGN(end);
677 up_write(¤t->mm->mmap_sem);
682 __ia32_drop_pp_list(struct partial_page_list *ppl)
684 struct partial_page *pp = ppl->pp_head;
687 struct partial_page *next = pp->next;
688 kmem_cache_free(partial_page_cachep, pp);
696 ia32_drop_partial_page_list(struct task_struct *task)
698 struct partial_page_list* ppl = task->thread.ppl;
700 if (ppl && atomic_dec_and_test(&ppl->pp_count))
701 __ia32_drop_pp_list(ppl);
705 * Copy current->thread.ppl to ppl (already initialized).
708 __ia32_copy_pp_list(struct partial_page_list *ppl)
710 struct partial_page *pp, *tmp, *prev;
711 struct rb_node **rb_link, *rb_parent;
715 ppl->ppl_rb = RB_ROOT;
716 rb_link = &ppl->ppl_rb.rb_node;
720 for (pp = current->thread.ppl->pp_head; pp; pp = pp->next) {
721 tmp = kmem_cache_alloc(partial_page_cachep, GFP_KERNEL);
725 __ia32_insert_pp(ppl, tmp, prev, rb_link, rb_parent);
727 rb_link = &tmp->pp_rb.rb_right;
728 rb_parent = &tmp->pp_rb;
734 ia32_copy_partial_page_list(struct task_struct *p, unsigned long clone_flags)
738 if (clone_flags & CLONE_VM) {
739 atomic_inc(¤t->thread.ppl->pp_count);
740 p->thread.ppl = current->thread.ppl;
742 p->thread.ppl = ia32_init_pp_list();
745 down_write(¤t->mm->mmap_sem);
747 retval = __ia32_copy_pp_list(p->thread.ppl);
749 up_write(¤t->mm->mmap_sem);
756 emulate_mmap (struct file *file, unsigned long start, unsigned long len, int prot, int flags,
759 unsigned long tmp, end, pend, pstart, ret, is_congruent, fudge = 0;
764 pstart = PAGE_START(start);
765 pend = PAGE_ALIGN(end);
767 if (flags & MAP_FIXED) {
768 ia32_set_pp((unsigned int)start, (unsigned int)end, flags);
769 if (start > pstart) {
770 if (flags & MAP_SHARED)
772 "%s(%d): emulate_mmap() can't share head (addr=0x%lx)\n",
773 current->comm, current->pid, start);
774 ret = mmap_subpage(file, start, min(PAGE_ALIGN(start), end), prot, flags,
776 if (IS_ERR((void *) ret))
783 if (flags & MAP_SHARED)
785 "%s(%d): emulate_mmap() can't share tail (end=0x%lx)\n",
786 current->comm, current->pid, end);
787 ret = mmap_subpage(file, max(start, PAGE_START(end)), end, prot, flags,
788 (off + len) - offset_in_page(end));
789 if (IS_ERR((void *) ret))
797 * If a start address was specified, use it if the entire rounded out area
800 if (start && !pstart)
801 fudge = 1; /* handle case of mapping to range (0,PAGE_SIZE) */
802 tmp = arch_get_unmapped_area(file, pstart - fudge, pend - pstart, 0, flags);
805 start = pstart + offset_in_page(off); /* make start congruent with off */
807 pend = PAGE_ALIGN(end);
811 poff = off + (pstart - start); /* note: (pstart - start) may be negative */
812 is_congruent = (flags & MAP_ANONYMOUS) || (offset_in_page(poff) == 0);
814 if ((flags & MAP_SHARED) && !is_congruent)
815 printk(KERN_INFO "%s(%d): emulate_mmap() can't share contents of incongruent mmap "
816 "(addr=0x%lx,off=0x%llx)\n", current->comm, current->pid, start, off);
818 DBG("mmap_body: mapping [0x%lx-0x%lx) %s with poff 0x%llx\n", pstart, pend,
819 is_congruent ? "congruent" : "not congruent", poff);
821 down_write(¤t->mm->mmap_sem);
823 if (!(flags & MAP_ANONYMOUS) && is_congruent)
824 ret = do_mmap(file, pstart, pend - pstart, prot, flags | MAP_FIXED, poff);
826 ret = do_mmap(NULL, pstart, pend - pstart,
827 prot | ((flags & MAP_ANONYMOUS) ? 0 : PROT_WRITE),
828 flags | MAP_FIXED | MAP_ANONYMOUS, 0);
830 up_write(¤t->mm->mmap_sem);
832 if (IS_ERR((void *) ret))
836 /* read the file contents */
837 inode = file->f_dentry->d_inode;
838 if (!inode->i_fop || !file->f_op->read
839 || ((*file->f_op->read)(file, (char __user *) pstart, pend - pstart, &poff)
842 sys_munmap(pstart, pend - pstart);
845 if (!(prot & PROT_WRITE) && sys_mprotect(pstart, pend - pstart, prot) < 0)
849 if (!(flags & MAP_FIXED))
850 ia32_set_pp((unsigned int)start, (unsigned int)end, flags);
855 #endif /* PAGE_SHIFT > IA32_PAGE_SHIFT */
857 static inline unsigned int
858 get_prot32 (unsigned int prot)
860 if (prot & PROT_WRITE)
861 /* on x86, PROT_WRITE implies PROT_READ which implies PROT_EEC */
862 prot |= PROT_READ | PROT_WRITE | PROT_EXEC;
863 else if (prot & (PROT_READ | PROT_EXEC))
864 /* on x86, there is no distinction between PROT_READ and PROT_EXEC */
865 prot |= (PROT_READ | PROT_EXEC);
871 ia32_do_mmap (struct file *file, unsigned long addr, unsigned long len, int prot, int flags,
874 DBG("ia32_do_mmap(file=%p,addr=0x%lx,len=0x%lx,prot=%x,flags=%x,offset=0x%llx)\n",
875 file, addr, len, prot, flags, offset);
877 if (file && (!file->f_op || !file->f_op->mmap))
880 len = IA32_PAGE_ALIGN(len);
884 if (len > IA32_PAGE_OFFSET || addr > IA32_PAGE_OFFSET - len)
886 if (flags & MAP_FIXED)
892 if (OFFSET4K(offset))
895 prot = get_prot32(prot);
897 #if PAGE_SHIFT > IA32_PAGE_SHIFT
898 mutex_lock(&ia32_mmap_mutex);
900 addr = emulate_mmap(file, addr, len, prot, flags, offset);
902 mutex_unlock(&ia32_mmap_mutex);
904 down_write(¤t->mm->mmap_sem);
906 addr = do_mmap(file, addr, len, prot, flags, offset);
908 up_write(¤t->mm->mmap_sem);
910 DBG("ia32_do_mmap: returning 0x%lx\n", addr);
915 * Linux/i386 didn't use to be able to handle more than 4 system call parameters, so these
916 * system calls used a memory block for parameter passing..
919 struct mmap_arg_struct {
929 sys32_mmap (struct mmap_arg_struct __user *arg)
931 struct mmap_arg_struct a;
932 struct file *file = NULL;
936 if (copy_from_user(&a, arg, sizeof(a)))
939 if (OFFSET4K(a.offset))
944 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
945 if (!(flags & MAP_ANONYMOUS)) {
951 addr = ia32_do_mmap(file, a.addr, a.len, a.prot, flags, a.offset);
959 sys32_mmap2 (unsigned int addr, unsigned int len, unsigned int prot, unsigned int flags,
960 unsigned int fd, unsigned int pgoff)
962 struct file *file = NULL;
963 unsigned long retval;
965 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
966 if (!(flags & MAP_ANONYMOUS)) {
972 retval = ia32_do_mmap(file, addr, len, prot, flags,
973 (unsigned long) pgoff << IA32_PAGE_SHIFT);
981 sys32_munmap (unsigned int start, unsigned int len)
983 unsigned int end = start + len;
986 #if PAGE_SHIFT <= IA32_PAGE_SHIFT
987 ret = sys_munmap(start, end - start);
992 end = IA32_PAGE_ALIGN(end);
996 ret = ia32_unset_pp(&start, &end);
1003 mutex_lock(&ia32_mmap_mutex);
1004 ret = sys_munmap(start, end - start);
1005 mutex_unlock(&ia32_mmap_mutex);
1010 #if PAGE_SHIFT > IA32_PAGE_SHIFT
1013 * When mprotect()ing a partial page, we set the permission to the union of the old
1014 * settings and the new settings. In other words, it's only possible to make access to a
1015 * partial page less restrictive.
1018 mprotect_subpage (unsigned long address, int new_prot)
1021 struct vm_area_struct *vma;
1023 if (new_prot == PROT_NONE)
1024 return 0; /* optimize case where nothing changes... */
1025 vma = find_vma(current->mm, address);
1026 old_prot = get_page_prot(vma, address);
1027 return sys_mprotect(address, PAGE_SIZE, new_prot | old_prot);
1030 #endif /* PAGE_SHIFT > IA32_PAGE_SHIFT */
1033 sys32_mprotect (unsigned int start, unsigned int len, int prot)
1035 unsigned int end = start + len;
1036 #if PAGE_SHIFT > IA32_PAGE_SHIFT
1040 prot = get_prot32(prot);
1042 #if PAGE_SHIFT <= IA32_PAGE_SHIFT
1043 return sys_mprotect(start, end - start, prot);
1045 if (OFFSET4K(start))
1048 end = IA32_PAGE_ALIGN(end);
1052 retval = ia32_compare_pp(&start, &end);
1057 mutex_lock(&ia32_mmap_mutex);
1059 if (offset_in_page(start)) {
1060 /* start address is 4KB aligned but not page aligned. */
1061 retval = mprotect_subpage(PAGE_START(start), prot);
1065 start = PAGE_ALIGN(start);
1067 goto out; /* retval is already zero... */
1070 if (offset_in_page(end)) {
1071 /* end address is 4KB aligned but not page aligned. */
1072 retval = mprotect_subpage(PAGE_START(end), prot);
1076 end = PAGE_START(end);
1078 retval = sys_mprotect(start, end - start, prot);
1081 mutex_unlock(&ia32_mmap_mutex);
1087 sys32_mremap (unsigned int addr, unsigned int old_len, unsigned int new_len,
1088 unsigned int flags, unsigned int new_addr)
1092 #if PAGE_SHIFT <= IA32_PAGE_SHIFT
1093 ret = sys_mremap(addr, old_len, new_len, flags, new_addr);
1095 unsigned int old_end, new_end;
1100 old_len = IA32_PAGE_ALIGN(old_len);
1101 new_len = IA32_PAGE_ALIGN(new_len);
1102 old_end = addr + old_len;
1103 new_end = addr + new_len;
1108 if ((flags & MREMAP_FIXED) && (OFFSET4K(new_addr)))
1111 if (old_len >= new_len) {
1112 ret = sys32_munmap(addr + new_len, old_len - new_len);
1113 if (ret && old_len != new_len)
1116 if (!(flags & MREMAP_FIXED) || (new_addr == addr))
1121 addr = PAGE_START(addr);
1122 old_len = PAGE_ALIGN(old_end) - addr;
1123 new_len = PAGE_ALIGN(new_end) - addr;
1125 mutex_lock(&ia32_mmap_mutex);
1126 ret = sys_mremap(addr, old_len, new_len, flags, new_addr);
1127 mutex_unlock(&ia32_mmap_mutex);
1129 if ((ret >= 0) && (old_len < new_len)) {
1130 /* mremap expanded successfully */
1131 ia32_set_pp(old_end, new_end, flags);
1138 sys32_pipe (int __user *fd)
1143 retval = do_pipe(fds);
1146 if (copy_to_user(fd, fds, sizeof(fds)))
1153 get_tv32 (struct timeval *o, struct compat_timeval __user *i)
1155 return (!access_ok(VERIFY_READ, i, sizeof(*i)) ||
1156 (__get_user(o->tv_sec, &i->tv_sec) | __get_user(o->tv_usec, &i->tv_usec)));
1160 put_tv32 (struct compat_timeval __user *o, struct timeval *i)
1162 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
1163 (__put_user(i->tv_sec, &o->tv_sec) | __put_user(i->tv_usec, &o->tv_usec)));
1166 asmlinkage unsigned long
1167 sys32_alarm (unsigned int seconds)
1169 struct itimerval it_new, it_old;
1170 unsigned int oldalarm;
1172 it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
1173 it_new.it_value.tv_sec = seconds;
1174 it_new.it_value.tv_usec = 0;
1175 do_setitimer(ITIMER_REAL, &it_new, &it_old);
1176 oldalarm = it_old.it_value.tv_sec;
1177 /* ehhh.. We can't return 0 if we have an alarm pending.. */
1178 /* And we'd better return too much than too little anyway */
1179 if (it_old.it_value.tv_usec)
1184 /* Translations due to time_t size differences. Which affects all
1185 sorts of things, like timeval and itimerval. */
1187 extern struct timezone sys_tz;
1190 sys32_gettimeofday (struct compat_timeval __user *tv, struct timezone __user *tz)
1194 do_gettimeofday(&ktv);
1195 if (put_tv32(tv, &ktv))
1199 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
1206 sys32_settimeofday (struct compat_timeval __user *tv, struct timezone __user *tz)
1209 struct timespec kts;
1210 struct timezone ktz;
1213 if (get_tv32(&ktv, tv))
1215 kts.tv_sec = ktv.tv_sec;
1216 kts.tv_nsec = ktv.tv_usec * 1000;
1219 if (copy_from_user(&ktz, tz, sizeof(ktz)))
1223 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
1226 struct getdents32_callback {
1227 struct compat_dirent __user *current_dir;
1228 struct compat_dirent __user *previous;
1233 struct readdir32_callback {
1234 struct old_linux32_dirent __user * dirent;
1239 filldir32 (void *__buf, const char *name, int namlen, loff_t offset, ino_t ino,
1240 unsigned int d_type)
1242 struct compat_dirent __user * dirent;
1243 struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
1244 int reclen = ROUND_UP(offsetof(struct compat_dirent, d_name) + namlen + 1, 4);
1246 buf->error = -EINVAL; /* only used if we fail.. */
1247 if (reclen > buf->count)
1249 buf->error = -EFAULT; /* only used if we fail.. */
1250 dirent = buf->previous;
1252 if (put_user(offset, &dirent->d_off))
1254 dirent = buf->current_dir;
1255 buf->previous = dirent;
1256 if (put_user(ino, &dirent->d_ino)
1257 || put_user(reclen, &dirent->d_reclen)
1258 || copy_to_user(dirent->d_name, name, namlen)
1259 || put_user(0, dirent->d_name + namlen))
1261 dirent = (struct compat_dirent __user *) ((char __user *) dirent + reclen);
1262 buf->current_dir = dirent;
1263 buf->count -= reclen;
1268 sys32_getdents (unsigned int fd, struct compat_dirent __user *dirent, unsigned int count)
1271 struct compat_dirent __user * lastdirent;
1272 struct getdents32_callback buf;
1280 buf.current_dir = dirent;
1281 buf.previous = NULL;
1285 error = vfs_readdir(file, filldir32, &buf);
1289 lastdirent = buf.previous;
1292 if (put_user(file->f_pos, &lastdirent->d_off))
1294 error = count - buf.count;
1304 fillonedir32 (void * __buf, const char * name, int namlen, loff_t offset, ino_t ino,
1305 unsigned int d_type)
1307 struct readdir32_callback * buf = (struct readdir32_callback *) __buf;
1308 struct old_linux32_dirent __user * dirent;
1313 dirent = buf->dirent;
1314 if (put_user(ino, &dirent->d_ino)
1315 || put_user(offset, &dirent->d_offset)
1316 || put_user(namlen, &dirent->d_namlen)
1317 || copy_to_user(dirent->d_name, name, namlen)
1318 || put_user(0, dirent->d_name + namlen))
1324 sys32_readdir (unsigned int fd, void __user *dirent, unsigned int count)
1328 struct readdir32_callback buf;
1336 buf.dirent = dirent;
1338 error = vfs_readdir(file, fillonedir32, &buf);
1346 struct sel_arg_struct {
1355 sys32_old_select (struct sel_arg_struct __user *arg)
1357 struct sel_arg_struct a;
1359 if (copy_from_user(&a, arg, sizeof(a)))
1361 return compat_sys_select(a.n, compat_ptr(a.inp), compat_ptr(a.outp),
1362 compat_ptr(a.exp), compat_ptr(a.tvp));
1368 #define SEMTIMEDOP 4
1379 sys32_ipc(u32 call, int first, int second, int third, u32 ptr, u32 fifth)
1383 version = call >> 16; /* hack for backward compatibility */
1389 return compat_sys_semtimedop(first, compat_ptr(ptr),
1390 second, compat_ptr(fifth));
1391 /* else fall through for normal semop() */
1393 /* struct sembuf is the same on 32 and 64bit :)) */
1394 return sys_semtimedop(first, compat_ptr(ptr), second,
1397 return sys_semget(first, second, third);
1399 return compat_sys_semctl(first, second, third, compat_ptr(ptr));
1402 return compat_sys_msgsnd(first, second, third, compat_ptr(ptr));
1404 return compat_sys_msgrcv(first, second, fifth, third, version, compat_ptr(ptr));
1406 return sys_msgget((key_t) first, second);
1408 return compat_sys_msgctl(first, second, compat_ptr(ptr));
1411 return compat_sys_shmat(first, second, third, version, compat_ptr(ptr));
1414 return sys_shmdt(compat_ptr(ptr));
1416 return sys_shmget(first, (unsigned)second, third);
1418 return compat_sys_shmctl(first, second, compat_ptr(ptr));
1427 compat_sys_wait4 (compat_pid_t pid, compat_uint_t * stat_addr, int options,
1428 struct compat_rusage *ru);
1431 sys32_waitpid (int pid, unsigned int *stat_addr, int options)
1433 return compat_sys_wait4(pid, stat_addr, options, NULL);
1437 ia32_peek (struct task_struct *child, unsigned long addr, unsigned int *val)
1442 copied = access_process_vm(child, addr, val, sizeof(*val), 0);
1443 return (copied != sizeof(ret)) ? -EIO : 0;
1447 ia32_poke (struct task_struct *child, unsigned long addr, unsigned int val)
1450 if (access_process_vm(child, addr, &val, sizeof(val), 1) != sizeof(val))
1456 * The order in which registers are stored in the ptrace regs structure
1469 #define PT_ORIG_EAX 11
1477 getreg (struct task_struct *child, int regno)
1479 struct pt_regs *child_regs;
1481 child_regs = task_pt_regs(child);
1482 switch (regno / sizeof(int)) {
1483 case PT_EBX: return child_regs->r11;
1484 case PT_ECX: return child_regs->r9;
1485 case PT_EDX: return child_regs->r10;
1486 case PT_ESI: return child_regs->r14;
1487 case PT_EDI: return child_regs->r15;
1488 case PT_EBP: return child_regs->r13;
1489 case PT_EAX: return child_regs->r8;
1490 case PT_ORIG_EAX: return child_regs->r1; /* see dispatch_to_ia32_handler() */
1491 case PT_EIP: return child_regs->cr_iip;
1492 case PT_UESP: return child_regs->r12;
1493 case PT_EFL: return child->thread.eflag;
1494 case PT_DS: case PT_ES: case PT_FS: case PT_GS: case PT_SS:
1496 case PT_CS: return __USER_CS;
1498 printk(KERN_ERR "ia32.getreg(): unknown register %d\n", regno);
1505 putreg (struct task_struct *child, int regno, unsigned int value)
1507 struct pt_regs *child_regs;
1509 child_regs = task_pt_regs(child);
1510 switch (regno / sizeof(int)) {
1511 case PT_EBX: child_regs->r11 = value; break;
1512 case PT_ECX: child_regs->r9 = value; break;
1513 case PT_EDX: child_regs->r10 = value; break;
1514 case PT_ESI: child_regs->r14 = value; break;
1515 case PT_EDI: child_regs->r15 = value; break;
1516 case PT_EBP: child_regs->r13 = value; break;
1517 case PT_EAX: child_regs->r8 = value; break;
1518 case PT_ORIG_EAX: child_regs->r1 = value; break;
1519 case PT_EIP: child_regs->cr_iip = value; break;
1520 case PT_UESP: child_regs->r12 = value; break;
1521 case PT_EFL: child->thread.eflag = value; break;
1522 case PT_DS: case PT_ES: case PT_FS: case PT_GS: case PT_SS:
1523 if (value != __USER_DS)
1525 "ia32.putreg: attempt to set invalid segment register %d = %x\n",
1529 if (value != __USER_CS)
1531 "ia32.putreg: attempt to to set invalid segment register %d = %x\n",
1535 printk(KERN_ERR "ia32.putreg: unknown register %d\n", regno);
1541 put_fpreg (int regno, struct _fpreg_ia32 __user *reg, struct pt_regs *ptp,
1542 struct switch_stack *swp, int tos)
1544 struct _fpreg_ia32 *f;
1547 f = (struct _fpreg_ia32 *)(((unsigned long)buf + 15) & ~15);
1548 if ((regno += tos) >= 8)
1552 ia64f2ia32f(f, &ptp->f8);
1555 ia64f2ia32f(f, &ptp->f9);
1558 ia64f2ia32f(f, &ptp->f10);
1561 ia64f2ia32f(f, &ptp->f11);
1567 ia64f2ia32f(f, &swp->f12 + (regno - 4));
1570 copy_to_user(reg, f, sizeof(*reg));
1574 get_fpreg (int regno, struct _fpreg_ia32 __user *reg, struct pt_regs *ptp,
1575 struct switch_stack *swp, int tos)
1578 if ((regno += tos) >= 8)
1582 copy_from_user(&ptp->f8, reg, sizeof(*reg));
1585 copy_from_user(&ptp->f9, reg, sizeof(*reg));
1588 copy_from_user(&ptp->f10, reg, sizeof(*reg));
1591 copy_from_user(&ptp->f11, reg, sizeof(*reg));
1597 copy_from_user(&swp->f12 + (regno - 4), reg, sizeof(*reg));
1604 save_ia32_fpstate (struct task_struct *tsk, struct ia32_user_i387_struct __user *save)
1606 struct switch_stack *swp;
1607 struct pt_regs *ptp;
1610 if (!access_ok(VERIFY_WRITE, save, sizeof(*save)))
1613 __put_user(tsk->thread.fcr & 0xffff, &save->cwd);
1614 __put_user(tsk->thread.fsr & 0xffff, &save->swd);
1615 __put_user((tsk->thread.fsr>>16) & 0xffff, &save->twd);
1616 __put_user(tsk->thread.fir, &save->fip);
1617 __put_user((tsk->thread.fir>>32) & 0xffff, &save->fcs);
1618 __put_user(tsk->thread.fdr, &save->foo);
1619 __put_user((tsk->thread.fdr>>32) & 0xffff, &save->fos);
1622 * Stack frames start with 16-bytes of temp space
1624 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1625 ptp = task_pt_regs(tsk);
1626 tos = (tsk->thread.fsr >> 11) & 7;
1627 for (i = 0; i < 8; i++)
1628 put_fpreg(i, &save->st_space[i], ptp, swp, tos);
1633 restore_ia32_fpstate (struct task_struct *tsk, struct ia32_user_i387_struct __user *save)
1635 struct switch_stack *swp;
1636 struct pt_regs *ptp;
1638 unsigned int fsrlo, fsrhi, num32;
1640 if (!access_ok(VERIFY_READ, save, sizeof(*save)))
1643 __get_user(num32, (unsigned int __user *)&save->cwd);
1644 tsk->thread.fcr = (tsk->thread.fcr & (~0x1f3f)) | (num32 & 0x1f3f);
1645 __get_user(fsrlo, (unsigned int __user *)&save->swd);
1646 __get_user(fsrhi, (unsigned int __user *)&save->twd);
1647 num32 = (fsrhi << 16) | fsrlo;
1648 tsk->thread.fsr = (tsk->thread.fsr & (~0xffffffff)) | num32;
1649 __get_user(num32, (unsigned int __user *)&save->fip);
1650 tsk->thread.fir = (tsk->thread.fir & (~0xffffffff)) | num32;
1651 __get_user(num32, (unsigned int __user *)&save->foo);
1652 tsk->thread.fdr = (tsk->thread.fdr & (~0xffffffff)) | num32;
1655 * Stack frames start with 16-bytes of temp space
1657 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1658 ptp = task_pt_regs(tsk);
1659 tos = (tsk->thread.fsr >> 11) & 7;
1660 for (i = 0; i < 8; i++)
1661 get_fpreg(i, &save->st_space[i], ptp, swp, tos);
1666 save_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct __user *save)
1668 struct switch_stack *swp;
1669 struct pt_regs *ptp;
1671 unsigned long mxcsr=0;
1672 unsigned long num128[2];
1674 if (!access_ok(VERIFY_WRITE, save, sizeof(*save)))
1677 __put_user(tsk->thread.fcr & 0xffff, &save->cwd);
1678 __put_user(tsk->thread.fsr & 0xffff, &save->swd);
1679 __put_user((tsk->thread.fsr>>16) & 0xffff, &save->twd);
1680 __put_user(tsk->thread.fir, &save->fip);
1681 __put_user((tsk->thread.fir>>32) & 0xffff, &save->fcs);
1682 __put_user(tsk->thread.fdr, &save->foo);
1683 __put_user((tsk->thread.fdr>>32) & 0xffff, &save->fos);
1686 * Stack frames start with 16-bytes of temp space
1688 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1689 ptp = task_pt_regs(tsk);
1690 tos = (tsk->thread.fsr >> 11) & 7;
1691 for (i = 0; i < 8; i++)
1692 put_fpreg(i, (struct _fpreg_ia32 __user *)&save->st_space[4*i], ptp, swp, tos);
1694 mxcsr = ((tsk->thread.fcr>>32) & 0xff80) | ((tsk->thread.fsr>>32) & 0x3f);
1695 __put_user(mxcsr & 0xffff, &save->mxcsr);
1696 for (i = 0; i < 8; i++) {
1697 memcpy(&(num128[0]), &(swp->f16) + i*2, sizeof(unsigned long));
1698 memcpy(&(num128[1]), &(swp->f17) + i*2, sizeof(unsigned long));
1699 copy_to_user(&save->xmm_space[0] + 4*i, num128, sizeof(struct _xmmreg_ia32));
1705 restore_ia32_fpxstate (struct task_struct *tsk, struct ia32_user_fxsr_struct __user *save)
1707 struct switch_stack *swp;
1708 struct pt_regs *ptp;
1710 unsigned int fsrlo, fsrhi, num32;
1712 unsigned long num64;
1713 unsigned long num128[2];
1715 if (!access_ok(VERIFY_READ, save, sizeof(*save)))
1718 __get_user(num32, (unsigned int __user *)&save->cwd);
1719 tsk->thread.fcr = (tsk->thread.fcr & (~0x1f3f)) | (num32 & 0x1f3f);
1720 __get_user(fsrlo, (unsigned int __user *)&save->swd);
1721 __get_user(fsrhi, (unsigned int __user *)&save->twd);
1722 num32 = (fsrhi << 16) | fsrlo;
1723 tsk->thread.fsr = (tsk->thread.fsr & (~0xffffffff)) | num32;
1724 __get_user(num32, (unsigned int __user *)&save->fip);
1725 tsk->thread.fir = (tsk->thread.fir & (~0xffffffff)) | num32;
1726 __get_user(num32, (unsigned int __user *)&save->foo);
1727 tsk->thread.fdr = (tsk->thread.fdr & (~0xffffffff)) | num32;
1730 * Stack frames start with 16-bytes of temp space
1732 swp = (struct switch_stack *)(tsk->thread.ksp + 16);
1733 ptp = task_pt_regs(tsk);
1734 tos = (tsk->thread.fsr >> 11) & 7;
1735 for (i = 0; i < 8; i++)
1736 get_fpreg(i, (struct _fpreg_ia32 __user *)&save->st_space[4*i], ptp, swp, tos);
1738 __get_user(mxcsr, (unsigned int __user *)&save->mxcsr);
1739 num64 = mxcsr & 0xff10;
1740 tsk->thread.fcr = (tsk->thread.fcr & (~0xff1000000000UL)) | (num64<<32);
1741 num64 = mxcsr & 0x3f;
1742 tsk->thread.fsr = (tsk->thread.fsr & (~0x3f00000000UL)) | (num64<<32);
1744 for (i = 0; i < 8; i++) {
1745 copy_from_user(num128, &save->xmm_space[0] + 4*i, sizeof(struct _xmmreg_ia32));
1746 memcpy(&(swp->f16) + i*2, &(num128[0]), sizeof(unsigned long));
1747 memcpy(&(swp->f17) + i*2, &(num128[1]), sizeof(unsigned long));
1753 sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data)
1755 struct task_struct *child;
1756 unsigned int value, tmp;
1760 if (request == PTRACE_TRACEME) {
1761 ret = ptrace_traceme();
1765 child = ptrace_get_task_struct(pid);
1766 if (IS_ERR(child)) {
1767 ret = PTR_ERR(child);
1771 if (request == PTRACE_ATTACH) {
1772 ret = sys_ptrace(request, pid, addr, data);
1776 ret = ptrace_check_attach(child, request == PTRACE_KILL);
1781 case PTRACE_PEEKTEXT:
1782 case PTRACE_PEEKDATA: /* read word at location addr */
1783 ret = ia32_peek(child, addr, &value);
1785 ret = put_user(value, (unsigned int __user *) compat_ptr(data));
1790 case PTRACE_POKETEXT:
1791 case PTRACE_POKEDATA: /* write the word at location addr */
1792 ret = ia32_poke(child, addr, data);
1795 case PTRACE_PEEKUSR: /* read word at addr in USER area */
1797 if ((addr & 3) || addr > 17*sizeof(int))
1800 tmp = getreg(child, addr);
1801 if (!put_user(tmp, (unsigned int __user *) compat_ptr(data)))
1805 case PTRACE_POKEUSR: /* write word at addr in USER area */
1807 if ((addr & 3) || addr > 17*sizeof(int))
1810 putreg(child, addr, data);
1814 case IA32_PTRACE_GETREGS:
1815 if (!access_ok(VERIFY_WRITE, compat_ptr(data), 17*sizeof(int))) {
1819 for (i = 0; i < (int) (17*sizeof(int)); i += sizeof(int) ) {
1820 put_user(getreg(child, i), (unsigned int __user *) compat_ptr(data));
1821 data += sizeof(int);
1826 case IA32_PTRACE_SETREGS:
1827 if (!access_ok(VERIFY_READ, compat_ptr(data), 17*sizeof(int))) {
1831 for (i = 0; i < (int) (17*sizeof(int)); i += sizeof(int) ) {
1832 get_user(tmp, (unsigned int __user *) compat_ptr(data));
1833 putreg(child, i, tmp);
1834 data += sizeof(int);
1839 case IA32_PTRACE_GETFPREGS:
1840 ret = save_ia32_fpstate(child, (struct ia32_user_i387_struct __user *)
1844 case IA32_PTRACE_GETFPXREGS:
1845 ret = save_ia32_fpxstate(child, (struct ia32_user_fxsr_struct __user *)
1849 case IA32_PTRACE_SETFPREGS:
1850 ret = restore_ia32_fpstate(child, (struct ia32_user_i387_struct __user *)
1854 case IA32_PTRACE_SETFPXREGS:
1855 ret = restore_ia32_fpxstate(child, (struct ia32_user_fxsr_struct __user *)
1859 case PTRACE_GETEVENTMSG:
1860 ret = put_user(child->ptrace_message, (unsigned int __user *) compat_ptr(data));
1863 case PTRACE_SYSCALL: /* continue, stop after next syscall */
1864 case PTRACE_CONT: /* restart after signal. */
1866 case PTRACE_SINGLESTEP: /* execute chile for one instruction */
1867 case PTRACE_DETACH: /* detach a process */
1868 ret = sys_ptrace(request, pid, addr, data);
1872 ret = ptrace_request(child, request, addr, data);
1877 put_task_struct(child);
1885 unsigned int ss_flags;
1886 unsigned int ss_size;
1890 sys32_sigaltstack (ia32_stack_t __user *uss32, ia32_stack_t __user *uoss32,
1891 long arg2, long arg3, long arg4, long arg5, long arg6,
1892 long arg7, struct pt_regs pt)
1897 mm_segment_t old_fs = get_fs();
1900 if (copy_from_user(&buf32, uss32, sizeof(ia32_stack_t)))
1902 uss.ss_sp = (void __user *) (long) buf32.ss_sp;
1903 uss.ss_flags = buf32.ss_flags;
1904 /* MINSIGSTKSZ is different for ia32 vs ia64. We lie here to pass the
1905 check and set it to the user requested value later */
1906 if ((buf32.ss_flags != SS_DISABLE) && (buf32.ss_size < MINSIGSTKSZ_IA32)) {
1910 uss.ss_size = MINSIGSTKSZ;
1913 ret = do_sigaltstack(uss32 ? (stack_t __user *) &uss : NULL,
1914 (stack_t __user *) &uoss, pt.r12);
1915 current->sas_ss_size = buf32.ss_size;
1921 buf32.ss_sp = (long __user) uoss.ss_sp;
1922 buf32.ss_flags = uoss.ss_flags;
1923 buf32.ss_size = uoss.ss_size;
1924 if (copy_to_user(uoss32, &buf32, sizeof(ia32_stack_t)))
1933 current->state = TASK_INTERRUPTIBLE;
1935 return -ERESTARTNOHAND;
1939 sys32_msync (unsigned int start, unsigned int len, int flags)
1943 if (OFFSET4K(start))
1945 addr = PAGE_START(start);
1946 return sys_msync(addr, len + (start - addr), flags);
1952 unsigned int oldval;
1953 unsigned int oldlenp;
1954 unsigned int newval;
1955 unsigned int newlen;
1956 unsigned int __unused[4];
1959 #ifdef CONFIG_SYSCTL
1961 sys32_sysctl (struct sysctl32 __user *args)
1963 struct sysctl32 a32;
1964 mm_segment_t old_fs = get_fs ();
1965 void __user *oldvalp, *newvalp;
1970 if (copy_from_user(&a32, args, sizeof(a32)))
1974 * We need to pre-validate these because we have to disable address checking
1975 * before calling do_sysctl() because of OLDLEN but we can't run the risk of the
1976 * user specifying bad addresses here. Well, since we're dealing with 32 bit
1977 * addresses, we KNOW that access_ok() will always succeed, so this is an
1978 * expensive NOP, but so what...
1980 namep = (int __user *) compat_ptr(a32.name);
1981 oldvalp = compat_ptr(a32.oldval);
1982 newvalp = compat_ptr(a32.newval);
1984 if ((oldvalp && get_user(oldlen, (int __user *) compat_ptr(a32.oldlenp)))
1985 || !access_ok(VERIFY_WRITE, namep, 0)
1986 || !access_ok(VERIFY_WRITE, oldvalp, 0)
1987 || !access_ok(VERIFY_WRITE, newvalp, 0))
1992 ret = do_sysctl(namep, a32.nlen, oldvalp, (size_t __user *) &oldlen,
1993 newvalp, (size_t) a32.newlen);
1997 if (oldvalp && put_user (oldlen, (int __user *) compat_ptr(a32.oldlenp)))
2005 sys32_newuname (struct new_utsname __user *name)
2007 int ret = sys_newuname(name);
2010 if (copy_to_user(name->machine, "i686\0\0\0", 8))
2016 sys32_getresuid16 (u16 __user *ruid, u16 __user *euid, u16 __user *suid)
2020 mm_segment_t old_fs = get_fs();
2023 ret = sys_getresuid((uid_t __user *) &a, (uid_t __user *) &b, (uid_t __user *) &c);
2026 if (put_user(a, ruid) || put_user(b, euid) || put_user(c, suid))
2032 sys32_getresgid16 (u16 __user *rgid, u16 __user *egid, u16 __user *sgid)
2036 mm_segment_t old_fs = get_fs();
2039 ret = sys_getresgid((gid_t __user *) &a, (gid_t __user *) &b, (gid_t __user *) &c);
2045 return put_user(a, rgid) | put_user(b, egid) | put_user(c, sgid);
2049 sys32_lseek (unsigned int fd, int offset, unsigned int whence)
2051 /* Sign-extension of "offset" is important here... */
2052 return sys_lseek(fd, offset, whence);
2056 groups16_to_user(short __user *grouplist, struct group_info *group_info)
2061 for (i = 0; i < group_info->ngroups; i++) {
2062 group = (short)GROUP_AT(group_info, i);
2063 if (put_user(group, grouplist+i))
2071 groups16_from_user(struct group_info *group_info, short __user *grouplist)
2076 for (i = 0; i < group_info->ngroups; i++) {
2077 if (get_user(group, grouplist+i))
2079 GROUP_AT(group_info, i) = (gid_t)group;
2086 sys32_getgroups16 (int gidsetsize, short __user *grouplist)
2093 get_group_info(current->group_info);
2094 i = current->group_info->ngroups;
2096 if (i > gidsetsize) {
2100 if (groups16_to_user(grouplist, current->group_info)) {
2106 put_group_info(current->group_info);
2111 sys32_setgroups16 (int gidsetsize, short __user *grouplist)
2113 struct group_info *group_info;
2116 if (!capable(CAP_SETGID))
2118 if ((unsigned)gidsetsize > NGROUPS_MAX)
2121 group_info = groups_alloc(gidsetsize);
2124 retval = groups16_from_user(group_info, grouplist);
2126 put_group_info(group_info);
2130 retval = set_current_groups(group_info);
2131 put_group_info(group_info);
2137 sys32_truncate64 (unsigned int path, unsigned int len_lo, unsigned int len_hi)
2139 return sys_truncate(compat_ptr(path), ((unsigned long) len_hi << 32) | len_lo);
2143 sys32_ftruncate64 (int fd, unsigned int len_lo, unsigned int len_hi)
2145 return sys_ftruncate(fd, ((unsigned long) len_hi << 32) | len_lo);
2149 putstat64 (struct stat64 __user *ubuf, struct kstat *kbuf)
2154 if (clear_user(ubuf, sizeof(*ubuf)))
2157 hdev = huge_encode_dev(kbuf->dev);
2158 err = __put_user(hdev, (u32 __user*)&ubuf->st_dev);
2159 err |= __put_user(hdev >> 32, ((u32 __user*)&ubuf->st_dev) + 1);
2160 err |= __put_user(kbuf->ino, &ubuf->__st_ino);
2161 err |= __put_user(kbuf->ino, &ubuf->st_ino_lo);
2162 err |= __put_user(kbuf->ino >> 32, &ubuf->st_ino_hi);
2163 err |= __put_user(kbuf->mode, &ubuf->st_mode);
2164 err |= __put_user(kbuf->nlink, &ubuf->st_nlink);
2165 err |= __put_user(kbuf->uid, &ubuf->st_uid);
2166 err |= __put_user(kbuf->gid, &ubuf->st_gid);
2167 hdev = huge_encode_dev(kbuf->rdev);
2168 err = __put_user(hdev, (u32 __user*)&ubuf->st_rdev);
2169 err |= __put_user(hdev >> 32, ((u32 __user*)&ubuf->st_rdev) + 1);
2170 err |= __put_user(kbuf->size, &ubuf->st_size_lo);
2171 err |= __put_user((kbuf->size >> 32), &ubuf->st_size_hi);
2172 err |= __put_user(kbuf->atime.tv_sec, &ubuf->st_atime);
2173 err |= __put_user(kbuf->atime.tv_nsec, &ubuf->st_atime_nsec);
2174 err |= __put_user(kbuf->mtime.tv_sec, &ubuf->st_mtime);
2175 err |= __put_user(kbuf->mtime.tv_nsec, &ubuf->st_mtime_nsec);
2176 err |= __put_user(kbuf->ctime.tv_sec, &ubuf->st_ctime);
2177 err |= __put_user(kbuf->ctime.tv_nsec, &ubuf->st_ctime_nsec);
2178 err |= __put_user(kbuf->blksize, &ubuf->st_blksize);
2179 err |= __put_user(kbuf->blocks, &ubuf->st_blocks);
2184 sys32_stat64 (char __user *filename, struct stat64 __user *statbuf)
2187 long ret = vfs_stat(filename, &s);
2189 ret = putstat64(statbuf, &s);
2194 sys32_lstat64 (char __user *filename, struct stat64 __user *statbuf)
2197 long ret = vfs_lstat(filename, &s);
2199 ret = putstat64(statbuf, &s);
2204 sys32_fstat64 (unsigned int fd, struct stat64 __user *statbuf)
2207 long ret = vfs_fstat(fd, &s);
2209 ret = putstat64(statbuf, &s);
2231 sys32_sysinfo (struct sysinfo32 __user *info)
2236 mm_segment_t old_fs = get_fs();
2239 ret = sys_sysinfo((struct sysinfo __user *) &s);
2241 /* Check to see if any memory value is too large for 32-bit and
2242 * scale down if needed.
2244 if ((s.totalram >> 32) || (s.totalswap >> 32)) {
2245 while (s.mem_unit < PAGE_SIZE) {
2249 s.totalram >>= bitcount;
2250 s.freeram >>= bitcount;
2251 s.sharedram >>= bitcount;
2252 s.bufferram >>= bitcount;
2253 s.totalswap >>= bitcount;
2254 s.freeswap >>= bitcount;
2255 s.totalhigh >>= bitcount;
2256 s.freehigh >>= bitcount;
2259 if (!access_ok(VERIFY_WRITE, info, sizeof(*info)))
2262 err = __put_user(s.uptime, &info->uptime);
2263 err |= __put_user(s.loads[0], &info->loads[0]);
2264 err |= __put_user(s.loads[1], &info->loads[1]);
2265 err |= __put_user(s.loads[2], &info->loads[2]);
2266 err |= __put_user(s.totalram, &info->totalram);
2267 err |= __put_user(s.freeram, &info->freeram);
2268 err |= __put_user(s.sharedram, &info->sharedram);
2269 err |= __put_user(s.bufferram, &info->bufferram);
2270 err |= __put_user(s.totalswap, &info->totalswap);
2271 err |= __put_user(s.freeswap, &info->freeswap);
2272 err |= __put_user(s.procs, &info->procs);
2273 err |= __put_user (s.totalhigh, &info->totalhigh);
2274 err |= __put_user (s.freehigh, &info->freehigh);
2275 err |= __put_user (s.mem_unit, &info->mem_unit);
2282 sys32_sched_rr_get_interval (pid_t pid, struct compat_timespec __user *interval)
2284 mm_segment_t old_fs = get_fs();
2289 ret = sys_sched_rr_get_interval(pid, (struct timespec __user *) &t);
2291 if (put_compat_timespec(&t, interval))
2297 sys32_pread (unsigned int fd, void __user *buf, unsigned int count, u32 pos_lo, u32 pos_hi)
2299 return sys_pread64(fd, buf, count, ((unsigned long) pos_hi << 32) | pos_lo);
2303 sys32_pwrite (unsigned int fd, void __user *buf, unsigned int count, u32 pos_lo, u32 pos_hi)
2305 return sys_pwrite64(fd, buf, count, ((unsigned long) pos_hi << 32) | pos_lo);
2309 sys32_sendfile (int out_fd, int in_fd, int __user *offset, unsigned int count)
2311 mm_segment_t old_fs = get_fs();
2315 if (offset && get_user(of, offset))
2319 ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *) &of : NULL, count);
2322 if (offset && put_user(of, offset))
2329 sys32_personality (unsigned int personality)
2333 if (current->personality == PER_LINUX32 && personality == PER_LINUX)
2334 personality = PER_LINUX32;
2335 ret = sys_personality(personality);
2336 if (ret == PER_LINUX32)
2341 asmlinkage unsigned long
2342 sys32_brk (unsigned int brk)
2344 unsigned long ret, obrk;
2345 struct mm_struct *mm = current->mm;
2350 clear_user(compat_ptr(ret), PAGE_ALIGN(ret) - ret);
2354 /* Structure for ia32 emulation on ia64 */
2355 struct epoll_event32
2362 sys32_epoll_ctl(int epfd, int op, int fd, struct epoll_event32 __user *event)
2364 mm_segment_t old_fs = get_fs();
2365 struct epoll_event event64;
2369 if (!access_ok(VERIFY_READ, event, sizeof(struct epoll_event32)))
2372 __get_user(event64.events, &event->events);
2373 __get_user(data_halfword, &event->data[0]);
2374 event64.data = data_halfword;
2375 __get_user(data_halfword, &event->data[1]);
2376 event64.data |= (u64)data_halfword << 32;
2379 error = sys_epoll_ctl(epfd, op, fd, (struct epoll_event __user *) &event64);
2386 sys32_epoll_wait(int epfd, struct epoll_event32 __user * events, int maxevents,
2389 struct epoll_event *events64 = NULL;
2390 mm_segment_t old_fs = get_fs();
2391 int numevents, size;
2393 int do_free_pages = 0;
2395 if (maxevents <= 0) {
2399 /* Verify that the area passed by the user is writeable */
2400 if (!access_ok(VERIFY_WRITE, events, maxevents * sizeof(struct epoll_event32)))
2404 * Allocate space for the intermediate copy. If the space needed
2405 * is large enough to cause kmalloc to fail, then try again with
2408 size = maxevents * sizeof(struct epoll_event);
2409 events64 = kmalloc(size, GFP_KERNEL);
2410 if (events64 == NULL) {
2411 events64 = (struct epoll_event *)
2412 __get_free_pages(GFP_KERNEL, get_order(size));
2413 if (events64 == NULL)
2418 /* Do the system call */
2419 set_fs(KERNEL_DS); /* copy_to/from_user should work on kernel mem*/
2420 numevents = sys_epoll_wait(epfd, (struct epoll_event __user *) events64,
2421 maxevents, timeout);
2424 /* Don't modify userspace memory if we're returning an error */
2425 if (numevents > 0) {
2426 /* Translate the 64-bit structures back into the 32-bit
2428 for (evt_idx = 0; evt_idx < numevents; evt_idx++) {
2429 __put_user(events64[evt_idx].events,
2430 &events[evt_idx].events);
2431 __put_user((u32)events64[evt_idx].data,
2432 &events[evt_idx].data[0]);
2433 __put_user((u32)(events64[evt_idx].data >> 32),
2434 &events[evt_idx].data[1]);
2439 free_pages((unsigned long) events64, get_order(size));
2446 * Get a yet unused TLS descriptor index.
2451 struct thread_struct *t = ¤t->thread;
2454 for (idx = 0; idx < GDT_ENTRY_TLS_ENTRIES; idx++)
2455 if (desc_empty(t->tls_array + idx))
2456 return idx + GDT_ENTRY_TLS_MIN;
2461 * Set a given TLS descriptor:
2464 sys32_set_thread_area (struct ia32_user_desc __user *u_info)
2466 struct thread_struct *t = ¤t->thread;
2467 struct ia32_user_desc info;
2468 struct desc_struct *desc;
2471 if (copy_from_user(&info, u_info, sizeof(info)))
2473 idx = info.entry_number;
2476 * index -1 means the kernel should try to find and allocate an empty descriptor:
2479 idx = get_free_idx();
2482 if (put_user(idx, &u_info->entry_number))
2486 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
2489 desc = t->tls_array + idx - GDT_ENTRY_TLS_MIN;
2491 cpu = smp_processor_id();
2493 if (LDT_empty(&info)) {
2497 desc->a = LDT_entry_a(&info);
2498 desc->b = LDT_entry_b(&info);
2505 * Get the current Thread-Local Storage area:
2508 #define GET_BASE(desc) ( \
2509 (((desc)->a >> 16) & 0x0000ffff) | \
2510 (((desc)->b << 16) & 0x00ff0000) | \
2511 ( (desc)->b & 0xff000000) )
2513 #define GET_LIMIT(desc) ( \
2514 ((desc)->a & 0x0ffff) | \
2515 ((desc)->b & 0xf0000) )
2517 #define GET_32BIT(desc) (((desc)->b >> 22) & 1)
2518 #define GET_CONTENTS(desc) (((desc)->b >> 10) & 3)
2519 #define GET_WRITABLE(desc) (((desc)->b >> 9) & 1)
2520 #define GET_LIMIT_PAGES(desc) (((desc)->b >> 23) & 1)
2521 #define GET_PRESENT(desc) (((desc)->b >> 15) & 1)
2522 #define GET_USEABLE(desc) (((desc)->b >> 20) & 1)
2525 sys32_get_thread_area (struct ia32_user_desc __user *u_info)
2527 struct ia32_user_desc info;
2528 struct desc_struct *desc;
2531 if (get_user(idx, &u_info->entry_number))
2533 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
2536 desc = current->thread.tls_array + idx - GDT_ENTRY_TLS_MIN;
2538 info.entry_number = idx;
2539 info.base_addr = GET_BASE(desc);
2540 info.limit = GET_LIMIT(desc);
2541 info.seg_32bit = GET_32BIT(desc);
2542 info.contents = GET_CONTENTS(desc);
2543 info.read_exec_only = !GET_WRITABLE(desc);
2544 info.limit_in_pages = GET_LIMIT_PAGES(desc);
2545 info.seg_not_present = !GET_PRESENT(desc);
2546 info.useable = GET_USEABLE(desc);
2548 if (copy_to_user(u_info, &info, sizeof(info)))
2553 long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high,
2554 __u32 len_low, __u32 len_high, int advice)
2556 return sys_fadvise64_64(fd,
2557 (((u64)offset_high)<<32) | offset_low,
2558 (((u64)len_high)<<32) | len_low,
2562 #ifdef NOTYET /* UNTESTED FOR IA64 FROM HERE DOWN */
2564 asmlinkage long sys32_setreuid(compat_uid_t ruid, compat_uid_t euid)
2568 sruid = (ruid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)ruid);
2569 seuid = (euid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)euid);
2570 return sys_setreuid(sruid, seuid);
2574 sys32_setresuid(compat_uid_t ruid, compat_uid_t euid,
2577 uid_t sruid, seuid, ssuid;
2579 sruid = (ruid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)ruid);
2580 seuid = (euid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)euid);
2581 ssuid = (suid == (compat_uid_t)-1) ? ((uid_t)-1) : ((uid_t)suid);
2582 return sys_setresuid(sruid, seuid, ssuid);
2586 sys32_setregid(compat_gid_t rgid, compat_gid_t egid)
2590 srgid = (rgid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)rgid);
2591 segid = (egid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)egid);
2592 return sys_setregid(srgid, segid);
2596 sys32_setresgid(compat_gid_t rgid, compat_gid_t egid,
2599 gid_t srgid, segid, ssgid;
2601 srgid = (rgid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)rgid);
2602 segid = (egid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)egid);
2603 ssgid = (sgid == (compat_gid_t)-1) ? ((gid_t)-1) : ((gid_t)sgid);
2604 return sys_setresgid(srgid, segid, ssgid);
2607 /* Handle adjtimex compatibility. */
2611 s32 offset, freq, maxerror, esterror;
2612 s32 status, constant, precision, tolerance;
2613 struct compat_timeval time;
2615 s32 ppsfreq, jitter, shift, stabil;
2616 s32 jitcnt, calcnt, errcnt, stbcnt;
2617 s32 :32; s32 :32; s32 :32; s32 :32;
2618 s32 :32; s32 :32; s32 :32; s32 :32;
2619 s32 :32; s32 :32; s32 :32; s32 :32;
2622 extern int do_adjtimex(struct timex *);
2625 sys32_adjtimex(struct timex32 *utp)
2630 memset(&txc, 0, sizeof(struct timex));
2632 if(get_user(txc.modes, &utp->modes) ||
2633 __get_user(txc.offset, &utp->offset) ||
2634 __get_user(txc.freq, &utp->freq) ||
2635 __get_user(txc.maxerror, &utp->maxerror) ||
2636 __get_user(txc.esterror, &utp->esterror) ||
2637 __get_user(txc.status, &utp->status) ||
2638 __get_user(txc.constant, &utp->constant) ||
2639 __get_user(txc.precision, &utp->precision) ||
2640 __get_user(txc.tolerance, &utp->tolerance) ||
2641 __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
2642 __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
2643 __get_user(txc.tick, &utp->tick) ||
2644 __get_user(txc.ppsfreq, &utp->ppsfreq) ||
2645 __get_user(txc.jitter, &utp->jitter) ||
2646 __get_user(txc.shift, &utp->shift) ||
2647 __get_user(txc.stabil, &utp->stabil) ||
2648 __get_user(txc.jitcnt, &utp->jitcnt) ||
2649 __get_user(txc.calcnt, &utp->calcnt) ||
2650 __get_user(txc.errcnt, &utp->errcnt) ||
2651 __get_user(txc.stbcnt, &utp->stbcnt))
2654 ret = do_adjtimex(&txc);
2656 if(put_user(txc.modes, &utp->modes) ||
2657 __put_user(txc.offset, &utp->offset) ||
2658 __put_user(txc.freq, &utp->freq) ||
2659 __put_user(txc.maxerror, &utp->maxerror) ||
2660 __put_user(txc.esterror, &utp->esterror) ||
2661 __put_user(txc.status, &utp->status) ||
2662 __put_user(txc.constant, &utp->constant) ||
2663 __put_user(txc.precision, &utp->precision) ||
2664 __put_user(txc.tolerance, &utp->tolerance) ||
2665 __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
2666 __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
2667 __put_user(txc.tick, &utp->tick) ||
2668 __put_user(txc.ppsfreq, &utp->ppsfreq) ||
2669 __put_user(txc.jitter, &utp->jitter) ||
2670 __put_user(txc.shift, &utp->shift) ||
2671 __put_user(txc.stabil, &utp->stabil) ||
2672 __put_user(txc.jitcnt, &utp->jitcnt) ||
2673 __put_user(txc.calcnt, &utp->calcnt) ||
2674 __put_user(txc.errcnt, &utp->errcnt) ||
2675 __put_user(txc.stbcnt, &utp->stbcnt))