4 * Copyright (c) 2003-2005 Fabrice Bellard
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 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"
22 #include "exec/exec-all.h"
23 #include "qemu/qemu-print.h"
26 /* Sparc MMU emulation */
28 #if defined(CONFIG_USER_ONLY)
30 bool sparc_cpu_tlb_fill(CPUState
*cs
, vaddr address
, int size
,
31 MMUAccessType access_type
, int mmu_idx
,
32 bool probe
, uintptr_t retaddr
)
34 SPARCCPU
*cpu
= SPARC_CPU(cs
);
35 CPUSPARCState
*env
= &cpu
->env
;
37 if (access_type
== MMU_INST_FETCH
) {
38 cs
->exception_index
= TT_TFAULT
;
40 cs
->exception_index
= TT_DFAULT
;
42 env
->dmmu
.mmuregs
[4] = address
;
44 env
->mmuregs
[4] = address
;
47 cpu_loop_exit_restore(cs
, retaddr
);
52 #ifndef TARGET_SPARC64
54 * Sparc V8 Reference MMU (SRMMU)
56 static const int access_table
[8][8] = {
57 { 0, 0, 0, 0, 8, 0, 12, 12 },
58 { 0, 0, 0, 0, 8, 0, 0, 0 },
59 { 8, 8, 0, 0, 0, 8, 12, 12 },
60 { 8, 8, 0, 0, 0, 8, 0, 0 },
61 { 8, 0, 8, 0, 8, 8, 12, 12 },
62 { 8, 0, 8, 0, 8, 0, 8, 0 },
63 { 8, 8, 8, 0, 8, 8, 12, 12 },
64 { 8, 8, 8, 0, 8, 8, 8, 0 }
67 static const int perm_table
[2][8] = {
70 PAGE_READ
| PAGE_WRITE
,
71 PAGE_READ
| PAGE_EXEC
,
72 PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
,
74 PAGE_READ
| PAGE_WRITE
,
75 PAGE_READ
| PAGE_EXEC
,
76 PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
80 PAGE_READ
| PAGE_WRITE
,
81 PAGE_READ
| PAGE_EXEC
,
82 PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
,
90 static int get_physical_address(CPUSPARCState
*env
, hwaddr
*physical
,
91 int *prot
, int *access_index
,
92 target_ulong address
, int rw
, int mmu_idx
,
93 target_ulong
*page_size
)
98 int error_code
= 0, is_dirty
, is_user
;
99 unsigned long page_offset
;
100 CPUState
*cs
= env_cpu(env
);
102 is_user
= mmu_idx
== MMU_USER_IDX
;
104 if (mmu_idx
== MMU_PHYS_IDX
) {
105 *page_size
= TARGET_PAGE_SIZE
;
106 /* Boot mode: instruction fetches are taken from PROM */
107 if (rw
== 2 && (env
->mmuregs
[0] & env
->def
.mmu_bm
)) {
108 *physical
= env
->prom_addr
| (address
& 0x7ffffULL
);
109 *prot
= PAGE_READ
| PAGE_EXEC
;
113 *prot
= PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
;
117 *access_index
= ((rw
& 1) << 2) | (rw
& 2) | (is_user
? 0 : 1);
118 *physical
= 0xffffffffffff0000ULL
;
120 /* SPARC reference MMU table walk: Context table->L1->L2->PTE */
121 /* Context base + context number */
122 pde_ptr
= (env
->mmuregs
[1] << 4) + (env
->mmuregs
[2] << 2);
123 pde
= ldl_phys(cs
->as
, pde_ptr
);
126 switch (pde
& PTE_ENTRYTYPE_MASK
) {
128 case 0: /* Invalid */
130 case 2: /* L0 PTE, maybe should not happen? */
131 case 3: /* Reserved */
134 pde_ptr
= ((address
>> 22) & ~3) + ((pde
& ~3) << 4);
135 pde
= ldl_phys(cs
->as
, pde_ptr
);
137 switch (pde
& PTE_ENTRYTYPE_MASK
) {
139 case 0: /* Invalid */
140 return (1 << 8) | (1 << 2);
141 case 3: /* Reserved */
142 return (1 << 8) | (4 << 2);
144 pde_ptr
= ((address
& 0xfc0000) >> 16) + ((pde
& ~3) << 4);
145 pde
= ldl_phys(cs
->as
, pde_ptr
);
147 switch (pde
& PTE_ENTRYTYPE_MASK
) {
149 case 0: /* Invalid */
150 return (2 << 8) | (1 << 2);
151 case 3: /* Reserved */
152 return (2 << 8) | (4 << 2);
154 pde_ptr
= ((address
& 0x3f000) >> 10) + ((pde
& ~3) << 4);
155 pde
= ldl_phys(cs
->as
, pde_ptr
);
157 switch (pde
& PTE_ENTRYTYPE_MASK
) {
159 case 0: /* Invalid */
160 return (3 << 8) | (1 << 2);
161 case 1: /* PDE, should not happen */
162 case 3: /* Reserved */
163 return (3 << 8) | (4 << 2);
167 *page_size
= TARGET_PAGE_SIZE
;
170 page_offset
= address
& 0x3f000;
171 *page_size
= 0x40000;
175 page_offset
= address
& 0xfff000;
176 *page_size
= 0x1000000;
181 access_perms
= (pde
& PTE_ACCESS_MASK
) >> PTE_ACCESS_SHIFT
;
182 error_code
= access_table
[*access_index
][access_perms
];
183 if (error_code
&& !((env
->mmuregs
[0] & MMU_NF
) && is_user
)) {
187 /* update page modified and dirty bits */
188 is_dirty
= (rw
& 1) && !(pde
& PG_MODIFIED_MASK
);
189 if (!(pde
& PG_ACCESSED_MASK
) || is_dirty
) {
190 pde
|= PG_ACCESSED_MASK
;
192 pde
|= PG_MODIFIED_MASK
;
194 stl_phys_notdirty(cs
->as
, pde_ptr
, pde
);
197 /* the page can be put in the TLB */
198 *prot
= perm_table
[is_user
][access_perms
];
199 if (!(pde
& PG_MODIFIED_MASK
)) {
200 /* only set write access if already dirty... otherwise wait
202 *prot
&= ~PAGE_WRITE
;
205 /* Even if large ptes, we map only one 4KB page in the cache to
206 avoid filling it too fast */
207 *physical
= ((hwaddr
)(pde
& PTE_ADDR_MASK
) << 4) + page_offset
;
211 /* Perform address translation */
212 bool sparc_cpu_tlb_fill(CPUState
*cs
, vaddr address
, int size
,
213 MMUAccessType access_type
, int mmu_idx
,
214 bool probe
, uintptr_t retaddr
)
216 SPARCCPU
*cpu
= SPARC_CPU(cs
);
217 CPUSPARCState
*env
= &cpu
->env
;
220 target_ulong page_size
;
221 int error_code
= 0, prot
, access_index
;
224 * TODO: If we ever need tlb_vaddr_to_host for this target,
225 * then we must figure out how to manipulate FSR and FAR
226 * when both MMU_NF and probe are set. In the meantime,
227 * do not support this use case.
231 address
&= TARGET_PAGE_MASK
;
232 error_code
= get_physical_address(env
, &paddr
, &prot
, &access_index
,
233 address
, access_type
,
234 mmu_idx
, &page_size
);
236 if (likely(error_code
== 0)) {
237 qemu_log_mask(CPU_LOG_MMU
,
238 "Translate at %" VADDR_PRIx
" -> "
239 TARGET_FMT_plx
", vaddr " TARGET_FMT_lx
"\n",
240 address
, paddr
, vaddr
);
241 tlb_set_page(cs
, vaddr
, paddr
, prot
, mmu_idx
, page_size
);
245 if (env
->mmuregs
[3]) { /* Fault status register */
246 env
->mmuregs
[3] = 1; /* overflow (not read before another fault) */
248 env
->mmuregs
[3] |= (access_index
<< 5) | error_code
| 2;
249 env
->mmuregs
[4] = address
; /* Fault address register */
251 if ((env
->mmuregs
[0] & MMU_NF
) || env
->psret
== 0) {
252 /* No fault mode: if a mapping is available, just override
253 permissions. If no mapping is available, redirect accesses to
254 neverland. Fake/overridden mappings will be flushed when
255 switching to normal mode. */
256 prot
= PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
;
257 tlb_set_page(cs
, vaddr
, paddr
, prot
, mmu_idx
, TARGET_PAGE_SIZE
);
260 if (access_type
== MMU_INST_FETCH
) {
261 cs
->exception_index
= TT_TFAULT
;
263 cs
->exception_index
= TT_DFAULT
;
265 cpu_loop_exit_restore(cs
, retaddr
);
269 target_ulong
mmu_probe(CPUSPARCState
*env
, target_ulong address
, int mmulev
)
271 CPUState
*cs
= env_cpu(env
);
275 /* Context base + context number */
276 pde_ptr
= (hwaddr
)(env
->mmuregs
[1] << 4) +
277 (env
->mmuregs
[2] << 2);
278 pde
= ldl_phys(cs
->as
, pde_ptr
);
280 switch (pde
& PTE_ENTRYTYPE_MASK
) {
282 case 0: /* Invalid */
283 case 2: /* PTE, maybe should not happen? */
284 case 3: /* Reserved */
290 pde_ptr
= ((address
>> 22) & ~3) + ((pde
& ~3) << 4);
291 pde
= ldl_phys(cs
->as
, pde_ptr
);
293 switch (pde
& PTE_ENTRYTYPE_MASK
) {
295 case 0: /* Invalid */
296 case 3: /* Reserved */
304 pde_ptr
= ((address
& 0xfc0000) >> 16) + ((pde
& ~3) << 4);
305 pde
= ldl_phys(cs
->as
, pde_ptr
);
307 switch (pde
& PTE_ENTRYTYPE_MASK
) {
309 case 0: /* Invalid */
310 case 3: /* Reserved */
318 pde_ptr
= ((address
& 0x3f000) >> 10) + ((pde
& ~3) << 4);
319 pde
= ldl_phys(cs
->as
, pde_ptr
);
321 switch (pde
& PTE_ENTRYTYPE_MASK
) {
323 case 0: /* Invalid */
324 case 1: /* PDE, should not happen */
325 case 3: /* Reserved */
336 void dump_mmu(CPUSPARCState
*env
)
338 CPUState
*cs
= env_cpu(env
);
339 target_ulong va
, va1
, va2
;
340 unsigned int n
, m
, o
;
344 pde_ptr
= (env
->mmuregs
[1] << 4) + (env
->mmuregs
[2] << 2);
345 pde
= ldl_phys(cs
->as
, pde_ptr
);
346 qemu_printf("Root ptr: " TARGET_FMT_plx
", ctx: %d\n",
347 (hwaddr
)env
->mmuregs
[1] << 4, env
->mmuregs
[2]);
348 for (n
= 0, va
= 0; n
< 256; n
++, va
+= 16 * 1024 * 1024) {
349 pde
= mmu_probe(env
, va
, 2);
351 pa
= cpu_get_phys_page_debug(cs
, va
);
352 qemu_printf("VA: " TARGET_FMT_lx
", PA: " TARGET_FMT_plx
353 " PDE: " TARGET_FMT_lx
"\n", va
, pa
, pde
);
354 for (m
= 0, va1
= va
; m
< 64; m
++, va1
+= 256 * 1024) {
355 pde
= mmu_probe(env
, va1
, 1);
357 pa
= cpu_get_phys_page_debug(cs
, va1
);
358 qemu_printf(" VA: " TARGET_FMT_lx
", PA: "
359 TARGET_FMT_plx
" PDE: " TARGET_FMT_lx
"\n",
361 for (o
= 0, va2
= va1
; o
< 64; o
++, va2
+= 4 * 1024) {
362 pde
= mmu_probe(env
, va2
, 0);
364 pa
= cpu_get_phys_page_debug(cs
, va2
);
365 qemu_printf(" VA: " TARGET_FMT_lx
", PA: "
366 TARGET_FMT_plx
" PTE: "
377 /* Gdb expects all registers windows to be flushed in ram. This function handles
378 * reads (and only reads) in stack frames as if windows were flushed. We assume
379 * that the sparc ABI is followed.
381 int sparc_cpu_memory_rw_debug(CPUState
*cs
, vaddr address
,
382 uint8_t *buf
, int len
, bool is_write
)
384 SPARCCPU
*cpu
= SPARC_CPU(cs
);
385 CPUSPARCState
*env
= &cpu
->env
;
386 target_ulong addr
= address
;
392 for (i
= 0; i
< env
->nwindows
; i
++) {
394 target_ulong fp
= env
->regbase
[cwp
* 16 + 22];
396 /* Assume fp == 0 means end of frame. */
401 cwp
= cpu_cwp_inc(env
, cwp
+ 1);
403 /* Invalid window ? */
404 if (env
->wim
& (1 << cwp
)) {
408 /* According to the ABI, the stack is growing downward. */
409 if (addr
+ len
< fp
) {
413 /* Not in this frame. */
414 if (addr
> fp
+ 64) {
418 /* Handle access before this window. */
421 if (cpu_memory_rw_debug(cs
, addr
, buf
, len1
, is_write
) != 0) {
429 /* Access byte per byte to registers. Not very efficient but speed
439 for (; len1
; len1
--) {
440 int reg
= cwp
* 16 + 8 + (off
>> 2);
445 u
.v
= cpu_to_be32(env
->regbase
[reg
]);
446 *buf
++ = u
.c
[off
& 3];
457 return cpu_memory_rw_debug(cs
, addr
, buf
, len
, is_write
);
460 #else /* !TARGET_SPARC64 */
462 /* 41 bit physical address space */
463 static inline hwaddr
ultrasparc_truncate_physical(uint64_t x
)
465 return x
& 0x1ffffffffffULL
;
469 * UltraSparc IIi I/DMMUs
472 /* Returns true if TTE tag is valid and matches virtual address value
473 in context requires virtual address mask value calculated from TTE
475 static inline int ultrasparc_tag_match(SparcTLBEntry
*tlb
,
476 uint64_t address
, uint64_t context
,
479 uint64_t mask
= -(8192ULL << 3 * TTE_PGSIZE(tlb
->tte
));
481 /* valid, context match, virtual address match? */
482 if (TTE_IS_VALID(tlb
->tte
) &&
483 (TTE_IS_GLOBAL(tlb
->tte
) || tlb_compare_context(tlb
, context
))
484 && compare_masked(address
, tlb
->tag
, mask
)) {
485 /* decode physical address */
486 *physical
= ((tlb
->tte
& mask
) | (address
& ~mask
)) & 0x1ffffffe000ULL
;
493 static int get_physical_address_data(CPUSPARCState
*env
,
494 hwaddr
*physical
, int *prot
,
495 target_ulong address
, int rw
, int mmu_idx
)
497 CPUState
*cs
= env_cpu(env
);
501 bool is_user
= false;
505 g_assert_not_reached();
510 context
= env
->dmmu
.mmu_primary_context
& 0x1fff;
511 sfsr
|= SFSR_CT_PRIMARY
;
513 case MMU_USER_SECONDARY_IDX
:
516 case MMU_KERNEL_SECONDARY_IDX
:
517 context
= env
->dmmu
.mmu_secondary_context
& 0x1fff;
518 sfsr
|= SFSR_CT_SECONDARY
;
520 case MMU_NUCLEUS_IDX
:
521 sfsr
|= SFSR_CT_NUCLEUS
;
529 sfsr
|= SFSR_WRITE_BIT
;
530 } else if (rw
== 4) {
534 for (i
= 0; i
< 64; i
++) {
535 /* ctx match, vaddr match, valid? */
536 if (ultrasparc_tag_match(&env
->dtlb
[i
], address
, context
, physical
)) {
540 /* multiple bits in SFSR.FT may be set on TT_DFAULT */
541 if (TTE_IS_PRIV(env
->dtlb
[i
].tte
) && is_user
) {
543 sfsr
|= SFSR_FT_PRIV_BIT
; /* privilege violation */
544 trace_mmu_helper_dfault(address
, context
, mmu_idx
, env
->tl
);
547 if (TTE_IS_SIDEEFFECT(env
->dtlb
[i
].tte
)) {
549 sfsr
|= SFSR_FT_NF_E_BIT
;
552 if (TTE_IS_NFO(env
->dtlb
[i
].tte
)) {
554 sfsr
|= SFSR_FT_NFO_BIT
;
559 /* faults above are reported with TT_DFAULT. */
560 cs
->exception_index
= TT_DFAULT
;
561 } else if (!TTE_IS_W_OK(env
->dtlb
[i
].tte
) && (rw
== 1)) {
563 cs
->exception_index
= TT_DPROT
;
565 trace_mmu_helper_dprot(address
, context
, mmu_idx
, env
->tl
);
570 if (TTE_IS_W_OK(env
->dtlb
[i
].tte
)) {
574 TTE_SET_USED(env
->dtlb
[i
].tte
);
579 if (env
->dmmu
.sfsr
& SFSR_VALID_BIT
) { /* Fault status register */
580 sfsr
|= SFSR_OW_BIT
; /* overflow (not read before
584 if (env
->pstate
& PS_PRIV
) {
588 /* FIXME: ASI field in SFSR must be set */
589 env
->dmmu
.sfsr
= sfsr
| SFSR_VALID_BIT
;
591 env
->dmmu
.sfar
= address
; /* Fault address register */
593 env
->dmmu
.tag_access
= (address
& ~0x1fffULL
) | context
;
599 trace_mmu_helper_dmiss(address
, context
);
603 * - UltraSPARC IIi: SFSR and SFAR unmodified
604 * - JPS1: SFAR updated and some fields of SFSR updated
606 env
->dmmu
.tag_access
= (address
& ~0x1fffULL
) | context
;
607 cs
->exception_index
= TT_DMISS
;
611 static int get_physical_address_code(CPUSPARCState
*env
,
612 hwaddr
*physical
, int *prot
,
613 target_ulong address
, int mmu_idx
)
615 CPUState
*cs
= env_cpu(env
);
618 bool is_user
= false;
622 case MMU_USER_SECONDARY_IDX
:
623 case MMU_KERNEL_SECONDARY_IDX
:
624 g_assert_not_reached();
629 context
= env
->dmmu
.mmu_primary_context
& 0x1fff;
637 /* PRIMARY context */
638 context
= env
->dmmu
.mmu_primary_context
& 0x1fff;
640 /* NUCLEUS context */
644 for (i
= 0; i
< 64; i
++) {
645 /* ctx match, vaddr match, valid? */
646 if (ultrasparc_tag_match(&env
->itlb
[i
],
647 address
, context
, physical
)) {
649 if (TTE_IS_PRIV(env
->itlb
[i
].tte
) && is_user
) {
650 /* Fault status register */
651 if (env
->immu
.sfsr
& SFSR_VALID_BIT
) {
652 env
->immu
.sfsr
= SFSR_OW_BIT
; /* overflow (not read before
657 if (env
->pstate
& PS_PRIV
) {
658 env
->immu
.sfsr
|= SFSR_PR_BIT
;
661 env
->immu
.sfsr
|= SFSR_CT_NUCLEUS
;
664 /* FIXME: ASI field in SFSR must be set */
665 env
->immu
.sfsr
|= SFSR_FT_PRIV_BIT
| SFSR_VALID_BIT
;
666 cs
->exception_index
= TT_TFAULT
;
668 env
->immu
.tag_access
= (address
& ~0x1fffULL
) | context
;
670 trace_mmu_helper_tfault(address
, context
);
675 TTE_SET_USED(env
->itlb
[i
].tte
);
680 trace_mmu_helper_tmiss(address
, context
);
682 /* Context is stored in DMMU (dmmuregs[1]) also for IMMU */
683 env
->immu
.tag_access
= (address
& ~0x1fffULL
) | context
;
684 cs
->exception_index
= TT_TMISS
;
688 static int get_physical_address(CPUSPARCState
*env
, hwaddr
*physical
,
689 int *prot
, int *access_index
,
690 target_ulong address
, int rw
, int mmu_idx
,
691 target_ulong
*page_size
)
693 /* ??? We treat everything as a small page, then explicitly flush
694 everything when an entry is evicted. */
695 *page_size
= TARGET_PAGE_SIZE
;
697 /* safety net to catch wrong softmmu index use from dynamic code */
698 if (env
->tl
> 0 && mmu_idx
!= MMU_NUCLEUS_IDX
) {
700 trace_mmu_helper_get_phys_addr_code(env
->tl
, mmu_idx
,
701 env
->dmmu
.mmu_primary_context
,
702 env
->dmmu
.mmu_secondary_context
,
705 trace_mmu_helper_get_phys_addr_data(env
->tl
, mmu_idx
,
706 env
->dmmu
.mmu_primary_context
,
707 env
->dmmu
.mmu_secondary_context
,
712 if (mmu_idx
== MMU_PHYS_IDX
) {
713 *physical
= ultrasparc_truncate_physical(address
);
714 *prot
= PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
;
719 return get_physical_address_code(env
, physical
, prot
, address
,
722 return get_physical_address_data(env
, physical
, prot
, address
, rw
,
727 /* Perform address translation */
728 bool sparc_cpu_tlb_fill(CPUState
*cs
, vaddr address
, int size
,
729 MMUAccessType access_type
, int mmu_idx
,
730 bool probe
, uintptr_t retaddr
)
732 SPARCCPU
*cpu
= SPARC_CPU(cs
);
733 CPUSPARCState
*env
= &cpu
->env
;
736 target_ulong page_size
;
737 int error_code
= 0, prot
, access_index
;
739 address
&= TARGET_PAGE_MASK
;
740 error_code
= get_physical_address(env
, &paddr
, &prot
, &access_index
,
741 address
, access_type
,
742 mmu_idx
, &page_size
);
743 if (likely(error_code
== 0)) {
746 trace_mmu_helper_mmu_fault(address
, paddr
, mmu_idx
, env
->tl
,
747 env
->dmmu
.mmu_primary_context
,
748 env
->dmmu
.mmu_secondary_context
);
750 tlb_set_page(cs
, vaddr
, paddr
, prot
, mmu_idx
, page_size
);
756 cpu_loop_exit_restore(cs
, retaddr
);
759 void dump_mmu(CPUSPARCState
*env
)
764 qemu_printf("MMU contexts: Primary: %" PRId64
", Secondary: %"
766 env
->dmmu
.mmu_primary_context
,
767 env
->dmmu
.mmu_secondary_context
);
768 qemu_printf("DMMU Tag Access: %" PRIx64
", TSB Tag Target: %" PRIx64
769 "\n", env
->dmmu
.tag_access
, env
->dmmu
.tsb_tag_target
);
770 if ((env
->lsu
& DMMU_E
) == 0) {
771 qemu_printf("DMMU disabled\n");
773 qemu_printf("DMMU dump\n");
774 for (i
= 0; i
< 64; i
++) {
775 switch (TTE_PGSIZE(env
->dtlb
[i
].tte
)) {
790 if (TTE_IS_VALID(env
->dtlb
[i
].tte
)) {
791 qemu_printf("[%02u] VA: %" PRIx64
", PA: %llx"
792 ", %s, %s, %s, %s, ctx %" PRId64
" %s\n",
794 env
->dtlb
[i
].tag
& (uint64_t)~0x1fffULL
,
795 TTE_PA(env
->dtlb
[i
].tte
),
797 TTE_IS_PRIV(env
->dtlb
[i
].tte
) ? "priv" : "user",
798 TTE_IS_W_OK(env
->dtlb
[i
].tte
) ? "RW" : "RO",
799 TTE_IS_LOCKED(env
->dtlb
[i
].tte
) ?
800 "locked" : "unlocked",
801 env
->dtlb
[i
].tag
& (uint64_t)0x1fffULL
,
802 TTE_IS_GLOBAL(env
->dtlb
[i
].tte
) ?
807 if ((env
->lsu
& IMMU_E
) == 0) {
808 qemu_printf("IMMU disabled\n");
810 qemu_printf("IMMU dump\n");
811 for (i
= 0; i
< 64; i
++) {
812 switch (TTE_PGSIZE(env
->itlb
[i
].tte
)) {
827 if (TTE_IS_VALID(env
->itlb
[i
].tte
)) {
828 qemu_printf("[%02u] VA: %" PRIx64
", PA: %llx"
829 ", %s, %s, %s, ctx %" PRId64
" %s\n",
831 env
->itlb
[i
].tag
& (uint64_t)~0x1fffULL
,
832 TTE_PA(env
->itlb
[i
].tte
),
834 TTE_IS_PRIV(env
->itlb
[i
].tte
) ? "priv" : "user",
835 TTE_IS_LOCKED(env
->itlb
[i
].tte
) ?
836 "locked" : "unlocked",
837 env
->itlb
[i
].tag
& (uint64_t)0x1fffULL
,
838 TTE_IS_GLOBAL(env
->itlb
[i
].tte
) ?
845 #endif /* TARGET_SPARC64 */
847 static int cpu_sparc_get_phys_page(CPUSPARCState
*env
, hwaddr
*phys
,
848 target_ulong addr
, int rw
, int mmu_idx
)
850 target_ulong page_size
;
851 int prot
, access_index
;
853 return get_physical_address(env
, phys
, &prot
, &access_index
, addr
, rw
,
854 mmu_idx
, &page_size
);
857 #if defined(TARGET_SPARC64)
858 hwaddr
cpu_get_phys_page_nofault(CPUSPARCState
*env
, target_ulong addr
,
863 if (cpu_sparc_get_phys_page(env
, &phys_addr
, addr
, 4, mmu_idx
) != 0) {
870 hwaddr
sparc_cpu_get_phys_page_debug(CPUState
*cs
, vaddr addr
)
872 SPARCCPU
*cpu
= SPARC_CPU(cs
);
873 CPUSPARCState
*env
= &cpu
->env
;
875 int mmu_idx
= cpu_mmu_index(env
, false);
877 if (cpu_sparc_get_phys_page(env
, &phys_addr
, addr
, 2, mmu_idx
) != 0) {
878 if (cpu_sparc_get_phys_page(env
, &phys_addr
, addr
, 0, mmu_idx
) != 0) {