From a3c35df6c05ff80145b1e520463b3b5973d0b81e Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 14 Jan 2007 00:01:08 +0000 Subject: [PATCH] The FP subsystem might not work properly when a vkernel is run inside a vkernel, but don't explicitly panic. Move an madvise() to after a mmap() error check. Fix a vkernel-on-vkernel bug in pmap_zero_page(). The VPTE was being given write access without read access and this confused the parent virtual kernel. --- sys/platform/vkernel/i386/trap.c | 3 +-- sys/platform/vkernel/include/vmparam.h | 4 ++-- sys/platform/vkernel/platform/init.c | 4 ++-- sys/platform/vkernel/platform/pmap.c | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/sys/platform/vkernel/i386/trap.c b/sys/platform/vkernel/i386/trap.c index e3e995cd35..dcf03c7dd9 100644 --- a/sys/platform/vkernel/i386/trap.c +++ b/sys/platform/vkernel/i386/trap.c @@ -36,7 +36,7 @@ * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $ - * $DragonFly: src/sys/platform/vkernel/i386/trap.c,v 1.10 2007/01/12 06:07:29 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/i386/trap.c,v 1.11 2007/01/14 00:01:06 dillon Exp $ */ /* @@ -1452,7 +1452,6 @@ set_vkernel_fp(struct trapframe *frame) { struct thread *td = curthread; - panic("set_vkernel_fp: vkernel-within-vkernel not yet supported"); if (frame->tf_xflags & FPEX_FAULT) { td->td_pcb->pcb_flags |= FP_VIRTFP; if (mdcpu->gd_npxthread == td) diff --git a/sys/platform/vkernel/include/vmparam.h b/sys/platform/vkernel/include/vmparam.h index 92e23a62cb..fa63fe8022 100644 --- a/sys/platform/vkernel/include/vmparam.h +++ b/sys/platform/vkernel/include/vmparam.h @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/platform/vkernel/include/vmparam.h,v 1.4 2007/01/07 08:37:36 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/include/vmparam.h,v 1.5 2007/01/14 00:01:07 dillon Exp $ */ #ifndef _MACHINE_VMPARAM_H_ @@ -76,7 +76,7 @@ #define KERNEL_KVA_SIZE 0x40000000 #define VM_MIN_USER_ADDRESS 0x00000000 -#define VM_MAX_USER_ADDRESS 0xB8000000 /* XXX match to real kernel */ +#define VM_MAX_USER_ADDRESS 0xBFC00000 /* XXX match to real kernel */ #define USRSTACK VM_MAX_USER_ADDRESS diff --git a/sys/platform/vkernel/platform/init.c b/sys/platform/vkernel/platform/init.c index d2e641c900..4407713b02 100644 --- a/sys/platform/vkernel/platform/init.c +++ b/sys/platform/vkernel/platform/init.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/platform/vkernel/platform/init.c,v 1.24 2007/01/12 18:31:18 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/platform/init.c,v 1.25 2007/01/14 00:01:08 dillon Exp $ */ #include @@ -300,11 +300,11 @@ init_kern_memory(void) */ base = mmap((void *)0x40000000, KERNEL_KVA_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED|MAP_VPAGETABLE, MemImageFd, 0); - madvise(base, KERNEL_KVA_SIZE, MADV_NOSYNC); if (base == MAP_FAILED) { err(1, "Unable to mmap() kernel virtual memory!"); /* NOT REACHED */ } + madvise(base, KERNEL_KVA_SIZE, MADV_NOSYNC); KvaStart = (vm_offset_t)base; KvaSize = KERNEL_KVA_SIZE; KvaEnd = KvaStart + KvaSize; diff --git a/sys/platform/vkernel/platform/pmap.c b/sys/platform/vkernel/platform/pmap.c index a4a6b0db76..aa4f12b166 100644 --- a/sys/platform/vkernel/platform/pmap.c +++ b/sys/platform/vkernel/platform/pmap.c @@ -38,7 +38,7 @@ * * from: @(#)pmap.c 7.7 (Berkeley) 5/12/91 * $FreeBSD: src/sys/i386/i386/pmap.c,v 1.250.2.18 2002/03/06 22:48:53 silby Exp $ - * $DragonFly: src/sys/platform/vkernel/platform/pmap.c,v 1.13 2007/01/12 22:12:52 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/platform/pmap.c,v 1.14 2007/01/14 00:01:08 dillon Exp $ */ /* * NOTE: PMAP_INVAL_ADD: In pc32 this function is called prior to adjusting @@ -2357,7 +2357,7 @@ pmap_zero_page(vm_paddr_t phys) crit_enter(); if (*gd->gd_CMAP3) panic("pmap_zero_page: CMAP3 busy"); - *gd->gd_CMAP3 = VPTE_V | VPTE_W | (phys & VPTE_FRAME) | VPTE_A | VPTE_M; + *gd->gd_CMAP3 = VPTE_V | VPTE_R | VPTE_W | (phys & VPTE_FRAME) | VPTE_A | VPTE_M; madvise(gd->gd_CADDR3, PAGE_SIZE, MADV_INVAL); bzero(gd->gd_CADDR3, PAGE_SIZE); -- 2.11.4.GIT