From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796295440; b=Wltxes826Jh4ofdvMOQSK5HeCoEOxqwHKjS/+j98ldXv+kyOtwSlSp4vCHGDVpH9vaI7 mqPx2oKCZGcW3uG1XdFW2JP1sfxLKKphrF46NPDiTy9UJnW8x344t7/F+s/lsXRzUeuWr V99C5qddJoUa7rWWhO8MjIxNWQVZ2vmS918ybobJy/dBlBom/EbqN9WQ+NKn0KLaqv2ys xbImCUcgTdPVAD2M+IaLVC00C35tObpdsCuSgGS7ATPOquUT1P6mcflyCV80MQKLttUrb MchjqPnb4zdoyC7HjGrpp0hKhSgVcJinc1lOxP5836wwntY7aVh7lPWijqVN61I0bSQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796295440; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=iZIEYz+oTBp1GZaXg8hTarFmSZy5eOqN8giAwFW7Ft8=; b=mA7nJwDH2qBqbQHVrN3G32HkSwaWqADENRNU/a49lIJp0kbA5zv3NQbTe5NG49tFOAdF cnGuYQubW6vhDaa+kur6q5pGZKt2UjSvSkPLgEaeuYqHgk5S8sPW+i/Z/rh0SL812pK24 c/f+8OglVLwB0A60IBmP7NsT3BAxqPIMKGfsn2sjvH7WmOxoelXI+NYSWZgS9ZqD9+W7D xKqOSOJcma1TKCb9LpmawYwU5LYsKiJSbxPbdMmzcdz9ys8ZVvKXmh718TfbNnUzxYNDe GcUupaIkLqgSaxKWxvxTIVZg9yPjrcAjrBb2d3pngrRNp4bvkjRkZb5g6QuC5CKRT5w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GMFBG90m; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73248606A691; Thu, 3 Dec 2026 10:57:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GMFBG90m Received: by smtp.kernel.org (Postfix) with ESMTPSA id 693DE1F00898; Thu, 3 Dec 2026 10:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796295440; bh=iZIEYz+oTBp1GZaXg8hTarFmSZy5eOqN8giAwFW7Ft8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=GMFBG90mHHPNNzl98RFyF+oSO9vUGavohujTTufecotpNxH8TS3v3tDK6hZSA2tyq 6vYcuMI5gNl/40GJIGTSzsV0NLMaKKZCLEYfZP1fRjfgBptCJIR1jVaSTyanS+4lqx Eb8MxSueFvqcJo1KPQtzCvpIihaXzfPJxQ7HCwO6BmYx6rz5nmlZjcbDFWwWGyYeDO GWhrLCB005XmX8TB9LhjKreG9UgP4Hgmr72Wy/5bTlQ9de05iSiufmvncvkpxSQlIH shMWyjVbsnpKXZ2+zqtWW2xkl3Sq5jCSq7Nc8zVH9qYJH/H4keC6jnXUjVDj6ST+OU j1VZdgiZCdptg== Subject: Re: [PATCH net v3 4/4] net: ethernet: ti: cpsw_ale: verify ALE table reads From: netdev-bot+sashiko@kernel.org To: manuel.janocha@amperfied.com Cc: s-vadapalli@ti.com, rogerq@kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, vigneshr@ti.com, linux-omap@vger.kernel.org, netdev@vger.kernel.org, kuniyu@google.com Date: Thu, 03 Dec 2026 10:57:18 +0000 Message-ID: <179629543898.3146.12845633090160671237@kernel.org> In-Reply-To: <20261202-cpsw-ale-lock-v3-4-b40dc361d6b9@amperfied.com> References: <20261202-cpsw-ale-lock-v3-4-b40dc361d6b9@amperfied.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 4 · Low: 2 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] cpsw_ale_dump() ignores the new -EIO from cpsw_ale_read() and keeps the last unverified read in the dump buffer. - [Medium] The new -EIO give-up path in the delete helpers leaves the ALE entry, and its p0_untag_vid_mask bit, in place, while the am65 callers… - [Medium] am65_cpsw_nuss_ndo_slave_set_mac_address() (am65-cpsw- nuss.c:1778-1784) ignores the returns of cpsw_ale_del_ucast() and… - [Medium] CPSW_ALE_F_TBL_READ_VERIFY is added to the "am64-cpswxg" entry of cpsw_ale_id_match[] (cpsw_ale.c:1586). - [Low] cpsw_ale_flush_multicast(), cpsw_ale_set_unreg_mcast() and cpsw_ale_set_allmulti() now `continue` past any index whose verified… - [Low] cpsw_ale_read() accepts an entry as soon as two back-to-back reads match (memcmp(prev, ale_entry) == 0). -- net: ethernet: ti: cpsw_ale: verify ALE table reads This patch adds a CPSW_ALE_F_TBL_READ_VERIFY feature flag for the am64-cpswxg ALE. With the flag set, each table read is done twice, and the pair is retried until both reads match. After four failed tries the read returns -EIO. The callers of cpsw_ale_read() are changed to return -EIO or to skip the unreadable index. > diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c > index 69861d451ce41..d2a718ebdf609 100644 > --- a/drivers/net/ethernet/ti/cpsw_ale.c > +++ b/drivers/net/ethernet/ti/cpsw_ale.c [ ... ] > +/* Returns idx, or -EIO if the entry could not be read reliably */ > +static int cpsw_ale_read(struct cpsw_ale *ale, int idx, u32 *ale_entry) > +{ > + u32 prev[ALE_ENTRY_WORDS]; > + int tries; > + > + WARN_ON(idx > ale->params.ale_entries); > + > + if (!(ale->features & CPSW_ALE_F_TBL_READ_VERIFY)) { > + cpsw_ale_read_entry(ale, idx, ale_entry); > + return idx; > + } > + > + for (tries = 0; tries < ALE_TABLE_READ_RETRIES; tries++) { > + cpsw_ale_read_entry(ale, idx, prev); > + cpsw_ale_read_entry(ale, idx, ale_entry); > + if (!memcmp(prev, ale_entry, sizeof(prev))) > + return idx; > + } [Severity: Low] The commit message names all zeros as one of the misread modes. If both reads of a live entry return zeros, memcmp() matches and the entry is accepted, and it decodes as ALE_TYPE_FREE. cpsw_ale_match_free() then hands out that index based only on the type check: type = cpsw_ale_get_entry_type(ale_entry); if (type == ALE_TYPE_FREE) return idx; The next cpsw_ale_add_mcast(), cpsw_ale_add_ucast() or __cpsw_ale_add_vlan() would then overwrite the live entry. That is the untagged VLAN failure described in the changelog. The changelog acknowledges this limit and supports it only with "In testing the two reads of a failing pair differed". Could the free-slot path get an extra check, since that is where a false FREE does damage? For example, the chosen index could be re-read just before the write, or more agreeing reads could be required there. > + > + dev_warn_ratelimited(ale->params.dev, > + "ALE table read of entry %d did not stabilize\n", > + idx); > + > + return -EIO; > } [Severity: Medium] When this returns -EIO, what happens to the data left behind for cpsw_ale_dump()? It ignores the return value: drivers/net/ethernet/ti/cpsw_ale.c:cpsw_ale_dump() { ... for (i = 0; i < ale->params.ale_entries; i++) { cpsw_ale_read(ale, i, data); data += ALE_ENTRY_WORDS; } ... } The buffer then holds the second read of the last mismatching pair. That value is known to be unreliable: it can be all zeros or another index's entry. On am64-cpswxg this buffer is written back to hardware on resume: am65_cpsw_nuss_suspend() cpsw_ale_dump(common->ale, common->ale_context) cpsw_ale_read() returns -EIO, which is ignored am65_cpsw_nuss_resume() cpsw_ale_restore(common->ale, common->ale_context) cpsw_ale_write() on every index, with no check Suppose the give-up path hits the index of the untagged VLAN during suspend. Could resume then free or replace that entry, which is the failure this patch is meant to prevent? The changelog says "The callers leave the hardware entry alone in that case" and "cpsw_ale_dump() cannot report an error and keeps what was read". It doesn't mention the write-back in cpsw_ale_restore(). [ ... ] > @@ -466,7 +502,8 @@ int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid) > > spin_lock_bh(&ale->lock); > for (idx = 0; idx < ale->params.ale_entries; idx++) { > - cpsw_ale_read(ale, idx, ale_entry); > + if (cpsw_ale_read(ale, idx, ale_entry) < 0) > + continue; [Severity: Low] With this continue, an index whose read gave up keeps its old port mask in hardware, and cpsw_ale_flush_multicast() still returns 0. The new skips in cpsw_ale_set_unreg_mcast() and cpsw_ale_set_allmulti() work the same way, and both of those functions return void. am65_cpsw_nuss_ndo_slave_set_rx_mode() calls cpsw_ale_set_allmulti() and cpsw_ale_flush_multicast() and ignores both results. After a flush or an allmulti change, can the ALE keep forwarding multicast to a port the stack removed, or keep withholding flooding the stack enabled, until the next rx_mode change? The only signal is the ratelimited warning, and nothing re-applies the change. > ret = cpsw_ale_get_entry_type(ale_entry); > if (ret != ALE_TYPE_ADDR && ret != ALE_TYPE_VLAN_ADDR) > continue; > @@ -524,6 +561,10 @@ int cpsw_ale_add_ucast(struct cpsw_ale *ale, const u8 *addr, int port, > > spin_lock_bh(&ale->lock); > idx = cpsw_ale_match_addr(ale, addr, (flags & ALE_VLAN) ? vid : 0); > + if (idx == -EIO) { > + spin_unlock_bh(&ale->lock); > + return -EIO; > + } [Severity: Medium] Before this patch, cpsw_ale_add_ucast() could only fail with -ENOMEM, and cpsw_ale_del_ucast() only with -ENOENT. Are the callers ready for the new -EIO, which means nothing was written to hardware? am65_cpsw_nuss_ndo_slave_set_mac_address() ignores both return values: cpsw_ale_del_ucast(common->ale, ndev->dev_addr, HOST_PORT_NUM, 0, 0); cpsw_ale_add_ucast(common->ale, sockaddr->sa_data, HOST_PORT_NUM, ALE_SECURE, 0); am65_cpsw_port_set_sl_mac(port, addr); eth_commit_mac_addr_change(ndev, sockaddr); It then returns 0. If cpsw_ale_add_ucast() returns -EIO, the new MAC is never programmed into the host port entry, yet the netdev reports the new address. Could host unicast receive to the new MAC stop working in that case? am65_cpsw_nuss_ndo_slave_set_rx_mode() also ignores the result of cpsw_ale_add_mcast(). An address on the netdev multicast list might therefore never reach the ALE. > if (idx < 0) > idx = cpsw_ale_match_free(ale); > if (idx < 0) [ ... ] > @@ -785,10 +840,13 @@ int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask) > idx = cpsw_ale_match_vlan(ale, vid); > if (idx < 0) { > spin_unlock_bh(&ale->lock); > - return -ENOENT; > + return idx; > } > > - cpsw_ale_read(ale, idx, ale_entry); > + if (cpsw_ale_read(ale, idx, ale_entry) < 0) { > + spin_unlock_bh(&ale->lock); > + return -EIO; > + } [Severity: Medium] On this -EIO path the VLAN entry stays in the ALE. The call cpsw_ale_set_vlan_untag(ale, ale_entry, vid, 0), which clears the p0_untag_vid_mask bit, is also skipped. The same holds for the -EIO now returned by cpsw_ale_del_ucast(), cpsw_ale_del_mcast() and cpsw_ale_vlan_del_modify(). Do the am65 callers handle this? am65_cpsw_nuss_ndo_slave_kill_vid() returns -EIO to the 8021q core, which removes the VID from its software state anyway. am65_cpsw_port_vlan_del() returns early when cpsw_ale_del_vlan() fails. It then also skips deleting the host MAC ucast entry and the broadcast mcast entry for that VID. am65_cpsw_port_mdb_del() ignores the result and always returns 0, so the bridge sees the MDB delete as successful: /* Ignore error as error code is returned only when entry is already removed */ cpsw_ale_del_mcast(cpsw->ale, mdb->addr, del_mask, ALE_VLAN, mdb->vid); The SWITCHDEV_FDB_DEL_TO_DEVICE case in am65_cpsw_switchdev_event_work() also ignores the return value of cpsw_ale_del_ucast(). The comments in am65-cpsw-switchdev.c that justify ignoring these errors ("error is returned only if the unicast entry is not present", "error is returned only if the multicast entry is not present", and the MDB one above) are no longer accurate after this change. Could this leave stale VLAN, unicast or multicast entries forwarding traffic for state the stack considers removed? These entries would also keep their table slots. cpsw_ale_match_free() never sees them as free, and cpsw_ale_find_ageable() does not reclaim VLAN or multicast entries. [ ... ] > @@ -1518,7 +1584,8 @@ static const struct cpsw_ale_dev_id cpsw_ale_id_match[] = { > }, > { > .dev_id = "am64-cpswxg", > - .features = CPSW_ALE_F_STATUS_REG | CPSW_ALE_F_HW_AUTOAGING, > + .features = CPSW_ALE_F_STATUS_REG | CPSW_ALE_F_HW_AUTOAGING | > + CPSW_ALE_F_TBL_READ_VERIFY, [Severity: Medium] The commit message says: "Add the feature flag CPSW_ALE_F_TBL_READ_VERIFY and set it only for am64-cpswxg." and: "The J7 variant was not tested and is left alone." Is the "am64-cpswxg" ALE dev_id actually limited to AM64/AM62x? In am65-cpsw-nuss.c, am64x_cpswxg_pdata, j722s_cpswxg_pdata, j7200_cpswxg_pdata, j721e_cpswxg_pdata and j784s4_cpswxg_pdata all select it, for example: static const struct am65_cpsw_pdata j7200_cpswxg_pdata = { .quirks = 0, .ale_dev_id = "am64-cpswxg", The "j721e-cpswxg" entry in cpsw_ale_id_match[] doesn't seem to have any user under drivers/. If so, the doubled reads, the longer ALE lock hold times in the table loops, and the new -EIO and skip paths also apply on J7200, J721E CPSW9G, J784S4 and J722S. The Fixes: tag points at the AM64 commit, so stable backports would bring the same change to those SoCs. Should the commit message describe this, or should the flag be scoped differently? > .reg_fields = ale_fields_cpsw_nu, > .num_fields = ARRAY_SIZE(ale_fields_cpsw_nu), > .vlan_entry_tbl = vlan_entry_k3_cpswxg, -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-cpsw-ale-lock-v3-0-b40dc361d6b9%40amperfied.com