summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2004-02-24 00:20:46 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2004-02-24 00:20:46 +0000
commit9a849fd3974295740bddbecc49ae9d1efb5e94e5 (patch)
tree0c999867d0ac3a9942acba7340653f32a5d9dd7e /sys/arch
parent59a2f25a8d2f2efeafac1ea5da0c8200f52dffcb (diff)
repair kvm; deraadt@ ok
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/amd64/amd64/machdep.c4
-rw-r--r--sys/arch/amd64/amd64/mem.c10
2 files changed, 11 insertions, 3 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index ff99498d051..fb3b6147b68 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.9 2004/02/23 09:12:59 mickey Exp $ */
+/* $OpenBSD: machdep.c,v 1.10 2004/02/24 00:20:45 mickey Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@@ -157,6 +157,7 @@ extern int boothowto;
int cpu_class;
char *ssym = NULL;
+vaddr_t kern_end;
#define CPUID2MODEL(cpuid) (((cpuid) >> 4) & 15)
@@ -1296,6 +1297,7 @@ init_x86_64(first_avail)
/* Make sure the end of the space used by the kernel is rounded. */
first_avail = round_page(first_avail);
+ kern_end = KERNBASE + first_avail;
/*
* Now, load the memory clusters (which have already been
diff --git a/sys/arch/amd64/amd64/mem.c b/sys/arch/amd64/amd64/mem.c
index 7bb187717c3..8f648733043 100644
--- a/sys/arch/amd64/amd64/mem.c
+++ b/sys/arch/amd64/amd64/mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.c,v 1.1 2004/01/28 01:39:39 mickey Exp $ */
+/* $OpenBSD: mem.c,v 1.2 2004/02/24 00:20:45 mickey Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1986, 1990, 1993
@@ -60,6 +60,7 @@
extern char *vmmap; /* poor name! */
caddr_t zeropage;
+extern int start, end, etext;
/* open counter for aperture */
#ifdef APERTURE
@@ -119,6 +120,7 @@ mmclose(dev, flag, mode, p)
int
mmrw(dev_t dev, struct uio *uio, int flags)
{
+ extern vaddr_t kern_end;
vaddr_t o, v;
int c;
struct iovec *iov;
@@ -166,7 +168,11 @@ mmrw(dev_t dev, struct uio *uio, int flags)
case 1:
v = uio->uio_offset;
c = min(iov->iov_len, MAXPHYS);
- if (!uvm_kernacc((caddr_t)v, c,
+ if (v >= (vaddr_t)&start && v < kern_end) {
+ if (v < (vaddr_t)&etext &&
+ uio->uio_rw == UIO_WRITE)
+ return EFAULT;
+ } else if (!uvm_kernacc((caddr_t)v, c,
uio->uio_rw == UIO_READ ? B_READ : B_WRITE))
return (EFAULT);
error = uiomove((caddr_t)v, c, uio);