From 610349693dd31d8b0efd33776516b7187cc5cda2 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 14 Sep 2018 13:33:34 +0200 Subject: if_ffec_mpc8xx: Fix incoming data invalidation With a write-back cache dirty cache lines may be evicted which could overwrite new data. Close #3523. --- rtemsbsd/sys/dev/ffec/if_ffec_mpc8xx.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/rtemsbsd/sys/dev/ffec/if_ffec_mpc8xx.c b/rtemsbsd/sys/dev/ffec/if_ffec_mpc8xx.c index a9d5eb46..bf204609 100644 --- a/rtemsbsd/sys/dev/ffec/if_ffec_mpc8xx.c +++ b/rtemsbsd/sys/dev/ffec/if_ffec_mpc8xx.c @@ -521,6 +521,7 @@ static void fec_rxDaemon (void *arg) rxBd = sc->rxBdBase + rxBdIndex; m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR); m->m_pkthdr.rcvif = ifp; + rtems_cache_invalidate_multiple_data_lines(mtod(m, void *), RBUF_SIZE); sc->rxMbuf[rxBdIndex] = m; rxBd->buffer = mtod (m, void *); rxBd->status = M8xx_BD_EMPTY; @@ -578,19 +579,15 @@ static void fec_rxDaemon (void *arg) if (n != NULL) { /* * Pass the packet up the chain. - * FIXME: Packet filtering hook could be done here. */ - - /* - * Invalidate the buffer for this descriptor - */ - rtems_cache_invalidate_multiple_data_lines(rxBd->buffer, rxBd->length); - m = sc->rxMbuf[rxBdIndex]; m->m_len = m->m_pkthdr.len = rxBd->length - ETHER_CRC_LEN; FEC_UNLOCK(sc); (*sc->ifp->if_input)(sc->ifp, m); FEC_LOCK(sc); + + n->m_pkthdr.rcvif = ifp; + rtems_cache_invalidate_multiple_data_lines(mtod(n, void *), RBUF_SIZE); } else { /* Drop incoming frame if no new mbuf is available */ n = m; @@ -618,7 +615,6 @@ static void fec_rxDaemon (void *arg) sc->rxCollision++; } - n->m_pkthdr.rcvif = ifp; sc->rxMbuf[rxBdIndex] = n; rxBd->buffer = mtod (n, void *); -- cgit v1.2.3