diff options
author | 2016-01-13 18:56:26 +0000 | |
---|---|---|
committer | 2016-01-13 18:56:26 +0000 | |
commit | 180e0ac6ae1607bff56648ca5f5c56097dd93863 (patch) | |
tree | cdf34557a55067fe26553f80a69cff3780a27f3b | |
parent | Convert to uiomove(); from Martin Natano, thanks! (diff) | |
download | wireguard-openbsd-180e0ac6ae1607bff56648ca5f5c56097dd93863.tar.xz wireguard-openbsd-180e0ac6ae1607bff56648ca5f5c56097dd93863.zip |
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.
-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); |