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"
25 /* Sparc MMU emulation */
27 #if defined(CONFIG_USER_ONLY)
29 int sparc_cpu_handle_mmu_fault(CPUState
*cs
, vaddr address
, int size
, int rw
,
32 SPARCCPU
*cpu
= SPARC_CPU(cs
);
33 CPUSPARCState
*env
= &cpu
->env
;
36 cs
->exception_index
= TT_TFAULT
;
38 cs
->exception_index
= TT_DFAULT
;
40 env
->dmmu
.mmuregs
[4] = address
;
42 env
->mmuregs
[4] = address
;
50 #ifndef TARGET_SPARC64
52 * Sparc V8 Reference MMU (SRMMU)
54 static const int access_table
[8][8] = {
55 { 0, 0, 0, 0, 8, 0, 12, 12 },
56 { 0, 0, 0, 0, 8, 0, 0, 0 },
57 { 8, 8, 0, 0, 0, 8, 12, 12 },
58 { 8, 8, 0, 0, 0, 8, 0, 0 },
59 { 8, 0, 8, 0, 8, 8, 12, 12 },
60 { 8, 0, 8, 0, 8, 0, 8, 0 },
61 { 8, 8, 8, 0, 8, 8, 12, 12 },
62 { 8, 8, 8, 0, 8, 8, 8, 0 }
65 static const int perm_table
[2][8] = {
68 PAGE_READ
| PAGE_WRITE
,
69 PAGE_READ
| PAGE_EXEC
,
70 PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
,
72 PAGE_READ
| PAGE_WRITE
,
73 PAGE_READ
| PAGE_EXEC
,
74 PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
78 PAGE_READ
| PAGE_WRITE
,
79 PAGE_READ
| PAGE_EXEC
,
80 PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
,
88 static int get_physical_address(CPUSPARCState
*env
, hwaddr
*physical
,
89 int *prot
, int *access_index
,
90 target_ulong address
, int rw
, int mmu_idx
,
91 target_ulong
*page_size
)
96 int error_code
= 0, is_dirty
, is_user
;
97 unsigned long page_offset
;
98 CPUState
*cs
= CPU(sparc_env_get_cpu(env
));
100 is_user
= mmu_idx
== MMU_USER_IDX
;
102 if (mmu_idx
== MMU_PHYS_IDX
) {
103 *page_size
= TARGET_PAGE_SIZE
;
104 /* Boot mode: instruction fetches are taken from PROM */
105 if (rw
== 2 && (env
->mmuregs
[0] & env
->def
.mmu_bm
)) {
106 *physical
= env
->prom_addr
| (address
& 0x7ffffULL
);
107 *prot
= PAGE_READ
| PAGE_EXEC
;
111 *prot
= PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
;
115 *access_index
= ((rw
& 1) << 2) | (rw
& 2) | (is_user
? 0 : 1);
116 *physical
= 0xffffffffffff0000ULL
;
118 /* SPARC reference MMU table walk: Context table->L1->L2->PTE */
119 /* Context base + context number */
120 pde_ptr
= (env
->mmuregs
[1] << 4) + (env
->mmuregs
[2] << 2);
121 pde
= ldl_phys(cs
->as
, pde_ptr
);
124 switch (pde
& PTE_ENTRYTYPE_MASK
) {
126 case 0: /* Invalid */
128 case 2: /* L0 PTE, maybe should not happen? */
129 case 3: /* Reserved */
132 pde_ptr
= ((address
>> 22) & ~3) + ((pde
& ~3) << 4);
133 pde
= ldl_phys(cs
->as
, pde_ptr
);
135 switch (pde
& PTE_ENTRYTYPE_MASK
) {
137 case 0: /* Invalid */
138 return (1 << 8) | (1 << 2);
139 case 3: /* Reserved */
140 return (1 << 8) | (4 << 2);
142 pde_ptr
= ((address
& 0xfc0000) >> 16) + ((pde
& ~3) << 4);
143 pde
= ldl_phys(cs
->as
, pde_ptr
);
145 switch (pde
& PTE_ENTRYTYPE_MASK
) {
147 case 0: /* Invalid */
148 return (2 << 8) | (1 << 2);
149 case 3: /* Reserved */
150 return (2 << 8) | (4 << 2);
152 pde_ptr
= ((address
& 0x3f000) >> 10) + ((pde
& ~3) << 4);
153 pde
= ldl_phys(cs
->as
, pde_ptr
);
155 switch (pde
& PTE_ENTRYTYPE_MASK
) {
157 case 0: /* Invalid */
158 return (3 << 8) | (1 << 2);
159 case 1: /* PDE, should not happen */
160 case 3: /* Reserved */
161 return (3 << 8) | (4 << 2);
165 *page_size
= TARGET_PAGE_SIZE
;
168 page_offset
= address
& 0x3f000;
169 *page_size
= 0x40000;
173 page_offset
= address
& 0xfff000;
174 *page_size
= 0x1000000;
179 access_perms
= (pde
& PTE_ACCESS_MASK
) >> PTE_ACCESS_SHIFT
;
180 error_code
= access_table
[*access_index
][access_perms
];
181 if (error_code
&& !((env
->mmuregs
[0] & MMU_NF
) && is_user
)) {
185 /* update page modified and dirty bits */
186 is_dirty
= (rw
& 1) && !(pde
& PG_MODIFIED_MASK
);
187 if (!(pde
& PG_ACCESSED_MASK
) || is_dirty
) {
188 pde
|= PG_ACCESSED_MASK
;
190 pde
|= PG_MODIFIED_MASK
;
192 stl_phys_notdirty(cs
->as
, pde_ptr
, pde
);
195 /* the page can be put in the TLB */
196 *prot
= perm_table
[is_user
][access_perms
];
197 if (!(pde
& PG_MODIFIED_MASK
)) {
198 /* only set write access if already dirty... otherwise wait
200 *prot
&= ~PAGE_WRITE
;
203 /* Even if large ptes, we map only one 4KB page in the cache to
204 avoid filling it too fast */
205 *physical
= ((hwaddr
)(pde
& PTE_ADDR_MASK
) << 4) + page_offset
;
209 /* Perform address translation */
210 int sparc_cpu_handle_mmu_fault(CPUState
*cs
, vaddr address
, int size
, int rw
,
213 SPARCCPU
*cpu
= SPARC_CPU(cs
);
214 CPUSPARCState
*env
= &cpu
->env
;
217 target_ulong page_size
;
218 int error_code
= 0, prot
, access_index
;
220 address
&= TARGET_PAGE_MASK
;
221 error_code
= get_physical_address(env
, &paddr
, &prot
, &access_index
,
222 address
, rw
, mmu_idx
, &page_size
);
224 if (error_code
== 0) {
225 qemu_log_mask(CPU_LOG_MMU
,
226 "Translate at %" VADDR_PRIx
" -> " TARGET_FMT_plx
", vaddr "
227 TARGET_FMT_lx
"\n", address
, paddr
, vaddr
);
228 tlb_set_page(cs
, vaddr
, paddr
, prot
, mmu_idx
, page_size
);
232 if (env
->mmuregs
[3]) { /* Fault status register */
233 env
->mmuregs
[3] = 1; /* overflow (not read before another fault) */
235 env
->mmuregs
[3] |= (access_index
<< 5) | error_code
| 2;
236 env
->mmuregs
[4] = address
; /* Fault address register */
238 if ((env
->mmuregs
[0] & MMU_NF
) || env
->psret
== 0) {
239 /* No fault mode: if a mapping is available, just override
240 permissions. If no mapping is available, redirect accesses to
241 neverland. Fake/overridden mappings will be flushed when
242 switching to normal mode. */
243 prot
= PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
;
244 tlb_set_page(cs
, vaddr
, paddr
, prot
, mmu_idx
, TARGET_PAGE_SIZE
);
248 cs
->exception_index
= TT_TFAULT
;
250 cs
->exception_index
= TT_DFAULT
;
256 target_ulong
mmu_probe(CPUSPARCState
*env
, target_ulong address
, int mmulev
)
258 CPUState
*cs
= CPU(sparc_env_get_cpu(env
));
262 /* Context base + context number */
263 pde_ptr
= (hwaddr
)(env
->mmuregs
[1] << 4) +
264 (env
->mmuregs
[2] << 2);
265 pde
= ldl_phys(cs
->as
, pde_ptr
);
267 switch (pde
& PTE_ENTRYTYPE_MASK
) {
269 case 0: /* Invalid */
270 case 2: /* PTE, maybe should not happen? */
271 case 3: /* Reserved */
277 pde_ptr
= ((address
>> 22) & ~3) + ((pde
& ~3) << 4);
278 pde
= ldl_phys(cs
->as
, pde_ptr
);
280 switch (pde
& PTE_ENTRYTYPE_MASK
) {
282 case 0: /* Invalid */
283 case 3: /* Reserved */
291 pde_ptr
= ((address
& 0xfc0000) >> 16) + ((pde
& ~3) << 4);
292 pde
= ldl_phys(cs
->as
, pde_ptr
);
294 switch (pde
& PTE_ENTRYTYPE_MASK
) {
296 case 0: /* Invalid */
297 case 3: /* Reserved */
305 pde_ptr
= ((address
& 0x3f000) >> 10) + ((pde
& ~3) << 4);
306 pde
= ldl_phys(cs
->as
, pde_ptr
);
308 switch (pde
& PTE_ENTRYTYPE_MASK
) {
310 case 0: /* Invalid */
311 case 1: /* PDE, should not happen */
312 case 3: /* Reserved */
323 void dump_mmu(FILE *f
, fprintf_function cpu_fprintf
, CPUSPARCState
*env
)
325 CPUState
*cs
= CPU(sparc_env_get_cpu(env
));
326 target_ulong va
, va1
, va2
;
327 unsigned int n
, m
, o
;
331 pde_ptr
= (env
->mmuregs
[1] << 4) + (env
->mmuregs
[2] << 2);
332 pde
= ldl_phys(cs
->as
, pde_ptr
);
333 (*cpu_fprintf
)(f
, "Root ptr: " TARGET_FMT_plx
", ctx: %d\n",
334 (hwaddr
)env
->mmuregs
[1] << 4, env
->mmuregs
[2]);
335 for (n
= 0, va
= 0; n
< 256; n
++, va
+= 16 * 1024 * 1024) {
336 pde
= mmu_probe(env
, va
, 2);
338 pa
= cpu_get_phys_page_debug(cs
, va
);
339 (*cpu_fprintf
)(f
, "VA: " TARGET_FMT_lx
", PA: " TARGET_FMT_plx
340 " PDE: " TARGET_FMT_lx
"\n", va
, pa
, pde
);
341 for (m
= 0, va1
= va
; m
< 64; m
++, va1
+= 256 * 1024) {
342 pde
= mmu_probe(env
, va1
, 1);
344 pa
= cpu_get_phys_page_debug(cs
, va1
);
345 (*cpu_fprintf
)(f
, " VA: " TARGET_FMT_lx
", PA: "
346 TARGET_FMT_plx
" PDE: " TARGET_FMT_lx
"\n",
348 for (o
= 0, va2
= va1
; o
< 64; o
++, va2
+= 4 * 1024) {
349 pde
= mmu_probe(env
, va2
, 0);
351 pa
= cpu_get_phys_page_debug(cs
, va2
);
352 (*cpu_fprintf
)(f
, " VA: " TARGET_FMT_lx
", PA: "
353 TARGET_FMT_plx
" PTE: "
364 /* Gdb expects all registers windows to be flushed in ram. This function handles
365 * reads (and only reads) in stack frames as if windows were flushed. We assume
366 * that the sparc ABI is followed.
368 int sparc_cpu_memory_rw_debug(CPUState
*cs
, vaddr address
,
369 uint8_t *buf
, int len
, bool is_write
)
371 SPARCCPU
*cpu
= SPARC_CPU(cs
);
372 CPUSPARCState
*env
= &cpu
->env
;
373 target_ulong addr
= address
;
379 for (i
= 0; i
< env
->nwindows
; i
++) {
381 target_ulong fp
= env
->regbase
[cwp
* 16 + 22];
383 /* Assume fp == 0 means end of frame. */
388 cwp
= cpu_cwp_inc(env
, cwp
+ 1);
390 /* Invalid window ? */
391 if (env
->wim
& (1 << cwp
)) {
395 /* According to the ABI, the stack is growing downward. */
396 if (addr
+ len
< fp
) {
400 /* Not in this frame. */
401 if (addr
> fp
+ 64) {
405 /* Handle access before this window. */
408 if (cpu_memory_rw_debug(cs
, addr
, buf
, len1
, is_write
) != 0) {
416 /* Access byte per byte to registers. Not very efficient but speed
426 for (; len1
; len1
--) {
427 int reg
= cwp
* 16 + 8 + (off
>> 2);
432 u
.v
= cpu_to_be32(env
->regbase
[reg
]);
433 *buf
++ = u
.c
[off
& 3];
444 return cpu_memory_rw_debug(cs
, addr
, buf
, len
, is_write
);
447 #else /* !TARGET_SPARC64 */
449 /* 41 bit physical address space */
450 static inline hwaddr
ultrasparc_truncate_physical(uint64_t x
)
452 return x
& 0x1ffffffffffULL
;
456 * UltraSparc IIi I/DMMUs
459 /* Returns true if TTE tag is valid and matches virtual address value
460 in context requires virtual address mask value calculated from TTE
462 static inline int ultrasparc_tag_match(SparcTLBEntry
*tlb
,
463 uint64_t address
, uint64_t context
,
466 uint64_t mask
= -(8192ULL << 3 * TTE_PGSIZE(tlb
->tte
));
468 /* valid, context match, virtual address match? */
469 if (TTE_IS_VALID(tlb
->tte
) &&
470 (TTE_IS_GLOBAL(tlb
->tte
) || tlb_compare_context(tlb
, context
))
471 && compare_masked(address
, tlb
->tag
, mask
)) {
472 /* decode physical address */
473 *physical
= ((tlb
->tte
& mask
) | (address
& ~mask
)) & 0x1ffffffe000ULL
;
480 static int get_physical_address_data(CPUSPARCState
*env
,
481 hwaddr
*physical
, int *prot
,
482 target_ulong address
, int rw
, int mmu_idx
)
484 CPUState
*cs
= CPU(sparc_env_get_cpu(env
));
488 bool is_user
= false;
492 g_assert_not_reached();
497 context
= env
->dmmu
.mmu_primary_context
& 0x1fff;
498 sfsr
|= SFSR_CT_PRIMARY
;
500 case MMU_USER_SECONDARY_IDX
:
503 case MMU_KERNEL_SECONDARY_IDX
:
504 context
= env
->dmmu
.mmu_secondary_context
& 0x1fff;
505 sfsr
|= SFSR_CT_SECONDARY
;
507 case MMU_NUCLEUS_IDX
:
508 sfsr
|= SFSR_CT_NUCLEUS
;
516 sfsr
|= SFSR_WRITE_BIT
;
517 } else if (rw
== 4) {
521 for (i
= 0; i
< 64; i
++) {
522 /* ctx match, vaddr match, valid? */
523 if (ultrasparc_tag_match(&env
->dtlb
[i
], address
, context
, physical
)) {
527 /* multiple bits in SFSR.FT may be set on TT_DFAULT */
528 if (TTE_IS_PRIV(env
->dtlb
[i
].tte
) && is_user
) {
530 sfsr
|= SFSR_FT_PRIV_BIT
; /* privilege violation */
531 trace_mmu_helper_dfault(address
, context
, mmu_idx
, env
->tl
);
534 if (TTE_IS_SIDEEFFECT(env
->dtlb
[i
].tte
)) {
536 sfsr
|= SFSR_FT_NF_E_BIT
;
539 if (TTE_IS_NFO(env
->dtlb
[i
].tte
)) {
541 sfsr
|= SFSR_FT_NFO_BIT
;
546 /* faults above are reported with TT_DFAULT. */
547 cs
->exception_index
= TT_DFAULT
;
548 } else if (!TTE_IS_W_OK(env
->dtlb
[i
].tte
) && (rw
== 1)) {
550 cs
->exception_index
= TT_DPROT
;
552 trace_mmu_helper_dprot(address
, context
, mmu_idx
, env
->tl
);
557 if (TTE_IS_W_OK(env
->dtlb
[i
].tte
)) {
561 TTE_SET_USED(env
->dtlb
[i
].tte
);
566 if (env
->dmmu
.sfsr
& SFSR_VALID_BIT
) { /* Fault status register */
567 sfsr
|= SFSR_OW_BIT
; /* overflow (not read before
571 if (env
->pstate
& PS_PRIV
) {
575 /* FIXME: ASI field in SFSR must be set */
576 env
->dmmu
.sfsr
= sfsr
| SFSR_VALID_BIT
;
578 env
->dmmu
.sfar
= address
; /* Fault address register */
580 env
->dmmu
.tag_access
= (address
& ~0x1fffULL
) | context
;
586 trace_mmu_helper_dmiss(address
, context
);
590 * - UltraSPARC IIi: SFSR and SFAR unmodified
591 * - JPS1: SFAR updated and some fields of SFSR updated
593 env
->dmmu
.tag_access
= (address
& ~0x1fffULL
) | context
;
594 cs
->exception_index
= TT_DMISS
;
598 static int get_physical_address_code(CPUSPARCState
*env
,
599 hwaddr
*physical
, int *prot
,
600 target_ulong address
, int mmu_idx
)
602 CPUState
*cs
= CPU(sparc_env_get_cpu(env
));
605 bool is_user
= false;
609 case MMU_USER_SECONDARY_IDX
:
610 case MMU_KERNEL_SECONDARY_IDX
:
611 g_assert_not_reached();
616 context
= env
->dmmu
.mmu_primary_context
& 0x1fff;
624 /* PRIMARY context */
625 context
= env
->dmmu
.mmu_primary_context
& 0x1fff;
627 /* NUCLEUS context */
631 for (i
= 0; i
< 64; i
++) {
632 /* ctx match, vaddr match, valid? */
633 if (ultrasparc_tag_match(&env
->itlb
[i
],
634 address
, context
, physical
)) {
636 if (TTE_IS_PRIV(env
->itlb
[i
].tte
) && is_user
) {
637 /* Fault status register */
638 if (env
->immu
.sfsr
& SFSR_VALID_BIT
) {
639 env
->immu
.sfsr
= SFSR_OW_BIT
; /* overflow (not read before
644 if (env
->pstate
& PS_PRIV
) {
645 env
->immu
.sfsr
|= SFSR_PR_BIT
;
648 env
->immu
.sfsr
|= SFSR_CT_NUCLEUS
;
651 /* FIXME: ASI field in SFSR must be set */
652 env
->immu
.sfsr
|= SFSR_FT_PRIV_BIT
| SFSR_VALID_BIT
;
653 cs
->exception_index
= TT_TFAULT
;
655 env
->immu
.tag_access
= (address
& ~0x1fffULL
) | context
;
657 trace_mmu_helper_tfault(address
, context
);
662 TTE_SET_USED(env
->itlb
[i
].tte
);
667 trace_mmu_helper_tmiss(address
, context
);
669 /* Context is stored in DMMU (dmmuregs[1]) also for IMMU */
670 env
->immu
.tag_access
= (address
& ~0x1fffULL
) | context
;
671 cs
->exception_index
= TT_TMISS
;
675 static int get_physical_address(CPUSPARCState
*env
, hwaddr
*physical
,
676 int *prot
, int *access_index
,
677 target_ulong address
, int rw
, int mmu_idx
,
678 target_ulong
*page_size
)
680 /* ??? We treat everything as a small page, then explicitly flush
681 everything when an entry is evicted. */
682 *page_size
= TARGET_PAGE_SIZE
;
684 /* safety net to catch wrong softmmu index use from dynamic code */
685 if (env
->tl
> 0 && mmu_idx
!= MMU_NUCLEUS_IDX
) {
687 trace_mmu_helper_get_phys_addr_code(env
->tl
, mmu_idx
,
688 env
->dmmu
.mmu_primary_context
,
689 env
->dmmu
.mmu_secondary_context
,
692 trace_mmu_helper_get_phys_addr_data(env
->tl
, mmu_idx
,
693 env
->dmmu
.mmu_primary_context
,
694 env
->dmmu
.mmu_secondary_context
,
699 if (mmu_idx
== MMU_PHYS_IDX
) {
700 *physical
= ultrasparc_truncate_physical(address
);
701 *prot
= PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
;
706 return get_physical_address_code(env
, physical
, prot
, address
,
709 return get_physical_address_data(env
, physical
, prot
, address
, rw
,
714 /* Perform address translation */
715 int sparc_cpu_handle_mmu_fault(CPUState
*cs
, vaddr address
, int size
, int rw
,
718 SPARCCPU
*cpu
= SPARC_CPU(cs
);
719 CPUSPARCState
*env
= &cpu
->env
;
722 target_ulong page_size
;
723 int error_code
= 0, prot
, access_index
;
725 address
&= TARGET_PAGE_MASK
;
726 error_code
= get_physical_address(env
, &paddr
, &prot
, &access_index
,
727 address
, rw
, mmu_idx
, &page_size
);
728 if (error_code
== 0) {
731 trace_mmu_helper_mmu_fault(address
, paddr
, mmu_idx
, env
->tl
,
732 env
->dmmu
.mmu_primary_context
,
733 env
->dmmu
.mmu_secondary_context
);
735 tlb_set_page(cs
, vaddr
, paddr
, prot
, mmu_idx
, page_size
);
742 void dump_mmu(FILE *f
, fprintf_function cpu_fprintf
, CPUSPARCState
*env
)
747 (*cpu_fprintf
)(f
, "MMU contexts: Primary: %" PRId64
", Secondary: %"
749 env
->dmmu
.mmu_primary_context
,
750 env
->dmmu
.mmu_secondary_context
);
751 (*cpu_fprintf
)(f
, "DMMU Tag Access: %" PRIx64
", TSB Tag Target: %" PRIx64
752 "\n", env
->dmmu
.tag_access
, env
->dmmu
.tsb_tag_target
);
753 if ((env
->lsu
& DMMU_E
) == 0) {
754 (*cpu_fprintf
)(f
, "DMMU disabled\n");
756 (*cpu_fprintf
)(f
, "DMMU dump\n");
757 for (i
= 0; i
< 64; i
++) {
758 switch (TTE_PGSIZE(env
->dtlb
[i
].tte
)) {
773 if (TTE_IS_VALID(env
->dtlb
[i
].tte
)) {
774 (*cpu_fprintf
)(f
, "[%02u] VA: %" PRIx64
", PA: %llx"
775 ", %s, %s, %s, %s, ctx %" PRId64
" %s\n",
777 env
->dtlb
[i
].tag
& (uint64_t)~0x1fffULL
,
778 TTE_PA(env
->dtlb
[i
].tte
),
780 TTE_IS_PRIV(env
->dtlb
[i
].tte
) ? "priv" : "user",
781 TTE_IS_W_OK(env
->dtlb
[i
].tte
) ? "RW" : "RO",
782 TTE_IS_LOCKED(env
->dtlb
[i
].tte
) ?
783 "locked" : "unlocked",
784 env
->dtlb
[i
].tag
& (uint64_t)0x1fffULL
,
785 TTE_IS_GLOBAL(env
->dtlb
[i
].tte
) ?
790 if ((env
->lsu
& IMMU_E
) == 0) {
791 (*cpu_fprintf
)(f
, "IMMU disabled\n");
793 (*cpu_fprintf
)(f
, "IMMU dump\n");
794 for (i
= 0; i
< 64; i
++) {
795 switch (TTE_PGSIZE(env
->itlb
[i
].tte
)) {
810 if (TTE_IS_VALID(env
->itlb
[i
].tte
)) {
811 (*cpu_fprintf
)(f
, "[%02u] VA: %" PRIx64
", PA: %llx"
812 ", %s, %s, %s, ctx %" PRId64
" %s\n",
814 env
->itlb
[i
].tag
& (uint64_t)~0x1fffULL
,
815 TTE_PA(env
->itlb
[i
].tte
),
817 TTE_IS_PRIV(env
->itlb
[i
].tte
) ? "priv" : "user",
818 TTE_IS_LOCKED(env
->itlb
[i
].tte
) ?
819 "locked" : "unlocked",
820 env
->itlb
[i
].tag
& (uint64_t)0x1fffULL
,
821 TTE_IS_GLOBAL(env
->itlb
[i
].tte
) ?
828 #endif /* TARGET_SPARC64 */
830 static int cpu_sparc_get_phys_page(CPUSPARCState
*env
, hwaddr
*phys
,
831 target_ulong addr
, int rw
, int mmu_idx
)
833 target_ulong page_size
;
834 int prot
, access_index
;
836 return get_physical_address(env
, phys
, &prot
, &access_index
, addr
, rw
,
837 mmu_idx
, &page_size
);
840 #if defined(TARGET_SPARC64)
841 hwaddr
cpu_get_phys_page_nofault(CPUSPARCState
*env
, target_ulong addr
,
846 if (cpu_sparc_get_phys_page(env
, &phys_addr
, addr
, 4, mmu_idx
) != 0) {
853 hwaddr
sparc_cpu_get_phys_page_debug(CPUState
*cs
, vaddr addr
)
855 SPARCCPU
*cpu
= SPARC_CPU(cs
);
856 CPUSPARCState
*env
= &cpu
->env
;
858 int mmu_idx
= cpu_mmu_index(env
, false);
860 if (cpu_sparc_get_phys_page(env
, &phys_addr
, addr
, 2, mmu_idx
) != 0) {
861 if (cpu_sparc_get_phys_page(env
, &phys_addr
, addr
, 0, mmu_idx
) != 0) {