From: "Kirill A. Korinsky" <[email protected]> The xuseg and xsseg checks only tested UX and SX respectively; kernel and supervisor accesses must instead use the mode bit that applies to the current execution mode.
Allow supervisor and kernel mode to use xuseg when SX or KX is set, and allow kernel mode to use xsseg when KX is set. Signed-off-by: Kirill A. Korinsky <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> --- target/mips/system/physaddr.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/target/mips/system/physaddr.c b/target/mips/system/physaddr.c index 523197f020..b9f44c27bc 100644 --- a/target/mips/system/physaddr.c +++ b/target/mips/system/physaddr.c @@ -145,7 +145,9 @@ int get_physical_address(const CPUMIPSState *env, hwaddr *physical, #if defined(TARGET_MIPS64) } else if (address < 0x4000000000000000ULL) { /* xuseg */ - if (UX && address <= (0x3FFFFFFFFFFFFFFFULL & env->SEGMask)) { + if (((user_mode && UX) || (supervisor_mode && SX) || + (kernel_mode && KX)) && + address <= (0x3FFFFFFFFFFFFFFFULL & env->SEGMask)) { ret = env->tlb->map_address(env, physical, prot, real_address, access_type); } else { @@ -153,8 +155,8 @@ int get_physical_address(const CPUMIPSState *env, hwaddr *physical, } } else if (address < 0x8000000000000000ULL) { /* xsseg */ - if ((supervisor_mode || kernel_mode) && - SX && address <= (0x7FFFFFFFFFFFFFFFULL & env->SEGMask)) { + if (((supervisor_mode && SX) || (kernel_mode && KX)) && + address <= (0x7FFFFFFFFFFFFFFFULL & env->SEGMask)) { ret = env->tlb->map_address(env, physical, prot, real_address, access_type); } else { -- 2.56.0
