summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2007-11-03 22:23:36 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2007-11-03 22:23:36 +0000
commitea29071c838af86d519036294124fda695fe1cba (patch)
tree83792b150267871029b4ac3729db5013bb2dd184 /sys/arch/amd64
parentff787073803a656dbca03eb2edebf35aac400ceb (diff)
Fix LKM support for amd64.
ok deraadt weingart
Diffstat (limited to 'sys/arch/amd64')
-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
3 files changed, 36 insertions, 7 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!");