0fe4cac5dd
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> |
||
---|---|---|
.. | ||
sysemu | ||
dsp_helper.c | ||
exception.c | ||
fpu_helper.c | ||
lcsr_translate.c | ||
lcsr.decode | ||
ldst_helper.c | ||
lmmi_helper.c | ||
meson.build | ||
micromips_translate.c.inc | ||
mips16e_translate.c.inc | ||
msa_helper.c | ||
msa_helper.h.inc | ||
msa_translate.c | ||
msa.decode | ||
mxu_translate.c | ||
nanomips_translate.c.inc | ||
octeon_translate.c | ||
octeon.decode | ||
op_helper.c | ||
rel6_translate.c | ||
rel6.decode | ||
sysemu_helper.h.inc | ||
tcg-internal.h | ||
trace-events | ||
trace.h | ||
translate_addr_const.c | ||
translate.c | ||
translate.h | ||
tx79_translate.c | ||
tx79.decode | ||
txx9_translate.c | ||
vr54xx_helper.c | ||
vr54xx_helper.h.inc | ||
vr54xx_translate.c | ||
vr54xx.decode |