]> git.proxmox.com Git - mirror_qemu.git/commitdiff
hw/ssi/xilinx_spips: Avoid out-of-bound access to lqspi_buf[]
authorPhilippe Mathieu-Daudé <philmd@redhat.com>
Mon, 15 Jul 2019 13:17:03 +0000 (14:17 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 15 Jul 2019 13:17:03 +0000 (14:17 +0100)
Both lqspi_read() and lqspi_load_cache() expect a 32-bit
aligned address.

>From UG1085 datasheet [*] chapter on 'Quad-SPI Controller':

  Transfer Size Limitations

    Because of the 32-bit wide TX, RX, and generic FIFO, all
    APB/AXI transfers must be an integer multiple of 4-bytes.
    Shorter transfers are not possible.

Set MemoryRegionOps.impl values to force 32-bit accesses,
this way we are sure we do not access the lqspi_buf[] array
out of bound.

[*] https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ultrascale-trm.pdf

Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
hw/ssi/xilinx_spips.c

index 3c4e8365ee1148ec991a4a0a14d622956c430e4e..b29e0a4a89ec67b5ca2ea56b8ac95d420a7d79cd 100644 (file)
@@ -1239,6 +1239,10 @@ static const MemoryRegionOps lqspi_ops = {
     .read_with_attrs = lqspi_read,
     .write_with_attrs = lqspi_write,
     .endianness = DEVICE_NATIVE_ENDIAN,
+    .impl = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
     .valid = {
         .min_access_size = 1,
         .max_access_size = 4