Sat Aug 27 16:54:14 2011 UTC ()
There are non-writable bits in MIPS_COP_0_TLB_HI between ASID and VPN, so
mips3_cp0_tlb_entry_hi_probe() returns a value with some 0 in the low 12 bits.
Thus the computed mips_vm_maxuser_address is wrong. Fix by oring PAGE_MASK to
return value of mips3_cp0_tlb_entry_hi_probe().


(bouyer)
diff -r1.247 -r1.248 src/sys/arch/mips/mips/mips_machdep.c

cvs diff -r1.247 -r1.248 src/sys/arch/mips/mips/mips_machdep.c (expand / switch to unified diff)

--- src/sys/arch/mips/mips/mips_machdep.c 2011/08/24 16:01:53 1.247
+++ src/sys/arch/mips/mips/mips_machdep.c 2011/08/27 16:54:14 1.248
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mips_machdep.c,v 1.247 2011/08/24 16:01:53 matt Exp $ */ 1/* $NetBSD: mips_machdep.c,v 1.248 2011/08/27 16:54:14 bouyer Exp $ */
2 2
3/* 3/*
4 * Copyright 2002 Wasabi Systems, Inc. 4 * Copyright 2002 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Simon Burge for Wasabi Systems, Inc. 7 * Written by Simon Burge for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -102,27 +102,27 @@ @@ -102,27 +102,27 @@
102 * Junior University. All Rights Reserved. 102 * Junior University. All Rights Reserved.
103 * 103 *
104 * Permission to use, copy, modify, and distribute this 104 * Permission to use, copy, modify, and distribute this
105 * software and its documentation for any purpose and without 105 * software and its documentation for any purpose and without
106 * fee is hereby granted, provided that the above copyright 106 * fee is hereby granted, provided that the above copyright
107 * notice appear in all copies. Stanford University 107 * notice appear in all copies. Stanford University
108 * makes no representations about the suitability of this 108 * makes no representations about the suitability of this
109 * software for any purpose. It is provided "as is" without 109 * software for any purpose. It is provided "as is" without
110 * express or implied warranty. 110 * express or implied warranty.
111 */ 111 */
112 112
113#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 113#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
114 114
115__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.247 2011/08/24 16:01:53 matt Exp $"); 115__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.248 2011/08/27 16:54:14 bouyer Exp $");
116 116
117#define __INTR_PRIVATE 117#define __INTR_PRIVATE
118#include "opt_cputype.h" 118#include "opt_cputype.h"
119#include "opt_compat_netbsd32.h" 119#include "opt_compat_netbsd32.h"
120 120
121#include <sys/param.h> 121#include <sys/param.h>
122#include <sys/systm.h> 122#include <sys/systm.h>
123#include <sys/proc.h> 123#include <sys/proc.h>
124#include <sys/intr.h> 124#include <sys/intr.h>
125#include <sys/exec.h> 125#include <sys/exec.h>
126#include <sys/reboot.h> 126#include <sys/reboot.h>
127#include <sys/mount.h> /* fsid_t for syscallargs */ 127#include <sys/mount.h> /* fsid_t for syscallargs */
128#include <sys/lwp.h> 128#include <sys/lwp.h>
@@ -1348,26 +1348,27 @@ mips_set_wbflush(void (*flush_fn)(void)) @@ -1348,26 +1348,27 @@ mips_set_wbflush(void (*flush_fn)(void))
1348{ 1348{
1349 mips_locoresw.lsw_wbflush = flush_fn; 1349 mips_locoresw.lsw_wbflush = flush_fn;
1350 (*flush_fn)(); 1350 (*flush_fn)();
1351} 1351}
1352 1352
1353#if defined(MIPS3_PLUS) 1353#if defined(MIPS3_PLUS)
1354static void 1354static void
1355mips3_tlb_probe(void) 1355mips3_tlb_probe(void)
1356{ 1356{
1357 struct mips_options * const opts = &mips_options; 1357 struct mips_options * const opts = &mips_options;
1358 opts->mips3_tlb_pg_mask = mips3_cp0_tlb_page_mask_probe(); 1358 opts->mips3_tlb_pg_mask = mips3_cp0_tlb_page_mask_probe();
1359 if (CPUIS64BITS) { 1359 if (CPUIS64BITS) {
1360 opts->mips3_tlb_vpn_mask = mips3_cp0_tlb_entry_hi_probe(); 1360 opts->mips3_tlb_vpn_mask = mips3_cp0_tlb_entry_hi_probe();
 1361 opts->mips3_tlb_vpn_mask |= PAGE_MASK;
1361 opts->mips3_tlb_vpn_mask <<= 2; 1362 opts->mips3_tlb_vpn_mask <<= 2;
1362 opts->mips3_tlb_vpn_mask >>= 2; 1363 opts->mips3_tlb_vpn_mask >>= 2;
1363 opts->mips3_tlb_pfn_mask = mips3_cp0_tlb_entry_lo_probe(); 1364 opts->mips3_tlb_pfn_mask = mips3_cp0_tlb_entry_lo_probe();
1364#if defined(_LP64) && defined(ENABLE_MIPS_16KB_PAGE) 1365#if defined(_LP64) && defined(ENABLE_MIPS_16KB_PAGE)
1365 /* 1366 /*
1366 * 16KB pages could cause our page table being able to address 1367 * 16KB pages could cause our page table being able to address
1367 * a larger address space than the actual chip supports. So 1368 * a larger address space than the actual chip supports. So
1368 * we need to limit the address space to what it can really 1369 * we need to limit the address space to what it can really
1369 * address. 1370 * address.
1370 */ 1371 */
1371 if (mips_vm_maxuser_address > opts->mips3_tlb_vpn_mask + 1) 1372 if (mips_vm_maxuser_address > opts->mips3_tlb_vpn_mask + 1)
1372 mips_vm_maxuser_address = opts->mips3_tlb_vpn_mask + 1; 1373 mips_vm_maxuser_address = opts->mips3_tlb_vpn_mask + 1;
1373#endif 1374#endif