Skip to contentSkip to conversation

Patch "tile: add <asm/word-at-a-time.h> and enable support functions" has been added to the 3.18-stable tree

PATCH [email protected] 1 participant 1 message Aug 5, 2017 Stable branch

lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

tile: add <asm/word-at-a-time.h> and enable support functions

to the 3.18-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
tile-add-asm-word-at-a-time.h-and-enable-support-functions.patch
and it can be found in the queue-3.18 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 5bf6c07a1843813d0065feaaecba622d49148d7e Mon Sep 17 00:00:00 2001

From: Chris Metcalf <[email protected]>
Date: Thu, 30 Apr 2015 15:12:42 -0400
Subject: tile: add <asm/word-at-a-time.h> and enable support functions

From: Chris Metcalf <[email protected]>

commit 5bf6c07a1843813d0065feaaecba622d49148d7e upstream.

This change enables the generic strncpy_from_user() and strnlen_user() using word-at-a-time.h. The tile implementation is trivial since both tilepro and tilegx have SIMD operations that do byte-wise comparisons against immediate zero for each byte, and return an 0x01 byte in each position where there is a 0x00 byte.

---
 arch/tile/Kconfig                      |    2 +
 arch/tile/include/asm/uaccess.h        |   66 +++++----------------------------
 arch/tile/include/asm/word-at-a-time.h |   36 ++++++++++++++++++
 arch/tile/lib/exports.c                |    2 -
 arch/tile/lib/usercopy_32.S            |   46 -----------------------
 arch/tile/lib/usercopy_64.S            |   46 -----------------------
 6 files changed, 48 insertions(+), 150 deletions(-)
arch/tile/Kconfig +2 -0
@@ -27,6 +27,8 @@ config TILE
 	select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
 	select HAVE_DEBUG_STACKOVERFLOW
 	select ARCH_WANT_FRAME_POINTERS
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
 
 # FIXME: investigate whether we need/want these options.
 #	select HAVE_IOREMAP_PROT
arch/tile/include/asm/uaccess.h +10 -56

78 lines not on this page · raw message

arch/tile/include/asm/word-at-a-time.h new file +36 -0
@@ -0,0 +1,36 @@
+#ifndef _ASM_WORD_AT_A_TIME_H
+#define _ASM_WORD_AT_A_TIME_H
+
+#include <asm/byteorder.h>
+
+struct word_at_a_time { /* unused */ };
+#define WORD_AT_A_TIME_CONSTANTS {}
+
+/* Generate 0x01 byte values for non-zero bytes using a SIMD instruction. */
+static inline unsigned long has_zero(unsigned long val, unsigned long *data,
+				     const struct word_at_a_time *c)
+{
+#ifdef __tilegx__
+	unsigned long mask = __insn_v1cmpeqi(val, 0);
+#else /* tilepro */
+	unsigned long mask = __insn_seqib(val, 0);
+#endif
+	*data = mask;
+	return mask;
+}
+
+/* These operations are both nops. */
+#define prep_zero_mask(val, data, c) (data)
+#define create_zero_mask(data) (data)
+
+/* And this operation just depends on endianness. */
+static inline long find_zero(unsigned long mask)
+{
+#ifdef __BIG_ENDIAN
+	return __builtin_clzl(mask) >> 3;
+#else
+	return __builtin_ctzl(mask) >> 3;
+#endif
+}
+
+#endif /* _ASM_WORD_AT_A_TIME_H */
arch/tile/lib/exports.c +0 -2
@@ -18,8 +18,6 @@
 
 /* arch/tile/lib/usercopy.S */
 #include <linux/uaccess.h>
-EXPORT_SYMBOL(strnlen_user_asm);
-EXPORT_SYMBOL(strncpy_from_user_asm);
 EXPORT_SYMBOL(clear_user_asm);
 EXPORT_SYMBOL(flush_user_asm);
 EXPORT_SYMBOL(finv_user_asm);
arch/tile/lib/usercopy_32.S +0 -46

52 lines not on this page · raw message

arch/tile/lib/usercopy_64.S +0 -46

52 lines not on this page · raw message

Patches currently in stable-queue which might be from [email protected] are

queue-3.18/strscpy-zero-any-trailing-garbage-bytes-in-the-destination.patch queue-3.18/word-at-a-time.h-support-zero_bytemask-on-alpha-and-tile.patch queue-3.18/tile-add-asm-word-at-a-time.h-and-enable-support-functions.patch queue-3.18/string-provide-strscpy.patch