kernel-fxtec-pro1x/drivers/misc/mic
Sherry Sun 424b9b83ac misc: vop: add round_up(x,4) for vring_size to avoid kernel panic
[ Upstream commit cc1a2679865a94b83804822996eed010a50a7c1d ]

Since struct _mic_vring_info and vring are allocated together and follow
vring, if the vring_size() is not four bytes aligned, which will cause
the start address of struct _mic_vring_info is not four byte aligned.
For example, when vring entries is 128, the vring_size() will be 5126
bytes. The _mic_vring_info struct layout in ddr looks like:
0x90002400:  00000000 00390000 EE010000 0000C0FF
Here 0x39 is the avail_idx member, and 0xC0FFEE01 is the magic member.

When EP use ioread32(magic) to reads the magic in RC's share memory, it
will cause kernel panic on ARM64 platform due to the cross-byte io read.
Here read magic in user space use le32toh(vr0->info->magic) will meet
the same issue.
So add round_up(x,4) for vring_size, then the struct _mic_vring_info
will store in this way:
0x90002400:  00000000 00000000 00000039 C0FFEE01
Which will avoid kernel panic when read magic in struct _mic_vring_info.

Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Link: https://lore.kernel.org/r/20200929091106.24624-4-sherry.sun@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-30 10:38:29 +01:00
..
bus misc: mic: Release reference count and memory for VOP device 2018-03-15 18:12:01 +01:00
card mic: avoid statically declaring a 'struct device'. 2020-01-27 14:51:02 +01:00
common misc: mic: Remove COSM functionality from the MIC card driver 2015-10-04 12:46:06 +01:00
cosm misc: mic: fix passing the current time 2018-07-07 17:44:52 +02:00
cosm_client misc: mic: fix passing the current time 2018-07-07 17:44:52 +02:00
host License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
scif misc: mic: scif: Fix error handling path 2020-10-29 09:55:11 +01:00
vop misc: vop: add round_up(x,4) for vring_size to avoid kernel panic 2020-10-30 10:38:29 +01:00
Kconfig misc: mic: move to its own menu in Misc devices 2017-10-04 10:45:18 +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