This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / arch / sparc64 / kernel / sys_sparc.c
1 /* $Id: sys_sparc.c,v 1.57 2002/02/09 19:49:30 davem Exp $
2  * linux/arch/sparc64/kernel/sys_sparc.c
3  *
4  * This file contains various random system calls that
5  * have a non-standard calling sequence on the Linux/sparc
6  * platform.
7  */
8
9 #include <linux/config.h>
10 #include <linux/errno.h>
11 #include <linux/types.h>
12 #include <linux/sched.h>
13 #include <linux/fs.h>
14 #include <linux/file.h>
15 #include <linux/mm.h>
16 #include <linux/sem.h>
17 #include <linux/msg.h>
18 #include <linux/shm.h>
19 #include <linux/stat.h>
20 #include <linux/mman.h>
21 #include <linux/utsname.h>
22 #include <linux/smp.h>
23 #include <linux/smp_lock.h>
24 #include <linux/slab.h>
25 #include <linux/syscalls.h>
26 #include <linux/ipc.h>
27 #include <linux/personality.h>
28
29 #include <asm/uaccess.h>
30 #include <asm/ipc.h>
31 #include <asm/utrap.h>
32 #include <asm/perfctr.h>
33
34 /* #define DEBUG_UNIMP_SYSCALL */
35
36 /* XXX Make this per-binary type, this way we can detect the type of
37  * XXX a binary.  Every Sparc executable calls this very early on.
38  */
39 asmlinkage unsigned long sys_getpagesize(void)
40 {
41         return PAGE_SIZE;
42 }
43
44 #define COLOUR_ALIGN(addr,pgoff)                \
45         ((((addr)+SHMLBA-1)&~(SHMLBA-1)) +      \
46          (((pgoff)<<PAGE_SHIFT) & (SHMLBA-1)))
47
48 unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
49 {
50         struct mm_struct *mm = current->mm;
51         struct vm_area_struct * vma;
52         unsigned long task_size = TASK_SIZE;
53         unsigned long start_addr;
54         int do_color_align;
55
56         if (flags & MAP_FIXED) {
57                 /* We do not accept a shared mapping if it would violate
58                  * cache aliasing constraints.
59                  */
60                 if ((flags & MAP_SHARED) &&
61                     ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
62                         return -EINVAL;
63                 return addr;
64         }
65
66         if (test_thread_flag(TIF_32BIT))
67                 task_size = 0xf0000000UL;
68         if (len > task_size || len > -PAGE_OFFSET)
69                 return -ENOMEM;
70
71         do_color_align = 0;
72         if (filp || (flags & MAP_SHARED))
73                 do_color_align = 1;
74
75         if (addr) {
76                 if (do_color_align)
77                         addr = COLOUR_ALIGN(addr, pgoff);
78                 else
79                         addr = PAGE_ALIGN(addr);
80
81                 vma = find_vma(mm, addr);
82                 if (task_size - len >= addr &&
83                     (!vma || addr + len <= vma->vm_start))
84                         return addr;
85         }
86
87         start_addr = addr = mm->free_area_cache;
88
89         task_size -= len;
90
91 full_search:
92         if (do_color_align)
93                 addr = COLOUR_ALIGN(addr, pgoff);
94         else
95                 addr = PAGE_ALIGN(addr);
96
97         for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
98                 /* At this point:  (!vma || addr < vma->vm_end). */
99                 if (addr < PAGE_OFFSET && -PAGE_OFFSET - len < addr) {
100                         addr = PAGE_OFFSET;
101                         vma = find_vma(mm, PAGE_OFFSET);
102                 }
103                 if (task_size < addr) {
104                         if (start_addr != TASK_UNMAPPED_BASE) {
105                                 start_addr = addr = TASK_UNMAPPED_BASE;
106                                 goto full_search;
107                         }
108                         return -ENOMEM;
109                 }
110                 if (!vma || addr + len <= vma->vm_start) {
111                         /*
112                          * Remember the place where we stopped the search:
113                          */
114                         mm->free_area_cache = addr + len;
115                         return addr;
116                 }
117                 addr = vma->vm_end;
118                 if (do_color_align)
119                         addr = COLOUR_ALIGN(addr, pgoff);
120         }
121 }
122
123 /* Try to align mapping such that we align it as much as possible. */
124 unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, unsigned long len, unsigned long pgoff, unsigned long flags)
125 {
126         unsigned long align_goal, addr = -ENOMEM;
127
128         if (flags & MAP_FIXED) {
129                 /* Ok, don't mess with it. */
130                 return get_unmapped_area(NULL, addr, len, pgoff, flags, 0);
131         }
132         flags &= ~MAP_SHARED;
133
134         align_goal = PAGE_SIZE;
135         if (len >= (4UL * 1024 * 1024))
136                 align_goal = (4UL * 1024 * 1024);
137         else if (len >= (512UL * 1024))
138                 align_goal = (512UL * 1024);
139         else if (len >= (64UL * 1024))
140                 align_goal = (64UL * 1024);
141
142         do {
143                 addr = get_unmapped_area(NULL, orig_addr, len + (align_goal - PAGE_SIZE), pgoff, flags, 0);
144                 if (!(addr & ~PAGE_MASK)) {
145                         addr = (addr + (align_goal - 1UL)) & ~(align_goal - 1UL);
146                         break;
147                 }
148
149                 if (align_goal == (4UL * 1024 * 1024))
150                         align_goal = (512UL * 1024);
151                 else if (align_goal == (512UL * 1024))
152                         align_goal = (64UL * 1024);
153                 else
154                         align_goal = PAGE_SIZE;
155         } while ((addr & ~PAGE_MASK) && align_goal > PAGE_SIZE);
156
157         /* Mapping is smaller than 64K or larger areas could not
158          * be obtained.
159          */
160         if (addr & ~PAGE_MASK)
161                 addr = get_unmapped_area(NULL, orig_addr, len, pgoff, flags, 0);
162
163         return addr;
164 }
165
166 asmlinkage unsigned long sparc_brk(unsigned long brk)
167 {
168         /* People could try to be nasty and use ta 0x6d in 32bit programs */
169         if (test_thread_flag(TIF_32BIT) &&
170             brk >= 0xf0000000UL)
171                 return current->mm->brk;
172
173         if ((current->mm->brk & PAGE_OFFSET) != (brk & PAGE_OFFSET))
174                 return current->mm->brk;
175         return sys_brk(brk);
176 }
177                                                                 
178 /*
179  * sys_pipe() is the normal C calling standard for creating
180  * a pipe. It's not the way unix traditionally does this, though.
181  */
182 asmlinkage long sparc_pipe(struct pt_regs *regs)
183 {
184         int fd[2];
185         int error;
186
187         error = do_pipe(fd);
188         if (error)
189                 goto out;
190         regs->u_regs[UREG_I1] = fd[1];
191         error = fd[0];
192 out:
193         return error;
194 }
195
196 /*
197  * sys_ipc() is the de-multiplexer for the SysV IPC calls..
198  *
199  * This is really horribly ugly.
200  */
201
202 asmlinkage long sys_ipc(unsigned int call, int first, int second, unsigned long third, void __user *ptr, long fifth)
203 {
204         int err;
205
206         /* No need for backward compatibility. We can start fresh... */
207         if (call <= SEMCTL) {
208                 switch (call) {
209                 case SEMOP:
210                         err = sys_semtimedop(first, ptr, second, NULL);
211                         goto out;
212                 case SEMTIMEDOP:
213                         err = sys_semtimedop(first, ptr, second,
214                                 (const struct timespec __user *) fifth);
215                         goto out;
216                 case SEMGET:
217                         err = sys_semget(first, second, (int)third);
218                         goto out;
219                 case SEMCTL: {
220                         union semun fourth;
221                         err = -EINVAL;
222                         if (!ptr)
223                                 goto out;
224                         err = -EFAULT;
225                         if (get_user(fourth.__pad,
226                                      (void __user * __user *) ptr))
227                                 goto out;
228                         err = sys_semctl(first, second | IPC_64,
229                                          (int)third, fourth);
230                         goto out;
231                 }
232                 default:
233                         err = -ENOSYS;
234                         goto out;
235                 };
236         }
237         if (call <= MSGCTL) {
238                 switch (call) {
239                 case MSGSND:
240                         err = sys_msgsnd(first, ptr, second, (int)third);
241                         goto out;
242                 case MSGRCV:
243                         err = sys_msgrcv(first, ptr, second, fifth,
244                                          (int)third);
245                         goto out;
246                 case MSGGET:
247                         err = sys_msgget((key_t) first, second);
248                         goto out;
249                 case MSGCTL:
250                         err = sys_msgctl(first, second | IPC_64, ptr);
251                         goto out;
252                 default:
253                         err = -ENOSYS;
254                         goto out;
255                 };
256         }
257         if (call <= SHMCTL) {
258                 switch (call) {
259                 case SHMAT: {
260                         ulong raddr;
261                         err = do_shmat(first, ptr, second, &raddr);
262                         if (!err) {
263                                 if (put_user(raddr,
264                                              (ulong __user *) third))
265                                         err = -EFAULT;
266                         }
267                         goto out;
268                 }
269                 case SHMDT:
270                         err = sys_shmdt(ptr);
271                         goto out;
272                 case SHMGET:
273                         err = sys_shmget(first, second, (int)third);
274                         goto out;
275                 case SHMCTL:
276                         err = sys_shmctl(first, second | IPC_64, ptr);
277                         goto out;
278                 default:
279                         err = -ENOSYS;
280                         goto out;
281                 };
282         } else {
283                 err = -ENOSYS;
284         }
285 out:
286         return err;
287 }
288
289 asmlinkage long sparc64_newuname(struct new_utsname __user *name)
290 {
291         int ret = sys_newuname(name);
292         
293         if (current->personality == PER_LINUX32 && !ret) {
294                 ret = (copy_to_user(name->machine, "sparc\0\0", 8)
295                        ? -EFAULT : 0);
296         }
297         return ret;
298 }
299
300 asmlinkage long sparc64_personality(unsigned long personality)
301 {
302         int ret;
303
304         if (current->personality == PER_LINUX32 &&
305             personality == PER_LINUX)
306                 personality = PER_LINUX32;
307         ret = sys_personality(personality);
308         if (ret == PER_LINUX32)
309                 ret = PER_LINUX;
310
311         return ret;
312 }
313
314 /* Linux version of mmap */
315 asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
316         unsigned long prot, unsigned long flags, unsigned long fd,
317         unsigned long off)
318 {
319         struct file * file = NULL;
320         unsigned long retval = -EBADF;
321
322         if (!(flags & MAP_ANONYMOUS)) {
323                 file = fget(fd);
324                 if (!file)
325                         goto out;
326         }
327         flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
328         len = PAGE_ALIGN(len);
329         retval = -EINVAL;
330
331         if (test_thread_flag(TIF_32BIT)) {
332                 if (len > 0xf0000000UL ||
333                     ((flags & MAP_FIXED) && addr > 0xf0000000UL - len))
334                         goto out_putf;
335         } else {
336                 if (len > -PAGE_OFFSET ||
337                     ((flags & MAP_FIXED) &&
338                      addr < PAGE_OFFSET && addr + len > -PAGE_OFFSET))
339                         goto out_putf;
340         }
341
342         down_write(&current->mm->mmap_sem);
343         retval = do_mmap(file, addr, len, prot, flags, off);
344         up_write(&current->mm->mmap_sem);
345
346 out_putf:
347         if (file)
348                 fput(file);
349 out:
350         return retval;
351 }
352
353 asmlinkage long sys64_munmap(unsigned long addr, size_t len)
354 {
355         long ret;
356
357         if (len > -PAGE_OFFSET ||
358             (addr < PAGE_OFFSET && addr + len > -PAGE_OFFSET))
359                 return -EINVAL;
360         down_write(&current->mm->mmap_sem);
361         ret = do_munmap(current->mm, addr, len);
362         up_write(&current->mm->mmap_sem);
363         return ret;
364 }
365
366 extern unsigned long do_mremap(unsigned long addr,
367         unsigned long old_len, unsigned long new_len,
368         unsigned long flags, unsigned long new_addr);
369                 
370 asmlinkage unsigned long sys64_mremap(unsigned long addr,
371         unsigned long old_len, unsigned long new_len,
372         unsigned long flags, unsigned long new_addr)
373 {
374         struct vm_area_struct *vma;
375         unsigned long ret = -EINVAL;
376         if (test_thread_flag(TIF_32BIT))
377                 goto out;
378         if (old_len > -PAGE_OFFSET || new_len > -PAGE_OFFSET)
379                 goto out;
380         if (addr < PAGE_OFFSET && addr + old_len > -PAGE_OFFSET)
381                 goto out;
382         down_write(&current->mm->mmap_sem);
383         if (flags & MREMAP_FIXED) {
384                 if (new_addr < PAGE_OFFSET &&
385                     new_addr + new_len > -PAGE_OFFSET)
386                         goto out_sem;
387         } else if (addr < PAGE_OFFSET && addr + new_len > -PAGE_OFFSET) {
388                 unsigned long map_flags = 0;
389                 struct file *file = NULL;
390
391                 ret = -ENOMEM;
392                 if (!(flags & MREMAP_MAYMOVE))
393                         goto out_sem;
394
395                 vma = find_vma(current->mm, addr);
396                 if (vma) {
397                         if (vma->vm_flags & VM_SHARED)
398                                 map_flags |= MAP_SHARED;
399                         file = vma->vm_file;
400                 }
401
402                 /* MREMAP_FIXED checked above. */
403                 new_addr = get_unmapped_area(file, addr, new_len,
404                                     vma ? vma->vm_pgoff : 0,
405                                     map_flags, vma->vm_flags & VM_EXEC);
406                 ret = new_addr;
407                 if (new_addr & ~PAGE_MASK)
408                         goto out_sem;
409                 flags |= MREMAP_FIXED;
410         }
411         ret = do_mremap(addr, old_len, new_len, flags, new_addr);
412 out_sem:
413         up_write(&current->mm->mmap_sem);
414 out:
415         return ret;       
416 }
417
418 /* we come to here via sys_nis_syscall so it can setup the regs argument */
419 asmlinkage unsigned long c_sys_nis_syscall(struct pt_regs *regs)
420 {
421         static int count;
422         
423         /* Don't make the system unusable, if someone goes stuck */
424         if (count++ > 5)
425                 return -ENOSYS;
426
427         printk ("Unimplemented SPARC system call %ld\n",regs->u_regs[1]);
428 #ifdef DEBUG_UNIMP_SYSCALL      
429         show_regs (regs);
430 #endif
431
432         return -ENOSYS;
433 }
434
435 /* #define DEBUG_SPARC_BREAKPOINT */
436
437 asmlinkage void sparc_breakpoint(struct pt_regs *regs)
438 {
439         siginfo_t info;
440
441         if (test_thread_flag(TIF_32BIT)) {
442                 regs->tpc &= 0xffffffff;
443                 regs->tnpc &= 0xffffffff;
444         }
445 #ifdef DEBUG_SPARC_BREAKPOINT
446         printk ("TRAP: Entering kernel PC=%lx, nPC=%lx\n", regs->tpc, regs->tnpc);
447 #endif
448         info.si_signo = SIGTRAP;
449         info.si_errno = 0;
450         info.si_code = TRAP_BRKPT;
451         info.si_addr = (void *)regs->tpc;
452         info.si_trapno = 0;
453         force_sig_info(SIGTRAP, &info, current);
454 #ifdef DEBUG_SPARC_BREAKPOINT
455         printk ("TRAP: Returning to space: PC=%lx nPC=%lx\n", regs->tpc, regs->tnpc);
456 #endif
457 }
458
459 extern void check_pending(int signum);
460
461 asmlinkage long sys_getdomainname(char __user *name, int len)
462 {
463         int nlen;
464         int err = -EFAULT;
465
466         down_read(&uts_sem);
467         
468         nlen = strlen(vx_new_uts(domainname)) + 1;
469
470         if (nlen < len)
471                 len = nlen;
472         if (len > __NEW_UTS_LEN)
473                 goto done;
474         if (copy_to_user(name, vx_new_uts(domainname), len))
475                 goto done;
476         err = 0;
477 done:
478         up_read(&uts_sem);
479         return err;
480 }
481
482 asmlinkage long solaris_syscall(struct pt_regs *regs)
483 {
484         static int count;
485
486         regs->tpc = regs->tnpc;
487         regs->tnpc += 4;
488         if (test_thread_flag(TIF_32BIT)) {
489                 regs->tpc &= 0xffffffff;
490                 regs->tnpc &= 0xffffffff;
491         }
492         if (++count <= 5) {
493                 printk ("For Solaris binary emulation you need solaris module loaded\n");
494                 show_regs (regs);
495         }
496         send_sig(SIGSEGV, current, 1);
497
498         return -ENOSYS;
499 }
500
501 #ifndef CONFIG_SUNOS_EMUL
502 asmlinkage long sunos_syscall(struct pt_regs *regs)
503 {
504         static int count;
505
506         regs->tpc = regs->tnpc;
507         regs->tnpc += 4;
508         if (test_thread_flag(TIF_32BIT)) {
509                 regs->tpc &= 0xffffffff;
510                 regs->tnpc &= 0xffffffff;
511         }
512         if (++count <= 20)
513                 printk ("SunOS binary emulation not compiled in\n");
514         force_sig(SIGSEGV, current);
515
516         return -ENOSYS;
517 }
518 #endif
519
520 asmlinkage long sys_utrap_install(utrap_entry_t type,
521                                   utrap_handler_t new_p,
522                                   utrap_handler_t new_d,
523                                   utrap_handler_t __user *old_p,
524                                   utrap_handler_t __user *old_d)
525 {
526         if (type < UT_INSTRUCTION_EXCEPTION || type > UT_TRAP_INSTRUCTION_31)
527                 return -EINVAL;
528         if (new_p == (utrap_handler_t)(long)UTH_NOCHANGE) {
529                 if (old_p) {
530                         if (!current_thread_info()->utraps) {
531                                 if (put_user(NULL, old_p))
532                                         return -EFAULT;
533                         } else {
534                                 if (put_user((utrap_handler_t)(current_thread_info()->utraps[type]), old_p))
535                                         return -EFAULT;
536                         }
537                 }
538                 if (old_d) {
539                         if (put_user(NULL, old_d))
540                                 return -EFAULT;
541                 }
542                 return 0;
543         }
544         if (!current_thread_info()->utraps) {
545                 current_thread_info()->utraps =
546                         kmalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long), GFP_KERNEL);
547                 if (!current_thread_info()->utraps)
548                         return -ENOMEM;
549                 current_thread_info()->utraps[0] = 1;
550                 memset(current_thread_info()->utraps+1, 0,
551                        UT_TRAP_INSTRUCTION_31*sizeof(long));
552         } else {
553                 if ((utrap_handler_t)current_thread_info()->utraps[type] != new_p &&
554                     current_thread_info()->utraps[0] > 1) {
555                         long *p = current_thread_info()->utraps;
556
557                         current_thread_info()->utraps =
558                                 kmalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long),
559                                         GFP_KERNEL);
560                         if (!current_thread_info()->utraps) {
561                                 current_thread_info()->utraps = p;
562                                 return -ENOMEM;
563                         }
564                         p[0]--;
565                         current_thread_info()->utraps[0] = 1;
566                         memcpy(current_thread_info()->utraps+1, p+1,
567                                UT_TRAP_INSTRUCTION_31*sizeof(long));
568                 }
569         }
570         if (old_p) {
571                 if (put_user((utrap_handler_t)(current_thread_info()->utraps[type]), old_p))
572                         return -EFAULT;
573         }
574         if (old_d) {
575                 if (put_user(NULL, old_d))
576                         return -EFAULT;
577         }
578         current_thread_info()->utraps[type] = (long)new_p;
579
580         return 0;
581 }
582
583 long sparc_memory_ordering(unsigned long model, struct pt_regs *regs)
584 {
585         if (model >= 3)
586                 return -EINVAL;
587         regs->tstate = (regs->tstate & ~TSTATE_MM) | (model << 14);
588         return 0;
589 }
590
591 asmlinkage long sys_rt_sigaction(int sig,
592                                  const struct sigaction __user *act,
593                                  struct sigaction __user *oact,
594                                  void __user *restorer,
595                                  size_t sigsetsize)
596 {
597         struct k_sigaction new_ka, old_ka;
598         int ret;
599
600         /* XXX: Don't preclude handling different sized sigset_t's.  */
601         if (sigsetsize != sizeof(sigset_t))
602                 return -EINVAL;
603
604         if (act) {
605                 new_ka.ka_restorer = restorer;
606                 if (copy_from_user(&new_ka.sa, act, sizeof(*act)))
607                         return -EFAULT;
608         }
609
610         ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
611
612         if (!ret && oact) {
613                 if (copy_to_user(oact, &old_ka.sa, sizeof(*oact)))
614                         return -EFAULT;
615         }
616
617         return ret;
618 }
619
620 /* Invoked by rtrap code to update performance counters in
621  * user space.
622  */
623 asmlinkage void update_perfctrs(void)
624 {
625         unsigned long pic, tmp;
626
627         read_pic(pic);
628         tmp = (current_thread_info()->kernel_cntd0 += (unsigned int)pic);
629         __put_user(tmp, current_thread_info()->user_cntd0);
630         tmp = (current_thread_info()->kernel_cntd1 += (pic >> 32));
631         __put_user(tmp, current_thread_info()->user_cntd1);
632         reset_pic();
633 }
634
635 asmlinkage long sys_perfctr(int opcode, unsigned long arg0, unsigned long arg1, unsigned long arg2)
636 {
637         int err = 0;
638
639         switch(opcode) {
640         case PERFCTR_ON:
641                 current_thread_info()->pcr_reg = arg2;
642                 current_thread_info()->user_cntd0 = (u64 __user *) arg0;
643                 current_thread_info()->user_cntd1 = (u64 __user *) arg1;
644                 current_thread_info()->kernel_cntd0 =
645                         current_thread_info()->kernel_cntd1 = 0;
646                 write_pcr(arg2);
647                 reset_pic();
648                 set_thread_flag(TIF_PERFCTR);
649                 break;
650
651         case PERFCTR_OFF:
652                 err = -EINVAL;
653                 if (test_thread_flag(TIF_PERFCTR)) {
654                         current_thread_info()->user_cntd0 =
655                                 current_thread_info()->user_cntd1 = NULL;
656                         current_thread_info()->pcr_reg = 0;
657                         write_pcr(0);
658                         clear_thread_flag(TIF_PERFCTR);
659                         err = 0;
660                 }
661                 break;
662
663         case PERFCTR_READ: {
664                 unsigned long pic, tmp;
665
666                 if (!test_thread_flag(TIF_PERFCTR)) {
667                         err = -EINVAL;
668                         break;
669                 }
670                 read_pic(pic);
671                 tmp = (current_thread_info()->kernel_cntd0 += (unsigned int)pic);
672                 err |= __put_user(tmp, current_thread_info()->user_cntd0);
673                 tmp = (current_thread_info()->kernel_cntd1 += (pic >> 32));
674                 err |= __put_user(tmp, current_thread_info()->user_cntd1);
675                 reset_pic();
676                 break;
677         }
678
679         case PERFCTR_CLRPIC:
680                 if (!test_thread_flag(TIF_PERFCTR)) {
681                         err = -EINVAL;
682                         break;
683                 }
684                 current_thread_info()->kernel_cntd0 =
685                         current_thread_info()->kernel_cntd1 = 0;
686                 reset_pic();
687                 break;
688
689         case PERFCTR_SETPCR: {
690                 u64 __user *user_pcr = (u64 __user *)arg0;
691
692                 if (!test_thread_flag(TIF_PERFCTR)) {
693                         err = -EINVAL;
694                         break;
695                 }
696                 err |= __get_user(current_thread_info()->pcr_reg, user_pcr);
697                 write_pcr(current_thread_info()->pcr_reg);
698                 current_thread_info()->kernel_cntd0 =
699                         current_thread_info()->kernel_cntd1 = 0;
700                 reset_pic();
701                 break;
702         }
703
704         case PERFCTR_GETPCR: {
705                 u64 __user *user_pcr = (u64 __user *)arg0;
706
707                 if (!test_thread_flag(TIF_PERFCTR)) {
708                         err = -EINVAL;
709                         break;
710                 }
711                 err |= __put_user(current_thread_info()->pcr_reg, user_pcr);
712                 break;
713         }
714
715         default:
716                 err = -EINVAL;
717                 break;
718         };
719         return err;
720 }