xref: /openbmc/qemu/include/exec/tlb-common.h (revision 32dbebcc)
1 /*
2  * Common definitions for the softmmu tlb
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.1 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 #ifndef EXEC_TLB_COMMON_H
20 #define EXEC_TLB_COMMON_H 1
21 
22 #define CPU_TLB_ENTRY_BITS 5
23 
24 /* Minimalized TLB entry for use by TCG fast path. */
25 typedef union CPUTLBEntry {
26     struct {
27         uint64_t addr_read;
28         uint64_t addr_write;
29         uint64_t addr_code;
30         /*
31          * Addend to virtual address to get host address.  IO accesses
32          * use the corresponding iotlb value.
33          */
34         uintptr_t addend;
35     };
36     /*
37      * Padding to get a power of two size, as well as index
38      * access to addr_{read,write,code}.
39      */
40     uint64_t addr_idx[(1 << CPU_TLB_ENTRY_BITS) / sizeof(uint64_t)];
41 } CPUTLBEntry;
42 
43 QEMU_BUILD_BUG_ON(sizeof(CPUTLBEntry) != (1 << CPU_TLB_ENTRY_BITS));
44 
45 /*
46  * Data elements that are per MMU mode, accessed by the fast path.
47  * The structure is aligned to aid loading the pair with one insn.
48  */
49 typedef struct CPUTLBDescFast {
50     /* Contains (n_entries - 1) << CPU_TLB_ENTRY_BITS */
51     uintptr_t mask;
52     /* The array of tlb entries itself. */
53     CPUTLBEntry *table;
54 } CPUTLBDescFast QEMU_ALIGNED(2 * sizeof(void *));
55 
56 #endif /* EXEC_TLB_COMMON_H */
57