linux-stable/samples
Sherry Sun 1b5a5face3 misc: vop: add round_up(x,4) for vring_size to avoid kernel panic
[ Upstream commit cc1a267986 ]

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-29 09:07:17 +01:00
..
auxdisplay License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
blackfin samples: move blackfin gptimers-example from Documentation 2016-10-10 07:12:02 -06:00
bpf samples: bpf: Fix build error 2020-06-03 08:17:55 +02:00
configfs configfs: remove old API 2015-10-13 22:17:57 -07:00
connector License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hidraw License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hw_breakpoint
kdb
kfifo kfifo: clean up example to not use page_link 2017-07-12 16:26:01 -07:00
kobject samples/kobject: be explicit in the module license 2015-03-25 13:41:42 +01:00
kprobes samples/kretprobe: fix the wrong type 2016-08-04 08:50:07 -04:00
livepatch livepatch: allow removal of a disabled patch 2017-03-08 09:38:43 +01:00
mei mei: samples: fix a signedness bug in amt_host_if_call() 2019-11-24 08:22:59 +01:00
mic/mpssd misc: vop: add round_up(x,4) for vring_size to avoid kernel panic 2020-10-29 09:07:17 +01:00
pktgen samples: pktgen: fix proc_cmd command result check logic 2019-12-31 12:37:00 +01:00
rpmsg rpmsg: Allow callback to return errors 2016-09-08 22:15:25 -07:00
seccomp License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sockmap bpf: avoid preempt enable/disable in sockmap using tcp_skb_cb region 2017-10-20 13:01:29 +01:00
statx statx: Include a mask for stx_attributes in struct statx 2017-04-03 01:06:00 -04:00
timers License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
trace_events License cleanup: add SPDX license identifiers to some files 2017-11-02 10:04:46 -07:00
trace_printk tracing: Add trace_printk sample code 2016-06-20 09:54:21 -04:00
uhid License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
v4l media: v4l2-pci-skeleton: constify vb2_ops structures 2017-08-20 08:03:09 -04:00
vfio-mdev vfio-mdev/samples: Use u8 instead of char for handle functions 2019-12-05 15:37:27 +01:00
watchdog License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Kconfig statx: Add a system call to make enhanced file info available 2017-03-02 20:51:15 -05:00
Makefile statx: Add a system call to make enhanced file info available 2017-03-02 20:51:15 -05:00