Mon Aug 27 12:05:30 2012 UTC ()
Use the correct (L1_S_PROT, not L2_S_PROT) macro for setting the protection
of the vector page.  This fixes a nasty little bug that shows up on armv7
systems when the vector page physical address changes (bit 12 of the address
is cleared) and then any exception causes the system to hang.


(matt)
diff -r1.230 -r1.231 src/sys/arch/arm/arm32/pmap.c

cvs diff -r1.230 -r1.231 src/sys/arch/arm/arm32/pmap.c (expand / switch to unified diff)

--- src/sys/arch/arm/arm32/pmap.c 2012/08/20 13:03:41 1.230
+++ src/sys/arch/arm/arm32/pmap.c 2012/08/27 12:05:30 1.231
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pmap.c,v 1.230 2012/08/20 13:03:41 matt Exp $ */ 1/* $NetBSD: pmap.c,v 1.231 2012/08/27 12:05:30 matt Exp $ */
2 2
3/* 3/*
4 * Copyright 2003 Wasabi Systems, Inc. 4 * Copyright 2003 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Steve C. Woodford for Wasabi Systems, Inc. 7 * Written by Steve C. Woodford 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
@@ -201,27 +201,27 @@ @@ -201,27 +201,27 @@
201#include <sys/kmem.h> 201#include <sys/kmem.h>
202#include <sys/cdefs.h> 202#include <sys/cdefs.h>
203#include <sys/cpu.h> 203#include <sys/cpu.h>
204#include <sys/sysctl.h> 204#include <sys/sysctl.h>
205 205
206#include <uvm/uvm.h> 206#include <uvm/uvm.h>
207 207
208#include <sys/bus.h> 208#include <sys/bus.h>
209#include <machine/pmap.h> 209#include <machine/pmap.h>
210#include <machine/pcb.h> 210#include <machine/pcb.h>
211#include <machine/param.h> 211#include <machine/param.h>
212#include <arm/arm32/katelib.h> 212#include <arm/arm32/katelib.h>
213 213
214__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.230 2012/08/20 13:03:41 matt Exp $"); 214__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.231 2012/08/27 12:05:30 matt Exp $");
215 215
216#ifdef PMAP_DEBUG 216#ifdef PMAP_DEBUG
217 217
218/* XXX need to get rid of all refs to this */ 218/* XXX need to get rid of all refs to this */
219int pmap_debug_level = 0; 219int pmap_debug_level = 0;
220 220
221/* 221/*
222 * for switching to potentially finer grained debugging 222 * for switching to potentially finer grained debugging
223 */ 223 */
224#define PDB_FOLLOW 0x0001 224#define PDB_FOLLOW 0x0001
225#define PDB_INIT 0x0002 225#define PDB_INIT 0x0002
226#define PDB_ENTER 0x0004 226#define PDB_ENTER 0x0004
227#define PDB_REMOVE 0x0008 227#define PDB_REMOVE 0x0008
@@ -4966,27 +4966,27 @@ out: @@ -4966,27 +4966,27 @@ out:
4966 * Manipulate the protection of the vector page. 4966 * Manipulate the protection of the vector page.
4967 */ 4967 */
4968void 4968void
4969vector_page_setprot(int prot) 4969vector_page_setprot(int prot)
4970{ 4970{
4971 struct l2_bucket *l2b; 4971 struct l2_bucket *l2b;
4972 pt_entry_t *ptep; 4972 pt_entry_t *ptep;
4973 4973
4974 l2b = pmap_get_l2_bucket(pmap_kernel(), vector_page); 4974 l2b = pmap_get_l2_bucket(pmap_kernel(), vector_page);
4975 KDASSERT(l2b != NULL); 4975 KDASSERT(l2b != NULL);
4976 4976
4977 ptep = &l2b->l2b_kva[l2pte_index(vector_page)]; 4977 ptep = &l2b->l2b_kva[l2pte_index(vector_page)];
4978 4978
4979 *ptep = (*ptep & ~L1_S_PROT_MASK) | L2_S_PROT(PTE_KERNEL, prot); 4979 *ptep = (*ptep & ~L1_S_PROT_MASK) | L1_S_PROT(PTE_KERNEL, prot);
4980 PTE_SYNC(ptep); 4980 PTE_SYNC(ptep);
4981 cpu_tlb_flushD_SE(vector_page); 4981 cpu_tlb_flushD_SE(vector_page);
4982 cpu_cpwait(); 4982 cpu_cpwait();
4983} 4983}
4984 4984
4985/* 4985/*
4986 * Fetch pointers to the PDE/PTE for the given pmap/VA pair. 4986 * Fetch pointers to the PDE/PTE for the given pmap/VA pair.
4987 * Returns true if the mapping exists, else false. 4987 * Returns true if the mapping exists, else false.
4988 * 4988 *
4989 * NOTE: This function is only used by a couple of arm-specific modules. 4989 * NOTE: This function is only used by a couple of arm-specific modules.
4990 * It is not safe to take any pmap locks here, since we could be right 4990 * It is not safe to take any pmap locks here, since we could be right
4991 * in the middle of debugging the pmap anyway... 4991 * in the middle of debugging the pmap anyway...
4992 * 4992 *