From d46862a1ed811ea75ce64b949869ab12f998ef8a Mon Sep 17 00:00:00 2001 From: Bob Beck Date: Sat, 2 Apr 2011 16:37:40 +0000 Subject: 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@ --- sys/arch/amd64/amd64/bus_dma.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sys/arch') 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 #include -#include +#include #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. */ -- cgit v1.2.3