From b6945981e5317b5f97b137ab2152d181b6f1c6b6 Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 24 Aug 2011 16:01:53 +0000 Subject: [PATCH] When using 16KB pages in a 64 bit kernel, the amount of address space our page table can address can be larger than the amount of address space the CPU implementation supports. This change limits the amount address space to what the CPU implementation provides. --- sys/arch/mips/include/vmparam.h | 12 ++++++++++-- sys/arch/mips/mips/mips_machdep.c | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/sys/arch/mips/include/vmparam.h b/sys/arch/mips/include/vmparam.h index e376907d37eb..a349cda87c93 100644 --- a/sys/arch/mips/include/vmparam.h +++ b/sys/arch/mips/include/vmparam.h @@ -1,4 +1,4 @@ -/* $NetBSD: vmparam.h,v 1.49 2011/07/21 23:03:39 macallan Exp $ */ +/* $NetBSD: vmparam.h,v 1.50 2011/08/24 16:01:53 matt Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -155,7 +155,12 @@ */ #define VM_MIN_ADDRESS ((vaddr_t)0x00000000) #ifdef _LP64 -#define VM_MAXUSER_ADDRESS ((vaddr_t) 1L << (4*PGSHIFT-8)) +#define MIPS_VM_MAXUSER_ADDRESS ((vaddr_t) 1L << (4*PGSHIFT-8)) +#ifdef ENABLE_MIPS_16KB_PAGE +#define VM_MAXUSER_ADDRESS mips_vm_maxuser_address +#else +#define VM_MAXUSER_ADDRESS MIPS_VM_MAXUSER_ADDRESS +#endif /* 0x0000010000000000 */ #define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS #define VM_MIN_KERNEL_ADDRESS ((vaddr_t) 3L << 62) /* 0xC000000000000000 */ @@ -197,6 +202,9 @@ #ifdef _KERNEL #define UVM_KM_VMFREELIST mips_poolpage_vmfreelist extern int mips_poolpage_vmfreelist; +#ifdef ENABLE_MIPS_16KB_PAGE +extern vaddr_t mips_vm_maxuser_address; +#endif #endif #endif /* ! _MIPS_VMPARAM_H_ */ diff --git a/sys/arch/mips/mips/mips_machdep.c b/sys/arch/mips/mips/mips_machdep.c index 0edbd5a8caa4..7da6813aa96c 100644 --- a/sys/arch/mips/mips/mips_machdep.c +++ b/sys/arch/mips/mips/mips_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: mips_machdep.c,v 1.246 2011/08/16 06:58:15 matt Exp $ */ +/* $NetBSD: mips_machdep.c,v 1.247 2011/08/24 16:01:53 matt Exp $ */ /* * Copyright 2002 Wasabi Systems, Inc. @@ -112,7 +112,7 @@ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.246 2011/08/16 06:58:15 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.247 2011/08/24 16:01:53 matt Exp $"); #define __INTR_PRIVATE #include "opt_cputype.h" @@ -193,6 +193,10 @@ int cpu_dump(void); static void mips_watchpoint_init(void); #endif +#if defined(_LP64) && defined(ENABLE_MIPS_16KB_PAGE) +vaddr_t mips_vm_maxuser_address = MIPS_VM_MAXUSER_ADDRESS; +#endif + #if defined(MIPS3_PLUS) uint32_t mips3_cp0_tlb_page_mask_probe(void); uint64_t mips3_cp0_tlb_entry_hi_probe(void); @@ -1357,6 +1361,16 @@ mips3_tlb_probe(void) opts->mips3_tlb_vpn_mask <<= 2; opts->mips3_tlb_vpn_mask >>= 2; opts->mips3_tlb_pfn_mask = mips3_cp0_tlb_entry_lo_probe(); +#if defined(_LP64) && defined(ENABLE_MIPS_16KB_PAGE) + /* + * 16KB pages could cause our page table being able to address + * a larger address space than the actual chip supports. So + * we need to limit the address space to what it can really + * address. + */ + if (mips_vm_maxuser_address > opts->mips3_tlb_vpn_mask + 1) + mips_vm_maxuser_address = opts->mips3_tlb_vpn_mask + 1; +#endif } } #endif