summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/amd64/amd64/machdep.c19
-rw-r--r--sys/arch/amd64/amd64/mem.c18
-rw-r--r--sys/arch/amd64/amd64/pmap.c6
-rw-r--r--sys/kern/kern_lkm.c18
-rw-r--r--sys/sys/lkm.h4
5 files changed, 52 insertions, 13 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index 23b67fde92d..3c8e1028a75 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.64 2007/10/31 15:55:46 deraadt Exp $ */
+/* $OpenBSD: machdep.c,v 1.65 2007/11/03 22:23:35 mikeb Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@@ -176,6 +176,12 @@ paddr_t lo32_paddr;
int kbd_reset;
+#ifdef LKM
+vaddr_t lkm_start, lkm_end;
+static struct vm_map lkm_map_store;
+extern struct vm_map *lkm_map;
+#endif
+
struct vm_map *exec_map = NULL;
struct vm_map *phys_map = NULL;
@@ -331,6 +337,12 @@ cpu_startup(void)
phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
VM_PHYS_SIZE, 0, FALSE, NULL);
+#ifdef LKM
+ uvm_map_setup(&lkm_map_store, lkm_start, lkm_end, VM_MAP_PAGEABLE);
+ lkm_map_store.pmap = pmap_kernel();
+ lkm_map = &lkm_map_store;
+#endif
+
printf("avail mem = %lu (%luMB)\n", ptoa((psize_t)uvmexp.free),
ptoa((psize_t)uvmexp.free)/1024/1024);
@@ -1293,6 +1305,11 @@ init_x86_64(paddr_t first_avail)
first_avail = round_page(first_avail);
kern_end = KERNBASE + first_avail;
+#ifdef LKM
+ lkm_start = KERNTEXTOFF + first_avail;
+ lkm_end = KERNBASE + NKL2_KIMG_ENTRIES * NBPD_L2;
+#endif
+
/*
* Now, load the memory clusters (which have already been
* rounded and truncated) into the VM system.
diff --git a/sys/arch/amd64/amd64/mem.c b/sys/arch/amd64/amd64/mem.c
index e25709e0bc7..175e3c69257 100644
--- a/sys/arch/amd64/amd64/mem.c
+++ b/sys/arch/amd64/amd64/mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.c,v 1.8 2007/10/28 10:25:09 martin Exp $ */
+/* $OpenBSD: mem.c,v 1.9 2007/11/03 22:23:35 mikeb Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1986, 1990, 1993
@@ -46,12 +46,17 @@
#include <sys/param.h>
#include <sys/buf.h>
#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/exec.h>
#include <sys/uio.h>
#include <sys/ioccom.h>
#include <sys/malloc.h>
#include <sys/memrange.h>
#include <sys/proc.h>
#include <sys/fcntl.h>
+#ifdef LKM
+#include <sys/lkm.h>
+#endif
#include <machine/cpu.h>
#include <machine/conf.h>
@@ -61,6 +66,10 @@
caddr_t zeropage;
extern int start, end, etext;
+#ifdef LKM
+extern vaddr_t lkm_start, lkm_end;
+#endif
+
/* open counter for aperture */
#ifdef APERTURE
static int ap_open_count = 0;
@@ -143,6 +152,13 @@ mmrw(dev_t dev, struct uio *uio, int flags)
if (v < (vaddr_t)&etext &&
uio->uio_rw == UIO_WRITE)
return EFAULT;
+#ifdef LKM
+ } else if (v >= lkm_start && v < lkm_end) {
+ if (!uvm_map_checkprot(lkm_map, v, v + c,
+ uio->uio_rw == UIO_READ ?
+ UVM_PROT_READ: UVM_PROT_WRITE))
+ return (EFAULT);
+#endif
} else if ((!uvm_kernacc((caddr_t)v, c,
uio->uio_rw == UIO_READ ? B_READ : B_WRITE)) &&
(v < PMAP_DIRECT_BASE && v > PMAP_DIRECT_END))
diff --git a/sys/arch/amd64/amd64/pmap.c b/sys/arch/amd64/amd64/pmap.c
index 38ccf4ed976..28f8accf5ef 100644
--- a/sys/arch/amd64/amd64/pmap.c
+++ b/sys/arch/amd64/amd64/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.28 2007/09/04 23:20:23 thib Exp $ */
+/* $OpenBSD: pmap.c,v 1.29 2007/11/03 22:23:35 mikeb Exp $ */
/* $NetBSD: pmap.c,v 1.3 2003/05/08 18:13:13 thorpej Exp $ */
/*
@@ -2077,10 +2077,6 @@ pmap_enter(struct pmap *pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags)
int error;
#ifdef DIAGNOSTIC
- /* sanity check: totally out of range? */
- if (va >= VM_MAX_KERNEL_ADDRESS)
- panic("pmap_enter: too big");
-
if (va == (vaddr_t) PDP_BASE || va == (vaddr_t) APDP_BASE)
panic("pmap_enter: trying to map over PDP/APDP!");
diff --git a/sys/kern/kern_lkm.c b/sys/kern/kern_lkm.c
index b14df59eceb..d2f640e416f 100644
--- a/sys/kern/kern_lkm.c
+++ b/sys/kern/kern_lkm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_lkm.c,v 1.44 2007/10/29 14:12:19 chl Exp $ */
+/* $OpenBSD: kern_lkm.c,v 1.45 2007/11/03 22:23:35 mikeb Exp $ */
/* $NetBSD: kern_lkm.c,v 1.31 1996/03/31 21:40:27 christos Exp $ */
/*
@@ -78,6 +78,8 @@
#define LKMS_LOADED 0x04
#define LKMS_UNLOADING 0x08
+struct vm_map *lkm_map = NULL;
+
static int lkm_v = 0;
static int lkm_state = LKMS_IDLE;
@@ -102,6 +104,12 @@ void
lkminit(void)
{
+ /*
+ * If machine-dependent code hasn't initialized the lkm_map
+ * then just use kernel_map.
+ */
+ if (lkm_map == NULL)
+ lkm_map = kernel_map;
TAILQ_INIT(&lkmods);
lkm_v |= LKM_INIT;
}
@@ -259,7 +267,7 @@ lkmunreserve(void)
#endif
if (curp && curp->syms) {
- uvm_km_free(kernel_map, (vaddr_t)curp->syms, curp->sym_size);
+ uvm_km_free(lkm_map, (vaddr_t)curp->syms, curp->sym_size);
curp->syms = NULL;
}
@@ -267,7 +275,7 @@ lkmunreserve(void)
* Actually unreserve the memory
*/
if (curp && curp->area) {
- uvm_km_free(kernel_map, curp->area, curp->size);
+ uvm_km_free(lkm_map, curp->area, curp->size);
curp->area = 0;
}
lkm_state = LKMS_IDLE;
@@ -339,14 +347,14 @@ lkmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
* Get memory for module
*/
curp->size = resrvp->size;
- curp->area = uvm_km_zalloc(kernel_map, curp->size);
+ curp->area = uvm_km_zalloc(lkm_map, curp->size);
curp->offset = 0;
resrvp->addr = curp->area;
if (cmd == LMRESERV && resrvp->sym_size) {
curp->sym_size = resrvp->sym_size;
curp->sym_symsize = resrvp->sym_symsize;
- curp->syms = (caddr_t)uvm_km_zalloc(kernel_map,
+ curp->syms = (caddr_t)uvm_km_zalloc(lkm_map,
curp->sym_size);
curp->sym_offset = 0;
resrvp->sym_addr = curp->syms;
diff --git a/sys/sys/lkm.h b/sys/sys/lkm.h
index 0724c86b46a..e5177a1a4d3 100644
--- a/sys/sys/lkm.h
+++ b/sys/sys/lkm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lkm.h,v 1.11 2002/01/09 18:20:52 ericj Exp $ */
+/* $OpenBSD: lkm.h,v 1.12 2007/11/03 22:23:35 mikeb Exp $ */
/* $NetBSD: lkm.h,v 1.12 1996/02/09 18:25:13 christos Exp $ */
/*
@@ -274,6 +274,8 @@ extern int lkmdispatch(struct lkm_table *, int);
} \
return lkmdispatch(lkmtp, cmd);
+extern struct vm_map *lkm_map;
+
#endif /* _KERNEL */
/****************************************************************************/