1commit 0f6bdc219e598de08a3f37887efa5dfa50e2b996 2Author: Aws Ismail <aws.ismail@windriver.com> 3Date: Fri Jun 22 15:47:08 2012 -0400 4 5Hash fix for MIPS64 and AARCH64 6 7Samhain uses the addresses of local variables in generating hash 8values. The hashing function is designed only for 32-bit values. 9For MIPS64 when a 64-bit address is passed in the resulting hash 10exceeds the limits of the underlying mechanism and samhain 11ultimately fails. The solution is to simply take the lower 1232-bits of the address and use that in generating hash values. 13 14Signed-off-by: Greg Moffatt <greg.moffatt@windriver.com> 15 16Upstream-Status: Pending 17 18Signed-off-by: Aws Ismail <aws.ismail@windriver.com> 19Signed-off-by: Jackie Huang <jackie.huang@windriver.com> 20 21diff --git a/src/dnmalloc.c b/src/dnmalloc.c 22index da9a5c5..fc91400 100644 23--- a/src/dnmalloc.c 24+++ b/src/dnmalloc.c 25@@ -2703,11 +2703,19 @@ static void freecilst_add(chunkinfoptr p) { 26 } 27 28 /* Calculate the hash table entry for a chunk */ 29+#if defined(CONFIG_ARCH_MIPS64) || defined(CONFIG_ARCH_AARCH64) 30+#ifdef STARTHEAP_IS_ZERO 31+#define hash(p) ((((unsigned long) p) & 0x7fffffff) >> 7) 32+#else 33+#define hash(p) ((((unsigned long) p - (unsigned long) startheap) & 0x7fffffff) >> 7) 34+#endif 35+#else 36 #ifdef STARTHEAP_IS_ZERO 37 #define hash(p) (((unsigned long) p) >> 7) 38 #else 39 #define hash(p) (((unsigned long) p - (unsigned long) startheap) >> 7) 40 #endif 41+#endif /* CONFIG_ARCH_MIPS64 */ 42 43 static void 44 hashtable_add (chunkinfoptr ci) 45