From 8710ef1128bf34692916c98e9b9152fbca209458 Mon Sep 17 00:00:00 2001 From: Artyom Tarasenko Date: Thu, 1 Mar 2018 20:45:14 -0500 Subject: [PATCH] target-sparc: hypervisor mode takes over nucleus mode Accordinf to UA2005, 9.3.3 "Address Space Identifiers", "In hyperprivileged mode, all instruction fetches and loads and stores with implicit ASIs use a physical address, regardless of the value of TL". Backports commit 9a10756d1204c3528e47892195349bf882069846 from qemu --- qemu/target-sparc/cpu.h | 4 ++-- qemu/target-sparc/translate.c | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/qemu/target-sparc/cpu.h b/qemu/target-sparc/cpu.h index 21afa7f4..2f503509 100644 --- a/qemu/target-sparc/cpu.h +++ b/qemu/target-sparc/cpu.h @@ -719,10 +719,10 @@ static inline int cpu_mmu_index(CPUSPARCState *env, bool ifetch) ? (env->lsu & IMMU_E) == 0 || (env->pstate & PS_RED) != 0 : (env->lsu & DMMU_E) == 0) { return MMU_PHYS_IDX; - } else if (env->tl > 0) { - return MMU_NUCLEUS_IDX; } else if (cpu_hypervisor_mode(env)) { return MMU_HYPV_IDX; + } else if (env->tl > 0) { + return MMU_NUCLEUS_IDX; } else if (cpu_supervisor_mode(env)) { return MMU_KERNEL_IDX; } else { diff --git a/qemu/target-sparc/translate.c b/qemu/target-sparc/translate.c index 27486900..7b917bb3 100644 --- a/qemu/target-sparc/translate.c +++ b/qemu/target-sparc/translate.c @@ -2292,7 +2292,11 @@ static DisasASI get_asi(DisasContext *dc, int insn, TCGMemOp memop) case ASI_TWINX_NL: case ASI_NUCLEUS_QUAD_LDD: case ASI_NUCLEUS_QUAD_LDD_L: - mem_idx = MMU_NUCLEUS_IDX; + if (hypervisor(dc)) { + mem_idx = MMU_HYPV_IDX; + } else { + mem_idx = MMU_NUCLEUS_IDX; + } break; case ASI_AIUP: /* As if user primary */ case ASI_AIUPL: /* As if user primary LE */