Skip to content

Commit fcbfb54

Browse files
wkzgregkh
authored andcommitted
net: mvpp2: Prevent parser TCAM memory corruption
[ Upstream commit 9684407 ] Protect the parser TCAM/SRAM memory, and the cached (shadow) SRAM information, from concurrent modifications. Both the TCAM and SRAM tables are indirectly accessed by configuring an index register that selects the row to read or write to. This means that operations must be atomic in order to, e.g., avoid spreading writes across multiple rows. Since the shadow SRAM array is used to find free rows in the hardware table, it must also be protected in order to avoid TOCTOU errors where multiple cores allocate the same row. This issue was detected in a situation where `mvpp2_set_rx_mode()` ran concurrently on two CPUs. In this particular case the MVPP2_PE_MAC_UC_PROMISCUOUS entry was corrupted, causing the classifier unit to drop all incoming unicast - indicated by the `rx_classifier_drops` counter. Fixes: 3f51850 ("ethernet: Add new driver for Marvell Armada 375 network unit") Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Link: https://patch.msgid.link/20250401065855.3113635-1-tobias@waldekranz.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e5178bf commit fcbfb54

File tree

3 files changed

+140
-67
lines changed

3 files changed

+140
-67
lines changed

drivers/net/ethernet/marvell/mvpp2/mvpp2.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,9 @@ struct mvpp2 {
11081108

11091109
/* Spinlocks for CM3 shared memory configuration */
11101110
spinlock_t mss_spinlock;
1111+
1112+
/* Spinlock for shared PRS parser memory and shadow table */
1113+
spinlock_t prs_spinlock;
11111114
};
11121115

11131116
struct mvpp2_pcpu_stats {

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7640,8 +7640,9 @@ static int mvpp2_probe(struct platform_device *pdev)
76407640
if (mvpp2_read(priv, MVPP2_VER_ID_REG) == MVPP2_VER_PP23)
76417641
priv->hw_version = MVPP23;
76427642

7643-
/* Init mss lock */
7643+
/* Init locks for shared packet processor resources */
76447644
spin_lock_init(&priv->mss_spinlock);
7645+
spin_lock_init(&priv->prs_spinlock);
76457646

76467647
/* Initialize network controller */
76477648
err = mvpp2_init(pdev, priv);

0 commit comments

Comments
 (0)