xref: /qemu/include/exec/tlb-flags.h (revision cc944932ecef3b7a56ae62d89dd92fb9e56c5cc8)
1 /*
2  * TLB flags definition
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 TLB_FLAGS_H
20 #define TLB_FLAGS_H
21 
22 #include "exec/cpu-defs.h"
23 
24 #ifdef CONFIG_USER_ONLY
25 
26 /*
27  * Allow some level of source compatibility with softmmu.  We do not
28  * support any of the more exotic features, so only invalid pages may
29  * be signaled by probe_access_flags().
30  */
31 #define TLB_INVALID_MASK    (1 << (TARGET_PAGE_BITS_MIN - 1))
32 #define TLB_MMIO            (1 << (TARGET_PAGE_BITS_MIN - 2))
33 #define TLB_WATCHPOINT      0
34 
35 #else
36 
37 /*
38  * Flags stored in the low bits of the TLB virtual address.
39  * These are defined so that fast path ram access is all zeros.
40  * The flags all must be between TARGET_PAGE_BITS and
41  * maximum address alignment bit.
42  *
43  * Use TARGET_PAGE_BITS_MIN so that these bits are constant
44  * when TARGET_PAGE_BITS_VARY is in effect.
45  *
46  * The count, if not the placement of these bits is known
47  * to tcg/tcg-op-ldst.c, check_max_alignment().
48  */
49 /* Zero if TLB entry is valid.  */
50 #define TLB_INVALID_MASK    (1 << (TARGET_PAGE_BITS_MIN - 1))
51 /*
52  * Set if TLB entry references a clean RAM page.  The iotlb entry will
53  * contain the page physical address.
54  */
55 #define TLB_NOTDIRTY        (1 << (TARGET_PAGE_BITS_MIN - 2))
56 /* Set if the slow path must be used; more flags in CPUTLBEntryFull. */
57 #define TLB_FORCE_SLOW      (1 << (TARGET_PAGE_BITS_MIN - 3))
58 
59 /*
60  * Use this mask to check interception with an alignment mask
61  * in a TCG backend.
62  */
63 #define TLB_FLAGS_MASK \
64     (TLB_INVALID_MASK | TLB_NOTDIRTY | TLB_FORCE_SLOW)
65 
66 /*
67  * Flags stored in CPUTLBEntryFull.slow_flags[x].
68  * TLB_FORCE_SLOW must be set in CPUTLBEntry.addr_idx[x].
69  */
70 /* Set if TLB entry requires byte swap.  */
71 #define TLB_BSWAP            (1 << 0)
72 /* Set if TLB entry contains a watchpoint.  */
73 #define TLB_WATCHPOINT       (1 << 1)
74 /* Set if TLB entry requires aligned accesses.  */
75 #define TLB_CHECK_ALIGNED    (1 << 2)
76 /* Set if TLB entry writes ignored.  */
77 #define TLB_DISCARD_WRITE    (1 << 3)
78 /* Set if TLB entry is an IO callback.  */
79 #define TLB_MMIO             (1 << 4)
80 
81 #define TLB_SLOW_FLAGS_MASK \
82     (TLB_BSWAP | TLB_WATCHPOINT | TLB_CHECK_ALIGNED | \
83      TLB_DISCARD_WRITE | TLB_MMIO)
84 
85 /* The two sets of flags must not overlap. */
86 QEMU_BUILD_BUG_ON(TLB_FLAGS_MASK & TLB_SLOW_FLAGS_MASK);
87 
88 #endif /* !CONFIG_USER_ONLY */
89 
90 #endif /* TLB_FLAGS_H */
91