linux/drivers/mtd/spi-nor
Thor Thayer 47016b341f mtd: spi-nor: cadence-quadspi: Fix page fault kernel panic
The current Cadence QSPI driver caused a kernel panic when loading
a Root Filesystem from QSPI. The problem was caused by reading more
bytes than needed because the QSPI operated on 4 bytes at a time.
<snip>
[    7.947754] spi_nor_read[1048]:from 0x037cad74, len 1 [bfe07fff]
[    7.956247] cqspi_read[910]:offset 0x58502516, buffer=bfe07fff
[    7.956247]
[    7.966046] Unable to handle kernel paging request at virtual
address bfe08002
[    7.973239] pgd = eebfc000
[    7.975931] [bfe08002] *pgd=2fffb811, *pte=00000000, *ppte=00000000
</snip>
Notice above how only 1 byte needed to be read but by reading 4 bytes
into the end of a mapped page, an unrecoverable page fault occurred.

This patch uses a temporary buffer to hold the 4 bytes read and then
copies only the bytes required into the buffer. A min() function is
used to limit the length to prevent buffer overflows.

Request testing of this patch on other platforms. This was tested
on the Intel Arria10 SoCFPGA DevKit.

Fixes: 0cf1725676 ("mtd: spi-nor: cqspi: Fix build on arches missing readsl/writesl")
Signed-off-by: Thor Thayer <thor.thayer@linux.intel.com>
Cc: <stable@vger.kernel.org>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
2018-04-23 21:42:56 +02:00
..
aspeed-smc.c mtd: spi-nor: aspeed: set 4B setting for all chips 2017-08-14 17:23:50 +02:00
atmel-quadspi.c mtd: atmel-quadspi: Remove unneeded pinctrl header 2017-08-01 21:23:21 +02:00
cadence-quadspi.c mtd: spi-nor: cadence-quadspi: Fix page fault kernel panic 2018-04-23 21:42:56 +02:00
fsl-quadspi.c mtd: fsl-quadspi: Distinguish the mtd device names 2018-03-30 10:04:53 +02:00
hisi-sfc.c mtd: Convert to using %pOF instead of full_name 2017-08-15 14:00:43 +02:00
intel-spi-pci.c mtd: intel-spi: Add Intel Lewisburg PCH SPI super SKU PCI ID 2017-10-30 11:51:18 +01:00
intel-spi-platform.c spi-nor: Add support for Intel SPI serial flash controller 2017-01-03 17:33:36 +00:00
intel-spi.c spi-nor: intel-spi: Remove unused preopcodes field 2018-01-07 21:22:32 +01:00
intel-spi.h spi-nor: Add support for Intel SPI serial flash controller 2017-01-03 17:33:36 +00:00
Kconfig spi-nor: intel-spi: Remove EXPERT dependency 2017-10-25 00:17:34 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mtk-quadspi.c mtd: mtk-nor: modify functions' name more generally 2018-01-14 16:14:06 +01:00
nxp-spifi.c mtd: spi-nor: introduce SPI 1-2-2 and SPI 1-4-4 protocols 2017-05-15 21:56:17 +02:00
spi-nor.c mtd: Stop updating erase_info->state and calling mtd_erase_callback() 2018-03-21 09:50:56 +01:00
stm32-quadspi.c mtd: spi-nor: stm32-quadspi: fix prefetching outside fsize 2017-10-29 18:54:22 +01:00