qemu/target/mips
Peter Maydell 0fe4cac5dd target/mips: Avoid shift by negative number in page_table_walk_refill()
Coverity points out that in page_table_walk_refill() we can
shift by a negative number, which is undefined behaviour
(CID 1452918, 1452920, 1452922).  We already catch the
negative directory_shift and leaf_shift as being a "bail
out early" case, but not until we've already used them to
calculated some offset values.

The shifts can be negative only if ptew > 1, so make the
bail-out-early check look directly at that, and only
calculate the shift amounts and the offsets based on them
after we have done that check. This allows
us to simplify the expressions used to calculate the
shift amounts, use an unsigned type, and avoids the
undefined behaviour.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
[PMD: Check for ptew > 1, use unsigned type]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20230717213504.24777-3-philmd@linaro.org>
2023-07-25 14:41:16 +02:00
..
sysemu target/mips: Rework cp0_timer with clock API 2023-07-10 21:53:03 +02:00
tcg target/mips: Avoid shift by negative number in page_table_walk_refill() 2023-07-25 14:41:16 +02:00
cpu-defs.c.inc target/mips: enable GINVx support for I6400 and I6500 2023-07-10 23:33:38 +02:00
cpu-param.h target/mips: Remove NB_MMU_MODES define 2023-03-13 06:44:37 -07:00
cpu-qom.h
cpu.c target/mips: Implement Loongson CSR instructions 2023-07-10 23:33:37 +02:00
cpu.h target/mips: Implement Loongson CSR instructions 2023-07-10 23:33:37 +02:00
fpu.c
fpu_helper.h
gdbstub.c
helper.h target/mips: Implement Loongson CSR instructions 2023-07-10 23:33:37 +02:00
internal.h target/mips: Implement Loongson CSR instructions 2023-07-10 23:33:37 +02:00
Kconfig
kvm.c
kvm_mips.h
meson.build meson: Replace softmmu_ss -> system_ss 2023-06-20 10:01:30 +02:00
mips-defs.h
msa.c