~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/sparc/include/asm/futex_64.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef _SPARC64_FUTEX_H
  3 #define _SPARC64_FUTEX_H
  4 
  5 #include <linux/futex.h>
  6 #include <linux/uaccess.h>
  7 #include <asm/errno.h>
  8 
  9 #define __futex_cas_op(insn, ret, oldval, uaddr, oparg) \
 10         __asm__ __volatile__(                           \
 11         "\n1:   lduwa   [%3] %%asi, %2\n"               \
 12         "       " insn "\n"                             \
 13         "2:     casa    [%3] %%asi, %2, %1\n"           \
 14         "       cmp     %2, %1\n"                       \
 15         "       bne,pn  %%icc, 1b\n"                    \
 16         "        mov    0, %0\n"                        \
 17         "3:\n"                                          \
 18         "       .section .fixup,#alloc,#execinstr\n"    \
 19         "       .align  4\n"                            \
 20         "4:     sethi   %%hi(3b), %0\n"                 \
 21         "       jmpl    %0 + %%lo(3b), %%g0\n"          \
 22         "        mov    %5, %0\n"                       \
 23         "       .previous\n"                            \
 24         "       .section __ex_table,\"a\"\n"            \
 25         "       .align  4\n"                            \
 26         "       .word   1b, 4b\n"                       \
 27         "       .word   2b, 4b\n"                       \
 28         "       .previous\n"                            \
 29         : "=&r" (ret), "=&r" (oldval), "=&r" (tem)      \
 30         : "r" (uaddr), "r" (oparg), "i" (-EFAULT)       \
 31         : "memory")
 32 
 33 static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval,
 34                 u32 __user *uaddr)
 35 {
 36         int oldval = 0, ret, tem;
 37 
 38         if (unlikely((((unsigned long) uaddr) & 0x3UL)))
 39                 return -EINVAL;
 40 
 41         switch (op) {
 42         case FUTEX_OP_SET:
 43                 __futex_cas_op("mov\t%4, %1", ret, oldval, uaddr, oparg);
 44                 break;
 45         case FUTEX_OP_ADD:
 46                 __futex_cas_op("add\t%2, %4, %1", ret, oldval, uaddr, oparg);
 47                 break;
 48         case FUTEX_OP_OR:
 49                 __futex_cas_op("or\t%2, %4, %1", ret, oldval, uaddr, oparg);
 50                 break;
 51         case FUTEX_OP_ANDN:
 52                 __futex_cas_op("andn\t%2, %4, %1", ret, oldval, uaddr, oparg);
 53                 break;
 54         case FUTEX_OP_XOR:
 55                 __futex_cas_op("xor\t%2, %4, %1", ret, oldval, uaddr, oparg);
 56                 break;
 57         default:
 58                 ret = -ENOSYS;
 59         }
 60 
 61         if (!ret)
 62                 *oval = oldval;
 63 
 64         return ret;
 65 }
 66 
 67 static inline int
 68 futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
 69                               u32 oldval, u32 newval)
 70 {
 71         int ret = 0;
 72 
 73         __asm__ __volatile__(
 74         "\n1:   casa    [%4] %%asi, %3, %1\n"
 75         "2:\n"
 76         "       .section .fixup,#alloc,#execinstr\n"
 77         "       .align  4\n"
 78         "3:     sethi   %%hi(2b), %0\n"
 79         "       jmpl    %0 + %%lo(2b), %%g0\n"
 80         "       mov     %5, %0\n"
 81         "       .previous\n"
 82         "       .section __ex_table,\"a\"\n"
 83         "       .align  4\n"
 84         "       .word   1b, 3b\n"
 85         "       .previous\n"
 86         : "+r" (ret), "=r" (newval)
 87         : "1" (newval), "r" (oldval), "r" (uaddr), "i" (-EFAULT)
 88         : "memory");
 89 
 90         *uval = newval;
 91         return ret;
 92 }
 93 
 94 #endif /* !(_SPARC64_FUTEX_H) */
 95 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php