diff options
author | Will Deacon <will.deacon@arm.com> | 2013-12-12 12:40:21 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-12-12 13:39:01 -0500 |
commit | a5c21dcefa1c3d759457a604b3cfc4af29c8713f (patch) | |
tree | 6832dfcb836f8d5043ba70f17a0ea9c2c428bc4d /include/linux | |
parent | 319720f534d88039615bceb88d4bc094a7cd4ce9 (diff) |
dcache: allow word-at-a-time name hashing with big-endian CPUs
When explicitly hashing the end of a string with the word-at-a-time
interface, we have to be careful which end of the word we pick up.
On big-endian CPUs, the upper-bits will contain the data we're after, so
ensure we generate our masks accordingly (and avoid hashing whatever
random junk may have been sitting after the string).
This patch adds a new dcache helper, bytemask_from_count, which creates
a mask appropriate for the CPU endianness.
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/dcache.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 57e87e749a48..bf72e9ac6de0 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -29,8 +29,10 @@ struct vfsmount; | |||
29 | /* The hash is always the low bits of hash_len */ | 29 | /* The hash is always the low bits of hash_len */ |
30 | #ifdef __LITTLE_ENDIAN | 30 | #ifdef __LITTLE_ENDIAN |
31 | #define HASH_LEN_DECLARE u32 hash; u32 len; | 31 | #define HASH_LEN_DECLARE u32 hash; u32 len; |
32 | #define bytemask_from_count(cnt) (~(~0ul << (cnt)*8)) | ||
32 | #else | 33 | #else |
33 | #define HASH_LEN_DECLARE u32 len; u32 hash; | 34 | #define HASH_LEN_DECLARE u32 len; u32 hash; |
35 | #define bytemask_from_count(cnt) (~(~0ul >> (cnt)*8)) | ||
34 | #endif | 36 | #endif |
35 | 37 | ||
36 | /* | 38 | /* |