]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
ARM: 9216/1: Fix MAX_DMA_ADDRESS overflow
authorFlorian Fainelli <f.fainelli@gmail.com>
Tue, 19 Jul 2022 16:33:21 +0000 (17:33 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 16 Sep 2022 08:53:47 +0000 (10:53 +0200)
commitff2a2690791e5d23057ed920c431c6294c58ae37
treed020dc3c3301a5e07e0185531d06c3cf30bc3b14
parent9bd659fd48f93223870ea4ca5bb7fd2b2d116f08
ARM: 9216/1: Fix MAX_DMA_ADDRESS overflow

BugLink: https://bugs.launchpad.net/bugs/1989218
[ Upstream commit fb0fd3469ead5b937293c213daa1f589b4b7ce46 ]

Commit 26f09e9b3a06 ("mm/memblock: add memblock memory allocation apis")
added a check to determine whether arm_dma_zone_size is exceeding the
amount of kernel virtual address space available between the upper 4GB
virtual address limit and PAGE_OFFSET in order to provide a suitable
definition of MAX_DMA_ADDRESS that should fit within the 32-bit virtual
address space. The quantity used for comparison was off by a missing
trailing 0, leading to MAX_DMA_ADDRESS to be overflowing a 32-bit
quantity.

This was caught thanks to CONFIG_DEBUG_VIRTUAL on the bcm2711 platform
where we define a dma_zone_size of 1GB and we have a PAGE_OFFSET value
of 0xc000_0000 (CONFIG_VMSPLIT_3G) leading to MAX_DMA_ADDRESS being
0x1_0000_0000 which overflows the unsigned long type used throughout
__pa() and then __virt_addr_valid(). Because the virtual address passed
to __virt_addr_valid() would now be 0, the function would loudly warn
and flood the kernel log, thus making the platform unable to boot
properly.

Fixes: 26f09e9b3a06 ("mm/memblock: add memblock memory allocation apis")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/arm/include/asm/dma.h