Fri Jan 29 07:58:57 2021 UTC ()
the last_fault_code DEBUG variable is not MP safe, so don't compile it in.


(skrll)
diff -r1.114 -r1.115 src/sys/arch/arm/arm32/fault.c

cvs diff -r1.114 -r1.115 src/sys/arch/arm/arm32/fault.c (expand / switch to unified diff)

--- src/sys/arch/arm/arm32/fault.c 2021/01/29 06:22:05 1.114
+++ src/sys/arch/arm/arm32/fault.c 2021/01/29 07:58:57 1.115
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fault.c,v 1.114 2021/01/29 06:22:05 skrll Exp $ */ 1/* $NetBSD: fault.c,v 1.115 2021/01/29 07:58:57 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
@@ -69,29 +69,30 @@ @@ -69,29 +69,30 @@
69 * SUCH DAMAGE. 69 * SUCH DAMAGE.
70 * 70 *
71 * RiscBSD kernel project 71 * RiscBSD kernel project
72 * 72 *
73 * fault.c 73 * fault.c
74 * 74 *
75 * Fault handlers 75 * Fault handlers
76 * 76 *
77 * Created : 28/11/94 77 * Created : 28/11/94
78 */ 78 */
79 79
80#include "opt_ddb.h" 80#include "opt_ddb.h"
81#include "opt_kgdb.h" 81#include "opt_kgdb.h"
 82#include "opt_multiprocessor.h"
82 83
83#include <sys/types.h> 84#include <sys/types.h>
84__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.114 2021/01/29 06:22:05 skrll Exp $"); 85__KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.115 2021/01/29 07:58:57 skrll Exp $");
85 86
86#include <sys/param.h> 87#include <sys/param.h>
87 88
88#include <sys/cpu.h> 89#include <sys/cpu.h>
89#include <sys/intr.h> 90#include <sys/intr.h>
90#include <sys/kauth.h> 91#include <sys/kauth.h>
91#include <sys/kernel.h> 92#include <sys/kernel.h>
92#include <sys/proc.h> 93#include <sys/proc.h>
93#include <sys/systm.h> 94#include <sys/systm.h>
94 95
95#include <uvm/uvm_extern.h> 96#include <uvm/uvm_extern.h>
96#include <uvm/uvm_stat.h> 97#include <uvm/uvm_stat.h>
97#ifdef UVMHIST 98#ifdef UVMHIST
@@ -104,27 +105,27 @@ __KERNEL_RCSID(0, "$NetBSD: fault.c,v 1. @@ -104,27 +105,27 @@ __KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.
104#if defined(DDB) || defined(KGDB) 105#if defined(DDB) || defined(KGDB)
105#include <machine/db_machdep.h> 106#include <machine/db_machdep.h>
106#ifdef KGDB 107#ifdef KGDB
107#include <sys/kgdb.h> 108#include <sys/kgdb.h>
108#endif 109#endif
109#if !defined(DDB) 110#if !defined(DDB)
110#define kdb_trap kgdb_trap 111#define kdb_trap kgdb_trap
111#endif 112#endif
112#endif 113#endif
113 114
114#include <arch/arm/arm/disassem.h> 115#include <arch/arm/arm/disassem.h>
115#include <arm/arm32/machdep.h> 116#include <arm/arm32/machdep.h>
116 117
117#ifdef DEBUG 118#if defined(DEBUG) && !defined(MULTIPROCESSOR)
118int last_fault_code; /* For the benefit of pmap_fault_fixup() */ 119int last_fault_code; /* For the benefit of pmap_fault_fixup() */
119#endif 120#endif
120 121
121#if defined(CPU_ARM6) || defined(CPU_ARM7) || defined(CPU_ARM7TDMI) 122#if defined(CPU_ARM6) || defined(CPU_ARM7) || defined(CPU_ARM7TDMI)
122/* These CPUs may need data/prefetch abort fixups */ 123/* These CPUs may need data/prefetch abort fixups */
123#define CPU_ABORT_FIXUP_REQUIRED 124#define CPU_ABORT_FIXUP_REQUIRED
124#endif 125#endif
125 126
126struct data_abort { 127struct data_abort {
127 int (*func)(trapframe_t *, u_int, u_int, struct lwp *, ksiginfo_t *); 128 int (*func)(trapframe_t *, u_int, u_int, struct lwp *, ksiginfo_t *);
128 const char *desc; 129 const char *desc;
129}; 130};
130 131
@@ -441,27 +442,27 @@ data_abort_handler(trapframe_t *tf) @@ -441,27 +442,27 @@ data_abort_handler(trapframe_t *tf)
441 ((insn & 0x0f9000f0) == 0x01800090)) /* STREX[BDH] */ 442 ((insn & 0x0f9000f0) == 0x01800090)) /* STREX[BDH] */
442 ftype = VM_PROT_WRITE; 443 ftype = VM_PROT_WRITE;
443 else if ((insn & 0x0fb00ff0) == 0x01000090)/* SWP */ 444 else if ((insn & 0x0fb00ff0) == 0x01000090)/* SWP */
444 ftype = VM_PROT_READ | VM_PROT_WRITE; 445 ftype = VM_PROT_READ | VM_PROT_WRITE;
445 else 446 else
446 ftype = VM_PROT_READ; 447 ftype = VM_PROT_READ;
447 } 448 }
448 } 449 }
449 450
450 /* 451 /*
451 * See if the fault is as a result of ref/mod emulation, 452 * See if the fault is as a result of ref/mod emulation,
452 * or domain mismatch. 453 * or domain mismatch.
453 */ 454 */
454#ifdef DEBUG 455#if defined(DEBUG) && !defined(MULTIPROCESSOR)
455 last_fault_code = fsr; 456 last_fault_code = fsr;
456#endif 457#endif
457 if (pmap_fault_fixup(map->pmap, va, ftype, user)) { 458 if (pmap_fault_fixup(map->pmap, va, ftype, user)) {
458 UVMHIST_LOG(maphist, " <- ref/mod emul", 0, 0, 0, 0); 459 UVMHIST_LOG(maphist, " <- ref/mod emul", 0, 0, 0, 0);
459 goto out; 460 goto out;
460 } 461 }
461 462
462 if (__predict_false(curcpu()->ci_intr_depth > 0)) { 463 if (__predict_false(curcpu()->ci_intr_depth > 0)) {
463 if (pcb->pcb_onfault) { 464 if (pcb->pcb_onfault) {
464 tf->tf_r0 = EINVAL; 465 tf->tf_r0 = EINVAL;
465 tf->tf_pc = (register_t)(intptr_t) pcb->pcb_onfault; 466 tf->tf_pc = (register_t)(intptr_t) pcb->pcb_onfault;
466 return; 467 return;
467 } 468 }
@@ -876,27 +877,27 @@ prefetch_abort_handler(trapframe_t *tf) @@ -876,27 +877,27 @@ prefetch_abort_handler(trapframe_t *tf)
876 ksi.ksi_signo = SIGSEGV; 877 ksi.ksi_signo = SIGSEGV;
877 ksi.ksi_code = SEGV_ACCERR; 878 ksi.ksi_code = SEGV_ACCERR;
878 ksi.ksi_addr = (uint32_t *)(intptr_t) fault_pc; 879 ksi.ksi_addr = (uint32_t *)(intptr_t) fault_pc;
879 ksi.ksi_trap = fault_pc; 880 ksi.ksi_trap = fault_pc;
880 goto do_trapsignal; 881 goto do_trapsignal;
881 } 882 }
882 883
883 map = &l->l_proc->p_vmspace->vm_map; 884 map = &l->l_proc->p_vmspace->vm_map;
884 va = trunc_page(fault_pc); 885 va = trunc_page(fault_pc);
885 886
886 /* 887 /*
887 * See if the pmap can handle this fault on its own... 888 * See if the pmap can handle this fault on its own...
888 */ 889 */
889#ifdef DEBUG 890#if defined(DEBUG) && !defined(MULTIPROCESSOR)
890 last_fault_code = -1; 891 last_fault_code = -1;
891#endif 892#endif
892 if (pmap_fault_fixup(map->pmap, va, VM_PROT_READ|VM_PROT_EXECUTE, 1)) { 893 if (pmap_fault_fixup(map->pmap, va, VM_PROT_READ|VM_PROT_EXECUTE, 1)) {
893 UVMHIST_LOG (maphist, " <- emulated", 0, 0, 0, 0); 894 UVMHIST_LOG (maphist, " <- emulated", 0, 0, 0, 0);
894 goto out; 895 goto out;
895 } 896 }
896 897
897#ifdef DIAGNOSTIC 898#ifdef DIAGNOSTIC
898 if (__predict_false(curcpu()->ci_intr_depth > 0)) { 899 if (__predict_false(curcpu()->ci_intr_depth > 0)) {
899 printf("\nNon-emulated prefetch abort with intr_depth > 0\n"); 900 printf("\nNon-emulated prefetch abort with intr_depth > 0\n");
900 dab_fatal(tf, 0, tf->tf_pc, NULL, NULL); 901 dab_fatal(tf, 0, tf->tf_pc, NULL, NULL);
901 } 902 }
902#endif 903#endif