target/arm: Fix calculation of secure mm_idx values
commitfe768788d29597ee56fc11ba2279d502c2617457
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 6 Oct 2017 15:46:49 +0000 (6 16:46 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Fri, 6 Oct 2017 15:46:49 +0000 (6 16:46 +0100)
treebd7d079816fbdabda75fe56643d072c02b115dc3
parent35337cc391245f251bfb9134f181c33e6375d6c1
target/arm: Fix calculation of secure mm_idx values

In cpu_mmu_index() we try to do this:
        if (env->v7m.secure) {
            mmu_idx += ARMMMUIdx_MSUser;
        }
but it will give the wrong answer, because ARMMMUIdx_MSUser
includes the 0x40 ARM_MMU_IDX_M field, and so does the
mmu_idx we're adding to, and we'll end up with 0x8n rather
than 0x4n. This error is then nullified by the call to
arm_to_core_mmu_idx() which masks out the high part, but
we're about to factor out the code that calculates the
ARMMMUIdx values so it can be used without passing it through
arm_to_core_mmu_idx(), so fix this bug first.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1506092407-26985-16-git-send-email-peter.maydell@linaro.org
target/arm/cpu.h