linux-imx/drivers/staging
Vladimir Oltean e0f9e2afd4 staging: fsl_qbman: don't dereference portal affine to CPU when it's redirected
When using a cmdline such as "bportals=s0 qportals=s0", Linux is given a
single QMan and a single BMan portal which is shared among all CPUs, and
accessed with locking.

This is only supported for the staging SDK QBMan driver and not for the
upstream variant.

In a strange twist of events, qman_create_affine_slave() also sets
affine_portals[] for CPUs which use the portal affine to a different CPU
(aka "slaves" here), and just have portal->sharing_redirect set to that
other portal.

But that panics the kernel hard, because these dummy portals, not
having been created by qman_create_portal(), have uninitialized struct
qm_portal :: addr, eqcr, dqrr, etc, but also portal->config. So any time
these are dereferenced, the kernel panics.

There are actually 2 code paths which are in this situation:

qman_enable_irqs()
-> qm_isr_status_clear()
   -> __qm_isr_write()
      -> __qm_out(&portal->addr, ...) // portal->addr uninitialized

qm_shutdown_fq()
-> qm_get_portal_for_channel()
   -> qman_p_get_portal_config()
      -> &p->config->public_cfg // p->config uninitialized

Both functions were actually copied over from the upstream QBMan driver
(for the purpose of kexec support), which does not support portal
sharing and thus the problem does not exist there.

Actually, we need to take into consideration in these code paths only
those affine portals created by qman_create_affine_portal(), and not the
fake ones with sharing_redirect. The qman_create_affine_portal() sets
the CPU in the &affine_mask retrievable through qman_affine_cpus().

This is also the way in which dpaa_eth_add_channel() from
drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_common.c avoids the
fake channels, when dereferencing the affine_cpus[] array through the
qman_get_affine_portal() API method.

Fixes: a218c908c8 ("staging: fsl_qbman: account for pre-initialized BARs in case of kexec")
Fixes: 78ff3aa0713b ("staging: fsl_qbman: use correct portal for static dequeues in qm_shutdown_fq()")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
2024-11-20 01:01:49 +02:00
..
axis-fifo staging: Explicitly include correct DT includes 2023-07-27 10:01:07 +02:00
board staging: board: Fix uninitialized spinlock when attaching genpd 2021-07-21 11:22:15 +02:00
emxx_udc staging: emxx_udc: Convert to platform remove callback returning void 2023-04-03 21:49:54 +02:00
ethosu Fix checkpatch issues for commit 7ca0f0f180 2024-07-25 17:18:04 +08:00
fbtft Linux 6.5-rc7 2023-08-24 07:26:06 +10:00
fieldbus staging: fieldbus: arcx-anybus: Remove redundant of_match_ptr() 2023-08-11 23:28:04 +02:00
fsl_ppfe LF-10777-2 staging: fsl_ppfe: remove unused pfe_eth_mdio_write_addr 2023-11-30 16:38:32 +08:00
fsl_qbman staging: fsl_qbman: don't dereference portal affine to CPU when it's redirected 2024-11-20 01:01:49 +02:00
fsl-dpaa2 staging: dpaa2-evb: Add Edge Virtual Bridge driver 2023-10-30 19:10:12 +02:00
gdm724x tty: gdm724x: use min_t() for size_t varable and a constant 2023-08-22 14:53:53 +02:00
greybus greybus: arche-ctrl: move device table to its right location 2024-06-12 11:12:17 +02:00
iio staging: iio: frequency: ad9834: Validate frequency parameter value 2024-09-12 11:11:40 +02:00
ks7010 staging: ks7010: disable bh on tx_dev_lock 2024-08-29 17:33:26 +02:00
media LF-12531: imx: pi: fix capture image bottom edge green line 2024-11-06 17:00:15 +08:00
most staging: Explicitly include correct DT includes 2023-07-27 10:01:07 +02:00
neutron AIR-11882: neutron: Enable neutron memory cache to improve npu benchmark performance 2024-11-19 16:15:19 +08:00
nvec staging: nvec_ps2: Convert to platform remove callback returning void 2023-04-03 21:49:55 +02:00
octeon staging: octeon: delete my name from TODO contact 2023-05-08 16:09:33 +02:00
olpc_dcon staging: olpc_dcon: Switch i2c driver back to use .probe() 2023-05-28 10:15:27 +01:00
pi433 staging: Explicitly include correct DT includes 2023-07-27 10:01:07 +02:00
qlge Staging: qlge: Fix indentation in conditional statement 2023-03-16 09:44:31 +01:00
rtl8192e staging: rtl8192e: Annotate struct rtllib_txb with __counted_by 2023-08-22 15:48:05 +02:00
rtl8192u staging: rtl8192u: Fix keyidx assignment within if condition 2023-07-27 10:00:02 +02:00
rtl8712 staging: rtl8712: fix race condition 2023-08-04 16:20:13 +02:00
rtl8723bs staging: rtl8723bs: Use helpers to check broadcast and multicast Ether addresses 2023-08-22 15:47:17 +02:00
rts5208 staging: rts5208: Correct line ending with '(' 2023-07-27 10:00:19 +02:00
sm750fb Staging driver changes for 6.6-rc1 2023-09-01 09:27:29 -07:00
vc04_services staging: vc04_services: fix information leak in create_component() 2024-04-03 15:28:59 +02:00
vme_user staging: vme_user: fix check lines should not end with a '(' 2023-08-22 15:47:35 +02:00
vt6655 staging: vt6655: replace camel case by snake case 2023-08-22 15:44:33 +02:00
vt6656 staging: vt6656: remove unused vnt_get_current_tsf() function 2023-03-17 08:07:23 +01:00
wlan-ng Fix nomenclature for USB and PCI wireless devices 2023-08-25 12:56:49 +03:00
Kconfig LF-10551-3: drivers: neutron: add support for neutron buffer allocation 2023-12-04 14:41:54 +08:00
Makefile LF-10551-2: drivers: Introduce a new driver for NXP neutron NPU 2023-12-04 14:41:54 +08:00