|
25 | 25 | #include "exec/memattrs.h"
|
26 | 26 | #include "exec/vaddr.h"
|
27 | 27 |
|
28 |
| -#ifdef CONFIG_TCG |
29 |
| - |
30 |
| -#if !defined(CONFIG_USER_ONLY) |
31 |
| -/* cputlb.c */ |
| 28 | +#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) |
32 | 29 | void tlb_protect_code(ram_addr_t ram_addr);
|
33 | 30 | void tlb_unprotect_code(ram_addr_t ram_addr);
|
34 | 31 | #endif
|
35 | 32 |
|
36 |
| -#endif /* CONFIG_TCG */ |
37 |
| - |
38 | 33 | #ifndef CONFIG_USER_ONLY
|
39 |
| - |
40 | 34 | void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
|
41 | 35 | void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length);
|
42 |
| - |
43 | 36 | #endif
|
44 | 37 |
|
45 | 38 | /**
|
@@ -101,4 +94,193 @@ void tlb_set_page(CPUState *cpu, vaddr addr,
|
101 | 94 | hwaddr paddr, int prot,
|
102 | 95 | int mmu_idx, vaddr size);
|
103 | 96 |
|
104 |
| -#endif |
| 97 | +#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) |
| 98 | +/** |
| 99 | + * tlb_flush_page: |
| 100 | + * @cpu: CPU whose TLB should be flushed |
| 101 | + * @addr: virtual address of page to be flushed |
| 102 | + * |
| 103 | + * Flush one page from the TLB of the specified CPU, for all |
| 104 | + * MMU indexes. |
| 105 | + */ |
| 106 | +void tlb_flush_page(CPUState *cpu, vaddr addr); |
| 107 | + |
| 108 | +/** |
| 109 | + * tlb_flush_page_all_cpus_synced: |
| 110 | + * @cpu: src CPU of the flush |
| 111 | + * @addr: virtual address of page to be flushed |
| 112 | + * |
| 113 | + * Flush one page from the TLB of all CPUs, for all |
| 114 | + * MMU indexes. |
| 115 | + * |
| 116 | + * When this function returns, no CPUs will subsequently perform |
| 117 | + * translations using the flushed TLBs. |
| 118 | + */ |
| 119 | +void tlb_flush_page_all_cpus_synced(CPUState *src, vaddr addr); |
| 120 | + |
| 121 | +/** |
| 122 | + * tlb_flush: |
| 123 | + * @cpu: CPU whose TLB should be flushed |
| 124 | + * |
| 125 | + * Flush the entire TLB for the specified CPU. Most CPU architectures |
| 126 | + * allow the implementation to drop entries from the TLB at any time |
| 127 | + * so this is generally safe. If more selective flushing is required |
| 128 | + * use one of the other functions for efficiency. |
| 129 | + */ |
| 130 | +void tlb_flush(CPUState *cpu); |
| 131 | + |
| 132 | +/** |
| 133 | + * tlb_flush_all_cpus_synced: |
| 134 | + * @cpu: src CPU of the flush |
| 135 | + * |
| 136 | + * Flush the entire TLB for all CPUs, for all MMU indexes. |
| 137 | + * |
| 138 | + * When this function returns, no CPUs will subsequently perform |
| 139 | + * translations using the flushed TLBs. |
| 140 | + */ |
| 141 | +void tlb_flush_all_cpus_synced(CPUState *src_cpu); |
| 142 | + |
| 143 | +/** |
| 144 | + * tlb_flush_page_by_mmuidx: |
| 145 | + * @cpu: CPU whose TLB should be flushed |
| 146 | + * @addr: virtual address of page to be flushed |
| 147 | + * @idxmap: bitmap of MMU indexes to flush |
| 148 | + * |
| 149 | + * Flush one page from the TLB of the specified CPU, for the specified |
| 150 | + * MMU indexes. |
| 151 | + */ |
| 152 | +void tlb_flush_page_by_mmuidx(CPUState *cpu, vaddr addr, |
| 153 | + uint16_t idxmap); |
| 154 | + |
| 155 | +/** |
| 156 | + * tlb_flush_page_by_mmuidx_all_cpus_synced: |
| 157 | + * @cpu: Originating CPU of the flush |
| 158 | + * @addr: virtual address of page to be flushed |
| 159 | + * @idxmap: bitmap of MMU indexes to flush |
| 160 | + * |
| 161 | + * Flush one page from the TLB of all CPUs, for the specified |
| 162 | + * MMU indexes. |
| 163 | + * |
| 164 | + * When this function returns, no CPUs will subsequently perform |
| 165 | + * translations using the flushed TLBs. |
| 166 | + */ |
| 167 | +void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, |
| 168 | + uint16_t idxmap); |
| 169 | + |
| 170 | +/** |
| 171 | + * tlb_flush_by_mmuidx: |
| 172 | + * @cpu: CPU whose TLB should be flushed |
| 173 | + * @wait: If true ensure synchronisation by exiting the cpu_loop |
| 174 | + * @idxmap: bitmap of MMU indexes to flush |
| 175 | + * |
| 176 | + * Flush all entries from the TLB of the specified CPU, for the specified |
| 177 | + * MMU indexes. |
| 178 | + */ |
| 179 | +void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap); |
| 180 | + |
| 181 | +/** |
| 182 | + * tlb_flush_by_mmuidx_all_cpus_synced: |
| 183 | + * @cpu: Originating CPU of the flush |
| 184 | + * @idxmap: bitmap of MMU indexes to flush |
| 185 | + * |
| 186 | + * Flush all entries from the TLB of all CPUs, for the specified |
| 187 | + * MMU indexes. |
| 188 | + * |
| 189 | + * When this function returns, no CPUs will subsequently perform |
| 190 | + * translations using the flushed TLBs. |
| 191 | + */ |
| 192 | +void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, uint16_t idxmap); |
| 193 | + |
| 194 | +/** |
| 195 | + * tlb_flush_page_bits_by_mmuidx |
| 196 | + * @cpu: CPU whose TLB should be flushed |
| 197 | + * @addr: virtual address of page to be flushed |
| 198 | + * @idxmap: bitmap of mmu indexes to flush |
| 199 | + * @bits: number of significant bits in address |
| 200 | + * |
| 201 | + * Similar to tlb_flush_page_mask, but with a bitmap of indexes. |
| 202 | + */ |
| 203 | +void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, vaddr addr, |
| 204 | + uint16_t idxmap, unsigned bits); |
| 205 | + |
| 206 | +/* Similarly, with broadcast and syncing. */ |
| 207 | +void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, |
| 208 | + uint16_t idxmap, |
| 209 | + unsigned bits); |
| 210 | + |
| 211 | +/** |
| 212 | + * tlb_flush_range_by_mmuidx |
| 213 | + * @cpu: CPU whose TLB should be flushed |
| 214 | + * @addr: virtual address of the start of the range to be flushed |
| 215 | + * @len: length of range to be flushed |
| 216 | + * @idxmap: bitmap of mmu indexes to flush |
| 217 | + * @bits: number of significant bits in address |
| 218 | + * |
| 219 | + * For each mmuidx in @idxmap, flush all pages within [@addr,@addr+@len), |
| 220 | + * comparing only the low @bits worth of each virtual page. |
| 221 | + */ |
| 222 | +void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, |
| 223 | + vaddr len, uint16_t idxmap, |
| 224 | + unsigned bits); |
| 225 | + |
| 226 | +/* Similarly, with broadcast and syncing. */ |
| 227 | +void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, |
| 228 | + vaddr addr, |
| 229 | + vaddr len, |
| 230 | + uint16_t idxmap, |
| 231 | + unsigned bits); |
| 232 | +#else |
| 233 | +static inline void tlb_flush_page(CPUState *cpu, vaddr addr) |
| 234 | +{ |
| 235 | +} |
| 236 | +static inline void tlb_flush_page_all_cpus_synced(CPUState *src, vaddr addr) |
| 237 | +{ |
| 238 | +} |
| 239 | +static inline void tlb_flush(CPUState *cpu) |
| 240 | +{ |
| 241 | +} |
| 242 | +static inline void tlb_flush_all_cpus_synced(CPUState *src_cpu) |
| 243 | +{ |
| 244 | +} |
| 245 | +static inline void tlb_flush_page_by_mmuidx(CPUState *cpu, |
| 246 | + vaddr addr, uint16_t idxmap) |
| 247 | +{ |
| 248 | +} |
| 249 | + |
| 250 | +static inline void tlb_flush_by_mmuidx(CPUState *cpu, uint16_t idxmap) |
| 251 | +{ |
| 252 | +} |
| 253 | +static inline void tlb_flush_page_by_mmuidx_all_cpus_synced(CPUState *cpu, |
| 254 | + vaddr addr, |
| 255 | + uint16_t idxmap) |
| 256 | +{ |
| 257 | +} |
| 258 | +static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, |
| 259 | + uint16_t idxmap) |
| 260 | +{ |
| 261 | +} |
| 262 | +static inline void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, |
| 263 | + vaddr addr, |
| 264 | + uint16_t idxmap, |
| 265 | + unsigned bits) |
| 266 | +{ |
| 267 | +} |
| 268 | +static inline void |
| 269 | +tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *cpu, vaddr addr, |
| 270 | + uint16_t idxmap, unsigned bits) |
| 271 | +{ |
| 272 | +} |
| 273 | +static inline void tlb_flush_range_by_mmuidx(CPUState *cpu, vaddr addr, |
| 274 | + vaddr len, uint16_t idxmap, |
| 275 | + unsigned bits) |
| 276 | +{ |
| 277 | +} |
| 278 | +static inline void tlb_flush_range_by_mmuidx_all_cpus_synced(CPUState *cpu, |
| 279 | + vaddr addr, |
| 280 | + vaddr len, |
| 281 | + uint16_t idxmap, |
| 282 | + unsigned bits) |
| 283 | +{ |
| 284 | +} |
| 285 | +#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ |
| 286 | +#endif /* CPUTLB_H */ |
0 commit comments