diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2016-01-13 18:56:27 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2016-01-13 18:56:27 +0000 |
commit | b423fadbf88692a4f1e1ed512d146f7f2ed8cc78 (patch) | |
tree | b3dcf363159a9dccd37a184aac40ce988c665f1c /sys/dev | |
parent | 9a43d369da9c7adb042927bfc2031119cae9d1f0 (diff) |
Create rx and tx fragment maps with a page size boundary restriction
We need to ensure that rx and tx fragments do not cross page boundary
since grant table reference can only point to a complete page. Add a
couple of kernel assertions in the dma map loading code to catch these
problems early in the future.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pv/if_xnf.c | 6 | ||||
-rw-r--r-- | sys/dev/pv/xen.c | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/sys/dev/pv/if_xnf.c b/sys/dev/pv/if_xnf.c index 289d49e8993..18d94756948 100644 --- a/sys/dev/pv/if_xnf.c +++ b/sys/dev/pv/if_xnf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_xnf.c,v 1.2 2016/01/08 14:59:37 reyk Exp $ */ +/* $OpenBSD: if_xnf.c,v 1.3 2016/01/13 18:56:26 mikeb Exp $ */ /* * Copyright (c) 2015, 2016 Mike Belopuhov @@ -784,7 +784,7 @@ xnf_rx_ring_create(struct xnf_softc *sc) for (i = 0; i < XNF_RX_DESC; i++) { if (bus_dmamap_create(sc->sc_dmat, XNF_MCLEN, 1, - XNF_MCLEN, 0, BUS_DMA_WAITOK, &sc->sc_rx_dmap[i])) { + XNF_MCLEN, PAGE_SIZE, BUS_DMA_WAITOK, &sc->sc_rx_dmap[i])) { printf("%s: failed to create a memory map for the" " rx slot %d\n", sc->sc_dev.dv_xname, i); goto errout; @@ -886,7 +886,7 @@ xnf_tx_ring_create(struct xnf_softc *sc) for (i = 0; i < XNF_TX_DESC; i++) { if (bus_dmamap_create(sc->sc_dmat, XNF_MCLEN, XNF_TX_FRAG, - XNF_MCLEN, 0, BUS_DMA_WAITOK, &sc->sc_tx_dmap[i])) { + XNF_MCLEN, PAGE_SIZE, BUS_DMA_WAITOK, &sc->sc_tx_dmap[i])) { printf("%s: failed to create a memory map for the" " tx slot %d\n", sc->sc_dev.dv_xname, i); goto errout; diff --git a/sys/dev/pv/xen.c b/sys/dev/pv/xen.c index ede837b4064..05726f723f5 100644 --- a/sys/dev/pv/xen.c +++ b/sys/dev/pv/xen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xen.c,v 1.23 2016/01/05 18:03:59 mikeb Exp $ */ +/* $OpenBSD: xen.c,v 1.24 2016/01/13 18:56:26 mikeb Exp $ */ /* * Copyright (c) 2015 Mike Belopuhov @@ -1075,6 +1075,10 @@ xen_bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0, gm[i].gm_paddr = map->dm_segs[i].ds_addr; map->dm_segs[i].ds_offset = map->dm_segs[i].ds_addr & PAGE_MASK; + KASSERT(map->dm_segs[i].ds_offset + + map->dm_segs[i].ds_len <= PAGE_SIZE); + KASSERT(map->dm_segs[i].ds_offset + + map->dm_segs[i].ds_len <= PAGE_SIZE); map->dm_segs[i].ds_addr = gm[i].gm_ref; } return (0); |