1 /* $Id: sys_sparc.c,v 1.57 2002/02/09 19:49:30 davem Exp $
2 * linux/arch/sparc64/kernel/sys_sparc.c
4 * This file contains various random system calls that
5 * have a non-standard calling sequence on the Linux/sparc
9 #include <linux/errno.h>
10 #include <linux/types.h>
11 #include <linux/sched.h>
13 #include <linux/file.h>
15 #include <linux/sem.h>
16 #include <linux/msg.h>
17 #include <linux/shm.h>
18 #include <linux/stat.h>
19 #include <linux/mman.h>
20 #include <linux/utsname.h>
21 #include <linux/smp.h>
22 #include <linux/slab.h>
23 #include <linux/syscalls.h>
24 #include <linux/ipc.h>
25 #include <linux/personality.h>
26 #include <linux/random.h>
28 #include <asm/uaccess.h>
29 #include <asm/utrap.h>
30 #include <asm/perfctr.h>
31 #include <asm/a.out.h>
32 #include <asm/unistd.h>
34 /* #define DEBUG_UNIMP_SYSCALL */
36 asmlinkage unsigned long sys_getpagesize(void)
41 #define VA_EXCLUDE_START (0x0000080000000000UL - (1UL << 32UL))
42 #define VA_EXCLUDE_END (0xfffff80000000000UL + (1UL << 32UL))
44 /* Does addr --> addr+len fall within 4GB of the VA-space hole or
45 * overflow past the end of the 64-bit address space?
47 static inline int invalid_64bit_range(unsigned long addr, unsigned long len)
49 unsigned long va_exclude_start, va_exclude_end;
51 va_exclude_start = VA_EXCLUDE_START;
52 va_exclude_end = VA_EXCLUDE_END;
54 if (unlikely(len >= va_exclude_start))
57 if (unlikely((addr + len) < addr))
60 if (unlikely((addr >= va_exclude_start && addr < va_exclude_end) ||
61 ((addr + len) >= va_exclude_start &&
62 (addr + len) < va_exclude_end)))
68 /* Does start,end straddle the VA-space hole? */
69 static inline int straddles_64bit_va_hole(unsigned long start, unsigned long end)
71 unsigned long va_exclude_start, va_exclude_end;
73 va_exclude_start = VA_EXCLUDE_START;
74 va_exclude_end = VA_EXCLUDE_END;
76 if (likely(start < va_exclude_start && end < va_exclude_start))
79 if (likely(start >= va_exclude_end && end >= va_exclude_end))
85 /* These functions differ from the default implementations in
86 * mm/mmap.c in two ways:
88 * 1) For file backed MAP_SHARED mmap()'s we D-cache color align,
89 * for fixed such mappings we just validate what the user gave us.
90 * 2) For 64-bit tasks we avoid mapping anything within 4GB of
91 * the spitfire/niagara VA-hole.
94 static inline unsigned long COLOUR_ALIGN(unsigned long addr,
97 unsigned long base = (addr+SHMLBA-1)&~(SHMLBA-1);
98 unsigned long off = (pgoff<<PAGE_SHIFT) & (SHMLBA-1);
103 static inline unsigned long COLOUR_ALIGN_DOWN(unsigned long addr,
106 unsigned long base = addr & ~(SHMLBA-1);
107 unsigned long off = (pgoff<<PAGE_SHIFT) & (SHMLBA-1);
109 if (base + off <= addr)
114 unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
116 struct mm_struct *mm = current->mm;
117 struct vm_area_struct * vma;
118 unsigned long task_size = TASK_SIZE;
119 unsigned long start_addr;
122 if (flags & MAP_FIXED) {
123 /* We do not accept a shared mapping if it would violate
124 * cache aliasing constraints.
126 if ((flags & MAP_SHARED) &&
127 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
132 if (test_thread_flag(TIF_32BIT))
133 task_size = STACK_TOP32;
134 if (unlikely(len > task_size || len >= VA_EXCLUDE_START))
138 if (filp || (flags & MAP_SHARED))
143 addr = COLOUR_ALIGN(addr, pgoff);
145 addr = PAGE_ALIGN(addr);
147 vma = find_vma(mm, addr);
148 if (task_size - len >= addr &&
149 (!vma || addr + len <= vma->vm_start))
153 if (len > mm->cached_hole_size) {
154 start_addr = addr = mm->free_area_cache;
156 start_addr = addr = TASK_UNMAPPED_BASE;
157 mm->cached_hole_size = 0;
164 addr = COLOUR_ALIGN(addr, pgoff);
166 addr = PAGE_ALIGN(addr);
168 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
169 /* At this point: (!vma || addr < vma->vm_end). */
170 if (addr < VA_EXCLUDE_START &&
171 (addr + len) >= VA_EXCLUDE_START) {
172 addr = VA_EXCLUDE_END;
173 vma = find_vma(mm, VA_EXCLUDE_END);
175 if (unlikely(task_size < addr)) {
176 if (start_addr != TASK_UNMAPPED_BASE) {
177 start_addr = addr = TASK_UNMAPPED_BASE;
178 mm->cached_hole_size = 0;
183 if (likely(!vma || addr + len <= vma->vm_start)) {
185 * Remember the place where we stopped the search:
187 mm->free_area_cache = addr + len;
190 if (addr + mm->cached_hole_size < vma->vm_start)
191 mm->cached_hole_size = vma->vm_start - addr;
195 addr = COLOUR_ALIGN(addr, pgoff);
200 arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
201 const unsigned long len, const unsigned long pgoff,
202 const unsigned long flags)
204 struct vm_area_struct *vma;
205 struct mm_struct *mm = current->mm;
206 unsigned long task_size = STACK_TOP32;
207 unsigned long addr = addr0;
210 /* This should only ever run for 32-bit processes. */
211 BUG_ON(!test_thread_flag(TIF_32BIT));
213 if (flags & MAP_FIXED) {
214 /* We do not accept a shared mapping if it would violate
215 * cache aliasing constraints.
217 if ((flags & MAP_SHARED) &&
218 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
223 if (unlikely(len > task_size))
227 if (filp || (flags & MAP_SHARED))
230 /* requesting a specific address */
233 addr = COLOUR_ALIGN(addr, pgoff);
235 addr = PAGE_ALIGN(addr);
237 vma = find_vma(mm, addr);
238 if (task_size - len >= addr &&
239 (!vma || addr + len <= vma->vm_start))
243 /* check if free_area_cache is useful for us */
244 if (len <= mm->cached_hole_size) {
245 mm->cached_hole_size = 0;
246 mm->free_area_cache = mm->mmap_base;
249 /* either no address requested or can't fit in requested address hole */
250 addr = mm->free_area_cache;
251 if (do_color_align) {
252 unsigned long base = COLOUR_ALIGN_DOWN(addr-len, pgoff);
257 /* make sure it can fit in the remaining address space */
258 if (likely(addr > len)) {
259 vma = find_vma(mm, addr-len);
260 if (!vma || addr <= vma->vm_start) {
261 /* remember the address as a hint for next time */
262 return (mm->free_area_cache = addr-len);
266 if (unlikely(mm->mmap_base < len))
269 addr = mm->mmap_base-len;
271 addr = COLOUR_ALIGN_DOWN(addr, pgoff);
275 * Lookup failure means no vma is above this address,
276 * else if new region fits below vma->vm_start,
277 * return with success:
279 vma = find_vma(mm, addr);
280 if (likely(!vma || addr+len <= vma->vm_start)) {
281 /* remember the address as a hint for next time */
282 return (mm->free_area_cache = addr);
285 /* remember the largest hole we saw so far */
286 if (addr + mm->cached_hole_size < vma->vm_start)
287 mm->cached_hole_size = vma->vm_start - addr;
289 /* try just below the current vma->vm_start */
290 addr = vma->vm_start-len;
292 addr = COLOUR_ALIGN_DOWN(addr, pgoff);
293 } while (likely(len < vma->vm_start));
297 * A failed mmap() very likely causes application failure,
298 * so fall back to the bottom-up function here. This scenario
299 * can happen with large stack limits and large mmap()
302 mm->cached_hole_size = ~0UL;
303 mm->free_area_cache = TASK_UNMAPPED_BASE;
304 addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
306 * Restore the topdown base:
308 mm->free_area_cache = mm->mmap_base;
309 mm->cached_hole_size = ~0UL;
314 /* Try to align mapping such that we align it as much as possible. */
315 unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, unsigned long len, unsigned long pgoff, unsigned long flags)
317 unsigned long align_goal, addr = -ENOMEM;
319 if (flags & MAP_FIXED) {
320 /* Ok, don't mess with it. */
321 return get_unmapped_area(NULL, orig_addr, len, pgoff, flags);
323 flags &= ~MAP_SHARED;
325 align_goal = PAGE_SIZE;
326 if (len >= (4UL * 1024 * 1024))
327 align_goal = (4UL * 1024 * 1024);
328 else if (len >= (512UL * 1024))
329 align_goal = (512UL * 1024);
330 else if (len >= (64UL * 1024))
331 align_goal = (64UL * 1024);
334 addr = get_unmapped_area(NULL, orig_addr, len + (align_goal - PAGE_SIZE), pgoff, flags);
335 if (!(addr & ~PAGE_MASK)) {
336 addr = (addr + (align_goal - 1UL)) & ~(align_goal - 1UL);
340 if (align_goal == (4UL * 1024 * 1024))
341 align_goal = (512UL * 1024);
342 else if (align_goal == (512UL * 1024))
343 align_goal = (64UL * 1024);
345 align_goal = PAGE_SIZE;
346 } while ((addr & ~PAGE_MASK) && align_goal > PAGE_SIZE);
348 /* Mapping is smaller than 64K or larger areas could not
351 if (addr & ~PAGE_MASK)
352 addr = get_unmapped_area(NULL, orig_addr, len, pgoff, flags);
357 /* Essentially the same as PowerPC... */
358 void arch_pick_mmap_layout(struct mm_struct *mm)
360 unsigned long random_factor = 0UL;
362 if (current->flags & PF_RANDOMIZE) {
363 random_factor = get_random_int();
364 if (test_thread_flag(TIF_32BIT))
365 random_factor &= ((1 * 1024 * 1024) - 1);
367 random_factor = ((random_factor << PAGE_SHIFT) &
372 * Fall back to the standard layout if the personality
373 * bit is set, or if the expected stack growth is unlimited:
375 if (!test_thread_flag(TIF_32BIT) ||
376 (current->personality & ADDR_COMPAT_LAYOUT) ||
377 current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY ||
378 sysctl_legacy_va_layout) {
379 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
380 mm->get_unmapped_area = arch_get_unmapped_area;
381 mm->unmap_area = arch_unmap_area;
383 /* We know it's 32-bit */
384 unsigned long task_size = STACK_TOP32;
387 gap = current->signal->rlim[RLIMIT_STACK].rlim_cur;
388 if (gap < 128 * 1024 * 1024)
389 gap = 128 * 1024 * 1024;
390 if (gap > (task_size / 6 * 5))
391 gap = (task_size / 6 * 5);
393 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
394 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
395 mm->unmap_area = arch_unmap_area_topdown;
399 asmlinkage unsigned long sparc_brk(unsigned long brk)
401 /* People could try to be nasty and use ta 0x6d in 32bit programs */
402 if (test_thread_flag(TIF_32BIT) && brk >= STACK_TOP32)
403 return current->mm->brk;
405 if (unlikely(straddles_64bit_va_hole(current->mm->brk, brk)))
406 return current->mm->brk;
412 * sys_pipe() is the normal C calling standard for creating
413 * a pipe. It's not the way unix traditionally does this, though.
415 asmlinkage long sparc_pipe(struct pt_regs *regs)
423 regs->u_regs[UREG_I1] = fd[1];
430 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
432 * This is really horribly ugly.
435 asmlinkage long sys_ipc(unsigned int call, int first, unsigned long second,
436 unsigned long third, void __user *ptr, long fifth)
440 /* No need for backward compatibility. We can start fresh... */
441 if (call <= SEMCTL) {
444 err = sys_semtimedop(first, ptr,
445 (unsigned)second, NULL);
448 err = sys_semtimedop(first, ptr, (unsigned)second,
449 (const struct timespec __user *) fifth);
452 err = sys_semget(first, (int)second, (int)third);
455 err = sys_semctl(first, third,
456 (int)second | IPC_64,
465 if (call <= MSGCTL) {
468 err = sys_msgsnd(first, ptr, (size_t)second,
472 err = sys_msgrcv(first, ptr, (size_t)second, fifth,
476 err = sys_msgget((key_t)first, (int)second);
479 err = sys_msgctl(first, (int)second | IPC_64, ptr);
486 if (call <= SHMCTL) {
490 err = do_shmat(first, ptr, (int)second, &raddr);
493 (ulong __user *) third))
499 err = sys_shmdt(ptr);
502 err = sys_shmget(first, (size_t)second, (int)third);
505 err = sys_shmctl(first, (int)second | IPC_64, ptr);
518 asmlinkage long sparc64_newuname(struct new_utsname __user *name)
520 int ret = sys_newuname(name);
522 if (current->personality == PER_LINUX32 && !ret) {
523 ret = (copy_to_user(name->machine, "sparc\0\0", 8)
529 asmlinkage long sparc64_personality(unsigned long personality)
533 if (current->personality == PER_LINUX32 &&
534 personality == PER_LINUX)
535 personality = PER_LINUX32;
536 ret = sys_personality(personality);
537 if (ret == PER_LINUX32)
543 int sparc64_mmap_check(unsigned long addr, unsigned long len,
546 if (test_thread_flag(TIF_32BIT)) {
547 if (len >= STACK_TOP32)
550 if ((flags & MAP_FIXED) && addr > STACK_TOP32 - len)
553 if (len >= VA_EXCLUDE_START)
556 if ((flags & MAP_FIXED) && invalid_64bit_range(addr, len))
563 /* Linux version of mmap */
564 asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
565 unsigned long prot, unsigned long flags, unsigned long fd,
568 struct file * file = NULL;
569 unsigned long retval = -EBADF;
571 if (!(flags & MAP_ANONYMOUS)) {
576 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
577 len = PAGE_ALIGN(len);
579 down_write(¤t->mm->mmap_sem);
580 retval = do_mmap(file, addr, len, prot, flags, off);
581 up_write(¤t->mm->mmap_sem);
589 asmlinkage long sys64_munmap(unsigned long addr, size_t len)
593 if (invalid_64bit_range(addr, len))
596 down_write(¤t->mm->mmap_sem);
597 ret = do_munmap(current->mm, addr, len);
598 up_write(¤t->mm->mmap_sem);
602 extern unsigned long do_mremap(unsigned long addr,
603 unsigned long old_len, unsigned long new_len,
604 unsigned long flags, unsigned long new_addr);
606 asmlinkage unsigned long sys64_mremap(unsigned long addr,
607 unsigned long old_len, unsigned long new_len,
608 unsigned long flags, unsigned long new_addr)
610 struct vm_area_struct *vma;
611 unsigned long ret = -EINVAL;
613 if (test_thread_flag(TIF_32BIT))
615 if (unlikely(new_len >= VA_EXCLUDE_START))
617 if (unlikely(invalid_64bit_range(addr, old_len)))
620 down_write(¤t->mm->mmap_sem);
621 if (flags & MREMAP_FIXED) {
622 if (invalid_64bit_range(new_addr, new_len))
624 } else if (invalid_64bit_range(addr, new_len)) {
625 unsigned long map_flags = 0;
626 struct file *file = NULL;
629 if (!(flags & MREMAP_MAYMOVE))
632 vma = find_vma(current->mm, addr);
634 if (vma->vm_flags & VM_SHARED)
635 map_flags |= MAP_SHARED;
639 /* MREMAP_FIXED checked above. */
640 new_addr = get_unmapped_area(file, addr, new_len,
641 vma ? vma->vm_pgoff : 0,
644 if (new_addr & ~PAGE_MASK)
646 flags |= MREMAP_FIXED;
648 ret = do_mremap(addr, old_len, new_len, flags, new_addr);
650 up_write(¤t->mm->mmap_sem);
655 /* we come to here via sys_nis_syscall so it can setup the regs argument */
656 asmlinkage unsigned long c_sys_nis_syscall(struct pt_regs *regs)
660 /* Don't make the system unusable, if someone goes stuck */
664 printk ("Unimplemented SPARC system call %ld\n",regs->u_regs[1]);
665 #ifdef DEBUG_UNIMP_SYSCALL
672 /* #define DEBUG_SPARC_BREAKPOINT */
674 asmlinkage void sparc_breakpoint(struct pt_regs *regs)
678 if (test_thread_flag(TIF_32BIT)) {
679 regs->tpc &= 0xffffffff;
680 regs->tnpc &= 0xffffffff;
682 #ifdef DEBUG_SPARC_BREAKPOINT
683 printk ("TRAP: Entering kernel PC=%lx, nPC=%lx\n", regs->tpc, regs->tnpc);
685 info.si_signo = SIGTRAP;
687 info.si_code = TRAP_BRKPT;
688 info.si_addr = (void __user *)regs->tpc;
690 force_sig_info(SIGTRAP, &info, current);
691 #ifdef DEBUG_SPARC_BREAKPOINT
692 printk ("TRAP: Returning to space: PC=%lx nPC=%lx\n", regs->tpc, regs->tnpc);
696 extern void check_pending(int signum);
698 asmlinkage long sys_getdomainname(char __user *name, int len)
707 nlen = strlen(utsname()->domainname) + 1;
713 if (!copy_to_user(name, utsname()->domainname, nlen))
721 asmlinkage long solaris_syscall(struct pt_regs *regs)
725 regs->tpc = regs->tnpc;
727 if (test_thread_flag(TIF_32BIT)) {
728 regs->tpc &= 0xffffffff;
729 regs->tnpc &= 0xffffffff;
732 printk ("For Solaris binary emulation you need solaris module loaded\n");
735 send_sig(SIGSEGV, current, 1);
740 #ifndef CONFIG_SUNOS_EMUL
741 asmlinkage long sunos_syscall(struct pt_regs *regs)
745 regs->tpc = regs->tnpc;
747 if (test_thread_flag(TIF_32BIT)) {
748 regs->tpc &= 0xffffffff;
749 regs->tnpc &= 0xffffffff;
752 printk ("SunOS binary emulation not compiled in\n");
753 force_sig(SIGSEGV, current);
759 asmlinkage long sys_utrap_install(utrap_entry_t type,
760 utrap_handler_t new_p,
761 utrap_handler_t new_d,
762 utrap_handler_t __user *old_p,
763 utrap_handler_t __user *old_d)
765 if (type < UT_INSTRUCTION_EXCEPTION || type > UT_TRAP_INSTRUCTION_31)
767 if (new_p == (utrap_handler_t)(long)UTH_NOCHANGE) {
769 if (!current_thread_info()->utraps) {
770 if (put_user(NULL, old_p))
773 if (put_user((utrap_handler_t)(current_thread_info()->utraps[type]), old_p))
778 if (put_user(NULL, old_d))
783 if (!current_thread_info()->utraps) {
784 current_thread_info()->utraps =
785 kzalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long), GFP_KERNEL);
786 if (!current_thread_info()->utraps)
788 current_thread_info()->utraps[0] = 1;
790 if ((utrap_handler_t)current_thread_info()->utraps[type] != new_p &&
791 current_thread_info()->utraps[0] > 1) {
792 long *p = current_thread_info()->utraps;
794 current_thread_info()->utraps =
795 kmalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long),
797 if (!current_thread_info()->utraps) {
798 current_thread_info()->utraps = p;
802 current_thread_info()->utraps[0] = 1;
803 memcpy(current_thread_info()->utraps+1, p+1,
804 UT_TRAP_INSTRUCTION_31*sizeof(long));
808 if (put_user((utrap_handler_t)(current_thread_info()->utraps[type]), old_p))
812 if (put_user(NULL, old_d))
815 current_thread_info()->utraps[type] = (long)new_p;
820 long sparc_memory_ordering(unsigned long model, struct pt_regs *regs)
824 regs->tstate = (regs->tstate & ~TSTATE_MM) | (model << 14);
828 asmlinkage long sys_rt_sigaction(int sig,
829 const struct sigaction __user *act,
830 struct sigaction __user *oact,
831 void __user *restorer,
834 struct k_sigaction new_ka, old_ka;
837 /* XXX: Don't preclude handling different sized sigset_t's. */
838 if (sigsetsize != sizeof(sigset_t))
842 new_ka.ka_restorer = restorer;
843 if (copy_from_user(&new_ka.sa, act, sizeof(*act)))
847 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
850 if (copy_to_user(oact, &old_ka.sa, sizeof(*oact)))
857 /* Invoked by rtrap code to update performance counters in
860 asmlinkage void update_perfctrs(void)
862 unsigned long pic, tmp;
865 tmp = (current_thread_info()->kernel_cntd0 += (unsigned int)pic);
866 __put_user(tmp, current_thread_info()->user_cntd0);
867 tmp = (current_thread_info()->kernel_cntd1 += (pic >> 32));
868 __put_user(tmp, current_thread_info()->user_cntd1);
872 asmlinkage long sys_perfctr(int opcode, unsigned long arg0, unsigned long arg1, unsigned long arg2)
878 current_thread_info()->pcr_reg = arg2;
879 current_thread_info()->user_cntd0 = (u64 __user *) arg0;
880 current_thread_info()->user_cntd1 = (u64 __user *) arg1;
881 current_thread_info()->kernel_cntd0 =
882 current_thread_info()->kernel_cntd1 = 0;
885 set_thread_flag(TIF_PERFCTR);
890 if (test_thread_flag(TIF_PERFCTR)) {
891 current_thread_info()->user_cntd0 =
892 current_thread_info()->user_cntd1 = NULL;
893 current_thread_info()->pcr_reg = 0;
895 clear_thread_flag(TIF_PERFCTR);
901 unsigned long pic, tmp;
903 if (!test_thread_flag(TIF_PERFCTR)) {
908 tmp = (current_thread_info()->kernel_cntd0 += (unsigned int)pic);
909 err |= __put_user(tmp, current_thread_info()->user_cntd0);
910 tmp = (current_thread_info()->kernel_cntd1 += (pic >> 32));
911 err |= __put_user(tmp, current_thread_info()->user_cntd1);
917 if (!test_thread_flag(TIF_PERFCTR)) {
921 current_thread_info()->kernel_cntd0 =
922 current_thread_info()->kernel_cntd1 = 0;
926 case PERFCTR_SETPCR: {
927 u64 __user *user_pcr = (u64 __user *)arg0;
929 if (!test_thread_flag(TIF_PERFCTR)) {
933 err |= __get_user(current_thread_info()->pcr_reg, user_pcr);
934 write_pcr(current_thread_info()->pcr_reg);
935 current_thread_info()->kernel_cntd0 =
936 current_thread_info()->kernel_cntd1 = 0;
941 case PERFCTR_GETPCR: {
942 u64 __user *user_pcr = (u64 __user *)arg0;
944 if (!test_thread_flag(TIF_PERFCTR)) {
948 err |= __put_user(current_thread_info()->pcr_reg, user_pcr);
960 * Do a system call from kernel instead of calling sys_execve so we
961 * end up with proper pt_regs.
963 int kernel_execve(const char *filename, char *const argv[], char *const envp[])
966 register long __g1 __asm__ ("g1") = __NR_execve;
967 register long __o0 __asm__ ("o0") = (long)(filename);
968 register long __o1 __asm__ ("o1") = (long)(argv);
969 register long __o2 __asm__ ("o2") = (long)(envp);
970 asm volatile ("t 0x6d\n\t"
971 "sub %%g0, %%o0, %0\n\t"
972 "movcc %%xcc, %%o0, %0\n\t"
973 : "=r" (__res), "=&r" (__o0)
974 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1)