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"
29 #include "helper_regs.h"
30 #include "qemu/error-report.h"
31 #include "qemu/qemu-print.h"
33 #include "mmu-book3s-v3.h"
34 #include "mmu-radix64.h"
35 #include "exec/helper-proto.h"
36 #include "exec/cpu_ldst.h"
38 /* #define FLUSH_ALL_TLBS */
40 /*****************************************************************************/
41 /* PowerPC MMU emulation */
43 /* Software driven TLB helpers */
44 static inline void ppc6xx_tlb_invalidate_all(CPUPPCState
*env
)
49 /* LOG_SWTLB("Invalidate all TLBs\n"); */
50 /* Invalidate all defined software TLB */
52 if (env
->id_tlbs
== 1) {
55 for (nr
= 0; nr
< max
; nr
++) {
56 tlb
= &env
->tlb
.tlb6
[nr
];
57 pte_invalidate(&tlb
->pte0
);
59 tlb_flush(env_cpu(env
));
62 static inline void ppc6xx_tlb_invalidate_virt2(CPUPPCState
*env
,
64 int is_code
, int match_epn
)
66 #if !defined(FLUSH_ALL_TLBS)
67 CPUState
*cs
= env_cpu(env
);
71 /* Invalidate ITLB + DTLB, all ways */
72 for (way
= 0; way
< env
->nb_ways
; way
++) {
73 nr
= ppc6xx_tlb_getnum(env
, eaddr
, way
, is_code
);
74 tlb
= &env
->tlb
.tlb6
[nr
];
75 if (pte_is_valid(tlb
->pte0
) && (match_epn
== 0 || eaddr
== tlb
->EPN
)) {
76 qemu_log_mask(CPU_LOG_MMU
, "TLB invalidate %d/%d "
77 TARGET_FMT_lx
"\n", nr
, env
->nb_tlb
, eaddr
);
78 pte_invalidate(&tlb
->pte0
);
79 tlb_flush_page(cs
, tlb
->EPN
);
83 /* XXX: PowerPC specification say this is valid as well */
84 ppc6xx_tlb_invalidate_all(env
);
88 static inline void ppc6xx_tlb_invalidate_virt(CPUPPCState
*env
,
89 target_ulong eaddr
, int is_code
)
91 ppc6xx_tlb_invalidate_virt2(env
, eaddr
, is_code
, 0);
94 static void ppc6xx_tlb_store(CPUPPCState
*env
, target_ulong EPN
, int way
,
95 int is_code
, target_ulong pte0
, target_ulong pte1
)
100 nr
= ppc6xx_tlb_getnum(env
, EPN
, way
, is_code
);
101 tlb
= &env
->tlb
.tlb6
[nr
];
102 qemu_log_mask(CPU_LOG_MMU
, "Set TLB %d/%d EPN " TARGET_FMT_lx
" PTE0 "
103 TARGET_FMT_lx
" PTE1 " TARGET_FMT_lx
"\n", nr
, env
->nb_tlb
,
105 /* Invalidate any pending reference in QEMU for this virtual address */
106 ppc6xx_tlb_invalidate_virt2(env
, EPN
, is_code
, 1);
110 /* Store last way for LRU mechanism */
114 /* Helpers specific to PowerPC 40x implementations */
115 static inline void ppc4xx_tlb_invalidate_all(CPUPPCState
*env
)
120 for (i
= 0; i
< env
->nb_tlb
; i
++) {
121 tlb
= &env
->tlb
.tlbe
[i
];
122 tlb
->prot
&= ~PAGE_VALID
;
124 tlb_flush(env_cpu(env
));
127 static void booke206_flush_tlb(CPUPPCState
*env
, int flags
,
128 const int check_iprot
)
132 ppcmas_tlb_t
*tlb
= env
->tlb
.tlbm
;
134 for (i
= 0; i
< BOOKE206_MAX_TLBN
; i
++) {
135 if (flags
& (1 << i
)) {
136 tlb_size
= booke206_tlb_size(env
, i
);
137 for (j
= 0; j
< tlb_size
; j
++) {
138 if (!check_iprot
|| !(tlb
[j
].mas1
& MAS1_IPROT
)) {
139 tlb
[j
].mas1
&= ~MAS1_VALID
;
143 tlb
+= booke206_tlb_size(env
, i
);
146 tlb_flush(env_cpu(env
));
149 /*****************************************************************************/
150 /* BATs management */
151 #if !defined(FLUSH_ALL_TLBS)
152 static inline void do_invalidate_BAT(CPUPPCState
*env
, target_ulong BATu
,
155 CPUState
*cs
= env_cpu(env
);
156 target_ulong base
, end
, page
;
158 base
= BATu
& ~0x0001FFFF;
159 end
= base
+ mask
+ 0x00020000;
160 if (((end
- base
) >> TARGET_PAGE_BITS
) > 1024) {
161 /* Flushing 1024 4K pages is slower than a complete flush */
162 qemu_log_mask(CPU_LOG_MMU
, "Flush all BATs\n");
164 qemu_log_mask(CPU_LOG_MMU
, "Flush done\n");
167 qemu_log_mask(CPU_LOG_MMU
, "Flush BAT from " TARGET_FMT_lx
168 " to " TARGET_FMT_lx
" (" TARGET_FMT_lx
")\n",
170 for (page
= base
; page
!= end
; page
+= TARGET_PAGE_SIZE
) {
171 tlb_flush_page(cs
, page
);
173 qemu_log_mask(CPU_LOG_MMU
, "Flush done\n");
177 static inline void dump_store_bat(CPUPPCState
*env
, char ID
, int ul
, int nr
,
180 qemu_log_mask(CPU_LOG_MMU
, "Set %cBAT%d%c to " TARGET_FMT_lx
" ("
181 TARGET_FMT_lx
")\n", ID
, nr
, ul
== 0 ? 'u' : 'l',
185 void helper_store_ibatu(CPUPPCState
*env
, uint32_t nr
, target_ulong value
)
189 dump_store_bat(env
, 'I', 0, nr
, value
);
190 if (env
->IBAT
[0][nr
] != value
) {
191 mask
= (value
<< 15) & 0x0FFE0000UL
;
192 #if !defined(FLUSH_ALL_TLBS)
193 do_invalidate_BAT(env
, env
->IBAT
[0][nr
], mask
);
196 * When storing valid upper BAT, mask BEPI and BRPN and
197 * invalidate all TLBs covered by this BAT
199 mask
= (value
<< 15) & 0x0FFE0000UL
;
200 env
->IBAT
[0][nr
] = (value
& 0x00001FFFUL
) |
201 (value
& ~0x0001FFFFUL
& ~mask
);
202 env
->IBAT
[1][nr
] = (env
->IBAT
[1][nr
] & 0x0000007B) |
203 (env
->IBAT
[1][nr
] & ~0x0001FFFF & ~mask
);
204 #if !defined(FLUSH_ALL_TLBS)
205 do_invalidate_BAT(env
, env
->IBAT
[0][nr
], mask
);
207 tlb_flush(env_cpu(env
));
212 void helper_store_ibatl(CPUPPCState
*env
, uint32_t nr
, target_ulong value
)
214 dump_store_bat(env
, 'I', 1, nr
, value
);
215 env
->IBAT
[1][nr
] = value
;
218 void helper_store_dbatu(CPUPPCState
*env
, uint32_t nr
, target_ulong value
)
222 dump_store_bat(env
, 'D', 0, nr
, value
);
223 if (env
->DBAT
[0][nr
] != value
) {
225 * When storing valid upper BAT, mask BEPI and BRPN and
226 * invalidate all TLBs covered by this BAT
228 mask
= (value
<< 15) & 0x0FFE0000UL
;
229 #if !defined(FLUSH_ALL_TLBS)
230 do_invalidate_BAT(env
, env
->DBAT
[0][nr
], mask
);
232 mask
= (value
<< 15) & 0x0FFE0000UL
;
233 env
->DBAT
[0][nr
] = (value
& 0x00001FFFUL
) |
234 (value
& ~0x0001FFFFUL
& ~mask
);
235 env
->DBAT
[1][nr
] = (env
->DBAT
[1][nr
] & 0x0000007B) |
236 (env
->DBAT
[1][nr
] & ~0x0001FFFF & ~mask
);
237 #if !defined(FLUSH_ALL_TLBS)
238 do_invalidate_BAT(env
, env
->DBAT
[0][nr
], mask
);
240 tlb_flush(env_cpu(env
));
245 void helper_store_dbatl(CPUPPCState
*env
, uint32_t nr
, target_ulong value
)
247 dump_store_bat(env
, 'D', 1, nr
, value
);
248 env
->DBAT
[1][nr
] = value
;
251 /*****************************************************************************/
253 void ppc_tlb_invalidate_all(CPUPPCState
*env
)
255 #if defined(TARGET_PPC64)
256 if (mmu_is_64bit(env
->mmu_model
)) {
257 env
->tlb_need_flush
= 0;
258 tlb_flush(env_cpu(env
));
260 #endif /* defined(TARGET_PPC64) */
261 switch (env
->mmu_model
) {
262 case POWERPC_MMU_SOFT_6xx
:
263 ppc6xx_tlb_invalidate_all(env
);
265 case POWERPC_MMU_SOFT_4xx
:
266 ppc4xx_tlb_invalidate_all(env
);
268 case POWERPC_MMU_REAL
:
269 cpu_abort(env_cpu(env
), "No TLB for PowerPC 4xx in real mode\n");
271 case POWERPC_MMU_MPC8xx
:
273 cpu_abort(env_cpu(env
), "MPC8xx MMU model is not implemented\n");
275 case POWERPC_MMU_BOOKE
:
276 tlb_flush(env_cpu(env
));
278 case POWERPC_MMU_BOOKE206
:
279 booke206_flush_tlb(env
, -1, 0);
281 case POWERPC_MMU_32B
:
282 env
->tlb_need_flush
= 0;
283 tlb_flush(env_cpu(env
));
287 cpu_abort(env_cpu(env
), "Unknown MMU model %x\n", env
->mmu_model
);
292 void ppc_tlb_invalidate_one(CPUPPCState
*env
, target_ulong addr
)
294 #if !defined(FLUSH_ALL_TLBS)
295 addr
&= TARGET_PAGE_MASK
;
296 #if defined(TARGET_PPC64)
297 if (mmu_is_64bit(env
->mmu_model
)) {
298 /* tlbie invalidate TLBs for all segments */
300 * XXX: given the fact that there are too many segments to invalidate,
301 * and we still don't have a tlb_flush_mask(env, n, mask) in QEMU,
302 * we just invalidate all TLBs
304 env
->tlb_need_flush
|= TLB_NEED_LOCAL_FLUSH
;
306 #endif /* defined(TARGET_PPC64) */
307 switch (env
->mmu_model
) {
308 case POWERPC_MMU_SOFT_6xx
:
309 ppc6xx_tlb_invalidate_virt(env
, addr
, 0);
310 if (env
->id_tlbs
== 1) {
311 ppc6xx_tlb_invalidate_virt(env
, addr
, 1);
314 case POWERPC_MMU_32B
:
316 * Actual CPUs invalidate entire congruence classes based on
317 * the geometry of their TLBs and some OSes take that into
318 * account, we just mark the TLB to be flushed later (context
319 * synchronizing event or sync instruction on 32-bit).
321 env
->tlb_need_flush
|= TLB_NEED_LOCAL_FLUSH
;
324 /* Should never reach here with other MMU models */
328 ppc_tlb_invalidate_all(env
);
332 /*****************************************************************************/
333 /* Special registers manipulation */
335 /* Segment registers load and store */
336 target_ulong
helper_load_sr(CPUPPCState
*env
, target_ulong sr_num
)
338 #if defined(TARGET_PPC64)
339 if (mmu_is_64bit(env
->mmu_model
)) {
344 return env
->sr
[sr_num
];
347 void helper_store_sr(CPUPPCState
*env
, target_ulong srnum
, target_ulong value
)
349 qemu_log_mask(CPU_LOG_MMU
,
350 "%s: reg=%d " TARGET_FMT_lx
" " TARGET_FMT_lx
"\n", __func__
,
351 (int)srnum
, value
, env
->sr
[srnum
]);
352 #if defined(TARGET_PPC64)
353 if (mmu_is_64bit(env
->mmu_model
)) {
354 PowerPCCPU
*cpu
= env_archcpu(env
);
358 esid
= ((uint64_t)(srnum
& 0xf) << 28) | SLB_ESID_V
;
361 vsid
= (value
& 0xfffffff) << 12;
363 vsid
|= ((value
>> 27) & 0xf) << 8;
365 ppc_store_slb(cpu
, srnum
, esid
, vsid
);
368 if (env
->sr
[srnum
] != value
) {
369 env
->sr
[srnum
] = value
;
371 * Invalidating 256MB of virtual memory in 4kB pages is way
372 * longer than flushing the whole TLB.
374 #if !defined(FLUSH_ALL_TLBS) && 0
376 target_ulong page
, end
;
377 /* Invalidate 256 MB of virtual memory */
378 page
= (16 << 20) * srnum
;
379 end
= page
+ (16 << 20);
380 for (; page
!= end
; page
+= TARGET_PAGE_SIZE
) {
381 tlb_flush_page(env_cpu(env
), page
);
385 env
->tlb_need_flush
|= TLB_NEED_LOCAL_FLUSH
;
391 void helper_tlbia(CPUPPCState
*env
)
393 ppc_tlb_invalidate_all(env
);
396 void helper_tlbie(CPUPPCState
*env
, target_ulong addr
)
398 ppc_tlb_invalidate_one(env
, addr
);
401 #if defined(TARGET_PPC64)
403 /* Invalidation Selector */
404 #define TLBIE_IS_VA 0
405 #define TLBIE_IS_PID 1
406 #define TLBIE_IS_LPID 2
407 #define TLBIE_IS_ALL 3
409 /* Radix Invalidation Control */
410 #define TLBIE_RIC_TLB 0
411 #define TLBIE_RIC_PWC 1
412 #define TLBIE_RIC_ALL 2
413 #define TLBIE_RIC_GRP 3
415 /* Radix Actual Page sizes */
416 #define TLBIE_R_AP_4K 0
417 #define TLBIE_R_AP_64K 5
418 #define TLBIE_R_AP_2M 1
419 #define TLBIE_R_AP_1G 2
422 #define TLBIE_RB_EPN_MASK PPC_BITMASK(0, 51)
423 #define TLBIE_RB_IS_MASK PPC_BITMASK(52, 53)
424 #define TLBIE_RB_AP_MASK PPC_BITMASK(56, 58)
426 void helper_tlbie_isa300(CPUPPCState
*env
, target_ulong rb
, target_ulong rs
,
429 unsigned ric
= (flags
& TLBIE_F_RIC_MASK
) >> TLBIE_F_RIC_SHIFT
;
431 * With the exception of the checks for invalid instruction forms,
432 * PRS is currently ignored, because we don't know if a given TLB entry
433 * is process or partition scoped.
435 bool prs
= flags
& TLBIE_F_PRS
;
436 bool r
= flags
& TLBIE_F_R
;
437 bool local
= flags
& TLBIE_F_LOCAL
;
439 unsigned is
= extract64(rb
, PPC_BIT_NR(53), 2);
440 unsigned ap
; /* actual page size */
441 target_ulong addr
, pgoffs_mask
;
443 qemu_log_mask(CPU_LOG_MMU
,
444 "%s: local=%d addr=" TARGET_FMT_lx
" ric=%u prs=%d r=%d is=%u\n",
445 __func__
, local
, rb
& TARGET_PAGE_MASK
, ric
, prs
, r
, is
);
447 effR
= FIELD_EX64(env
->msr
, MSR
, HV
) ? r
: env
->spr
[SPR_LPCR
] & LPCR_HR
;
449 /* Partial TLB invalidation is supported for Radix only for now. */
454 /* Check for invalid instruction forms (effR=1). */
455 if (unlikely(ric
== TLBIE_RIC_GRP
||
456 ((ric
== TLBIE_RIC_PWC
|| ric
== TLBIE_RIC_ALL
) &&
457 is
== TLBIE_IS_VA
) ||
458 (!prs
&& is
== TLBIE_IS_PID
))) {
459 qemu_log_mask(LOG_GUEST_ERROR
,
460 "%s: invalid instruction form: ric=%u prs=%d r=%d is=%u\n",
461 __func__
, ric
, prs
, r
, is
);
465 /* We don't cache Page Walks. */
466 if (ric
== TLBIE_RIC_PWC
) {
468 unsigned set
= extract64(rb
, PPC_BIT_NR(51), 12);
470 qemu_log_mask(LOG_GUEST_ERROR
, "%s: invalid set: %d\n",
479 * Invalidation by LPID or PID is not supported, so fallback
480 * to full TLB flush in these cases.
482 if (is
!= TLBIE_IS_VA
) {
487 * The results of an attempt to invalidate a translation outside of
488 * quadrant 0 for Radix Tree translation (effR=1, RIC=0, PRS=1, IS=0,
489 * and EA 0:1 != 0b00) are boundedly undefined.
491 if (unlikely(ric
== TLBIE_RIC_TLB
&& prs
&& is
== TLBIE_IS_VA
&&
492 (rb
& R_EADDR_QUADRANT
) != R_EADDR_QUADRANT0
)) {
493 qemu_log_mask(LOG_GUEST_ERROR
,
494 "%s: attempt to invalidate a translation outside of quadrant 0\n",
499 assert(is
== TLBIE_IS_VA
);
500 assert(ric
== TLBIE_RIC_TLB
|| ric
== TLBIE_RIC_ALL
);
502 ap
= extract64(rb
, PPC_BIT_NR(58), 3);
505 pgoffs_mask
= 0xfffull
;
509 pgoffs_mask
= 0xffffull
;
513 pgoffs_mask
= 0x1fffffull
;
517 pgoffs_mask
= 0x3fffffffull
;
522 * If the value specified in RS 0:31, RS 32:63, RB 54:55, RB 56:58,
523 * RB 44:51, or RB 56:63, when it is needed to perform the specified
524 * operation, is not supported by the implementation, the instruction
525 * is treated as if the instruction form were invalid.
527 qemu_log_mask(LOG_GUEST_ERROR
, "%s: invalid AP: %d\n", __func__
, ap
);
531 addr
= rb
& TLBIE_RB_EPN_MASK
& ~pgoffs_mask
;
534 tlb_flush_page(env_cpu(env
), addr
);
536 tlb_flush_page_all_cpus(env_cpu(env
), addr
);
541 env
->tlb_need_flush
|= TLB_NEED_LOCAL_FLUSH
;
543 env
->tlb_need_flush
|= TLB_NEED_GLOBAL_FLUSH
;
548 raise_exception_err_ra(env
, POWERPC_EXCP_PROGRAM
,
550 POWERPC_EXCP_INVAL_INVAL
, GETPC());
555 void helper_tlbiva(CPUPPCState
*env
, target_ulong addr
)
557 /* tlbiva instruction only exists on BookE */
558 assert(env
->mmu_model
== POWERPC_MMU_BOOKE
);
560 cpu_abort(env_cpu(env
), "BookE MMU model is not implemented\n");
563 /* Software driven TLBs management */
564 /* PowerPC 602/603 software TLB load instructions helpers */
565 static void do_6xx_tlb(CPUPPCState
*env
, target_ulong new_EPN
, int is_code
)
567 target_ulong RPN
, CMP
, EPN
;
570 RPN
= env
->spr
[SPR_RPA
];
572 CMP
= env
->spr
[SPR_ICMP
];
573 EPN
= env
->spr
[SPR_IMISS
];
575 CMP
= env
->spr
[SPR_DCMP
];
576 EPN
= env
->spr
[SPR_DMISS
];
578 way
= (env
->spr
[SPR_SRR1
] >> 17) & 1;
579 (void)EPN
; /* avoid a compiler warning */
580 qemu_log_mask(CPU_LOG_MMU
, "%s: EPN " TARGET_FMT_lx
" " TARGET_FMT_lx
581 " PTE0 " TARGET_FMT_lx
" PTE1 " TARGET_FMT_lx
" way %d\n",
582 __func__
, new_EPN
, EPN
, CMP
, RPN
, way
);
584 ppc6xx_tlb_store(env
, (uint32_t)(new_EPN
& TARGET_PAGE_MASK
),
585 way
, is_code
, CMP
, RPN
);
588 void helper_6xx_tlbd(CPUPPCState
*env
, target_ulong EPN
)
590 do_6xx_tlb(env
, EPN
, 0);
593 void helper_6xx_tlbi(CPUPPCState
*env
, target_ulong EPN
)
595 do_6xx_tlb(env
, EPN
, 1);
598 /*****************************************************************************/
599 /* PowerPC 601 specific instructions (POWER bridge) */
601 target_ulong
helper_rac(CPUPPCState
*env
, target_ulong addr
)
605 target_ulong ret
= 0;
608 * We don't have to generate many instances of this instruction,
609 * as rac is supervisor only.
611 * XXX: FIX THIS: Pretend we have no BAT
613 nb_BATs
= env
->nb_BATs
;
615 if (get_physical_address_wtlb(env
, &ctx
, addr
, 0, ACCESS_INT
, 0) == 0) {
618 env
->nb_BATs
= nb_BATs
;
622 static inline target_ulong
booke_tlb_to_page_size(int size
)
624 return 1024 << (2 * size
);
627 static inline int booke_page_size_to_tlb(target_ulong page_size
)
665 #if defined(TARGET_PPC64)
666 case 0x000100000000ULL
:
669 case 0x000400000000ULL
:
672 case 0x001000000000ULL
:
675 case 0x004000000000ULL
:
678 case 0x010000000000ULL
:
690 /* Helpers for 4xx TLB management */
691 #define PPC4XX_TLB_ENTRY_MASK 0x0000003f /* Mask for 64 TLB entries */
693 #define PPC4XX_TLBHI_V 0x00000040
694 #define PPC4XX_TLBHI_E 0x00000020
695 #define PPC4XX_TLBHI_SIZE_MIN 0
696 #define PPC4XX_TLBHI_SIZE_MAX 7
697 #define PPC4XX_TLBHI_SIZE_DEFAULT 1
698 #define PPC4XX_TLBHI_SIZE_SHIFT 7
699 #define PPC4XX_TLBHI_SIZE_MASK 0x00000007
701 #define PPC4XX_TLBLO_EX 0x00000200
702 #define PPC4XX_TLBLO_WR 0x00000100
703 #define PPC4XX_TLBLO_ATTR_MASK 0x000000FF
704 #define PPC4XX_TLBLO_RPN_MASK 0xFFFFFC00
706 void helper_store_40x_pid(CPUPPCState
*env
, target_ulong val
)
708 if (env
->spr
[SPR_40x_PID
] != val
) {
709 env
->spr
[SPR_40x_PID
] = val
;
710 env
->tlb_need_flush
|= TLB_NEED_LOCAL_FLUSH
;
714 target_ulong
helper_4xx_tlbre_hi(CPUPPCState
*env
, target_ulong entry
)
720 entry
&= PPC4XX_TLB_ENTRY_MASK
;
721 tlb
= &env
->tlb
.tlbe
[entry
];
723 if (tlb
->prot
& PAGE_VALID
) {
724 ret
|= PPC4XX_TLBHI_V
;
726 size
= booke_page_size_to_tlb(tlb
->size
);
727 if (size
< PPC4XX_TLBHI_SIZE_MIN
|| size
> PPC4XX_TLBHI_SIZE_MAX
) {
728 size
= PPC4XX_TLBHI_SIZE_DEFAULT
;
730 ret
|= size
<< PPC4XX_TLBHI_SIZE_SHIFT
;
731 helper_store_40x_pid(env
, tlb
->PID
);
735 target_ulong
helper_4xx_tlbre_lo(CPUPPCState
*env
, target_ulong entry
)
740 entry
&= PPC4XX_TLB_ENTRY_MASK
;
741 tlb
= &env
->tlb
.tlbe
[entry
];
743 if (tlb
->prot
& PAGE_EXEC
) {
744 ret
|= PPC4XX_TLBLO_EX
;
746 if (tlb
->prot
& PAGE_WRITE
) {
747 ret
|= PPC4XX_TLBLO_WR
;
752 void helper_4xx_tlbwe_hi(CPUPPCState
*env
, target_ulong entry
,
755 CPUState
*cs
= env_cpu(env
);
757 target_ulong page
, end
;
759 qemu_log_mask(CPU_LOG_MMU
, "%s entry %d val " TARGET_FMT_lx
"\n",
760 __func__
, (int)entry
,
762 entry
&= PPC4XX_TLB_ENTRY_MASK
;
763 tlb
= &env
->tlb
.tlbe
[entry
];
764 /* Invalidate previous TLB (if it's valid) */
765 if (tlb
->prot
& PAGE_VALID
) {
766 end
= tlb
->EPN
+ tlb
->size
;
767 qemu_log_mask(CPU_LOG_MMU
, "%s: invalidate old TLB %d start "
768 TARGET_FMT_lx
" end " TARGET_FMT_lx
"\n", __func__
,
769 (int)entry
, tlb
->EPN
, end
);
770 for (page
= tlb
->EPN
; page
< end
; page
+= TARGET_PAGE_SIZE
) {
771 tlb_flush_page(cs
, page
);
774 tlb
->size
= booke_tlb_to_page_size((val
>> PPC4XX_TLBHI_SIZE_SHIFT
)
775 & PPC4XX_TLBHI_SIZE_MASK
);
777 * We cannot handle TLB size < TARGET_PAGE_SIZE.
778 * If this ever occurs, we should implement TARGET_PAGE_BITS_VARY
780 if ((val
& PPC4XX_TLBHI_V
) && tlb
->size
< TARGET_PAGE_SIZE
) {
781 cpu_abort(cs
, "TLB size " TARGET_FMT_lu
" < %u "
782 "are not supported (%d)\n"
783 "Please implement TARGET_PAGE_BITS_VARY\n",
784 tlb
->size
, TARGET_PAGE_SIZE
, (int)((val
>> 7) & 0x7));
786 tlb
->EPN
= val
& ~(tlb
->size
- 1);
787 if (val
& PPC4XX_TLBHI_V
) {
788 tlb
->prot
|= PAGE_VALID
;
789 if (val
& PPC4XX_TLBHI_E
) {
790 /* XXX: TO BE FIXED */
792 "Little-endian TLB entries are not supported by now\n");
795 tlb
->prot
&= ~PAGE_VALID
;
797 tlb
->PID
= env
->spr
[SPR_40x_PID
]; /* PID */
798 qemu_log_mask(CPU_LOG_MMU
, "%s: set up TLB %d RPN " HWADDR_FMT_plx
799 " EPN " TARGET_FMT_lx
" size " TARGET_FMT_lx
800 " prot %c%c%c%c PID %d\n", __func__
,
801 (int)entry
, tlb
->RPN
, tlb
->EPN
, tlb
->size
,
802 tlb
->prot
& PAGE_READ
? 'r' : '-',
803 tlb
->prot
& PAGE_WRITE
? 'w' : '-',
804 tlb
->prot
& PAGE_EXEC
? 'x' : '-',
805 tlb
->prot
& PAGE_VALID
? 'v' : '-', (int)tlb
->PID
);
806 /* Invalidate new TLB (if valid) */
807 if (tlb
->prot
& PAGE_VALID
) {
808 end
= tlb
->EPN
+ tlb
->size
;
809 qemu_log_mask(CPU_LOG_MMU
, "%s: invalidate TLB %d start "
810 TARGET_FMT_lx
" end " TARGET_FMT_lx
"\n", __func__
,
811 (int)entry
, tlb
->EPN
, end
);
812 for (page
= tlb
->EPN
; page
< end
; page
+= TARGET_PAGE_SIZE
) {
813 tlb_flush_page(cs
, page
);
818 void helper_4xx_tlbwe_lo(CPUPPCState
*env
, target_ulong entry
,
823 qemu_log_mask(CPU_LOG_MMU
, "%s entry %i val " TARGET_FMT_lx
"\n",
824 __func__
, (int)entry
, val
);
825 entry
&= PPC4XX_TLB_ENTRY_MASK
;
826 tlb
= &env
->tlb
.tlbe
[entry
];
827 tlb
->attr
= val
& PPC4XX_TLBLO_ATTR_MASK
;
828 tlb
->RPN
= val
& PPC4XX_TLBLO_RPN_MASK
;
829 tlb
->prot
= PAGE_READ
;
830 if (val
& PPC4XX_TLBLO_EX
) {
831 tlb
->prot
|= PAGE_EXEC
;
833 if (val
& PPC4XX_TLBLO_WR
) {
834 tlb
->prot
|= PAGE_WRITE
;
836 qemu_log_mask(CPU_LOG_MMU
, "%s: set up TLB %d RPN " HWADDR_FMT_plx
837 " EPN " TARGET_FMT_lx
838 " size " TARGET_FMT_lx
" prot %c%c%c%c PID %d\n", __func__
,
839 (int)entry
, tlb
->RPN
, tlb
->EPN
, tlb
->size
,
840 tlb
->prot
& PAGE_READ
? 'r' : '-',
841 tlb
->prot
& PAGE_WRITE
? 'w' : '-',
842 tlb
->prot
& PAGE_EXEC
? 'x' : '-',
843 tlb
->prot
& PAGE_VALID
? 'v' : '-', (int)tlb
->PID
);
845 env
->tlb_need_flush
|= TLB_NEED_LOCAL_FLUSH
;
848 target_ulong
helper_4xx_tlbsx(CPUPPCState
*env
, target_ulong address
)
850 return ppcemb_tlb_search(env
, address
, env
->spr
[SPR_40x_PID
]);
853 /* PowerPC 440 TLB management */
854 void helper_440_tlbwe(CPUPPCState
*env
, uint32_t word
, target_ulong entry
,
858 target_ulong EPN
, RPN
, size
;
861 qemu_log_mask(CPU_LOG_MMU
, "%s word %d entry %d value " TARGET_FMT_lx
"\n",
862 __func__
, word
, (int)entry
, value
);
865 tlb
= &env
->tlb
.tlbe
[entry
];
868 /* Just here to please gcc */
870 EPN
= value
& 0xFFFFFC00;
871 if ((tlb
->prot
& PAGE_VALID
) && EPN
!= tlb
->EPN
) {
875 size
= booke_tlb_to_page_size((value
>> 4) & 0xF);
876 if ((tlb
->prot
& PAGE_VALID
) && tlb
->size
< size
) {
881 tlb
->attr
|= (value
>> 8) & 1;
883 tlb
->prot
|= PAGE_VALID
;
885 if (tlb
->prot
& PAGE_VALID
) {
886 tlb
->prot
&= ~PAGE_VALID
;
890 tlb
->PID
= env
->spr
[SPR_440_MMUCR
] & 0x000000FF;
892 tlb_flush(env_cpu(env
));
896 RPN
= value
& 0xFFFFFC0F;
897 if ((tlb
->prot
& PAGE_VALID
) && tlb
->RPN
!= RPN
) {
898 tlb_flush(env_cpu(env
));
903 tlb
->attr
= (tlb
->attr
& 0x1) | (value
& 0x0000FF00);
904 tlb
->prot
= tlb
->prot
& PAGE_VALID
;
906 tlb
->prot
|= PAGE_READ
<< 4;
909 tlb
->prot
|= PAGE_WRITE
<< 4;
912 tlb
->prot
|= PAGE_EXEC
<< 4;
915 tlb
->prot
|= PAGE_READ
;
918 tlb
->prot
|= PAGE_WRITE
;
921 tlb
->prot
|= PAGE_EXEC
;
927 target_ulong
helper_440_tlbre(CPUPPCState
*env
, uint32_t word
,
935 tlb
= &env
->tlb
.tlbe
[entry
];
938 /* Just here to please gcc */
941 size
= booke_page_size_to_tlb(tlb
->size
);
942 if (size
< 0 || size
> 0xF) {
946 if (tlb
->attr
& 0x1) {
949 if (tlb
->prot
& PAGE_VALID
) {
952 env
->spr
[SPR_440_MMUCR
] &= ~0x000000FF;
953 env
->spr
[SPR_440_MMUCR
] |= tlb
->PID
;
959 ret
= tlb
->attr
& ~0x1;
960 if (tlb
->prot
& (PAGE_READ
<< 4)) {
963 if (tlb
->prot
& (PAGE_WRITE
<< 4)) {
966 if (tlb
->prot
& (PAGE_EXEC
<< 4)) {
969 if (tlb
->prot
& PAGE_READ
) {
972 if (tlb
->prot
& PAGE_WRITE
) {
975 if (tlb
->prot
& PAGE_EXEC
) {
983 target_ulong
helper_440_tlbsx(CPUPPCState
*env
, target_ulong address
)
985 return ppcemb_tlb_search(env
, address
, env
->spr
[SPR_440_MMUCR
] & 0xFF);
988 /* PowerPC BookE 2.06 TLB management */
990 static ppcmas_tlb_t
*booke206_cur_tlb(CPUPPCState
*env
)
992 uint32_t tlbncfg
= 0;
993 int esel
= (env
->spr
[SPR_BOOKE_MAS0
] & MAS0_ESEL_MASK
) >> MAS0_ESEL_SHIFT
;
994 int ea
= (env
->spr
[SPR_BOOKE_MAS2
] & MAS2_EPN_MASK
);
997 tlb
= (env
->spr
[SPR_BOOKE_MAS0
] & MAS0_TLBSEL_MASK
) >> MAS0_TLBSEL_SHIFT
;
998 tlbncfg
= env
->spr
[SPR_BOOKE_TLB0CFG
+ tlb
];
1000 if ((tlbncfg
& TLBnCFG_HES
) && (env
->spr
[SPR_BOOKE_MAS0
] & MAS0_HES
)) {
1001 cpu_abort(env_cpu(env
), "we don't support HES yet\n");
1004 return booke206_get_tlbm(env
, tlb
, ea
, esel
);
1007 void helper_booke_setpid(CPUPPCState
*env
, uint32_t pidn
, target_ulong pid
)
1009 env
->spr
[pidn
] = pid
;
1010 /* changing PIDs mean we're in a different address space now */
1011 tlb_flush(env_cpu(env
));
1014 void helper_booke_set_eplc(CPUPPCState
*env
, target_ulong val
)
1016 env
->spr
[SPR_BOOKE_EPLC
] = val
& EPID_MASK
;
1017 tlb_flush_by_mmuidx(env_cpu(env
), 1 << PPC_TLB_EPID_LOAD
);
1019 void helper_booke_set_epsc(CPUPPCState
*env
, target_ulong val
)
1021 env
->spr
[SPR_BOOKE_EPSC
] = val
& EPID_MASK
;
1022 tlb_flush_by_mmuidx(env_cpu(env
), 1 << PPC_TLB_EPID_STORE
);
1025 static inline void flush_page(CPUPPCState
*env
, ppcmas_tlb_t
*tlb
)
1027 if (booke206_tlb_to_page_size(env
, tlb
) == TARGET_PAGE_SIZE
) {
1028 tlb_flush_page(env_cpu(env
), tlb
->mas2
& MAS2_EPN_MASK
);
1030 tlb_flush(env_cpu(env
));
1034 void helper_booke206_tlbwe(CPUPPCState
*env
)
1036 uint32_t tlbncfg
, tlbn
;
1038 uint32_t size_tlb
, size_ps
;
1042 switch (env
->spr
[SPR_BOOKE_MAS0
] & MAS0_WQ_MASK
) {
1043 case MAS0_WQ_ALWAYS
:
1044 /* good to go, write that entry */
1047 /* XXX check if reserved */
1052 case MAS0_WQ_CLR_RSRV
:
1053 /* XXX clear entry */
1056 /* no idea what to do */
1060 if (((env
->spr
[SPR_BOOKE_MAS0
] & MAS0_ATSEL
) == MAS0_ATSEL_LRAT
) &&
1061 !FIELD_EX64(env
->msr
, MSR
, GS
)) {
1062 /* XXX we don't support direct LRAT setting yet */
1063 fprintf(stderr
, "cpu: don't support LRAT setting yet\n");
1067 tlbn
= (env
->spr
[SPR_BOOKE_MAS0
] & MAS0_TLBSEL_MASK
) >> MAS0_TLBSEL_SHIFT
;
1068 tlbncfg
= env
->spr
[SPR_BOOKE_TLB0CFG
+ tlbn
];
1070 tlb
= booke206_cur_tlb(env
);
1073 raise_exception_err_ra(env
, POWERPC_EXCP_PROGRAM
,
1074 POWERPC_EXCP_INVAL
|
1075 POWERPC_EXCP_INVAL_INVAL
, GETPC());
1078 /* check that we support the targeted size */
1079 size_tlb
= (env
->spr
[SPR_BOOKE_MAS1
] & MAS1_TSIZE_MASK
) >> MAS1_TSIZE_SHIFT
;
1080 size_ps
= booke206_tlbnps(env
, tlbn
);
1081 if ((env
->spr
[SPR_BOOKE_MAS1
] & MAS1_VALID
) && (tlbncfg
& TLBnCFG_AVAIL
) &&
1082 !(size_ps
& (1 << size_tlb
))) {
1083 raise_exception_err_ra(env
, POWERPC_EXCP_PROGRAM
,
1084 POWERPC_EXCP_INVAL
|
1085 POWERPC_EXCP_INVAL_INVAL
, GETPC());
1088 if (FIELD_EX64(env
->msr
, MSR
, GS
)) {
1089 cpu_abort(env_cpu(env
), "missing HV implementation\n");
1092 if (tlb
->mas1
& MAS1_VALID
) {
1094 * Invalidate the page in QEMU TLB if it was a valid entry.
1096 * In "PowerPC e500 Core Family Reference Manual, Rev. 1",
1097 * Section "12.4.2 TLB Write Entry (tlbwe) Instruction":
1098 * (https://www.nxp.com/docs/en/reference-manual/E500CORERM.pdf)
1100 * "Note that when an L2 TLB entry is written, it may be displacing an
1101 * already valid entry in the same L2 TLB location (a victim). If a
1102 * valid L1 TLB entry corresponds to the L2 MMU victim entry, that L1
1103 * TLB entry is automatically invalidated."
1105 flush_page(env
, tlb
);
1108 tlb
->mas7_3
= ((uint64_t)env
->spr
[SPR_BOOKE_MAS7
] << 32) |
1109 env
->spr
[SPR_BOOKE_MAS3
];
1110 tlb
->mas1
= env
->spr
[SPR_BOOKE_MAS1
];
1112 if ((env
->spr
[SPR_MMUCFG
] & MMUCFG_MAVN
) == MMUCFG_MAVN_V2
) {
1113 /* For TLB which has a fixed size TSIZE is ignored with MAV2 */
1114 booke206_fixed_size_tlbn(env
, tlbn
, tlb
);
1116 if (!(tlbncfg
& TLBnCFG_AVAIL
)) {
1117 /* force !AVAIL TLB entries to correct page size */
1118 tlb
->mas1
&= ~MAS1_TSIZE_MASK
;
1119 /* XXX can be configured in MMUCSR0 */
1120 tlb
->mas1
|= (tlbncfg
& TLBnCFG_MINSIZE
) >> 12;
1124 /* Make a mask from TLB size to discard invalid bits in EPN field */
1125 mask
= ~(booke206_tlb_to_page_size(env
, tlb
) - 1);
1126 /* Add a mask for page attributes */
1127 mask
|= MAS2_ACM
| MAS2_VLE
| MAS2_W
| MAS2_I
| MAS2_M
| MAS2_G
| MAS2_E
;
1129 if (!FIELD_EX64(env
->msr
, MSR
, CM
)) {
1131 * Executing a tlbwe instruction in 32-bit mode will set bits
1132 * 0:31 of the TLB EPN field to zero.
1137 tlb
->mas2
= env
->spr
[SPR_BOOKE_MAS2
] & mask
;
1139 if (!(tlbncfg
& TLBnCFG_IPROT
)) {
1140 /* no IPROT supported by TLB */
1141 tlb
->mas1
&= ~MAS1_IPROT
;
1144 flush_page(env
, tlb
);
1147 static inline void booke206_tlb_to_mas(CPUPPCState
*env
, ppcmas_tlb_t
*tlb
)
1149 int tlbn
= booke206_tlbm_to_tlbn(env
, tlb
);
1150 int way
= booke206_tlbm_to_way(env
, tlb
);
1152 env
->spr
[SPR_BOOKE_MAS0
] = tlbn
<< MAS0_TLBSEL_SHIFT
;
1153 env
->spr
[SPR_BOOKE_MAS0
] |= way
<< MAS0_ESEL_SHIFT
;
1154 env
->spr
[SPR_BOOKE_MAS0
] |= env
->last_way
<< MAS0_NV_SHIFT
;
1156 env
->spr
[SPR_BOOKE_MAS1
] = tlb
->mas1
;
1157 env
->spr
[SPR_BOOKE_MAS2
] = tlb
->mas2
;
1158 env
->spr
[SPR_BOOKE_MAS3
] = tlb
->mas7_3
;
1159 env
->spr
[SPR_BOOKE_MAS7
] = tlb
->mas7_3
>> 32;
1162 void helper_booke206_tlbre(CPUPPCState
*env
)
1164 ppcmas_tlb_t
*tlb
= NULL
;
1166 tlb
= booke206_cur_tlb(env
);
1168 env
->spr
[SPR_BOOKE_MAS1
] = 0;
1170 booke206_tlb_to_mas(env
, tlb
);
1174 void helper_booke206_tlbsx(CPUPPCState
*env
, target_ulong address
)
1176 ppcmas_tlb_t
*tlb
= NULL
;
1181 spid
= (env
->spr
[SPR_BOOKE_MAS6
] & MAS6_SPID_MASK
) >> MAS6_SPID_SHIFT
;
1182 sas
= env
->spr
[SPR_BOOKE_MAS6
] & MAS6_SAS
;
1184 for (i
= 0; i
< BOOKE206_MAX_TLBN
; i
++) {
1185 int ways
= booke206_tlb_ways(env
, i
);
1187 for (j
= 0; j
< ways
; j
++) {
1188 tlb
= booke206_get_tlbm(env
, i
, address
, j
);
1194 if (ppcmas_tlb_check(env
, tlb
, &raddr
, address
, spid
)) {
1198 if (sas
!= ((tlb
->mas1
& MAS1_TS
) >> MAS1_TS_SHIFT
)) {
1202 booke206_tlb_to_mas(env
, tlb
);
1207 /* no entry found, fill with defaults */
1208 env
->spr
[SPR_BOOKE_MAS0
] = env
->spr
[SPR_BOOKE_MAS4
] & MAS4_TLBSELD_MASK
;
1209 env
->spr
[SPR_BOOKE_MAS1
] = env
->spr
[SPR_BOOKE_MAS4
] & MAS4_TSIZED_MASK
;
1210 env
->spr
[SPR_BOOKE_MAS2
] = env
->spr
[SPR_BOOKE_MAS4
] & MAS4_WIMGED_MASK
;
1211 env
->spr
[SPR_BOOKE_MAS3
] = 0;
1212 env
->spr
[SPR_BOOKE_MAS7
] = 0;
1214 if (env
->spr
[SPR_BOOKE_MAS6
] & MAS6_SAS
) {
1215 env
->spr
[SPR_BOOKE_MAS1
] |= MAS1_TS
;
1218 env
->spr
[SPR_BOOKE_MAS1
] |= (env
->spr
[SPR_BOOKE_MAS6
] >> 16)
1221 /* next victim logic */
1222 env
->spr
[SPR_BOOKE_MAS0
] |= env
->last_way
<< MAS0_ESEL_SHIFT
;
1224 env
->last_way
&= booke206_tlb_ways(env
, 0) - 1;
1225 env
->spr
[SPR_BOOKE_MAS0
] |= env
->last_way
<< MAS0_NV_SHIFT
;
1228 static inline void booke206_invalidate_ea_tlb(CPUPPCState
*env
, int tlbn
,
1232 int ways
= booke206_tlb_ways(env
, tlbn
);
1235 for (i
= 0; i
< ways
; i
++) {
1236 ppcmas_tlb_t
*tlb
= booke206_get_tlbm(env
, tlbn
, ea
, i
);
1240 mask
= ~(booke206_tlb_to_page_size(env
, tlb
) - 1);
1241 if (((tlb
->mas2
& MAS2_EPN_MASK
) == (ea
& mask
)) &&
1242 !(tlb
->mas1
& MAS1_IPROT
)) {
1243 tlb
->mas1
&= ~MAS1_VALID
;
1248 void helper_booke206_tlbivax(CPUPPCState
*env
, target_ulong address
)
1252 if (address
& 0x4) {
1253 /* flush all entries */
1254 if (address
& 0x8) {
1255 /* flush all of TLB1 */
1256 booke206_flush_tlb(env
, BOOKE206_FLUSH_TLB1
, 1);
1258 /* flush all of TLB0 */
1259 booke206_flush_tlb(env
, BOOKE206_FLUSH_TLB0
, 0);
1264 if (address
& 0x8) {
1265 /* flush TLB1 entries */
1266 booke206_invalidate_ea_tlb(env
, 1, address
);
1271 /* flush TLB0 entries */
1272 booke206_invalidate_ea_tlb(env
, 0, address
);
1274 tlb_flush_page(cs
, address
& MAS2_EPN_MASK
);
1279 void helper_booke206_tlbilx0(CPUPPCState
*env
, target_ulong address
)
1281 /* XXX missing LPID handling */
1282 booke206_flush_tlb(env
, -1, 1);
1285 void helper_booke206_tlbilx1(CPUPPCState
*env
, target_ulong address
)
1288 int tid
= (env
->spr
[SPR_BOOKE_MAS6
] & MAS6_SPID
);
1289 ppcmas_tlb_t
*tlb
= env
->tlb
.tlbm
;
1292 /* XXX missing LPID handling */
1293 for (i
= 0; i
< BOOKE206_MAX_TLBN
; i
++) {
1294 tlb_size
= booke206_tlb_size(env
, i
);
1295 for (j
= 0; j
< tlb_size
; j
++) {
1296 if (!(tlb
[j
].mas1
& MAS1_IPROT
) &&
1297 ((tlb
[j
].mas1
& MAS1_TID_MASK
) == tid
)) {
1298 tlb
[j
].mas1
&= ~MAS1_VALID
;
1301 tlb
+= booke206_tlb_size(env
, i
);
1303 tlb_flush(env_cpu(env
));
1306 void helper_booke206_tlbilx3(CPUPPCState
*env
, target_ulong address
)
1310 int tid
= (env
->spr
[SPR_BOOKE_MAS6
] & MAS6_SPID
);
1311 int pid
= tid
>> MAS6_SPID_SHIFT
;
1312 int sgs
= env
->spr
[SPR_BOOKE_MAS5
] & MAS5_SGS
;
1313 int ind
= (env
->spr
[SPR_BOOKE_MAS6
] & MAS6_SIND
) ? MAS1_IND
: 0;
1314 /* XXX check for unsupported isize and raise an invalid opcode then */
1315 int size
= env
->spr
[SPR_BOOKE_MAS6
] & MAS6_ISIZE_MASK
;
1316 /* XXX implement MAV2 handling */
1319 /* XXX missing LPID handling */
1320 /* flush by pid and ea */
1321 for (i
= 0; i
< BOOKE206_MAX_TLBN
; i
++) {
1322 int ways
= booke206_tlb_ways(env
, i
);
1324 for (j
= 0; j
< ways
; j
++) {
1325 tlb
= booke206_get_tlbm(env
, i
, address
, j
);
1329 if ((ppcmas_tlb_check(env
, tlb
, NULL
, address
, pid
) != 0) ||
1330 (tlb
->mas1
& MAS1_IPROT
) ||
1331 ((tlb
->mas1
& MAS1_IND
) != ind
) ||
1332 ((tlb
->mas8
& MAS8_TGS
) != sgs
)) {
1335 if (mav2
&& ((tlb
->mas1
& MAS1_TSIZE_MASK
) != size
)) {
1336 /* XXX only check when MMUCFG[TWC] || TLBnCFG[HES] */
1339 /* XXX e500mc doesn't match SAS, but other cores might */
1340 tlb
->mas1
&= ~MAS1_VALID
;
1343 tlb_flush(env_cpu(env
));
1346 void helper_booke206_tlbflush(CPUPPCState
*env
, target_ulong type
)
1351 flags
|= BOOKE206_FLUSH_TLB1
;
1355 flags
|= BOOKE206_FLUSH_TLB0
;
1358 booke206_flush_tlb(env
, flags
, 1);
1362 void helper_check_tlb_flush_local(CPUPPCState
*env
)
1364 check_tlb_flush(env
, false);
1367 void helper_check_tlb_flush_global(CPUPPCState
*env
)
1369 check_tlb_flush(env
, true);
1373 bool ppc_cpu_tlb_fill(CPUState
*cs
, vaddr eaddr
, int size
,
1374 MMUAccessType access_type
, int mmu_idx
,
1375 bool probe
, uintptr_t retaddr
)
1377 PowerPCCPU
*cpu
= POWERPC_CPU(cs
);
1379 int page_size
, prot
;
1381 if (ppc_xlate(cpu
, eaddr
, access_type
, &raddr
,
1382 &page_size
, &prot
, mmu_idx
, !probe
)) {
1383 tlb_set_page(cs
, eaddr
& TARGET_PAGE_MASK
, raddr
& TARGET_PAGE_MASK
,
1384 prot
, mmu_idx
, 1UL << page_size
);
1390 raise_exception_err_ra(&cpu
->env
, cs
->exception_index
,
1391 cpu
->env
.error_code
, retaddr
);