xref: /openbmc/qemu/accel/tcg/tb-jmp-cache.h (revision 2b74dd91)
1 /*
2  * The per-CPU TranslationBlock jump cache.
3  *
4  *  Copyright (c) 2003 Fabrice Bellard
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8 
9 #ifndef ACCEL_TCG_TB_JMP_CACHE_H
10 #define ACCEL_TCG_TB_JMP_CACHE_H
11 
12 #include "qemu/rcu.h"
13 #include "exec/cpu-common.h"
14 
15 #define TB_JMP_CACHE_BITS 12
16 #define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS)
17 
18 /*
19  * Invalidated in parallel; all accesses to 'tb' must be atomic.
20  * A valid entry is read/written by a single CPU, therefore there is
21  * no need for qatomic_rcu_read() and pc is always consistent with a
22  * non-NULL value of 'tb'.  Strictly speaking pc is only needed for
23  * CF_PCREL, but it's used always for simplicity.
24  */
25 typedef struct CPUJumpCache {
26     struct rcu_head rcu;
27     struct {
28         TranslationBlock *tb;
29         vaddr pc;
30     } array[TB_JMP_CACHE_SIZE];
31 } CPUJumpCache;
32 
33 #endif /* ACCEL_TCG_TB_JMP_CACHE_H */
34