qemu-e2k/include/hw
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
..
acpi hw/acpi/ich9: Add compat prop to keep HPC bit set for 6.1 machine type 2021-11-15 09:44:46 -05:00
adc hw/adc: Add basic Aspeed ADC model 2021-10-12 08:20:08 +02:00
arm Add dummy Aspeed AST2600 Display Port MCU (DPMCU) 2022-01-07 17:07:57 +00:00
audio
block
char hw/m68k: Fix typo in SPDX tag 2021-11-09 10:11:27 +01:00
core linux-user: Add code for PR_GET/SET_UNALIGN 2022-01-06 11:40:52 +01:00
cpu
cris
display macfb: add vertical blank interrupt 2021-10-08 13:31:03 +02:00
dma
firmware
gpio hw: aspeed_gpio: Fix GPIO array indexing 2021-10-12 08:20:08 +02:00
hyperv
i2c aspeed/i2c: QOMify AspeedI2CBus 2021-10-12 08:20:08 +02:00
i386 hw: Add compat machines for 7.0 2022-01-05 09:06:36 +01:00
ide ide: Rename ide_bus_new() to ide_bus_init() 2021-09-30 13:44:13 +01:00
input
intc hw/intc/arm_gicv3_its: Fix various off-by-one errors 2022-01-07 17:08:00 +00:00
ipack ipack: Rename ipack_bus_new_inplace() to ipack_bus_init() 2021-09-30 13:42:10 +01:00
ipmi
isa vt82c686: Add a method to VIA_ISA to raise ISA interrupts 2021-10-18 00:41:36 +02:00
kvm
m68k
mem
mips
misc hw/m68k: Fix typo in SPDX tag 2021-11-09 10:11:27 +01:00
net
nubus
nvram hw/nvram: Introduce Xilinx battery-backed ram 2021-09-30 13:42:10 +01:00
pci pci: Let ld*_pci_dma() propagate MemTxResult 2021-12-31 01:05:27 +01:00
pci-bridge
pci-host ppc/pnv: Remove the PHB4 "device-id" property 2022-01-04 07:55:34 +01:00
ppc dma: Let ld*_dma() propagate MemTxResult 2021-12-31 01:05:27 +01:00
rdma qapi: introduce x-query-rdma QMP command 2021-11-02 15:55:14 +00:00
remote
riscv hw/riscv: microchip_pfsoc: Use the PLIC config helper function 2021-10-28 14:39:23 +10:00
rtc
rx
s390x s390x/pci: add supported DT information to clp response 2021-12-17 09:12:37 +01:00
scsi hw/scsi: Fix scsi_bus_init_named() docstring 2021-12-18 10:57:36 +01:00
sd hw/sd: add nuvoton MMC 2021-11-02 14:14:55 -04:00
sensor
sh4 hw/intc/sh_intc: Inline and drop sh_intc_source() function 2021-10-30 18:39:37 +02:00
southbridge
sparc
ssi aspeed/smc: Use a container for the flash mmio address space 2021-10-22 09:52:17 +02:00
timer
tricore
usb usb-storage: tag usb_msd_csw as packed struct 2021-11-02 17:24:18 +01:00
vfio
virtio virtio-gpu: do not byteswap padding 2021-12-10 09:47:18 +01:00
watchdog
xen
xtensa
boards.h hw: Add compat machines for 7.0 2022-01-05 09:06:36 +01:00
clock.h host-utils: add 128-bit quotient support to divu128/divs128 2021-10-27 17:10:00 -07:00
elf_ops.h hw/elf_ops.h: switch to ssize_t for elf loader return type 2021-10-20 16:26:19 -07:00
fw-path-provider.h
hotplug.h
hw.h
ide.h
irq.h
loader-fit.h
loader.h hw/elf_ops.h: switch to ssize_t for elf loader return type 2021-10-20 16:26:19 -07:00
nmi.h
or-irq.h
pcmcia.h
platform-bus.h
ptimer.h
qdev-clock.h
qdev-core.h hw/qdev: Rename qdev_connect_gpio_out*() 'input_pin' parameter 2021-12-31 13:21:36 +01:00
qdev-dma.h
qdev-properties-system.h
qdev-properties.h
register.h
registerfields.h
resettable.h
stream.h
sysbus.h
usb.h
vmstate-if.h