qemu-patch-raspberry4/include/hw/intc
Peter Maydell 80dcd37feb hw/intc/arm_gicv3_its: Fix various off-by-one errors
The ITS code has to check whether various parameters passed in
commands are in-bounds, where the limit is defined in terms of the
number of bits that are available for the parameter.  (For example,
the GITS_TYPER.Devbits ID register field specifies the number of
DeviceID bits minus 1, and device IDs passed in the MAPTI and MAPD
command packets must fit in that many bits.)

Currently we have off-by-one bugs in many of these bounds checks.
The typical problem is that we define a max_foo as 1 << n. In
the Devbits example, we set
  s->dt.max_ids = 1UL << (GITS_TYPER.Devbits + 1).
However later when we do the bounds check we write
  if (devid > s->dt.max_ids) { /* command error */ }
which incorrectly permits a devid of 1 << n.

These bugs will not cause QEMU crashes because the ID values being
checked are only used for accesses into tables held in guest memory
which we access with address_space_*() functions, but they are
incorrect behaviour of our emulation.

Fix them by standardizing on this pattern:
 * bounds limits are named num_foos and are the 2^n value
   (equal to the number of valid foo values)
 * bounds checks are either
   if (fooid < num_foos) { good }
   or
   if (fooid >= num_foos) { bad }

In this commit we fix the handling of the number of IDs
in the device table and the collection table, and the number
of commands that will fit in the command queue.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
2022-01-07 17:08:00 +00:00
..
allwinner-a10-pic.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
arm_gic.h Use DECLARE_*CHECKER* when possible (--force mode) 2020-09-09 09:27:11 -04:00
arm_gic_common.h Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
arm_gicv3.h Use DECLARE_*CHECKER* when possible (--force mode) 2020-09-09 09:27:11 -04:00
arm_gicv3_common.h hw/intc/arm_gicv3: Support multiple redistributor regions 2021-11-15 16:12:59 +00:00
arm_gicv3_its_common.h hw/intc/arm_gicv3_its: Fix various off-by-one errors 2022-01-07 17:08:00 +00:00
armv7m_nvic.h arm: Move system PPB container handling to armv7m 2021-09-01 11:08:18 +01:00
aspeed_vic.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
bcm2835_ic.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
bcm2836_control.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
goldfish_pic.h hw/m68k: Fix typo in SPDX tag 2021-11-09 10:11:27 +01:00
heathrow_pic.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
i8259.h hw: replace hw/i386/pc.h with a header just for the i8259 2019-12-17 19:33:49 +01:00
ibex_plic.h hw/intc: ibex_plic: Convert the PLIC to use RISC-V CPU GPIO lines 2021-09-21 07:56:49 +10:00
imx_avic.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
imx_gpcv2.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
intc.h Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
loongson_liointc.h hw/intc: Rework Loongson LIOINTC 2021-01-04 23:24:44 +01:00
m68k_irqc.h hw/m68k: Fix typo in SPDX tag 2021-11-09 10:11:27 +01:00
mips_gic.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
ppc-uic.h hw/ppc: Remove unused ppcuic_init() 2021-01-19 10:20:29 +11:00
realview_gic.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
riscv_aclint.h hw/intc: Upgrade the SiFive CLINT implementation to RISC-V ACLINT 2021-09-21 07:56:49 +10:00
rx_icu.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
sifive_plic.h hw/intc: sifive_plic: Convert the PLIC to use RISC-V CPU GPIO lines 2021-09-21 07:56:49 +10:00
xlnx-pmu-iomod-intc.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
xlnx-zynqmp-ipi.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00