Sat Mar 13 17:14:12 2021 UTC ()
s/pfi_faultpte/&p/ for consistency with arm / other uses of ptep


(skrll)
diff -r1.27 -r1.28 src/sys/arch/mips/include/pcb.h
diff -r1.257 -r1.258 src/sys/arch/mips/mips/trap.c
diff -r1.59 -r1.60 src/sys/uvm/pmap/pmap.c

cvs diff -r1.27 -r1.28 src/sys/arch/mips/include/pcb.h (expand / switch to unified diff)

--- src/sys/arch/mips/include/pcb.h 2020/09/26 04:31:53 1.27
+++ src/sys/arch/mips/include/pcb.h 2021/03/13 17:14:11 1.28
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pcb.h,v 1.27 2020/09/26 04:31:53 simonb Exp $ */ 1/* $NetBSD: pcb.h,v 1.28 2021/03/13 17:14:11 skrll Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988 University of Utah. 4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1992, 1993 5 * Copyright (c) 1992, 1993
6 * The Regents of the University of California. All rights reserved. 6 * The Regents of the University of California. All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to Berkeley by 8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer 9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department and Ralph Campbell. 10 * Science Department and Ralph Campbell.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -35,27 +35,27 @@ @@ -35,27 +35,27 @@
35 * 35 *
36 * from: Utah Hdr: pcb.h 1.13 89/04/23 36 * from: Utah Hdr: pcb.h 1.13 89/04/23
37 * 37 *
38 * @(#)pcb.h 8.1 (Berkeley) 6/10/93 38 * @(#)pcb.h 8.1 (Berkeley) 6/10/93
39 */ 39 */
40 40
41#ifndef _MIPS_PCB_H_ 41#ifndef _MIPS_PCB_H_
42#define _MIPS_PCB_H_ 42#define _MIPS_PCB_H_
43 43
44#include <mips/types.h> 44#include <mips/types.h>
45#include <mips/reg.h> 45#include <mips/reg.h>
46 46
47struct pcb_faultinfo { 47struct pcb_faultinfo {
48 void *pfi_faultpte; 48 void *pfi_faultptep;
49 vaddr_t pfi_faultaddr; 49 vaddr_t pfi_faultaddr;
50 u_int pfi_repeats; 50 u_int pfi_repeats;
51 pid_t pfi_lastpid; 51 pid_t pfi_lastpid;
52 uint8_t pfi_faulttype; 52 uint8_t pfi_faulttype;
53}; 53};
54 54
55/* 55/*
56 * MIPS process control block 56 * MIPS process control block
57 */ 57 */
58struct pcb { 58struct pcb {
59 mips_label_t pcb_context; /* kernel context for resume */ 59 mips_label_t pcb_context; /* kernel context for resume */
60 void *pcb_onfault; /* for copyin/copyout faults */ 60 void *pcb_onfault; /* for copyin/copyout faults */
61 uint32_t pcb_ppl; /* previous priority level */ 61 uint32_t pcb_ppl; /* previous priority level */

cvs diff -r1.257 -r1.258 src/sys/arch/mips/mips/trap.c (expand / switch to unified diff)

--- src/sys/arch/mips/mips/trap.c 2021/03/07 15:10:05 1.257
+++ src/sys/arch/mips/mips/trap.c 2021/03/13 17:14:11 1.258
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: trap.c,v 1.257 2021/03/07 15:10:05 christos Exp $ */ 1/* $NetBSD: trap.c,v 1.258 2021/03/13 17:14:11 skrll Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988 University of Utah. 4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1992, 1993 5 * Copyright (c) 1992, 1993
6 * The Regents of the University of California. All rights reserved. 6 * The Regents of the University of California. All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to Berkeley by 8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer 9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department and Ralph Campbell. 10 * Science Department and Ralph Campbell.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * from: Utah Hdr: trap.c 1.32 91/04/06 36 * from: Utah Hdr: trap.c 1.32 91/04/06
37 * 37 *
38 * @(#)trap.c 8.5 (Berkeley) 1/11/94 38 * @(#)trap.c 8.5 (Berkeley) 1/11/94
39 */ 39 */
40 40
41#include <sys/cdefs.h> 41#include <sys/cdefs.h>
42__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.257 2021/03/07 15:10:05 christos Exp $"); 42__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.258 2021/03/13 17:14:11 skrll Exp $");
43 43
44#include "opt_cputype.h" /* which mips CPU levels do we support? */ 44#include "opt_cputype.h" /* which mips CPU levels do we support? */
45#include "opt_ddb.h" 45#include "opt_ddb.h"
46#include "opt_kgdb.h" 46#include "opt_kgdb.h"
47#include "opt_multiprocessor.h" 47#include "opt_multiprocessor.h"
48 48
49#include <sys/param.h> 49#include <sys/param.h>
50#include <sys/systm.h> 50#include <sys/systm.h>
51#include <sys/kernel.h> 51#include <sys/kernel.h>
52#include <sys/cpu.h> 52#include <sys/cpu.h>
53#include <sys/proc.h> 53#include <sys/proc.h>
54#include <sys/ras.h> 54#include <sys/ras.h>
55#include <sys/signalvar.h> 55#include <sys/signalvar.h>
@@ -373,46 +373,46 @@ trap(uint32_t status, uint32_t cause, va @@ -373,46 +373,46 @@ trap(uint32_t status, uint32_t cause, va
373 userret(l); 373 userret(l);
374 } 374 }
375 return; /* GEN */ 375 return; /* GEN */
376 } 376 }
377#endif 377#endif
378 KASSERT(KERNLAND_P(va) || curcpu()->ci_pmap_asid_cur != 0); 378 KASSERT(KERNLAND_P(va) || curcpu()->ci_pmap_asid_cur != 0);
379 pmap_tlb_asid_check(); 379 pmap_tlb_asid_check();
380 kpreempt_enable(); 380 kpreempt_enable();
381 381
382#ifdef PMAP_FAULTINFO 382#ifdef PMAP_FAULTINFO
383 if (p->p_pid == pfi->pfi_lastpid && va == pfi->pfi_faultaddr) { 383 if (p->p_pid == pfi->pfi_lastpid && va == pfi->pfi_faultaddr) {
384 if (++pfi->pfi_repeats > 4) { 384 if (++pfi->pfi_repeats > 4) {
385 tlb_asid_t asid = tlb_get_asid(); 385 tlb_asid_t asid = tlb_get_asid();
386 pt_entry_t *ptep = pfi->pfi_faultpte; 386 pt_entry_t *ptep = pfi->pfi_faultptep;
387 printf("trap: fault #%u (%s/%s) for %#" 387 printf("trap: fault #%u (%s/%s) for %#"
388 PRIxVADDR" (%#"PRIxVADDR") at pc %#" 388 PRIxVADDR" (%#"PRIxVADDR") at pc %#"
389 PRIxVADDR" curpid=%u/%u ptep@%p=%#" 389 PRIxVADDR" curpid=%u/%u ptep@%p=%#"
390 PRIxPTE")\n", pfi->pfi_repeats, 390 PRIxPTE")\n", pfi->pfi_repeats,
391 trap_names[TRAPTYPE(cause)], 391 trap_names[TRAPTYPE(cause)],
392 trap_names[pfi->pfi_faulttype], va, 392 trap_names[pfi->pfi_faulttype], va,
393 vaddr, pc, map->pmap->pm_pai[0].pai_asid, 393 vaddr, pc, map->pmap->pm_pai[0].pai_asid,
394 asid, ptep, ptep ? pte_value(*ptep) : 0); 394 asid, ptep, ptep ? pte_value(*ptep) : 0);
395 if (pfi->pfi_repeats >= 4) { 395 if (pfi->pfi_repeats >= 4) {
396 cpu_Debugger(); 396 cpu_Debugger();
397 } else { 397 } else {
398 pfi->pfi_faulttype = TRAPTYPE(cause); 398 pfi->pfi_faulttype = TRAPTYPE(cause);
399 } 399 }
400 } 400 }
401 } else { 401 } else {
402 pfi->pfi_lastpid = p->p_pid; 402 pfi->pfi_lastpid = p->p_pid;
403 pfi->pfi_faultaddr = va; 403 pfi->pfi_faultaddr = va;
404 pfi->pfi_repeats = 0; 404 pfi->pfi_repeats = 0;
405 pfi->pfi_faultpte = NULL; 405 pfi->pfi_faultptep = NULL;
406 pfi->pfi_faulttype = TRAPTYPE(cause); 406 pfi->pfi_faulttype = TRAPTYPE(cause);
407 } 407 }
408#endif /* PMAP_FAULTINFO */ 408#endif /* PMAP_FAULTINFO */
409 409
410 onfault = pcb->pcb_onfault; 410 onfault = pcb->pcb_onfault;
411 pcb->pcb_onfault = NULL; 411 pcb->pcb_onfault = NULL;
412 rv = uvm_fault(map, va, ftype); 412 rv = uvm_fault(map, va, ftype);
413 pcb->pcb_onfault = onfault; 413 pcb->pcb_onfault = onfault;
414 414
415#if defined(VMFAULT_TRACE) 415#if defined(VMFAULT_TRACE)
416 if (!KERNLAND_P(va)) 416 if (!KERNLAND_P(va))
417 printf( 417 printf(
418 "uvm_fault(%p (pmap %p), %#"PRIxVADDR 418 "uvm_fault(%p (pmap %p), %#"PRIxVADDR
@@ -425,30 +425,30 @@ trap(uint32_t status, uint32_t cause, va @@ -425,30 +425,30 @@ trap(uint32_t status, uint32_t cause, va
425 * failure it is due to accessing the stack region outside 425 * failure it is due to accessing the stack region outside
426 * the current limit and we need to reflect that as an access 426 * the current limit and we need to reflect that as an access
427 * error. 427 * error.
428 */ 428 */
429 if ((void *)va >= vm->vm_maxsaddr) { 429 if ((void *)va >= vm->vm_maxsaddr) {
430 if (rv == 0) 430 if (rv == 0)
431 uvm_grow(p, va); 431 uvm_grow(p, va);
432 else if (rv == EACCES) 432 else if (rv == EACCES)
433 rv = EFAULT; 433 rv = EFAULT;
434 } 434 }
435 if (rv == 0) { 435 if (rv == 0) {
436#ifdef PMAP_FAULTINFO 436#ifdef PMAP_FAULTINFO
437 if (pfi->pfi_repeats == 0) { 437 if (pfi->pfi_repeats == 0) {
438 pfi->pfi_faultpte = 438 pfi->pfi_faultptep =
439 pmap_pte_lookup(map->pmap, va); 439 pmap_pte_lookup(map->pmap, va);
440 } 440 }
441 KASSERT(*(pt_entry_t *)pfi->pfi_faultpte); 441 KASSERT(*(pt_entry_t *)pfi->pfi_faultptep);
442#endif 442#endif
443 if (type & T_USER) { 443 if (type & T_USER) {
444 userret(l); 444 userret(l);
445 } 445 }
446 return; /* GEN */ 446 return; /* GEN */
447 } 447 }
448 if ((type & T_USER) == 0) 448 if ((type & T_USER) == 0)
449 goto copyfault; 449 goto copyfault;
450 450
451 KSI_INIT_TRAP(&ksi); 451 KSI_INIT_TRAP(&ksi);
452 switch (rv) { 452 switch (rv) {
453 case EINVAL: 453 case EINVAL:
454 ksi.ksi_signo = SIGBUS; 454 ksi.ksi_signo = SIGBUS;

cvs diff -r1.59 -r1.60 src/sys/uvm/pmap/pmap.c (expand / switch to unified diff)

--- src/sys/uvm/pmap/pmap.c 2021/03/13 15:29:13 1.59
+++ src/sys/uvm/pmap/pmap.c 2021/03/13 17:14:11 1.60
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pmap.c,v 1.59 2021/03/13 15:29:13 skrll Exp $ */ 1/* $NetBSD: pmap.c,v 1.60 2021/03/13 17:14:11 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center and by Chris G. Demetriou. 9 * NASA Ames Research Center and by Chris G. Demetriou.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -57,27 +57,27 @@ @@ -57,27 +57,27 @@
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE. 63 * SUCH DAMAGE.
64 * 64 *
65 * @(#)pmap.c 8.4 (Berkeley) 1/26/94 65 * @(#)pmap.c 8.4 (Berkeley) 1/26/94
66 */ 66 */
67 67
68#include <sys/cdefs.h> 68#include <sys/cdefs.h>
69 69
70__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.59 2021/03/13 15:29:13 skrll Exp $"); 70__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.60 2021/03/13 17:14:11 skrll Exp $");
71 71
72/* 72/*
73 * Manages physical address maps. 73 * Manages physical address maps.
74 * 74 *
75 * In addition to hardware address maps, this 75 * In addition to hardware address maps, this
76 * module is called upon to provide software-use-only 76 * module is called upon to provide software-use-only
77 * maps which may or may not be stored in the same 77 * maps which may or may not be stored in the same
78 * form as hardware maps. These pseudo-maps are 78 * form as hardware maps. These pseudo-maps are
79 * used to store intermediate results from copy 79 * used to store intermediate results from copy
80 * operations to and from address spaces. 80 * operations to and from address spaces.
81 * 81 *
82 * Since the information managed by this module is 82 * Since the information managed by this module is
83 * also stored by the logical address mapping module, 83 * also stored by the logical address mapping module,
@@ -1017,27 +1017,27 @@ pmap_remove(pmap_t pmap, vaddr_t sva, va @@ -1017,27 +1017,27 @@ pmap_remove(pmap_t pmap, vaddr_t sva, va
1017 1017
1018 UVMHIST_FUNC(__func__); 1018 UVMHIST_FUNC(__func__);
1019 UVMHIST_CALLARGS(pmaphist, "(pmap=%#jx, va=%#jx..%#jx)", 1019 UVMHIST_CALLARGS(pmaphist, "(pmap=%#jx, va=%#jx..%#jx)",
1020 (uintptr_t)pmap, sva, eva, 0); 1020 (uintptr_t)pmap, sva, eva, 0);
1021 1021
1022 if (is_kernel_pmap_p) { 1022 if (is_kernel_pmap_p) {
1023 PMAP_COUNT(remove_kernel_calls); 1023 PMAP_COUNT(remove_kernel_calls);
1024 } else { 1024 } else {
1025 PMAP_COUNT(remove_user_calls); 1025 PMAP_COUNT(remove_user_calls);
1026 } 1026 }
1027#ifdef PMAP_FAULTINFO 1027#ifdef PMAP_FAULTINFO
1028 curpcb->pcb_faultinfo.pfi_faultaddr = 0; 1028 curpcb->pcb_faultinfo.pfi_faultaddr = 0;
1029 curpcb->pcb_faultinfo.pfi_repeats = 0; 1029 curpcb->pcb_faultinfo.pfi_repeats = 0;
1030 curpcb->pcb_faultinfo.pfi_faultpte = NULL; 1030 curpcb->pcb_faultinfo.pfi_faultptep = NULL;
1031#endif 1031#endif
1032 kpreempt_disable(); 1032 kpreempt_disable();
1033 pmap_addr_range_check(pmap, sva, eva, __func__); 1033 pmap_addr_range_check(pmap, sva, eva, __func__);
1034 pmap_pte_process(pmap, sva, eva, pmap_pte_remove, npte); 1034 pmap_pte_process(pmap, sva, eva, pmap_pte_remove, npte);
1035 kpreempt_enable(); 1035 kpreempt_enable();
1036 1036
1037 UVMHIST_LOG(pmaphist, " <-- done", 0, 0, 0, 0); 1037 UVMHIST_LOG(pmaphist, " <-- done", 0, 0, 0, 0);
1038} 1038}
1039 1039
1040/* 1040/*
1041 * pmap_page_protect: 1041 * pmap_page_protect:
1042 * 1042 *
1043 * Lower the permission for all mappings to a given page. 1043 * Lower the permission for all mappings to a given page.
@@ -1562,27 +1562,27 @@ pmap_remove_all(struct pmap *pmap) @@ -1562,27 +1562,27 @@ pmap_remove_all(struct pmap *pmap)
1562 if (kcpuset_isset(pmap->pm_onproc, cpu_index(curcpu()))) 1562 if (kcpuset_isset(pmap->pm_onproc, cpu_index(curcpu())))
1563#endif 1563#endif
1564 pmap_tlb_asid_deactivate(pmap); 1564 pmap_tlb_asid_deactivate(pmap);
1565#ifdef MULTIPROCESSOR 1565#ifdef MULTIPROCESSOR
1566 KASSERT(kcpuset_iszero(pmap->pm_onproc)); 1566 KASSERT(kcpuset_iszero(pmap->pm_onproc));
1567#endif 1567#endif
1568 pmap_tlb_asid_release_all(pmap); 1568 pmap_tlb_asid_release_all(pmap);
1569 pmap_tlb_miss_lock_exit(); 1569 pmap_tlb_miss_lock_exit();
1570 pmap->pm_flags |= PMAP_DEFERRED_ACTIVATE; 1570 pmap->pm_flags |= PMAP_DEFERRED_ACTIVATE;
1571 1571
1572#ifdef PMAP_FAULTINFO 1572#ifdef PMAP_FAULTINFO
1573 curpcb->pcb_faultinfo.pfi_faultaddr = 0; 1573 curpcb->pcb_faultinfo.pfi_faultaddr = 0;
1574 curpcb->pcb_faultinfo.pfi_repeats = 0; 1574 curpcb->pcb_faultinfo.pfi_repeats = 0;
1575 curpcb->pcb_faultinfo.pfi_faultpte = NULL; 1575 curpcb->pcb_faultinfo.pfi_faultptep = NULL;
1576#endif 1576#endif
1577 kpreempt_enable(); 1577 kpreempt_enable();
1578 1578
1579 UVMHIST_LOG(pmaphist, " <-- done", 0, 0, 0, 0); 1579 UVMHIST_LOG(pmaphist, " <-- done", 0, 0, 0, 0);
1580 return false; 1580 return false;
1581} 1581}
1582 1582
1583/* 1583/*
1584 * Routine: pmap_unwire 1584 * Routine: pmap_unwire
1585 * Function: Clear the wired attribute for a map/virtual-address 1585 * Function: Clear the wired attribute for a map/virtual-address
1586 * pair. 1586 * pair.
1587 * In/out conditions: 1587 * In/out conditions:
1588 * The mapping must already exist in the pmap. 1588 * The mapping must already exist in the pmap.