Tue Apr 21 06:45:16 2020 UTC ()
There is no fast spoon^Wfast path in pmap_clearbit.

PR port-arm/55186: tests crash arm pmap

Tested by martin@


(skrll)
diff -r1.411 -r1.412 src/sys/arch/arm/arm32/pmap.c

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

--- src/sys/arch/arm/arm32/pmap.c 2020/04/19 21:24:36 1.411
+++ src/sys/arch/arm/arm32/pmap.c 2020/04/21 06:45:16 1.412
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pmap.c,v 1.411 2020/04/19 21:24:36 ad Exp $ */ 1/* $NetBSD: pmap.c,v 1.412 2020/04/21 06:45:16 skrll 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
@@ -182,27 +182,27 @@ @@ -182,27 +182,27 @@
182/* Include header files */ 182/* Include header files */
183 183
184#include "opt_arm_debug.h" 184#include "opt_arm_debug.h"
185#include "opt_cpuoptions.h" 185#include "opt_cpuoptions.h"
186#include "opt_ddb.h" 186#include "opt_ddb.h"
187#include "opt_lockdebug.h" 187#include "opt_lockdebug.h"
188#include "opt_multiprocessor.h" 188#include "opt_multiprocessor.h"
189 189
190#ifdef MULTIPROCESSOR 190#ifdef MULTIPROCESSOR
191#define _INTR_PRIVATE 191#define _INTR_PRIVATE
192#endif 192#endif
193 193
194#include <sys/cdefs.h> 194#include <sys/cdefs.h>
195__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.411 2020/04/19 21:24:36 ad Exp $"); 195__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.412 2020/04/21 06:45:16 skrll Exp $");
196 196
197#include <sys/atomic.h> 197#include <sys/atomic.h>
198#include <sys/param.h> 198#include <sys/param.h>
199#include <sys/types.h> 199#include <sys/types.h>
200#include <sys/atomic.h> 200#include <sys/atomic.h>
201#include <sys/bus.h> 201#include <sys/bus.h>
202#include <sys/cpu.h> 202#include <sys/cpu.h>
203#include <sys/intr.h> 203#include <sys/intr.h>
204#include <sys/kernel.h> 204#include <sys/kernel.h>
205#include <sys/kernhist.h> 205#include <sys/kernhist.h>
206#include <sys/kmem.h> 206#include <sys/kmem.h>
207#include <sys/pool.h> 207#include <sys/pool.h>
208#include <sys/proc.h> 208#include <sys/proc.h>
@@ -2364,34 +2364,26 @@ pmap_clearbit(struct vm_page_md *md, pad @@ -2364,34 +2364,26 @@ pmap_clearbit(struct vm_page_md *md, pad
2364 const vaddr_t va = pv->pv_va; 2364 const vaddr_t va = pv->pv_va;
2365 const u_int oflags = pv->pv_flags; 2365 const u_int oflags = pv->pv_flags;
2366#ifndef ARM_MMU_EXTENDED 2366#ifndef ARM_MMU_EXTENDED
2367 /* 2367 /*
2368 * Kernel entries are unmanaged and as such not to be changed. 2368 * Kernel entries are unmanaged and as such not to be changed.
2369 */ 2369 */
2370 if (PV_IS_KENTRY_P(oflags)) { 2370 if (PV_IS_KENTRY_P(oflags)) {
2371 pv = SLIST_NEXT(pv, pv_link); 2371 pv = SLIST_NEXT(pv, pv_link);
2372 continue; 2372 continue;
2373 } 2373 }
2374#endif 2374#endif
2375 2375
2376 /* 2376 /*
2377 * Anything to do? 
2378 */ 
2379 if ((oflags & maskbits) == 0 && execbits == 0) { 
2380 pv = SLIST_NEXT(pv, pv_link); 
2381 continue; 
2382 } 
2383 
2384 /* 
2385 * Try to get a hold on the pmap's lock. We must do this 2377 * Try to get a hold on the pmap's lock. We must do this
2386 * while still holding the page locked, to know that the 2378 * while still holding the page locked, to know that the
2387 * page is still associated with the pmap and the mapping is 2379 * page is still associated with the pmap and the mapping is
2388 * in place. If a hold can't be had, unlock and wait for 2380 * in place. If a hold can't be had, unlock and wait for
2389 * the pmap's lock to become available and retry. The pmap 2381 * the pmap's lock to become available and retry. The pmap
2390 * must be ref'd over this dance to stop it disappearing 2382 * must be ref'd over this dance to stop it disappearing
2391 * behind us. 2383 * behind us.
2392 */ 2384 */
2393 if (!mutex_tryenter(&pm->pm_lock)) { 2385 if (!mutex_tryenter(&pm->pm_lock)) {
2394 pmap_reference(pm); 2386 pmap_reference(pm);
2395 pmap_release_page_lock(md); 2387 pmap_release_page_lock(md);
2396 pmap_acquire_pmap_lock(pm); 2388 pmap_acquire_pmap_lock(pm);
2397 /* nothing, just wait for it */ 2389 /* nothing, just wait for it */