]>
Commit | Line | Data |
---|---|---|
e1b89321 PC |
1 | /* |
2 | * internal execution defines for qemu | |
3 | * | |
4 | * Copyright (c) 2003 Fabrice Bellard | |
5 | * | |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Lesser General Public | |
8 | * License as published by the Free Software Foundation; either | |
9 | * version 2 of the License, or (at your option) any later version. | |
10 | * | |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Lesser General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Lesser General Public | |
17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
2a6a4076 MA |
20 | #ifndef EXEC_TB_HASH_H |
21 | #define EXEC_TB_HASH_H | |
e1b89321 | 22 | |
fe656e31 | 23 | #include "qemu/xxhash.h" |
42bd3228 | 24 | |
6f165318 EC |
25 | #ifdef CONFIG_SOFTMMU |
26 | ||
41da4bd6 PC |
27 | /* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for |
28 | addresses on the same page. The top bits are the same. This allows | |
29 | TLB invalidation to quickly clear a subset of the hash table. */ | |
30 | #define TB_JMP_PAGE_BITS (TB_JMP_CACHE_BITS / 2) | |
31 | #define TB_JMP_PAGE_SIZE (1 << TB_JMP_PAGE_BITS) | |
32 | #define TB_JMP_ADDR_MASK (TB_JMP_PAGE_SIZE - 1) | |
33 | #define TB_JMP_PAGE_MASK (TB_JMP_CACHE_SIZE - TB_JMP_PAGE_SIZE) | |
34 | ||
e1b89321 PC |
35 | static inline unsigned int tb_jmp_cache_hash_page(target_ulong pc) |
36 | { | |
37 | target_ulong tmp; | |
38 | tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); | |
39 | return (tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK; | |
40 | } | |
41 | ||
42 | static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc) | |
43 | { | |
44 | target_ulong tmp; | |
45 | tmp = pc ^ (pc >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)); | |
46 | return (((tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK) | |
47 | | (tmp & TB_JMP_ADDR_MASK)); | |
48 | } | |
49 | ||
6f165318 EC |
50 | #else |
51 | ||
52 | /* In user-mode we can get better hashing because we do not have a TLB */ | |
53 | static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc) | |
54 | { | |
55 | return (pc ^ (pc >> TB_JMP_CACHE_BITS)) & (TB_JMP_CACHE_SIZE - 1); | |
56 | } | |
57 | ||
58 | #endif /* CONFIG_SOFTMMU */ | |
59 | ||
42bd3228 | 60 | static inline |
61a67f71 | 61 | uint32_t tb_hash_func(tb_page_addr_t phys_pc, target_ulong pc, uint32_t flags, |
4e2ca83e | 62 | uint32_t cf_mask, uint32_t trace_vcpu_dstate) |
e1b89321 | 63 | { |
c971d8fa | 64 | return qemu_xxhash7(phys_pc, pc, flags, cf_mask, trace_vcpu_dstate); |
e1b89321 PC |
65 | } |
66 | ||
67 | #endif |