Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86_64/x86_64 Change kmem access check to match the...



details:   https://anonhg.NetBSD.org/src/rev/6bf6509d485e
branches:  trunk
changeset: 532357:6bf6509d485e
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Wed Jun 05 21:58:30 2002 +0000

description:
Change kmem access check to match the actual kva layout.

diffstat:

 sys/arch/x86_64/x86_64/mem.c |  15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r 0f088430d6ce -r 6bf6509d485e sys/arch/x86_64/x86_64/mem.c
--- a/sys/arch/x86_64/x86_64/mem.c      Wed Jun 05 21:56:46 2002 +0000
+++ b/sys/arch/x86_64/x86_64/mem.c      Wed Jun 05 21:58:30 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mem.c,v 1.2 2002/02/27 01:20:56 christos Exp $ */
+/*     $NetBSD: mem.c,v 1.3 2002/06/05 21:58:30 fvdl Exp $     */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -61,6 +61,7 @@
 
 extern char *vmmap;            /* poor name! */
 caddr_t zeropage;
+extern int start, end, etext;
 
 /*ARGSUSED*/
 int
@@ -136,9 +137,15 @@
                case DEV_KMEM:
                        v = uio->uio_offset;
                        c = min(iov->iov_len, MAXPHYS);
-                       if (!uvm_kernacc((caddr_t)v, c,
-                           uio->uio_rw == UIO_READ ? B_READ : B_WRITE))
-                               return (EFAULT);
+                       if (v >= (vaddr_t)&start && (v + c) < (vaddr_t)&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);
                        break;
 



Home | Main Index | Thread Index | Old Index