2 * PowerPC MMU, TLB, SLB and BAT emulation helpers for QEMU.
4 * Copyright (c) 2003-2007 Jocelyn Mayer
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.
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.
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/>.
20 #include "qemu/osdep.h"
21 #include "qemu/units.h"
23 #include "sysemu/kvm.h"
25 #include "mmu-hash64.h"
26 #include "mmu-hash32.h"
27 #include "exec/exec-all.h"
28 #include "exec/page-protection.h"
30 #include "helper_regs.h"
31 #include "qemu/error-report.h"
32 #include "qemu/qemu-print.h"
34 #include "mmu-book3s-v3.h"
35 #include "mmu-radix64.h"
36 #include "mmu-booke.h"
37 #include "exec/helper-proto.h"
38 #include "exec/cpu_ldst.h"
40 /* #define FLUSH_ALL_TLBS */
42 /*****************************************************************************/
43 /* PowerPC MMU emulation */
45 /* Software driven TLB helpers */
46 static inline void ppc6xx_tlb_invalidate_all(CPUPPCState
*env
)
49 int nr
, max
= 2 * env
->nb_tlb
;
51 for (nr
= 0; nr
< max
; nr
++) {
52 tlb
= &env
->tlb
.tlb6
[nr
];
53 pte_invalidate(&tlb
->pte0
);
55 tlb_flush(env_cpu(env
));
58 static inline void ppc6xx_tlb_invalidate_virt2(CPUPPCState
*env
,
60 int is_code
, int match_epn
)
62 #if !defined(FLUSH_ALL_TLBS)
63 CPUState
*cs
= env_cpu(env
);
67 /* Invalidate ITLB + DTLB, all ways */
68 for (way
= 0; way
< env
->nb_ways
; way
++) {
69 nr
= ppc6xx_tlb_getnum(env
, eaddr
, way
, is_code
);
70 tlb
= &env
->tlb
.tlb6
[nr
];
71 if (pte_is_valid(tlb
->pte0
) && (match_epn
== 0 || eaddr
== tlb
->EPN
)) {
72 qemu_log_mask(CPU_LOG_MMU
, "TLB invalidate %d/%d "
73 TARGET_FMT_lx
"\n", nr
, env
->nb_tlb
, eaddr
);
74 pte_invalidate(&tlb
->pte0
);
75 tlb_flush_page(cs
, tlb
->EPN
);
79 /* XXX: PowerPC specification say this is valid as well */
80 ppc6xx_tlb_invalidate_all(env
);
84 static inline void ppc6xx_tlb_invalidate_virt(CPUPPCState
*env
,
85 target_ulong eaddr
, int is_code
)
87 ppc6xx_tlb_invalidate_virt2(env
, eaddr
, is_code
, 0);
90 static void ppc6xx_tlb_store(CPUPPCState
*env
, target_ulong EPN
, int way
,
91 int is_code
, target_ulong pte0
, target_ulong pte1
)
96 nr
= ppc6xx_tlb_getnum(env
, EPN
, way
, is_code
);
97 tlb
= &env
->tlb
.tlb6
[nr
];
98 qemu_log_mask(CPU_LOG_MMU
, "Set TLB %d/%d EPN " TARGET_FMT_lx
" PTE0 "
99 TARGET_FMT_lx
" PTE1 " TARGET_FMT_lx
"\n", nr
, env
->nb_tlb
,
101 /* Invalidate any pending reference in QEMU for this virtual address */
102 ppc6xx_tlb_invalidate_virt2(env
, EPN
, is_code
, 1);
106 /* Store last way for LRU mechanism */
110 /* Helpers specific to PowerPC 40x implementations */
111 static inline void ppc4xx_tlb_invalidate_all(CPUPPCState
*env
)
116 for (i
= 0; i
< env
->nb_tlb
; i
++) {
117 tlb
= &env
->tlb
.tlbe
[i
];
118 tlb
->prot
&= ~PAGE_VALID
;
120 tlb_flush(env_cpu(env
));
123 static void booke206_flush_tlb(CPUPPCState
*env
, int flags
,
124 const int check_iprot
)
128 ppcmas_tlb_t
*tlb
= env
->tlb
.tlbm
;
130 for (i
= 0; i
< BOOKE206_MAX_TLBN
; i
++) {
131 if (flags
& (1 << i
)) {
132 tlb_size
= booke206_tlb_size(env
, i
);
133 for (j
= 0; j
< tlb_size
; j
++) {
134 if (!check_iprot
|| !(tlb
[j
].mas1
& MAS1_IPROT
)) {
135 tlb
[j
].mas1
&= ~MAS1_VALID
;
139 tlb
+= booke206_tlb_size(env
, i
);
142 tlb_flush(env_cpu(env
));
145 /*****************************************************************************/
146 /* BATs management */
147 #if !defined(FLUSH_ALL_TLBS)
148 static inline void do_invalidate_BAT(CPUPPCState
*env
, target_ulong BATu
,
151 CPUState
*cs
= env_cpu(env
);
152 target_ulong base
, end
, page
;
154 base
= BATu
& ~0x0001FFFF;
155 end
= base
+ mask
+ 0x00020000;
156 if (((end
- base
) >> TARGET_PAGE_BITS
) > 1024) {
157 /* Flushing 1024 4K pages is slower than a complete flush */
158 qemu_log_mask(CPU_LOG_MMU
, "Flush all BATs\n");
160 qemu_log_mask(CPU_LOG_MMU
, "Flush done\n");
163 qemu_log_mask(CPU_LOG_MMU
, "Flush BAT from " TARGET_FMT_lx
164 " to " TARGET_FMT_lx
" (" TARGET_FMT_lx
")\n",
166 for (page
= base
; page
!= end
; page
+= TARGET_PAGE_SIZE
) {
167 tlb_flush_page(cs
, page
);
169 qemu_log_mask(CPU_LOG_MMU
, "Flush done\n");
173 static inline void dump_store_bat(CPUPPCState
*env
, char ID
, int ul
, int nr
,
176 qemu_log_mask(CPU_LOG_MMU
, "Set %cBAT%d%c to " TARGET_FMT_lx
" ("
177 TARGET_FMT_lx
")\n", ID
, nr
, ul
== 0 ? 'u' : 'l',
181 void helper_store_ibatu(CPUPPCState
*env
, uint32_t nr
, target_ulong value
)
185 dump_store_bat(env
, 'I', 0, nr
, value
);
186 if (env
->IBAT
[0][nr
] != value
) {
187 mask
= (value
<< 15) & 0x0FFE0000UL
;
188 #if !defined(FLUSH_ALL_TLBS)
189 do_invalidate_BAT(env
, env
->IBAT
[0][nr
], mask
);
192 * When storing valid upper BAT, mask BEPI and BRPN and
193 * invalidate all TLBs covered by this BAT
195 mask
= (value
<< 15) & 0x0FFE0000UL
;
196 env
->IBAT
[0][nr
] = (value
& 0x00001FFFUL
) |
197 (value
& ~0x0001FFFFUL
& ~mask
);
198 env
->IBAT
[1][nr
] = (env
->IBAT
[1][nr
] & 0x0000007B) |
199 (env
->IBAT
[1][nr
] & ~0x0001FFFF & ~mask
);
200 #if !defined(FLUSH_ALL_TLBS)
201 do_invalidate_BAT(env
, env
->IBAT
[0][nr
], mask
);
203 tlb_flush(env_cpu(env
));
208 void helper_store_ibatl(CPUPPCState
*env
, uint32_t nr
, target_ulong value
)
210 dump_store_bat(env
, 'I', 1, nr
, value
);
211 env
->IBAT
[1][nr
] = value
;
214 void helper_store_dbatu(CPUPPCState
*env
, uint32_t nr
, target_ulong value
)
218 dump_store_bat(env
, 'D', 0, nr
, value
);
219 if (env
->DBAT
[0][nr
] != value
) {
221 * When storing valid upper BAT, mask BEPI and BRPN and
222 * invalidate all TLBs covered by this BAT
224 mask
= (value
<< 15) & 0x0FFE0000UL
;
225 #if !defined(FLUSH_ALL_TLBS)
226 do_invalidate_BAT(env
, env
->DBAT
[0][nr
], mask
);
228 mask
= (value
<< 15) & 0x0FFE0000UL
;
229 env
->DBAT
[0][nr
] = (value
& 0x00001FFFUL
) |
230 (value
& ~0x0001FFFFUL
& ~mask
);
231 env
->DBAT
[1][nr
] = (env
->DBAT
[1][nr
] & 0x0000007B) |
232 (env
->DBAT
[1][nr
] & ~0x0001FFFF & ~mask
);
233 #if !defined(FLUSH_ALL_TLBS)
234 do_invalidate_BAT(env
, env
->DBAT
[0][nr
], mask
);
236 tlb_flush(env_cpu(env
));
241 void helper_store_dbatl(CPUPPCState
*env
, uint32_t nr
, target_ulong value
)
243 dump_store_bat(env
, 'D', 1, nr
, value
);
244 env
->DBAT
[1][nr
] = value
;
247 /*****************************************************************************/
249 void ppc_tlb_invalidate_all(CPUPPCState
*env
)
251 #if defined(TARGET_PPC64)
252 if (mmu_is_64bit(env
->mmu_model
)) {
253 env
->tlb_need_flush
= 0;
254 tlb_flush(env_cpu(env
));
256 #endif /* defined(TARGET_PPC64) */
257 switch (env
->mmu_model
) {
258 case POWERPC_MMU_SOFT_6xx
:
259 ppc6xx_tlb_invalidate_all(env
);
261 case POWERPC_MMU_SOFT_4xx
:
262 ppc4xx_tlb_invalidate_all(env
);
264 case POWERPC_MMU_REAL
:
265 cpu_abort(env_cpu(env
), "No TLB for PowerPC 4xx in real mode\n");
267 case POWERPC_MMU_MPC8xx
:
269 cpu_abort(env_cpu(env
), "MPC8xx MMU model is not implemented\n");
271 case POWERPC_MMU_BOOKE
:
272 tlb_flush(env_cpu(env
));
274 case POWERPC_MMU_BOOKE206
:
275 booke206_flush_tlb(env
, -1, 0);
277 case POWERPC_MMU_32B
:
278 env
->tlb_need_flush
= 0;
279 tlb_flush(env_cpu(env
));
283 cpu_abort(env_cpu(env
), "Unknown MMU model %x\n", env
->mmu_model
);
288 void ppc_tlb_invalidate_one(CPUPPCState
*env
, target_ulong addr
)
290 #if !defined(FLUSH_ALL_TLBS)
291 addr
&= TARGET_PAGE_MASK
;
292 #if defined(TARGET_PPC64)
293 if (mmu_is_64bit(env
->mmu_model
)) {
294 /* tlbie invalidate TLBs for all segments */
296 * XXX: given the fact that there are too many segments to invalidate,
297 * and we still don't have a tlb_flush_mask(env, n, mask) in QEMU,
298 * we just invalidate all TLBs
300 env
->tlb_need_flush
|= TLB_NEED_LOCAL_FLUSH
;
302 #endif /* defined(TARGET_PPC64) */
303 switch (env
->mmu_model
) {
304 case POWERPC_MMU_SOFT_6xx
:
305 ppc6xx_tlb_invalidate_virt(env
, addr
, 0);
306 ppc6xx_tlb_invalidate_virt(env
, addr
, 1);
308 case POWERPC_MMU_32B
:
310 * Actual CPUs invalidate entire congruence classes based on
311 * the geometry of their TLBs and some OSes take that into
312 * account, we just mark the TLB to be flushed later (context
313 * synchronizing event or sync instruction on 32-bit).
315 env
->tlb_need_flush
|= TLB_NEED_LOCAL_FLUSH
;
318 /* Should never reach here with other MMU models */
322 ppc_tlb_invalidate_all(env
);
326 /*****************************************************************************/
327 /* Special registers manipulation */
329 /* Segment registers load and store */
330 target_ulong
helper_load_sr(CPUPPCState
*env
, target_ulong sr_num
)
332 #if defined(TARGET_PPC64)
333 if (mmu_is_64bit(env
->mmu_model
)) {
338 return env
->sr
[sr_num
];
341 void helper_store_sr(CPUPPCState
*env
, target_ulong srnum
, target_ulong value
)
343 qemu_log_mask(CPU_LOG_MMU
,
344 "%s: reg=%d " TARGET_FMT_lx
" " TARGET_FMT_lx
"\n", __func__
,
345 (int)srnum
, value
, env
->sr
[srnum
]);
346 #if defined(TARGET_PPC64)
347 if (mmu_is_64bit(env
->mmu_model
)) {
348 PowerPCCPU
*cpu
= env_archcpu(env
);
352 esid
= ((uint64_t)(srnum
& 0xf) << 28) | SLB_ESID_V
;
355 vsid
= (value
& 0xfffffff) << 12;
357 vsid
|= ((value
>> 27) & 0xf) << 8;
359 ppc_store_slb(cpu
, srnum
, esid
, vsid
);
362 if (env
->sr
[srnum
] != value
) {
363 env
->sr
[srnum
] = value
;
365 * Invalidating 256MB of virtual memory in 4kB pages is way
366 * longer than flushing the whole TLB.
368 #if !defined(FLUSH_ALL_TLBS) && 0
370 target_ulong page
, end
;
371 /* Invalidate 256 MB of virtual memory */
372 page
= (16 << 20) * srnum
;
373 end
= page
+ (16 << 20);
374 for (; page
!= end
; page
+= TARGET_PAGE_SIZE
) {
375 tlb_flush_page(env_cpu(env
), page
);
379 env
->tlb_need_flush
|= TLB_NEED_LOCAL_FLUSH
;
385 void helper_tlbia(CPUPPCState
*env
)
387 ppc_tlb_invalidate_all(env
);
390 void helper_tlbie(CPUPPCState
*env
, target_ulong addr
)
392 ppc_tlb_invalidate_one(env
, addr
);
395 #if defined(TARGET_PPC64)
397 /* Invalidation Selector */
398 #define TLBIE_IS_VA 0
399 #define TLBIE_IS_PID 1
400 #define TLBIE_IS_LPID 2
401 #define TLBIE_IS_ALL 3
403 /* Radix Invalidation Control */
404 #define TLBIE_RIC_TLB 0
405 #define TLBIE_RIC_PWC 1
406 #define TLBIE_RIC_ALL 2
407 #define TLBIE_RIC_GRP 3
409 /* Radix Actual Page sizes */
410 #define TLBIE_R_AP_4K 0
411 #define TLBIE_R_AP_64K 5
412 #define TLBIE_R_AP_2M 1
413 #define TLBIE_R_AP_1G 2
416 #define TLBIE_RB_EPN_MASK PPC_BITMASK(0, 51)
417 #define TLBIE_RB_IS_MASK PPC_BITMASK(52, 53)
418 #define TLBIE_RB_AP_MASK PPC_BITMASK(56, 58)
420 void helper_tlbie_isa300(CPUPPCState
*env
, target_ulong rb
, target_ulong rs
,
423 unsigned ric
= (flags
& TLBIE_F_RIC_MASK
) >> TLBIE_F_RIC_SHIFT
;
425 * With the exception of the checks for invalid instruction forms,
426 * PRS is currently ignored, because we don't know if a given TLB entry
427 * is process or partition scoped.
429 bool prs
= flags
& TLBIE_F_PRS
;
430 bool r
= flags
& TLBIE_F_R
;
431 bool local
= flags
& TLBIE_F_LOCAL
;
433 unsigned is
= extract64(rb
, PPC_BIT_NR(53), 2);
434 unsigned ap
; /* actual page size */
435 target_ulong addr
, pgoffs_mask
;
437 qemu_log_mask(CPU_LOG_MMU
,
438 "%s: local=%d addr=" TARGET_FMT_lx
" ric=%u prs=%d r=%d is=%u\n",
439 __func__
, local
, rb
& TARGET_PAGE_MASK
, ric
, prs
, r
, is
);
441 effR
= FIELD_EX64(env
->msr
, MSR
, HV
) ? r
: env
->spr
[SPR_LPCR
] & LPCR_HR
;
443 /* Partial TLB invalidation is supported for Radix only for now. */
448 /* Check for invalid instruction forms (effR=1). */
449 if (unlikely(ric
== TLBIE_RIC_GRP
||
450 ((ric
== TLBIE_RIC_PWC
|| ric
== TLBIE_RIC_ALL
) &&
451 is
== TLBIE_IS_VA
) ||
452 (!prs
&& is
== TLBIE_IS_PID
))) {
453 qemu_log_mask(LOG_GUEST_ERROR
,
454 "%s: invalid instruction form: ric=%u prs=%d r=%d is=%u\n",
455 __func__
, ric
, prs
, r
, is
);
459 /* We don't cache Page Walks. */
460 if (ric
== TLBIE_RIC_PWC
) {
462 unsigned set
= extract64(rb
, PPC_BIT_NR(51), 12);
464 qemu_log_mask(LOG_GUEST_ERROR
, "%s: invalid set: %d\n",
473 * Invalidation by LPID or PID is not supported, so fallback
474 * to full TLB flush in these cases.
476 if (is
!= TLBIE_IS_VA
) {
481 * The results of an attempt to invalidate a translation outside of
482 * quadrant 0 for Radix Tree translation (effR=1, RIC=0, PRS=1, IS=0,
483 * and EA 0:1 != 0b00) are boundedly undefined.
485 if (unlikely(ric
== TLBIE_RIC_TLB
&& prs
&& is
== TLBIE_IS_VA
&&
486 (rb
& R_EADDR_QUADRANT
) != R_EADDR_QUADRANT0
)) {
487 qemu_log_mask(LOG_GUEST_ERROR
,
488 "%s: attempt to invalidate a translation outside of quadrant 0\n",
493 assert(is
== TLBIE_IS_VA
);
494 assert(ric
== TLBIE_RIC_TLB
|| ric
== TLBIE_RIC_ALL
);
496 ap
= extract64(rb
, PPC_BIT_NR(58), 3);
499 pgoffs_mask
= 0xfffull
;
503 pgoffs_mask
= 0xffffull
;
507 pgoffs_mask
= 0x1fffffull
;
511 pgoffs_mask
= 0x3fffffffull
;
516 * If the value specified in RS 0:31, RS 32:63, RB 54:55, RB 56:58,
517 * RB 44:51, or RB 56:63, when it is needed to perform the specified
518 * operation, is not supported by the implementation, the instruction
519 * is treated as if the instruction form were invalid.
521 qemu_log_mask(LOG_GUEST_ERROR
, "%s: invalid AP: %d\n", __func__
, ap
);
525 addr
= rb
& TLBIE_RB_EPN_MASK
& ~pgoffs_mask
;
528 tlb_flush_page(env_cpu(env
), addr
);
530 tlb_flush_page_all_cpus_synced(env_cpu(env
), addr
);
535 env
->tlb_need_flush
|= TLB_NEED_LOCAL_FLUSH
;
537 env
->tlb_need_flush
|= TLB_NEED_GLOBAL_FLUSH
;
542 raise_exception_err_ra(env
, POWERPC_EXCP_PROGRAM
,
544 POWERPC_EXCP_INVAL_INVAL
, GETPC());
549 void helper_tlbiva(CPUPPCState
*env
, target_ulong addr
)
551 /* tlbiva instruction only exists on BookE */
552 assert(env
->mmu_model
== POWERPC_MMU_BOOKE
);
554 cpu_abort(env_cpu(env
), "BookE MMU model is not implemented\n");
557 /* Software driven TLBs management */
558 /* PowerPC 602/603 software TLB load instructions helpers */
559 static void do_6xx_tlb(CPUPPCState
*env
, target_ulong new_EPN
, int is_code
)
561 target_ulong RPN
, CMP
, EPN
;
564 RPN
= env
->spr
[SPR_RPA
];
566 CMP
= env
->spr
[SPR_ICMP
];
567 EPN
= env
->spr
[SPR_IMISS
];
569 CMP
= env
->spr
[SPR_DCMP
];
570 EPN
= env
->spr
[SPR_DMISS
];
572 way
= (env
->spr
[SPR_SRR1
] >> 17) & 1;
573 (void)EPN
; /* avoid a compiler warning */
574 qemu_log_mask(CPU_LOG_MMU
, "%s: EPN " TARGET_FMT_lx
" " TARGET_FMT_lx
575 " PTE0 " TARGET_FMT_lx
" PTE1 " TARGET_FMT_lx
" way %d\n",
576 __func__
, new_EPN
, EPN
, CMP
, RPN
, way
);
578 ppc6xx_tlb_store(env
, (uint32_t)(new_EPN
& TARGET_PAGE_MASK
),
579 way
, is_code
, CMP
, RPN
);
582 void helper_6xx_tlbd(CPUPPCState
*env
, target_ulong EPN
)
584 do_6xx_tlb(env
, EPN
, 0);
587 void helper_6xx_tlbi(CPUPPCState
*env
, target_ulong EPN
)
589 do_6xx_tlb(env
, EPN
, 1);
592 static inline target_ulong
booke_tlb_to_page_size(int size
)
594 return 1024 << (2 * size
);
597 static inline int booke_page_size_to_tlb(target_ulong page_size
)
635 #if defined(TARGET_PPC64)
636 case 0x000100000000ULL
:
639 case 0x000400000000ULL
:
642 case 0x001000000000ULL
:
645 case 0x004000000000ULL
:
648 case 0x010000000000ULL
:
660 /* Helpers for 4xx TLB management */
661 #define PPC4XX_TLB_ENTRY_MASK 0x0000003f /* Mask for 64 TLB entries */
663 #define PPC4XX_TLBHI_V 0x00000040
664 #define PPC4XX_TLBHI_E 0x00000020
665 #define PPC4XX_TLBHI_SIZE_MIN 0
666 #define PPC4XX_TLBHI_SIZE_MAX 7
667 #define PPC4XX_TLBHI_SIZE_DEFAULT 1
668 #define PPC4XX_TLBHI_SIZE_SHIFT 7
669 #define PPC4XX_TLBHI_SIZE_MASK 0x00000007
671 #define PPC4XX_TLBLO_EX 0x00000200
672 #define PPC4XX_TLBLO_WR 0x00000100
673 #define PPC4XX_TLBLO_ATTR_MASK 0x000000FF
674 #define PPC4XX_TLBLO_RPN_MASK 0xFFFFFC00
676 void helper_store_40x_pid(CPUPPCState
*env
, target_ulong val
)
678 if (env
->spr
[SPR_40x_PID
] != val
) {
679 env
->spr
[SPR_40x_PID
] = val
;
680 env
->tlb_need_flush
|= TLB_NEED_LOCAL_FLUSH
;
684 target_ulong
helper_4xx_tlbre_hi(CPUPPCState
*env
, target_ulong entry
)
690 entry
&= PPC4XX_TLB_ENTRY_MASK
;
691 tlb
= &env
->tlb
.tlbe
[entry
];
693 if (tlb
->prot
& PAGE_VALID
) {
694 ret
|= PPC4XX_TLBHI_V
;
696 size
= booke_page_size_to_tlb(tlb
->size
);
697 if (size
< PPC4XX_TLBHI_SIZE_MIN
|| size
> PPC4XX_TLBHI_SIZE_MAX
) {
698 size
= PPC4XX_TLBHI_SIZE_DEFAULT
;
700 ret
|= size
<< PPC4XX_TLBHI_SIZE_SHIFT
;
701 helper_store_40x_pid(env
, tlb
->PID
);
705 target_ulong
helper_4xx_tlbre_lo(CPUPPCState
*env
, target_ulong entry
)
710 entry
&= PPC4XX_TLB_ENTRY_MASK
;
711 tlb
= &env
->tlb
.tlbe
[entry
];
713 if (tlb
->prot
& PAGE_EXEC
) {
714 ret
|= PPC4XX_TLBLO_EX
;
716 if (tlb
->prot
& PAGE_WRITE
) {
717 ret
|= PPC4XX_TLBLO_WR
;
722 static void ppcemb_tlb_flush(CPUState
*cs
, ppcemb_tlb_t
*tlb
)
724 unsigned mmu_idx
= 0;
726 if (tlb
->prot
& 0xf) {
729 if ((tlb
->prot
>> 4) & 0xf) {
736 tlb_flush_range_by_mmuidx(cs
, tlb
->EPN
, tlb
->size
, mmu_idx
,
740 void helper_4xx_tlbwe_hi(CPUPPCState
*env
, target_ulong entry
,
743 CPUState
*cs
= env_cpu(env
);
746 qemu_log_mask(CPU_LOG_MMU
, "%s entry %d val " TARGET_FMT_lx
"\n",
747 __func__
, (int)entry
,
749 entry
&= PPC4XX_TLB_ENTRY_MASK
;
750 tlb
= &env
->tlb
.tlbe
[entry
];
751 /* Invalidate previous TLB (if it's valid) */
752 if ((tlb
->prot
& PAGE_VALID
) && tlb
->PID
== env
->spr
[SPR_40x_PID
]) {
753 qemu_log_mask(CPU_LOG_MMU
, "%s: invalidate old TLB %d start "
754 TARGET_FMT_lx
" end " TARGET_FMT_lx
"\n", __func__
,
755 (int)entry
, tlb
->EPN
, tlb
->EPN
+ tlb
->size
);
756 ppcemb_tlb_flush(cs
, tlb
);
758 tlb
->size
= booke_tlb_to_page_size((val
>> PPC4XX_TLBHI_SIZE_SHIFT
)
759 & PPC4XX_TLBHI_SIZE_MASK
);
761 * We cannot handle TLB size < TARGET_PAGE_SIZE.
762 * If this ever occurs, we should implement TARGET_PAGE_BITS_VARY
764 if ((val
& PPC4XX_TLBHI_V
) && tlb
->size
< TARGET_PAGE_SIZE
) {
765 cpu_abort(cs
, "TLB size " TARGET_FMT_lu
" < %u "
766 "are not supported (%d)\n"
767 "Please implement TARGET_PAGE_BITS_VARY\n",
768 tlb
->size
, TARGET_PAGE_SIZE
, (int)((val
>> 7) & 0x7));
770 tlb
->EPN
= val
& ~(tlb
->size
- 1);
771 if (val
& PPC4XX_TLBHI_V
) {
772 tlb
->prot
|= PAGE_VALID
;
773 if (val
& PPC4XX_TLBHI_E
) {
774 /* XXX: TO BE FIXED */
776 "Little-endian TLB entries are not supported by now\n");
779 tlb
->prot
&= ~PAGE_VALID
;
781 tlb
->PID
= env
->spr
[SPR_40x_PID
]; /* PID */
782 qemu_log_mask(CPU_LOG_MMU
, "%s: set up TLB %d RPN " HWADDR_FMT_plx
783 " EPN " TARGET_FMT_lx
" size " TARGET_FMT_lx
784 " prot %c%c%c%c PID %d\n", __func__
,
785 (int)entry
, tlb
->RPN
, tlb
->EPN
, tlb
->size
,
786 tlb
->prot
& PAGE_READ
? 'r' : '-',
787 tlb
->prot
& PAGE_WRITE
? 'w' : '-',
788 tlb
->prot
& PAGE_EXEC
? 'x' : '-',
789 tlb
->prot
& PAGE_VALID
? 'v' : '-', (int)tlb
->PID
);
792 void helper_4xx_tlbwe_lo(CPUPPCState
*env
, target_ulong entry
,
795 CPUState
*cs
= env_cpu(env
);
798 qemu_log_mask(CPU_LOG_MMU
, "%s entry %i val " TARGET_FMT_lx
"\n",
799 __func__
, (int)entry
, val
);
800 entry
&= PPC4XX_TLB_ENTRY_MASK
;
801 tlb
= &env
->tlb
.tlbe
[entry
];
802 /* Invalidate previous TLB (if it's valid) */
803 if ((tlb
->prot
& PAGE_VALID
) && tlb
->PID
== env
->spr
[SPR_40x_PID
]) {
804 qemu_log_mask(CPU_LOG_MMU
, "%s: invalidate old TLB %d start "
805 TARGET_FMT_lx
" end " TARGET_FMT_lx
"\n", __func__
,
806 (int)entry
, tlb
->EPN
, tlb
->EPN
+ tlb
->size
);
807 ppcemb_tlb_flush(cs
, tlb
);
809 tlb
->attr
= val
& PPC4XX_TLBLO_ATTR_MASK
;
810 tlb
->RPN
= val
& PPC4XX_TLBLO_RPN_MASK
;
811 tlb
->prot
= PAGE_READ
;
812 if (val
& PPC4XX_TLBLO_EX
) {
813 tlb
->prot
|= PAGE_EXEC
;
815 if (val
& PPC4XX_TLBLO_WR
) {
816 tlb
->prot
|= PAGE_WRITE
;
818 qemu_log_mask(CPU_LOG_MMU
, "%s: set up TLB %d RPN " HWADDR_FMT_plx
819 " EPN " TARGET_FMT_lx
820 " size " TARGET_FMT_lx
" prot %c%c%c%c PID %d\n", __func__
,
821 (int)entry
, tlb
->RPN
, tlb
->EPN
, tlb
->size
,
822 tlb
->prot
& PAGE_READ
? 'r' : '-',
823 tlb
->prot
& PAGE_WRITE
? 'w' : '-',
824 tlb
->prot
& PAGE_EXEC
? 'x' : '-',
825 tlb
->prot
& PAGE_VALID
? 'v' : '-', (int)tlb
->PID
);
828 target_ulong
helper_4xx_tlbsx(CPUPPCState
*env
, target_ulong address
)
830 return ppcemb_tlb_search(env
, address
, env
->spr
[SPR_40x_PID
]);
833 static bool mmubooke_pid_match(CPUPPCState
*env
, ppcemb_tlb_t
*tlb
)
835 if (tlb
->PID
== env
->spr
[SPR_BOOKE_PID
]) {
842 if (env
->spr
[SPR_BOOKE_PID1
] && tlb
->PID
== env
->spr
[SPR_BOOKE_PID1
]) {
845 if (env
->spr
[SPR_BOOKE_PID2
] && tlb
->PID
== env
->spr
[SPR_BOOKE_PID2
]) {
852 /* PowerPC 440 TLB management */
853 void helper_440_tlbwe(CPUPPCState
*env
, uint32_t word
, target_ulong entry
,
858 qemu_log_mask(CPU_LOG_MMU
, "%s word %d entry %d value " TARGET_FMT_lx
"\n",
859 __func__
, word
, (int)entry
, value
);
861 tlb
= &env
->tlb
.tlbe
[entry
];
863 /* Invalidate previous TLB (if it's valid) */
864 if ((tlb
->prot
& PAGE_VALID
) && mmubooke_pid_match(env
, tlb
)) {
865 qemu_log_mask(CPU_LOG_MMU
, "%s: invalidate old TLB %d start "
866 TARGET_FMT_lx
" end " TARGET_FMT_lx
"\n", __func__
,
867 (int)entry
, tlb
->EPN
, tlb
->EPN
+ tlb
->size
);
868 ppcemb_tlb_flush(env_cpu(env
), tlb
);
873 /* Just here to please gcc */
875 tlb
->EPN
= value
& 0xFFFFFC00;
876 tlb
->size
= booke_tlb_to_page_size((value
>> 4) & 0xF);
878 tlb
->attr
|= (value
>> 8) & 1;
880 tlb
->prot
|= PAGE_VALID
;
882 tlb
->prot
&= ~PAGE_VALID
;
884 tlb
->PID
= env
->spr
[SPR_440_MMUCR
] & 0x000000FF;
887 tlb
->RPN
= value
& 0xFFFFFC0F;
890 tlb
->attr
= (tlb
->attr
& 0x1) | (value
& 0x0000FF00);
891 tlb
->prot
= tlb
->prot
& PAGE_VALID
;
893 tlb
->prot
|= PAGE_READ
<< 4;
896 tlb
->prot
|= PAGE_WRITE
<< 4;
899 tlb
->prot
|= PAGE_EXEC
<< 4;
902 tlb
->prot
|= PAGE_READ
;
905 tlb
->prot
|= PAGE_WRITE
;
908 tlb
->prot
|= PAGE_EXEC
;
914 target_ulong
helper_440_tlbre(CPUPPCState
*env
, uint32_t word
,
922 tlb
= &env
->tlb
.tlbe
[entry
];
925 /* Just here to please gcc */
928 size
= booke_page_size_to_tlb(tlb
->size
);
929 if (size
< 0 || size
> 0xF) {
933 if (tlb
->attr
& 0x1) {
936 if (tlb
->prot
& PAGE_VALID
) {
939 env
->spr
[SPR_440_MMUCR
] &= ~0x000000FF;
940 env
->spr
[SPR_440_MMUCR
] |= tlb
->PID
;
946 ret
= tlb
->attr
& ~0x1;
947 if (tlb
->prot
& (PAGE_READ
<< 4)) {
950 if (tlb
->prot
& (PAGE_WRITE
<< 4)) {
953 if (tlb
->prot
& (PAGE_EXEC
<< 4)) {
956 if (tlb
->prot
& PAGE_READ
) {
959 if (tlb
->prot
& PAGE_WRITE
) {
962 if (tlb
->prot
& PAGE_EXEC
) {
970 target_ulong
helper_440_tlbsx(CPUPPCState
*env
, target_ulong address
)
972 return ppcemb_tlb_search(env
, address
, env
->spr
[SPR_440_MMUCR
] & 0xFF);
975 /* PowerPC BookE 2.06 TLB management */
977 static ppcmas_tlb_t
*booke206_cur_tlb(CPUPPCState
*env
)
979 uint32_t tlbncfg
= 0;
980 int esel
= (env
->spr
[SPR_BOOKE_MAS0
] & MAS0_ESEL_MASK
) >> MAS0_ESEL_SHIFT
;
981 int ea
= (env
->spr
[SPR_BOOKE_MAS2
] & MAS2_EPN_MASK
);
984 tlb
= (env
->spr
[SPR_BOOKE_MAS0
] & MAS0_TLBSEL_MASK
) >> MAS0_TLBSEL_SHIFT
;
985 tlbncfg
= env
->spr
[SPR_BOOKE_TLB0CFG
+ tlb
];
987 if ((tlbncfg
& TLBnCFG_HES
) && (env
->spr
[SPR_BOOKE_MAS0
] & MAS0_HES
)) {
988 cpu_abort(env_cpu(env
), "we don't support HES yet\n");
991 return booke206_get_tlbm(env
, tlb
, ea
, esel
);
994 void helper_booke_setpid(CPUPPCState
*env
, uint32_t pidn
, target_ulong pid
)
996 env
->spr
[pidn
] = pid
;
997 /* changing PIDs mean we're in a different address space now */
998 tlb_flush(env_cpu(env
));
1001 void helper_booke_set_eplc(CPUPPCState
*env
, target_ulong val
)
1003 env
->spr
[SPR_BOOKE_EPLC
] = val
& EPID_MASK
;
1004 tlb_flush_by_mmuidx(env_cpu(env
), 1 << PPC_TLB_EPID_LOAD
);
1006 void helper_booke_set_epsc(CPUPPCState
*env
, target_ulong val
)
1008 env
->spr
[SPR_BOOKE_EPSC
] = val
& EPID_MASK
;
1009 tlb_flush_by_mmuidx(env_cpu(env
), 1 << PPC_TLB_EPID_STORE
);
1012 static inline void flush_page(CPUPPCState
*env
, ppcmas_tlb_t
*tlb
)
1014 if (booke206_tlb_to_page_size(env
, tlb
) == TARGET_PAGE_SIZE
) {
1015 tlb_flush_page(env_cpu(env
), tlb
->mas2
& MAS2_EPN_MASK
);
1017 tlb_flush(env_cpu(env
));
1021 void helper_booke206_tlbwe(CPUPPCState
*env
)
1023 uint32_t tlbncfg
, tlbn
;
1025 uint32_t size_tlb
, size_ps
;
1029 switch (env
->spr
[SPR_BOOKE_MAS0
] & MAS0_WQ_MASK
) {
1030 case MAS0_WQ_ALWAYS
:
1031 /* good to go, write that entry */
1034 /* XXX check if reserved */
1039 case MAS0_WQ_CLR_RSRV
:
1040 /* XXX clear entry */
1043 /* no idea what to do */
1047 if (((env
->spr
[SPR_BOOKE_MAS0
] & MAS0_ATSEL
) == MAS0_ATSEL_LRAT
) &&
1048 !FIELD_EX64(env
->msr
, MSR
, GS
)) {
1049 /* XXX we don't support direct LRAT setting yet */
1050 fprintf(stderr
, "cpu: don't support LRAT setting yet\n");
1054 tlbn
= (env
->spr
[SPR_BOOKE_MAS0
] & MAS0_TLBSEL_MASK
) >> MAS0_TLBSEL_SHIFT
;
1055 tlbncfg
= env
->spr
[SPR_BOOKE_TLB0CFG
+ tlbn
];
1057 tlb
= booke206_cur_tlb(env
);
1060 raise_exception_err_ra(env
, POWERPC_EXCP_PROGRAM
,
1061 POWERPC_EXCP_INVAL
|
1062 POWERPC_EXCP_INVAL_INVAL
, GETPC());
1065 /* check that we support the targeted size */
1066 size_tlb
= (env
->spr
[SPR_BOOKE_MAS1
] & MAS1_TSIZE_MASK
) >> MAS1_TSIZE_SHIFT
;
1067 size_ps
= booke206_tlbnps(env
, tlbn
);
1068 if ((env
->spr
[SPR_BOOKE_MAS1
] & MAS1_VALID
) && (tlbncfg
& TLBnCFG_AVAIL
) &&
1069 !(size_ps
& (1 << size_tlb
))) {
1070 raise_exception_err_ra(env
, POWERPC_EXCP_PROGRAM
,
1071 POWERPC_EXCP_INVAL
|
1072 POWERPC_EXCP_INVAL_INVAL
, GETPC());
1075 if (FIELD_EX64(env
->msr
, MSR
, GS
)) {
1076 cpu_abort(env_cpu(env
), "missing HV implementation\n");
1079 if (tlb
->mas1
& MAS1_VALID
) {
1081 * Invalidate the page in QEMU TLB if it was a valid entry.
1083 * In "PowerPC e500 Core Family Reference Manual, Rev. 1",
1084 * Section "12.4.2 TLB Write Entry (tlbwe) Instruction":
1085 * (https://www.nxp.com/docs/en/reference-manual/E500CORERM.pdf)
1087 * "Note that when an L2 TLB entry is written, it may be displacing an
1088 * already valid entry in the same L2 TLB location (a victim). If a
1089 * valid L1 TLB entry corresponds to the L2 MMU victim entry, that L1
1090 * TLB entry is automatically invalidated."
1092 flush_page(env
, tlb
);
1095 tlb
->mas7_3
= ((uint64_t)env
->spr
[SPR_BOOKE_MAS7
] << 32) |
1096 env
->spr
[SPR_BOOKE_MAS3
];
1097 tlb
->mas1
= env
->spr
[SPR_BOOKE_MAS1
];
1099 if ((env
->spr
[SPR_MMUCFG
] & MMUCFG_MAVN
) == MMUCFG_MAVN_V2
) {
1100 /* For TLB which has a fixed size TSIZE is ignored with MAV2 */
1101 booke206_fixed_size_tlbn(env
, tlbn
, tlb
);
1103 if (!(tlbncfg
& TLBnCFG_AVAIL
)) {
1104 /* force !AVAIL TLB entries to correct page size */
1105 tlb
->mas1
&= ~MAS1_TSIZE_MASK
;
1106 /* XXX can be configured in MMUCSR0 */
1107 tlb
->mas1
|= (tlbncfg
& TLBnCFG_MINSIZE
) >> 12;
1111 /* Make a mask from TLB size to discard invalid bits in EPN field */
1112 mask
= ~(booke206_tlb_to_page_size(env
, tlb
) - 1);
1113 /* Add a mask for page attributes */
1114 mask
|= MAS2_ACM
| MAS2_VLE
| MAS2_W
| MAS2_I
| MAS2_M
| MAS2_G
| MAS2_E
;
1116 if (!FIELD_EX64(env
->msr
, MSR
, CM
)) {
1118 * Executing a tlbwe instruction in 32-bit mode will set bits
1119 * 0:31 of the TLB EPN field to zero.
1124 tlb
->mas2
= env
->spr
[SPR_BOOKE_MAS2
] & mask
;
1126 if (!(tlbncfg
& TLBnCFG_IPROT
)) {
1127 /* no IPROT supported by TLB */
1128 tlb
->mas1
&= ~MAS1_IPROT
;
1131 flush_page(env
, tlb
);
1134 static inline void booke206_tlb_to_mas(CPUPPCState
*env
, ppcmas_tlb_t
*tlb
)
1136 int tlbn
= booke206_tlbm_to_tlbn(env
, tlb
);
1137 int way
= booke206_tlbm_to_way(env
, tlb
);
1139 env
->spr
[SPR_BOOKE_MAS0
] = tlbn
<< MAS0_TLBSEL_SHIFT
;
1140 env
->spr
[SPR_BOOKE_MAS0
] |= way
<< MAS0_ESEL_SHIFT
;
1141 env
->spr
[SPR_BOOKE_MAS0
] |= env
->last_way
<< MAS0_NV_SHIFT
;
1143 env
->spr
[SPR_BOOKE_MAS1
] = tlb
->mas1
;
1144 env
->spr
[SPR_BOOKE_MAS2
] = tlb
->mas2
;
1145 env
->spr
[SPR_BOOKE_MAS3
] = tlb
->mas7_3
;
1146 env
->spr
[SPR_BOOKE_MAS7
] = tlb
->mas7_3
>> 32;
1149 void helper_booke206_tlbre(CPUPPCState
*env
)
1151 ppcmas_tlb_t
*tlb
= NULL
;
1153 tlb
= booke206_cur_tlb(env
);
1155 env
->spr
[SPR_BOOKE_MAS1
] = 0;
1157 booke206_tlb_to_mas(env
, tlb
);
1161 void helper_booke206_tlbsx(CPUPPCState
*env
, target_ulong address
)
1163 ppcmas_tlb_t
*tlb
= NULL
;
1168 spid
= (env
->spr
[SPR_BOOKE_MAS6
] & MAS6_SPID_MASK
) >> MAS6_SPID_SHIFT
;
1169 sas
= env
->spr
[SPR_BOOKE_MAS6
] & MAS6_SAS
;
1171 for (i
= 0; i
< BOOKE206_MAX_TLBN
; i
++) {
1172 int ways
= booke206_tlb_ways(env
, i
);
1174 for (j
= 0; j
< ways
; j
++) {
1175 tlb
= booke206_get_tlbm(env
, i
, address
, j
);
1181 if (ppcmas_tlb_check(env
, tlb
, &raddr
, address
, spid
)) {
1185 if (sas
!= ((tlb
->mas1
& MAS1_TS
) >> MAS1_TS_SHIFT
)) {
1189 booke206_tlb_to_mas(env
, tlb
);
1194 /* no entry found, fill with defaults */
1195 env
->spr
[SPR_BOOKE_MAS0
] = env
->spr
[SPR_BOOKE_MAS4
] & MAS4_TLBSELD_MASK
;
1196 env
->spr
[SPR_BOOKE_MAS1
] = env
->spr
[SPR_BOOKE_MAS4
] & MAS4_TSIZED_MASK
;
1197 env
->spr
[SPR_BOOKE_MAS2
] = env
->spr
[SPR_BOOKE_MAS4
] & MAS4_WIMGED_MASK
;
1198 env
->spr
[SPR_BOOKE_MAS3
] = 0;
1199 env
->spr
[SPR_BOOKE_MAS7
] = 0;
1201 if (env
->spr
[SPR_BOOKE_MAS6
] & MAS6_SAS
) {
1202 env
->spr
[SPR_BOOKE_MAS1
] |= MAS1_TS
;
1205 env
->spr
[SPR_BOOKE_MAS1
] |= (env
->spr
[SPR_BOOKE_MAS6
] >> 16)
1208 /* next victim logic */
1209 env
->spr
[SPR_BOOKE_MAS0
] |= env
->last_way
<< MAS0_ESEL_SHIFT
;
1211 env
->last_way
&= booke206_tlb_ways(env
, 0) - 1;
1212 env
->spr
[SPR_BOOKE_MAS0
] |= env
->last_way
<< MAS0_NV_SHIFT
;
1215 static inline void booke206_invalidate_ea_tlb(CPUPPCState
*env
, int tlbn
,
1219 int ways
= booke206_tlb_ways(env
, tlbn
);
1222 for (i
= 0; i
< ways
; i
++) {
1223 ppcmas_tlb_t
*tlb
= booke206_get_tlbm(env
, tlbn
, ea
, i
);
1227 mask
= ~(booke206_tlb_to_page_size(env
, tlb
) - 1);
1228 if (((tlb
->mas2
& MAS2_EPN_MASK
) == (ea
& mask
)) &&
1229 !(tlb
->mas1
& MAS1_IPROT
)) {
1230 tlb
->mas1
&= ~MAS1_VALID
;
1235 void helper_booke206_tlbivax(CPUPPCState
*env
, target_ulong address
)
1239 if (address
& 0x4) {
1240 /* flush all entries */
1241 if (address
& 0x8) {
1242 /* flush all of TLB1 */
1243 booke206_flush_tlb(env
, BOOKE206_FLUSH_TLB1
, 1);
1245 /* flush all of TLB0 */
1246 booke206_flush_tlb(env
, BOOKE206_FLUSH_TLB0
, 0);
1251 if (address
& 0x8) {
1252 /* flush TLB1 entries */
1253 booke206_invalidate_ea_tlb(env
, 1, address
);
1258 /* flush TLB0 entries */
1259 booke206_invalidate_ea_tlb(env
, 0, address
);
1261 tlb_flush_page(cs
, address
& MAS2_EPN_MASK
);
1266 void helper_booke206_tlbilx0(CPUPPCState
*env
, target_ulong address
)
1268 /* XXX missing LPID handling */
1269 booke206_flush_tlb(env
, -1, 1);
1272 void helper_booke206_tlbilx1(CPUPPCState
*env
, target_ulong address
)
1275 int tid
= (env
->spr
[SPR_BOOKE_MAS6
] & MAS6_SPID
);
1276 ppcmas_tlb_t
*tlb
= env
->tlb
.tlbm
;
1279 /* XXX missing LPID handling */
1280 for (i
= 0; i
< BOOKE206_MAX_TLBN
; i
++) {
1281 tlb_size
= booke206_tlb_size(env
, i
);
1282 for (j
= 0; j
< tlb_size
; j
++) {
1283 if (!(tlb
[j
].mas1
& MAS1_IPROT
) &&
1284 ((tlb
[j
].mas1
& MAS1_TID_MASK
) == tid
)) {
1285 tlb
[j
].mas1
&= ~MAS1_VALID
;
1288 tlb
+= booke206_tlb_size(env
, i
);
1290 tlb_flush(env_cpu(env
));
1293 void helper_booke206_tlbilx3(CPUPPCState
*env
, target_ulong address
)
1297 int tid
= (env
->spr
[SPR_BOOKE_MAS6
] & MAS6_SPID
);
1298 int pid
= tid
>> MAS6_SPID_SHIFT
;
1299 int sgs
= env
->spr
[SPR_BOOKE_MAS5
] & MAS5_SGS
;
1300 int ind
= (env
->spr
[SPR_BOOKE_MAS6
] & MAS6_SIND
) ? MAS1_IND
: 0;
1301 /* XXX check for unsupported isize and raise an invalid opcode then */
1302 int size
= env
->spr
[SPR_BOOKE_MAS6
] & MAS6_ISIZE_MASK
;
1303 /* XXX implement MAV2 handling */
1306 /* XXX missing LPID handling */
1307 /* flush by pid and ea */
1308 for (i
= 0; i
< BOOKE206_MAX_TLBN
; i
++) {
1309 int ways
= booke206_tlb_ways(env
, i
);
1311 for (j
= 0; j
< ways
; j
++) {
1312 tlb
= booke206_get_tlbm(env
, i
, address
, j
);
1316 if ((ppcmas_tlb_check(env
, tlb
, NULL
, address
, pid
) != 0) ||
1317 (tlb
->mas1
& MAS1_IPROT
) ||
1318 ((tlb
->mas1
& MAS1_IND
) != ind
) ||
1319 ((tlb
->mas8
& MAS8_TGS
) != sgs
)) {
1322 if (mav2
&& ((tlb
->mas1
& MAS1_TSIZE_MASK
) != size
)) {
1323 /* XXX only check when MMUCFG[TWC] || TLBnCFG[HES] */
1326 /* XXX e500mc doesn't match SAS, but other cores might */
1327 tlb
->mas1
&= ~MAS1_VALID
;
1330 tlb_flush(env_cpu(env
));
1333 void helper_booke206_tlbflush(CPUPPCState
*env
, target_ulong type
)
1338 flags
|= BOOKE206_FLUSH_TLB1
;
1342 flags
|= BOOKE206_FLUSH_TLB0
;
1345 booke206_flush_tlb(env
, flags
, 1);
1349 void helper_check_tlb_flush_local(CPUPPCState
*env
)
1351 check_tlb_flush(env
, false);
1354 void helper_check_tlb_flush_global(CPUPPCState
*env
)
1356 check_tlb_flush(env
, true);
1360 bool ppc_cpu_tlb_fill(CPUState
*cs
, vaddr eaddr
, int size
,
1361 MMUAccessType access_type
, int mmu_idx
,
1362 bool probe
, uintptr_t retaddr
)
1364 PowerPCCPU
*cpu
= POWERPC_CPU(cs
);
1366 int page_size
, prot
;
1368 if (ppc_xlate(cpu
, eaddr
, access_type
, &raddr
,
1369 &page_size
, &prot
, mmu_idx
, !probe
)) {
1370 tlb_set_page(cs
, eaddr
& TARGET_PAGE_MASK
, raddr
& TARGET_PAGE_MASK
,
1371 prot
, mmu_idx
, 1UL << page_size
);
1377 raise_exception_err_ra(&cpu
->env
, cs
->exception_index
,
1378 cpu
->env
.error_code
, retaddr
);