diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2011-04-02 16:37:40 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2011-04-02 16:37:40 +0000 |
commit | d46862a1ed811ea75ce64b949869ab12f998ef8a (patch) | |
tree | 8de6e021f6b92c5f979bdafe177db373d20ee0db /sys/arch | |
parent | aceb690be312a10ddc0f200f94f3eb59cde42096 (diff) |
Constraint checking - ensure that physical addresses for dma are below
the top of the dma constraint range and panic if they are not.
ok deraadt@, thib@, oga@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/bus_dma.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/arch/amd64/amd64/bus_dma.c b/sys/arch/amd64/amd64/bus_dma.c index 3b936f13237..02b6cdd0df3 100644 --- a/sys/arch/amd64/amd64/bus_dma.c +++ b/sys/arch/amd64/amd64/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.35 2010/12/26 15:40:58 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.36 2011/04/02 16:37:39 beck Exp $ */ /* $NetBSD: bus_dma.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */ /*- @@ -100,7 +100,7 @@ #include <dev/isa/isareg.h> #include <dev/isa/isavar.h> -#include <uvm/uvm_extern.h> +#include <uvm/uvm.h> #include "ioapic.h" @@ -333,6 +333,10 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs, if (plen < sgsize) sgsize = plen; + if (paddr > dma_constraint.ucr_high) + panic("Non dma-reachable buffer at paddr %p(raw)", + paddr); + /* * Make sure we don't cross any boundaries. */ @@ -586,6 +590,10 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map, void *buf, */ pmap_extract(pmap, vaddr, (paddr_t *)&curaddr); + if (curaddr > dma_constraint.ucr_high) + panic("Non dma-reachable buffer at curaddr %p(raw)", + curaddr); + /* * Compute the segment size, and adjust counts. */ |