immortalwrt/package
Mathias Kresin e7574b49c7 uboot-lantiq: fix out of bounds cache invalidate
With gcc10 the variables are placed more tightly to each other, which
uncovers a long existing bug in the lantiq DMA code. It can be observed
when using tftpboot with the filename parameter, which gets reset during
the tftpboot execution.

NetRxPackets[] points to cache line size aligned addresses. In
ltq_eth_rx_packet_align() the address NetRxPackets[] points to is
increased by LTQ_ETH_IP_ALIGN and the resulting not cache aligned
address is used further on. While doing so, the length/size is never
updated.

The "not cache aligned address" + len/size for a cache aligned address
is passed to invalidate_dcache_range(). Hence, invalidate_dcache_range()
invalidates the next 32 bit as well, which flashes the BootFile variable
as well.

   variable BootFile is at address: 0x83ffe12c
   NetRxPackets[] points to 0x83ffdb20 (len is 0x600)
   data points to: 0x83ffdb22 (len is 0x600)

   ltq_dma_dcache_inv: 0x83ffdb22 (for len 0x600)
   invalidate_dcache_range: 0x83ffdb20 to 0x83ffe120 (size: 32)
   invalidate_dcache_range: 0x83ffdb20 to 0x83ffdb40 (Bootfile: a.bin)
   ...
   invalidate_dcache_range: 0x83ffe100 to 0x83ffe120 (Bootfile: a.bin)
   invalidate_dcache_range: 0x83ffe120 to 0x83ffe140 (Bootfile: )

In ltq_dma_tx_map() and ltq_dma_rx_map() the start address passed to
ltq_dma_dcache_wb_inv() is incorrect. By considering the offset, the
start address passed to flush_dcache_range() is always aligned to 32, 64
or 128 bytes dependent on configured DMA burst size.

Fixes: FS#4113

Signed-off-by: Mathias Kresin <dev@kresin.me>
2021-12-02 00:03:43 +08:00
..
base-files base-files, metadata: support additional group membership 2021-11-10 15:42:57 +08:00
boot uboot-lantiq: fix out of bounds cache invalidate 2021-12-02 00:03:43 +08:00
devel Merge Mainline 2021-08-29 00:53:33 +08:00
emortal Merge Mainline 2021-12-01 00:15:25 +08:00
firmware Merge Mainline 2021-10-27 12:18:41 +08:00
kernel Merge Mainline 2021-12-01 00:15:25 +08:00
libs Merge Mainline 2021-12-01 00:15:25 +08:00
network Merge Mainline 2021-12-01 00:15:25 +08:00
system Merge Mainline 2021-11-18 15:52:19 +08:00
utils Merge Mainline 2021-11-18 15:52:19 +08:00
Makefile Merge Mainline 2021-05-13 23:01:12 +08:00