Skip to content

Commit 8809a2b

Browse files
committed
fix hashing
1 parent abd1d3a commit 8809a2b

File tree

5 files changed

+8
-5606
lines changed

5 files changed

+8
-5606
lines changed

accel/tcg/tcg-runtime.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "tcg/tcg.h"
3434

3535
#include "qemuafl/common.h"
36+
#include "qemu/xxhash.h"
3637

3738
void HELPER(afl_entry_routine)(CPUArchState *env) {
3839

@@ -282,7 +283,7 @@ void HELPER(afl_cmplog_rtn)(CPUArchState *env) {
282283
uintptr_t k = 0;
283284
#endif
284285

285-
k = (uintptr_t)(XXH64((u8 *)&k, sizeof(uintptr_t), HASH_CONST));
286+
k = (uintptr_t)(qemu_xxhash64_4((uint64_t)k, 0, 0, HASH_CONST));
286287
k &= (CMP_MAP_W - 1);
287288

288289
u32 hits = 0;

accel/tcg/translate-all.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565

6666
#include "qemuafl/common.h"
6767
#include "tcg/tcg-op.h"
68+
#include "qemu/xxhash.h"
6869

6970
#include <math.h>
7071

@@ -106,7 +107,7 @@ static void afl_gen_trace(target_ulong cur_loc) {
106107

107108
// cur_loc = (cur_loc >> 4) ^ (cur_loc << 8);
108109
// cur_loc &= MAP_SIZE - 1;
109-
cur_loc = (uintptr_t)(XXH64((u8 *)&cur_loc, sizeof(uintptr_t), HASH_CONST));
110+
cur_loc = (uintptr_t)(qemu_xxhash64_4((uint64_t)cur_loc, 0, 0, HASH_CONST));
110111
cur_loc &= (MAP_SIZE - 1);
111112

112113
/* Implement probabilistic instrumentation by looking at scrambled block

qemuafl/common.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
#include "imported/types.h"
3939
#include "imported/cmplog.h"
4040

41-
#define XXH_INLINE_ALL
42-
#include "xxhash.h"
43-
#undef XXH_INLINE_ALL
44-
4541
#include "api.h"
4642

4743
#define AFL_G2H g2h_untagged

qemuafl/cpu-translate.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#include "tcg/tcg.h"
3636
#include "tcg/tcg-op.h"
3737

38+
#include "qemu/xxhash.h"
39+
3840
#if TARGET_LONG_BITS == 64
3941
#define _DEFAULT_MO MO_64
4042
#else
@@ -48,7 +50,7 @@ static void afl_gen_compcov(target_ulong cur_loc, TCGv arg1, TCGv arg2,
4850

4951
if (__afl_cmp_map) {
5052

51-
cur_loc = (uintptr_t)(XXH64((u8 *)&cur_loc, sizeof(uintptr_t), HASH_CONST));
53+
cur_loc = (uintptr_t)(qemu_xxhash64_4((uint64_t)cur_loc, 0, 0, HASH_CONST));
5254
cur_loc &= (CMP_MAP_W - 1);
5355

5456
TCGv cur_loc_v = tcg_const_tl(cur_loc);
@@ -78,7 +80,7 @@ static void afl_gen_compcov(target_ulong cur_loc, TCGv arg1, TCGv arg2,
7880

7981
if (!is_imm && afl_compcov_level < 2) return;
8082

81-
cur_loc = (uintptr_t)(XXH64((u8 *)&cur_loc, sizeof(uintptr_t), HASH_CONST));
83+
cur_loc = (uintptr_t)(qemu_xxhash64_4((uint64_t)cur_loc, 0, 0, HASH_CONST));
8284
cur_loc &= (MAP_SIZE - 1);
8385

8486
TCGv cur_loc_v = tcg_const_tl(cur_loc);

0 commit comments

Comments
 (0)