openwrtv3/target/linux/ramips
André Draszik ace1686200 ramips: mt7620: eMMC: stop invalid memory access if only one device is defined
pdev->id is -1 when only one device exists, and is used:
* as an index into drv_mode[] to determine whether to use
  PIO or DMA mode (via host->id)
* as an index into msdc_6575_host[], to store the
  mmc_priv() data.

Obviously, -1 is not a valid index in either case, causing
us to read invalid memory, and memory corruption,
respectively.

The invalid memory read is causing non-deterministic
behaviour, in particular in the v4.4 kernel it still
picked DMA mode, but in the v4.9 it now always picks
PIO mode.
Also, PIO mode doesn't work, causing the following:

/ # echo 3 > /proc/sys/vm/drop_caches
[ 3845.249237] sh (128): drop_caches: 3

/ # /root/usr/lib/libc.so
[ 3846.096070] do_page_fault(): sending SIGSEGV to libc.so for invalid read access from 7f9cb5a0
[ 3846.104758] epc = 779b0ea4 in libc.so[7792f000+c3000]
[ 3846.109907] ra  = 779a8004 in libc.so[7792f000+c3000]
Segmentation fault

/ # /root/usr/lib/libc.so
musl libc (mipsel-sf)
Version 1.1.16-git-40-g54807d47
Dynamic Program Loader
Usage: /root/usr/lib/libc.so [options] [--] pathname [args]

(i.e. initial page-in of any binary causes a segfault,
subsequent access works.)

While this change doesn't fix PIO mode, it at least makes
us deterministically use DMA (which works), and it also
stops us from corrupting memory.

Signed-off-by: André Draszik <git@andred.net>
2018-04-04 08:29:17 +02:00
..
base-files ramips: fix switch and MAC address for WHR-G300N 2018-03-23 20:31:49 +01:00
dts ramips: fix switch and MAC address for WHR-G300N 2018-03-23 20:31:49 +01:00
files-4.9/drivers/net/ethernet/mtk ramips: mt7620: power up ephy port 4 2018-03-06 19:49:05 +01:00
files-4.14/drivers/net/ethernet/mtk ramips: remove dead (and potentially crashy) code in mt7621 gsw init 2018-03-23 20:56:34 +01:00
image ramips: add support for TP-Link TL-WR902AC v3 2018-03-18 22:22:38 +01:00
mt76x8 kernel: optimize for performance by default starting with 4.14 2018-02-24 16:05:28 +01:00
mt7620 ramips: add support for D-Link DWR-116-A1/2 2018-03-18 22:22:38 +01:00
mt7621 ramips: preliminary support for 4.14 2018-02-15 10:46:39 +01:00
patches-4.9 ramips: mt7620: eMMC: stop invalid memory access if only one device is defined 2018-04-04 08:29:17 +02:00
patches-4.14 ramips: mt7620: eMMC: stop invalid memory access if only one device is defined 2018-04-04 08:29:17 +02:00
rt288x kernel: optimize for performance by default starting with 4.14 2018-02-24 16:05:28 +01:00
rt305x kernel: optimize for performance by default starting with 4.14 2018-02-24 16:05:28 +01:00
rt3883 kernel: optimize for performance by default starting with 4.14 2018-02-24 16:05:28 +01:00
Makefile ramips: merge mt7628/mt7688 into mt76x8 2017-08-30 17:05:10 +02:00
modules.mk ramips: fix mt76x8 dependencies 2017-09-05 08:08:36 +02:00