Richard Marian Thomaiyar | 14fddef | 2018-07-13 23:55:56 +0530 | [diff] [blame^] | 1 | commit 0f6bdc219e598de08a3f37887efa5dfa50e2b996 |
| 2 | Author: Aws Ismail <aws.ismail@windriver.com> |
| 3 | Date: Fri Jun 22 15:47:08 2012 -0400 |
| 4 | |
| 5 | Hash fix for MIPS64 and AARCH64 |
| 6 | |
| 7 | Samhain uses the addresses of local variables in generating hash |
| 8 | values. The hashing function is designed only for 32-bit values. |
| 9 | For MIPS64 when a 64-bit address is passed in the resulting hash |
| 10 | exceeds the limits of the underlying mechanism and samhain |
| 11 | ultimately fails. The solution is to simply take the lower |
| 12 | 32-bits of the address and use that in generating hash values. |
| 13 | |
| 14 | Signed-off-by: Greg Moffatt <greg.moffatt@windriver.com> |
| 15 | |
| 16 | Upstream-Status: Pending |
| 17 | |
| 18 | Signed-off-by: Aws Ismail <aws.ismail@windriver.com> |
| 19 | Signed-off-by: Jackie Huang <jackie.huang@windriver.com> |
| 20 | |
| 21 | diff --git a/src/dnmalloc.c b/src/dnmalloc.c |
| 22 | index 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) |