summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2015-06-25 18:35:48 +0000
committerderaadt <deraadt@openbsd.org>2015-06-25 18:35:48 +0000
commitec7f6c9b50085952c30f1690b4c1482d731738d6 (patch)
tree974c12e6a12c98f0cf2e40ed0f79ecc705f7e9fc
parentOF_getprop() returns an int, so comparing its return value against sizeof casts (diff)
downloadwireguard-openbsd-ec7f6c9b50085952c30f1690b4c1482d731738d6.tar.xz
wireguard-openbsd-ec7f6c9b50085952c30f1690b4c1482d731738d6.zip
Ensure the setup block is DMA reachable.
tested by reyk, mlarkin, others
-rw-r--r--sys/dev/pci/if_de.c16
-rw-r--r--sys/dev/pci/if_devar.h8
2 files changed, 13 insertions, 11 deletions
diff --git a/sys/dev/pci/if_de.c b/sys/dev/pci/if_de.c
index a6d3d9a82b8..af660e2d4d2 100644
--- a/sys/dev/pci/if_de.c
+++ b/sys/dev/pci/if_de.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_de.c,v 1.121 2015/06/24 09:40:54 mpi Exp $ */
+/* $OpenBSD: if_de.c,v 1.122 2015/06/25 18:35:48 deraadt Exp $ */
/* $NetBSD: if_de.c,v 1.58 1998/01/12 09:39:58 thorpej Exp $ */
/*-
@@ -49,6 +49,7 @@
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/timeout.h>
+#include <sys/pool.h>
#include <net/if.h>
#include <net/if_media.h>
@@ -4084,8 +4085,7 @@ tulip_txput_setup(tulip_softc_t * const sc)
sc->tulip_if.if_start = tulip_ifstart;
return;
}
- bcopy(sc->tulip_setupdata, sc->tulip_setupbuf,
- sizeof(sc->tulip_setupbuf));
+ bcopy(sc->tulip_setupdata, sc->tulip_setupdma, sizeof(sc->tulip_setupdata));
/*
* Clear WANTSETUP and set DOINGSETUP. Set know that WANTSETUP is
* set and DOINGSETUP is clear doing an XOR of the two will DTRT.
@@ -4356,16 +4356,16 @@ tulip_busdma_init(tulip_softc_t * const sc)
{
int error = 0;
+ sc->tulip_setupdma = dma_alloc(sizeof(sc->tulip_setupdata), PR_WAITOK);
+
/*
* Allocate dmamap for setup descriptor
*/
- error = bus_dmamap_create(sc->tulip_dmatag, sizeof(sc->tulip_setupbuf), 2,
- sizeof(sc->tulip_setupbuf), 0, BUS_DMA_NOWAIT,
- &sc->tulip_setupmap);
+ error = bus_dmamap_create(sc->tulip_dmatag, TULIP_SETUP, 2,
+ TULIP_SETUP, 0, BUS_DMA_NOWAIT, &sc->tulip_setupmap);
if (error == 0) {
error = bus_dmamap_load(sc->tulip_dmatag, sc->tulip_setupmap,
- sc->tulip_setupbuf, sizeof(sc->tulip_setupbuf),
- NULL, BUS_DMA_NOWAIT);
+ sc->tulip_setupdma, TULIP_SETUP, NULL, BUS_DMA_NOWAIT);
if (error)
bus_dmamap_destroy(sc->tulip_dmatag, sc->tulip_setupmap);
}
diff --git a/sys/dev/pci/if_devar.h b/sys/dev/pci/if_devar.h
index bccb72fcefa..e1e1cd8d7ec 100644
--- a/sys/dev/pci/if_devar.h
+++ b/sys/dev/pci/if_devar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_devar.h,v 1.33 2015/02/10 03:51:58 mpi Exp $ */
+/* $OpenBSD: if_devar.h,v 1.34 2015/06/25 18:35:48 deraadt Exp $ */
/* $NetBSD: if_devar.h,v 1.13 1997/06/08 18:46:36 thorpej Exp $ */
/*-
@@ -600,8 +600,10 @@ struct _tulip_softc_t {
* one is the one being sent while the other is the one being
* filled.
*/
- u_int32_t tulip_setupbuf[192/sizeof(u_int32_t)];
- u_int32_t tulip_setupdata[192/sizeof(u_int32_t)];
+#define TULIP_SETUP 192
+ u_int32_t *tulip_setupdma;
+ u_int32_t tulip_setupdata[TULIP_SETUP / sizeof(u_int32_t)];
+
char tulip_boardid[16]; /* buffer for board ID */
u_int8_t tulip_rombuf[128];
struct device *tulip_pci_busno; /* needed for multiport boards */