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.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"
23 #include "exec/exec-all.h"
24 #include "qemu/qemu-print.h"
27 /* Sparc MMU emulation */
29 #ifndef TARGET_SPARC64
31 * Sparc V8 Reference MMU (SRMMU)
33 static const int access_table[8][8] = {
34 { 0, 0, 0, 0, 8, 0, 12, 12 },
35 { 0, 0, 0, 0, 8, 0, 0, 0 },
36 { 8, 8, 0, 0, 0, 8, 12, 12 },
37 { 8, 8, 0, 0, 0, 8, 0, 0 },
38 { 8, 0, 8, 0, 8, 8, 12, 12 },
39 { 8, 0, 8, 0, 8, 0, 8, 0 },
40 { 8, 8, 8, 0, 8, 8, 12, 12 },
41 { 8, 8, 8, 0, 8, 8, 8, 0 }
44 static const int perm_table[2][8] = {
47 PAGE_READ | PAGE_WRITE,
48 PAGE_READ | PAGE_EXEC,
49 PAGE_READ | PAGE_WRITE | PAGE_EXEC,
51 PAGE_READ | PAGE_WRITE,
52 PAGE_READ | PAGE_EXEC,
53 PAGE_READ | PAGE_WRITE | PAGE_EXEC
57 PAGE_READ | PAGE_WRITE,
58 PAGE_READ | PAGE_EXEC,
59 PAGE_READ | PAGE_WRITE | PAGE_EXEC,
67 static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,
68 int *access_index, target_ulong address,
74 int error_code = 0, is_dirty, is_user;
75 unsigned long page_offset;
76 CPUState *cs = env_cpu(env);
79 is_user = mmu_idx == MMU_USER_IDX;
81 if (mmu_idx == MMU_PHYS_IDX) {
82 full->lg_page_size = TARGET_PAGE_BITS;
83 /* Boot mode: instruction fetches are taken from PROM */
84 if (rw == 2 && (env->mmuregs[0] & env->def.mmu_bm)) {
85 full->phys_addr = env->prom_addr | (address & 0x7ffffULL);
86 full->prot = PAGE_READ | PAGE_EXEC;
89 full->phys_addr = address;
90 full->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
94 *access_index = ((rw & 1) << 2) | (rw & 2) | (is_user ? 0 : 1);
95 full->phys_addr = 0xffffffffffff0000ULL;
97 /* SPARC reference MMU table walk: Context table->L1->L2->PTE */
98 /* Context base + context number */
99 pde_ptr = (env->mmuregs[1] << 4) + (env->mmuregs[2] << 2);
100 pde = address_space_ldl(cs->as, pde_ptr, MEMTXATTRS_UNSPECIFIED, &result);
101 if (result != MEMTX_OK) {
102 return 4 << 2; /* Translation fault, L = 0 */
106 switch (pde & PTE_ENTRYTYPE_MASK) {
108 case 0: /* Invalid */
110 case 2: /* L0 PTE, maybe should not happen? */
111 case 3: /* Reserved */
114 pde_ptr = ((address >> 22) & ~3) + ((pde & ~3) << 4);
115 pde = address_space_ldl(cs->as, pde_ptr,
116 MEMTXATTRS_UNSPECIFIED, &result);
117 if (result != MEMTX_OK) {
118 return (1 << 8) | (4 << 2); /* Translation fault, L = 1 */
121 switch (pde & PTE_ENTRYTYPE_MASK) {
123 case 0: /* Invalid */
124 return (1 << 8) | (1 << 2);
125 case 3: /* Reserved */
126 return (1 << 8) | (4 << 2);
128 pde_ptr = ((address & 0xfc0000) >> 16) + ((pde & ~3) << 4);
129 pde = address_space_ldl(cs->as, pde_ptr,
130 MEMTXATTRS_UNSPECIFIED, &result);
131 if (result != MEMTX_OK) {
132 return (2 << 8) | (4 << 2); /* Translation fault, L = 2 */
135 switch (pde & PTE_ENTRYTYPE_MASK) {
137 case 0: /* Invalid */
138 return (2 << 8) | (1 << 2);
139 case 3: /* Reserved */
140 return (2 << 8) | (4 << 2);
142 pde_ptr = ((address & 0x3f000) >> 10) + ((pde & ~3) << 4);
143 pde = address_space_ldl(cs->as, pde_ptr,
144 MEMTXATTRS_UNSPECIFIED, &result);
145 if (result != MEMTX_OK) {
146 return (3 << 8) | (4 << 2); /* Translation fault, L = 3 */
149 switch (pde & PTE_ENTRYTYPE_MASK) {
151 case 0: /* Invalid */
152 return (3 << 8) | (1 << 2);
153 case 1: /* PDE, should not happen */
154 case 3: /* Reserved */
155 return (3 << 8) | (4 << 2);
159 full->lg_page_size = TARGET_PAGE_BITS;
162 page_offset = address & 0x3f000;
163 full->lg_page_size = 18;
167 page_offset = address & 0xfff000;
168 full->lg_page_size = 24;
174 access_perms = (pde & PTE_ACCESS_MASK) >> PTE_ACCESS_SHIFT;
175 error_code = access_table[*access_index][access_perms];
176 if (error_code && !((env->mmuregs[0] & MMU_NF) && is_user)) {
180 /* update page modified and dirty bits */
181 is_dirty = (rw & 1) && !(pde & PG_MODIFIED_MASK);
182 if (!(pde & PG_ACCESSED_MASK) || is_dirty) {
183 pde |= PG_ACCESSED_MASK;
185 pde |= PG_MODIFIED_MASK;
187 stl_phys_notdirty(cs->as, pde_ptr, pde);
190 /* the page can be put in the TLB */
191 full->prot = perm_table[is_user][access_perms];
192 if (!(pde & PG_MODIFIED_MASK)) {
193 /* only set write access if already dirty... otherwise wait
195 full->prot &= ~PAGE_WRITE;
198 /* Even if large ptes, we map only one 4KB page in the cache to
199 avoid filling it too fast */
200 full->phys_addr = ((hwaddr)(pde & PTE_ADDR_MASK) << 4) + page_offset;
204 /* Perform address translation */
205 bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
206 MMUAccessType access_type, int mmu_idx,
207 bool probe, uintptr_t retaddr)
209 SPARCCPU *cpu = SPARC_CPU(cs);
210 CPUSPARCState *env = &cpu->env;
211 CPUTLBEntryFull full = {};
213 int error_code = 0, access_index;
216 * TODO: If we ever need tlb_vaddr_to_host for this target,
217 * then we must figure out how to manipulate FSR and FAR
218 * when both MMU_NF and probe are set. In the meantime,
219 * do not support this use case.
223 address &= TARGET_PAGE_MASK;
224 error_code = get_physical_address(env, &full, &access_index,
225 address, access_type, mmu_idx);
227 if (likely(error_code == 0)) {
228 qemu_log_mask(CPU_LOG_MMU,
229 "Translate at %" VADDR_PRIx " -> "
230 HWADDR_FMT_plx ", vaddr " TARGET_FMT_lx "\n",
231 address, full.phys_addr, vaddr);
232 tlb_set_page_full(cs, mmu_idx, vaddr, &full);
236 if (env->mmuregs[3]) { /* Fault status register */
237 env->mmuregs[3] = 1; /* overflow (not read before another fault) */
239 env->mmuregs[3] |= (access_index << 5) | error_code | 2;
240 env->mmuregs[4] = address; /* Fault address register */
242 if ((env->mmuregs[0] & MMU_NF) || env->psret == 0) {
243 /* No fault mode: if a mapping is available, just override
244 permissions. If no mapping is available, redirect accesses to
245 neverland. Fake/overridden mappings will be flushed when
246 switching to normal mode. */
247 full.prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
248 tlb_set_page_full(cs, mmu_idx, vaddr, &full);
251 if (access_type == MMU_INST_FETCH) {
252 cs->exception_index = TT_TFAULT;
254 cs->exception_index = TT_DFAULT;
256 cpu_loop_exit_restore(cs, retaddr);
260 target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev)
262 CPUState *cs = env_cpu(env);
268 * TODO: MMU probe operations are supposed to set the fault
269 * status registers, but we don't do this.
272 /* Context base + context number */
273 pde_ptr = (hwaddr)(env->mmuregs[1] << 4) +
274 (env->mmuregs[2] << 2);
275 pde = address_space_ldl(cs->as, pde_ptr, MEMTXATTRS_UNSPECIFIED, &result);
276 if (result != MEMTX_OK) {
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 = address_space_ldl(cs->as, pde_ptr,
292 MEMTXATTRS_UNSPECIFIED, &result);
293 if (result != MEMTX_OK) {
297 switch (pde & PTE_ENTRYTYPE_MASK) {
299 case 0: /* Invalid */
300 case 3: /* Reserved */
308 pde_ptr = ((address & 0xfc0000) >> 16) + ((pde & ~3) << 4);
309 pde = address_space_ldl(cs->as, pde_ptr,
310 MEMTXATTRS_UNSPECIFIED, &result);
311 if (result != MEMTX_OK) {
315 switch (pde & PTE_ENTRYTYPE_MASK) {
317 case 0: /* Invalid */
318 case 3: /* Reserved */
326 pde_ptr = ((address & 0x3f000) >> 10) + ((pde & ~3) << 4);
327 pde = address_space_ldl(cs->as, pde_ptr,
328 MEMTXATTRS_UNSPECIFIED, &result);
329 if (result != MEMTX_OK) {
333 switch (pde & PTE_ENTRYTYPE_MASK) {
335 case 0: /* Invalid */
336 case 1: /* PDE, should not happen */
337 case 3: /* Reserved */
348 void dump_mmu(CPUSPARCState *env)
350 CPUState *cs = env_cpu(env);
351 target_ulong va, va1, va2;
352 unsigned int n, m, o;
356 qemu_printf("Root ptr: " HWADDR_FMT_plx ", ctx: %d\n",
357 (hwaddr)env->mmuregs[1] << 4, env->mmuregs[2]);
358 for (n = 0, va = 0; n < 256; n++, va += 16 * 1024 * 1024) {
359 pde = mmu_probe(env, va, 2);
361 pa = cpu_get_phys_page_debug(cs, va);
362 qemu_printf("VA: " TARGET_FMT_lx ", PA: " HWADDR_FMT_plx
363 " PDE: " TARGET_FMT_lx "\n", va, pa, pde);
364 for (m = 0, va1 = va; m < 64; m++, va1 += 256 * 1024) {
365 pde = mmu_probe(env, va1, 1);
367 pa = cpu_get_phys_page_debug(cs, va1);
368 qemu_printf(" VA: " TARGET_FMT_lx ", PA: "
369 HWADDR_FMT_plx " PDE: " TARGET_FMT_lx "\n",
371 for (o = 0, va2 = va1; o < 64; o++, va2 += 4 * 1024) {
372 pde = mmu_probe(env, va2, 0);
374 pa = cpu_get_phys_page_debug(cs, va2);
375 qemu_printf(" VA: " TARGET_FMT_lx ", PA: "
376 HWADDR_FMT_plx " PTE: "
387 /* Gdb expects all registers windows to be flushed in ram. This function handles
388 * reads (and only reads) in stack frames as if windows were flushed. We assume
389 * that the sparc ABI is followed.
391 int sparc_cpu_memory_rw_debug(CPUState *cs, vaddr address,
392 uint8_t *buf, int len, bool is_write)
394 SPARCCPU *cpu = SPARC_CPU(cs);
395 CPUSPARCState *env = &cpu->env;
396 target_ulong addr = address;
402 for (i = 0; i < env->nwindows; i++) {
404 target_ulong fp = env->regbase[cwp * 16 + 22];
406 /* Assume fp == 0 means end of frame. */
411 cwp = cpu_cwp_inc(env, cwp + 1);
413 /* Invalid window ? */
414 if (env->wim & (1 << cwp)) {
418 /* According to the ABI, the stack is growing downward. */
419 if (addr + len < fp) {
423 /* Not in this frame. */
424 if (addr > fp + 64) {
428 /* Handle access before this window. */
431 if (cpu_memory_rw_debug(cs, addr, buf, len1, is_write) != 0) {
439 /* Access byte per byte to registers. Not very efficient but speed
449 for (; len1; len1--) {
450 int reg = cwp * 16 + 8 + (off >> 2);
455 u.v = cpu_to_be32(env->regbase[reg]);
456 *buf++ = u.c[off & 3];
467 return cpu_memory_rw_debug(cs, addr, buf, len, is_write);
470 #else /* !TARGET_SPARC64 */
472 /* 41 bit physical address space */
473 static inline hwaddr ultrasparc_truncate_physical(uint64_t x)
475 return x & 0x1ffffffffffULL;
479 * UltraSparc IIi I/DMMUs
482 /* Returns true if TTE tag is valid and matches virtual address value
483 in context requires virtual address mask value calculated from TTE
485 static inline int ultrasparc_tag_match(SparcTLBEntry *tlb,
486 uint64_t address, uint64_t context,
489 uint64_t mask = -(8192ULL << 3 * TTE_PGSIZE(tlb->tte));
491 /* valid, context match, virtual address match? */
492 if (TTE_IS_VALID(tlb->tte) &&
493 (TTE_IS_GLOBAL(tlb->tte) || tlb_compare_context(tlb, context))
494 && compare_masked(address, tlb->tag, mask)) {
495 /* decode physical address */
496 *physical = ((tlb->tte & mask) | (address & ~mask)) & 0x1ffffffe000ULL;
503 static uint64_t build_sfsr(CPUSPARCState *env, int mmu_idx, int rw)
505 uint64_t sfsr = SFSR_VALID_BIT;
509 sfsr |= SFSR_CT_NOTRANS;
513 sfsr |= SFSR_CT_PRIMARY;
515 case MMU_USER_SECONDARY_IDX:
516 case MMU_KERNEL_SECONDARY_IDX:
517 sfsr |= SFSR_CT_SECONDARY;
519 case MMU_NUCLEUS_IDX:
520 sfsr |= SFSR_CT_NUCLEUS;
523 g_assert_not_reached();
527 sfsr |= SFSR_WRITE_BIT;
528 } else if (rw == 4) {
532 if (env->pstate & PS_PRIV) {
536 if (env->dmmu.sfsr & SFSR_VALID_BIT) { /* Fault status register */
537 sfsr |= SFSR_OW_BIT; /* overflow (not read before another fault) */
540 /* FIXME: ASI field in SFSR must be set */
545 static int get_physical_address_data(CPUSPARCState *env, CPUTLBEntryFull *full,
546 target_ulong address, int rw, int mmu_idx)
548 CPUState *cs = env_cpu(env);
552 bool is_user = false;
554 sfsr = build_sfsr(env, mmu_idx, rw);
558 g_assert_not_reached();
563 context = env->dmmu.mmu_primary_context & 0x1fff;
565 case MMU_USER_SECONDARY_IDX:
568 case MMU_KERNEL_SECONDARY_IDX:
569 context = env->dmmu.mmu_secondary_context & 0x1fff;
576 for (i = 0; i < 64; i++) {
577 /* ctx match, vaddr match, valid? */
578 if (ultrasparc_tag_match(&env->dtlb[i], address, context,
582 if (TTE_IS_IE(env->dtlb[i].tte)) {
583 full->attrs.byte_swap = true;
587 /* multiple bits in SFSR.FT may be set on TT_DFAULT */
588 if (TTE_IS_PRIV(env->dtlb[i].tte) && is_user) {
590 sfsr |= SFSR_FT_PRIV_BIT; /* privilege violation */
591 trace_mmu_helper_dfault(address, context, mmu_idx, env->tl);
594 if (TTE_IS_SIDEEFFECT(env->dtlb[i].tte)) {
596 sfsr |= SFSR_FT_NF_E_BIT;
599 if (TTE_IS_NFO(env->dtlb[i].tte)) {
601 sfsr |= SFSR_FT_NFO_BIT;
606 /* faults above are reported with TT_DFAULT. */
607 cs->exception_index = TT_DFAULT;
608 } else if (!TTE_IS_W_OK(env->dtlb[i].tte) && (rw == 1)) {
610 cs->exception_index = TT_DPROT;
612 trace_mmu_helper_dprot(address, context, mmu_idx, env->tl);
616 full->prot = PAGE_READ;
617 if (TTE_IS_W_OK(env->dtlb[i].tte)) {
618 full->prot |= PAGE_WRITE;
621 TTE_SET_USED(env->dtlb[i].tte);
626 env->dmmu.sfsr = sfsr;
627 env->dmmu.sfar = address; /* Fault address register */
628 env->dmmu.tag_access = (address & ~0x1fffULL) | context;
633 trace_mmu_helper_dmiss(address, context);
637 * - UltraSPARC IIi: SFSR and SFAR unmodified
638 * - JPS1: SFAR updated and some fields of SFSR updated
640 env->dmmu.tag_access = (address & ~0x1fffULL) | context;
641 cs->exception_index = TT_DMISS;
645 static int get_physical_address_code(CPUSPARCState *env, CPUTLBEntryFull *full,
646 target_ulong address, int mmu_idx)
648 CPUState *cs = env_cpu(env);
651 bool is_user = false;
655 case MMU_USER_SECONDARY_IDX:
656 case MMU_KERNEL_SECONDARY_IDX:
657 g_assert_not_reached();
662 context = env->dmmu.mmu_primary_context & 0x1fff;
670 /* PRIMARY context */
671 context = env->dmmu.mmu_primary_context & 0x1fff;
673 /* NUCLEUS context */
677 for (i = 0; i < 64; i++) {
678 /* ctx match, vaddr match, valid? */
679 if (ultrasparc_tag_match(&env->itlb[i],
680 address, context, &full->phys_addr)) {
682 if (TTE_IS_PRIV(env->itlb[i].tte) && is_user) {
683 /* Fault status register */
684 if (env->immu.sfsr & SFSR_VALID_BIT) {
685 env->immu.sfsr = SFSR_OW_BIT; /* overflow (not read before
690 if (env->pstate & PS_PRIV) {
691 env->immu.sfsr |= SFSR_PR_BIT;
694 env->immu.sfsr |= SFSR_CT_NUCLEUS;
697 /* FIXME: ASI field in SFSR must be set */
698 env->immu.sfsr |= SFSR_FT_PRIV_BIT | SFSR_VALID_BIT;
699 cs->exception_index = TT_TFAULT;
701 env->immu.tag_access = (address & ~0x1fffULL) | context;
703 trace_mmu_helper_tfault(address, context);
707 full->prot = PAGE_EXEC;
708 TTE_SET_USED(env->itlb[i].tte);
713 trace_mmu_helper_tmiss(address, context);
715 /* Context is stored in DMMU (dmmuregs[1]) also for IMMU */
716 env->immu.tag_access = (address & ~0x1fffULL) | context;
717 cs->exception_index = TT_TMISS;
721 static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,
722 int *access_index, target_ulong address,
725 /* ??? We treat everything as a small page, then explicitly flush
726 everything when an entry is evicted. */
727 full->lg_page_size = TARGET_PAGE_BITS;
729 /* safety net to catch wrong softmmu index use from dynamic code */
730 if (env->tl > 0 && mmu_idx != MMU_NUCLEUS_IDX) {
732 trace_mmu_helper_get_phys_addr_code(env->tl, mmu_idx,
733 env->dmmu.mmu_primary_context,
734 env->dmmu.mmu_secondary_context,
737 trace_mmu_helper_get_phys_addr_data(env->tl, mmu_idx,
738 env->dmmu.mmu_primary_context,
739 env->dmmu.mmu_secondary_context,
744 if (mmu_idx == MMU_PHYS_IDX) {
745 full->phys_addr = ultrasparc_truncate_physical(address);
746 full->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
751 return get_physical_address_code(env, full, address, mmu_idx);
753 return get_physical_address_data(env, full, address, rw, mmu_idx);
757 /* Perform address translation */
758 bool sparc_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
759 MMUAccessType access_type, int mmu_idx,
760 bool probe, uintptr_t retaddr)
762 SPARCCPU *cpu = SPARC_CPU(cs);
763 CPUSPARCState *env = &cpu->env;
764 CPUTLBEntryFull full = {};
765 int error_code = 0, access_index;
767 address &= TARGET_PAGE_MASK;
768 error_code = get_physical_address(env, &full, &access_index,
769 address, access_type, mmu_idx);
770 if (likely(error_code == 0)) {
771 trace_mmu_helper_mmu_fault(address, full.phys_addr, mmu_idx, env->tl,
772 env->dmmu.mmu_primary_context,
773 env->dmmu.mmu_secondary_context);
774 tlb_set_page_full(cs, mmu_idx, address, &full);
780 cpu_loop_exit_restore(cs, retaddr);
783 void dump_mmu(CPUSPARCState *env)
788 qemu_printf("MMU contexts: Primary: %" PRId64 ", Secondary: %"
790 env->dmmu.mmu_primary_context,
791 env->dmmu.mmu_secondary_context);
792 qemu_printf("DMMU Tag Access: %" PRIx64 ", TSB Tag Target: %" PRIx64
793 "\n", env->dmmu.tag_access, env->dmmu.tsb_tag_target);
794 if ((env->lsu & DMMU_E) == 0) {
795 qemu_printf("DMMU disabled\n");
797 qemu_printf("DMMU dump\n");
798 for (i = 0; i < 64; i++) {
799 switch (TTE_PGSIZE(env->dtlb[i].tte)) {
814 if (TTE_IS_VALID(env->dtlb[i].tte)) {
815 qemu_printf("[%02u] VA: %" PRIx64 ", PA: %llx"
816 ", %s, %s, %s, %s, ie %s, ctx %" PRId64 " %s\n",
818 env->dtlb[i].tag & (uint64_t)~0x1fffULL,
819 TTE_PA(env->dtlb[i].tte),
821 TTE_IS_PRIV(env->dtlb[i].tte) ? "priv" : "user",
822 TTE_IS_W_OK(env->dtlb[i].tte) ? "RW" : "RO",
823 TTE_IS_LOCKED(env->dtlb[i].tte) ?
824 "locked" : "unlocked",
825 TTE_IS_IE(env->dtlb[i].tte) ?
827 env->dtlb[i].tag & (uint64_t)0x1fffULL,
828 TTE_IS_GLOBAL(env->dtlb[i].tte) ?
833 if ((env->lsu & IMMU_E) == 0) {
834 qemu_printf("IMMU disabled\n");
836 qemu_printf("IMMU dump\n");
837 for (i = 0; i < 64; i++) {
838 switch (TTE_PGSIZE(env->itlb[i].tte)) {
853 if (TTE_IS_VALID(env->itlb[i].tte)) {
854 qemu_printf("[%02u] VA: %" PRIx64 ", PA: %llx"
855 ", %s, %s, %s, ctx %" PRId64 " %s\n",
857 env->itlb[i].tag & (uint64_t)~0x1fffULL,
858 TTE_PA(env->itlb[i].tte),
860 TTE_IS_PRIV(env->itlb[i].tte) ? "priv" : "user",
861 TTE_IS_LOCKED(env->itlb[i].tte) ?
862 "locked" : "unlocked",
863 env->itlb[i].tag & (uint64_t)0x1fffULL,
864 TTE_IS_GLOBAL(env->itlb[i].tte) ?
871 #endif /* TARGET_SPARC64 */
873 static int cpu_sparc_get_phys_page(CPUSPARCState *env, hwaddr *phys,
874 target_ulong addr, int rw, int mmu_idx)
876 CPUTLBEntryFull full = {};
877 int access_index, ret;
879 ret = get_physical_address(env, &full, &access_index, addr, rw, mmu_idx);
881 *phys = full.phys_addr;
886 #if defined(TARGET_SPARC64)
887 hwaddr cpu_get_phys_page_nofault(CPUSPARCState *env, target_ulong addr,
892 if (cpu_sparc_get_phys_page(env, &phys_addr, addr, 4, mmu_idx) != 0) {
899 hwaddr sparc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
901 SPARCCPU *cpu = SPARC_CPU(cs);
902 CPUSPARCState *env = &cpu->env;
904 int mmu_idx = cpu_mmu_index(env, false);
906 if (cpu_sparc_get_phys_page(env, &phys_addr, addr, 2, mmu_idx) != 0) {
907 if (cpu_sparc_get_phys_page(env, &phys_addr, addr, 0, mmu_idx) != 0) {
914 G_NORETURN void sparc_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
915 MMUAccessType access_type,
919 SPARCCPU *cpu = SPARC_CPU(cs);
920 CPUSPARCState *env = &cpu->env;
922 #ifdef TARGET_SPARC64
923 env->dmmu.sfsr = build_sfsr(env, mmu_idx, access_type);
924 env->dmmu.sfar = addr;
926 env->mmuregs[4] = addr;
929 cpu_raise_exception_ra(env, TT_UNALIGNED, retaddr);