aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-09 12:45:41 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-09 12:45:41 -0800
commita4a26e8e924a8e2412b63276c1a23cc127997a73 (patch)
tree28f2774c581722cd1e488a46b8ffda1b05eb1e76 /include
parentMerge tag 'scsi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi (diff)
parentnios2: Make NIOS2_CMDLINE_IGNORE_DTB depend on CMDLINE_BOOL (diff)
downloadwireguard-linux-a4a26e8e924a8e2412b63276c1a23cc127997a73.tar.xz
wireguard-linux-a4a26e8e924a8e2412b63276c1a23cc127997a73.zip
Merge tag 'nios2-v3.19-rc1' of git://git.rocketboards.org/linux-socfpga-next
Pull Altera Nios II processor support from Ley Foon Tan: "Here is the Linux port for Nios II processor (from Altera) arch/nios2/ tree for v3.19. The patchset has been discussed on the kernel mailing lists since April and has gone through 6 revisions of review. The additional changes since then have been mostly further cleanups and fixes when merged with other trees. The arch code is in arch/nios2 and one asm-generic change (acked by Arnd)" Arnd Bergmann says: "I've reviewed the architecture port in the past and it looks good in its latest version" Acked-by: Arnd Bergmann <arnd@arndb.de> * tag 'nios2-v3.19-rc1' of git://git.rocketboards.org/linux-socfpga-next: (40 commits) nios2: Make NIOS2_CMDLINE_IGNORE_DTB depend on CMDLINE_BOOL nios2: Add missing NR_CPUS to Kconfig nios2: asm-offsets: Remove unused definition TI_TASK nios2: Remove write-only struct member from nios2_timer nios2: Remove unused extern declaration of shm_align_mask nios2: include linux/type.h in io.h nios2: move include asm-generic/io.h to end of file nios2: remove include asm-generic/iomap.h from io.h nios2: remove unnecessary space before define nios2: fix error handling of irq_of_parse_and_map nios2: Use IS_ENABLED instead of #ifdefs to check config symbols nios2: Build infrastructure Documentation: Add documentation for Nios2 architecture MAINTAINERS: Add nios2 maintainer nios2: ptrace support nios2: Module support nios2: Nios2 registers nios2: Miscellaneous header files nios2: Cpuinfo handling nios2: Time keeping ...
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/futex.h114
-rw-r--r--include/uapi/linux/elf-em.h1
2 files changed, 115 insertions, 0 deletions
diff --git a/include/asm-generic/futex.h b/include/asm-generic/futex.h
index 01f227e14254..b59b5a52637e 100644
--- a/include/asm-generic/futex.h
+++ b/include/asm-generic/futex.h
@@ -5,6 +5,119 @@
#include <linux/uaccess.h>
#include <asm/errno.h>
+#ifndef CONFIG_SMP
+/*
+ * The following implementation only for uniprocessor machines.
+ * For UP, it's relies on the fact that pagefault_disable() also disables
+ * preemption to ensure mutual exclusion.
+ *
+ */
+
+/**
+ * futex_atomic_op_inuser() - Atomic arithmetic operation with constant
+ * argument and comparison of the previous
+ * futex value with another constant.
+ *
+ * @encoded_op: encoded operation to execute
+ * @uaddr: pointer to user space address
+ *
+ * Return:
+ * 0 - On success
+ * <0 - On error
+ */
+static inline int
+futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
+{
+ int op = (encoded_op >> 28) & 7;
+ int cmp = (encoded_op >> 24) & 15;
+ int oparg = (encoded_op << 8) >> 20;
+ int cmparg = (encoded_op << 20) >> 20;
+ int oldval, ret;
+ u32 tmp;
+
+ if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
+ oparg = 1 << oparg;
+
+ pagefault_disable();
+
+ ret = -EFAULT;
+ if (unlikely(get_user(oldval, uaddr) != 0))
+ goto out_pagefault_enable;
+
+ ret = 0;
+ tmp = oldval;
+
+ switch (op) {
+ case FUTEX_OP_SET:
+ tmp = oparg;
+ break;
+ case FUTEX_OP_ADD:
+ tmp += oparg;
+ break;
+ case FUTEX_OP_OR:
+ tmp |= oparg;
+ break;
+ case FUTEX_OP_ANDN:
+ tmp &= ~oparg;
+ break;
+ case FUTEX_OP_XOR:
+ tmp ^= oparg;
+ break;
+ default:
+ ret = -ENOSYS;
+ }
+
+ if (ret == 0 && unlikely(put_user(tmp, uaddr) != 0))
+ ret = -EFAULT;
+
+out_pagefault_enable:
+ pagefault_enable();
+
+ if (ret == 0) {
+ switch (cmp) {
+ case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
+ case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
+ case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
+ case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
+ case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
+ case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
+ default: ret = -ENOSYS;
+ }
+ }
+ return ret;
+}
+
+/**
+ * futex_atomic_cmpxchg_inatomic() - Compare and exchange the content of the
+ * uaddr with newval if the current value is
+ * oldval.
+ * @uval: pointer to store content of @uaddr
+ * @uaddr: pointer to user space address
+ * @oldval: old value
+ * @newval: new value to store to @uaddr
+ *
+ * Return:
+ * 0 - On success
+ * <0 - On error
+ */
+static inline int
+futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
+ u32 oldval, u32 newval)
+{
+ u32 val;
+
+ if (unlikely(get_user(val, uaddr) != 0))
+ return -EFAULT;
+
+ if (val == oldval && unlikely(put_user(newval, uaddr) != 0))
+ return -EFAULT;
+
+ *uval = val;
+
+ return 0;
+}
+
+#else
static inline int
futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
{
@@ -54,4 +167,5 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
return -ENOSYS;
}
+#endif /* CONFIG_SMP */
#endif
diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index aa90bc98b6e2..ae99f7743cf4 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -34,6 +34,7 @@
#define EM_MN10300 89 /* Panasonic/MEI MN10300, AM33 */
#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
#define EM_BLACKFIN 106 /* ADI Blackfin Processor */
+#define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */
#define EM_TI_C6000 140 /* TI C6X DSPs */
#define EM_AARCH64 183 /* ARM 64 bit */
#define EM_FRV 0x5441 /* Fujitsu FR-V */