@@ -980,9 +980,10 @@ uint32_t HELPER(pptlb)(CPUXtensaState *env, uint32_t v)
} else if (nhits == 1 && (env->sregs[MPUENB] & (1u << segment))) {
return env->mpu_fg[segment].attr | segment | XTENSA_MPU_PROBE_V;
} else {
- xtensa_mpu_lookup(env->config->mpu_bg,
- env->config->n_mpu_bg_segments,
- v, &bg_segment);
+ nhits = xtensa_mpu_lookup(env->config->mpu_bg,
+ env->config->n_mpu_bg_segments,
+ v, &bg_segment);
+ assert(nhits > 0);
return env->config->mpu_bg[bg_segment].attr | segment;
}
}
@@ -1005,9 +1006,10 @@ static int get_physical_addr_mpu(CPUXtensaState *env,
} else if (nhits == 1 && (env->sregs[MPUENB] & (1u << segment))) {
attr = env->mpu_fg[segment].attr;
} else {
- xtensa_mpu_lookup(env->config->mpu_bg,
- env->config->n_mpu_bg_segments,
- vaddr, &segment);
+ nhits = xtensa_mpu_lookup(env->config->mpu_bg,
+ env->config->n_mpu_bg_segments,
+ vaddr, &segment);
+ assert(nhits > 0);
attr = env->config->mpu_bg[segment].attr;
}
Fix when using GCC v11.4 (Ubuntu 11.4.0-1ubuntu1~22.04) with CFLAGS=-Og: target/xtensa/mmu_helper.c: In function ‘helper_pptlb’: target/xtensa/mmu_helper.c:986:35: error: ‘bg_segment’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 986 | return env->config->mpu_bg[bg_segment].attr | segment; | ^ target/xtensa/mmu_helper.c: In function ‘xtensa_get_physical_addr’: target/xtensa/mmu_helper.c:1011:35: error: ‘segment’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 1011 | attr = env->config->mpu_bg[segment].attr; | ^ target/xtensa/mmu_helper.c:996:14: note: ‘segment’ was declared here 996 | unsigned segment; | ^~~~~~~ Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- target/xtensa/mmu_helper.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)