From 38f15737fd904588df912b0771bb72eadb96b212 Mon Sep 17 00:00:00 2001 From: thorpej Date: Mon, 25 Aug 1997 21:17:48 +0000 Subject: [PATCH] Protect access to kmem_map with splimp()/splx(). From Chuck Cranor. --- sys/arch/alpha/common/bus_dma.c | 14 +++++++++++--- sys/arch/i386/i386/machdep.c | 11 +++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/sys/arch/alpha/common/bus_dma.c b/sys/arch/alpha/common/bus_dma.c index 5674a5cb2e3d..1e6b7ac8edce 100644 --- a/sys/arch/alpha/common/bus_dma.c +++ b/sys/arch/alpha/common/bus_dma.c @@ -1,4 +1,4 @@ -/* $NetBSD: bus_dma.c,v 1.2 1997/06/06 23:58:02 thorpej Exp $ */ +/* $NetBSD: bus_dma.c,v 1.3 1997/08/25 21:21:23 thorpej Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ #include /* Config options headers */ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.2 1997/06/06 23:58:02 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.3 1997/08/25 21:21:23 thorpej Exp $"); #include #include @@ -54,6 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.2 1997/06/06 23:58:02 thorpej Exp $"); #define _ALPHA_BUS_DMA_PRIVATE #include +#include /* * Common function for DMA map creation. May be called by bus-specific @@ -399,10 +400,14 @@ _bus_dmamem_map(t, segs, nsegs, size, kvap, flags) { vm_offset_t va; bus_addr_t addr; - int curseg; + int curseg, s; size = round_page(size); + + s = splimp(); va = kmem_alloc_pageable(kmem_map, size); + splx(s); + if (va == 0) return (ENOMEM); @@ -436,6 +441,7 @@ _bus_dmamem_unmap(t, kva, size) caddr_t kva; size_t size; { + int s; #ifdef DIAGNOSTIC if ((u_long)kva & PGOFSET) @@ -443,7 +449,9 @@ _bus_dmamem_unmap(t, kva, size) #endif size = round_page(size); + s = splimp(); kmem_free(kmem_map, (vm_offset_t)kva, size); + splx(s); } /* diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index c0003ec81337..2b943670b16e 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.246 1997/08/24 09:38:19 drochner Exp $ */ +/* $NetBSD: machdep.c,v 1.247 1997/08/25 21:17:48 thorpej Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -2357,10 +2357,14 @@ _bus_dmamem_map(t, segs, nsegs, size, kvap, flags) { vm_offset_t va; bus_addr_t addr; - int curseg; + int curseg, s; size = round_page(size); + + s = splimp(); va = kmem_alloc_pageable(kmem_map, size); + splx(s); + if (va == 0) return (ENOMEM); @@ -2396,6 +2400,7 @@ _bus_dmamem_unmap(t, kva, size) caddr_t kva; size_t size; { + int s; #ifdef DIAGNOSTIC if ((u_long)kva & PGOFSET) @@ -2403,7 +2408,9 @@ _bus_dmamem_unmap(t, kva, size) #endif size = round_page(size); + s = splimp(); kmem_free(kmem_map, (vm_offset_t)kva, size); + splx(s); } /*