| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: pmap.c,v 1.23 2018/09/10 16:43:24 maxv Exp $ */ | | 1 | /* $NetBSD: pmap.c,v 1.24 2018/09/17 00:15:55 ryo Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2017 Ryo Shimizu <ryo@nerv.org> | | 4 | * Copyright (c) 2017 Ryo Shimizu <ryo@nerv.org> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | | 19 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | | 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 22 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | | 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | | 24 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
25 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 25 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. | | 26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.23 2018/09/10 16:43:24 maxv Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.24 2018/09/17 00:15:55 ryo Exp $"); |
31 | | | 31 | |
32 | #include "opt_arm_debug.h" | | 32 | #include "opt_arm_debug.h" |
33 | #include "opt_ddb.h" | | 33 | #include "opt_ddb.h" |
34 | #include "opt_uvmhist.h" | | 34 | #include "opt_uvmhist.h" |
35 | #include "opt_pmap.h" | | 35 | #include "opt_pmap.h" |
36 | | | 36 | |
37 | #include <sys/param.h> | | 37 | #include <sys/param.h> |
38 | #include <sys/types.h> | | 38 | #include <sys/types.h> |
39 | #include <sys/kmem.h> | | 39 | #include <sys/kmem.h> |
40 | #include <sys/vmem.h> | | 40 | #include <sys/vmem.h> |
41 | #include <sys/atomic.h> | | 41 | #include <sys/atomic.h> |
42 | | | 42 | |
43 | #include <uvm/uvm.h> | | 43 | #include <uvm/uvm.h> |
| @@ -1814,43 +1814,29 @@ pmap_fault_fixup(struct pmap *pm, vaddr_ | | | @@ -1814,43 +1814,29 @@ pmap_fault_fixup(struct pmap *pm, vaddr_ |
1814 | | | 1814 | |
1815 | UVMHIST_LOG(pmaphist, "va=%016lx, pmapprot=%08x, accessprot=%08x", | | 1815 | UVMHIST_LOG(pmaphist, "va=%016lx, pmapprot=%08x, accessprot=%08x", |
1816 | va, pmap_prot, accessprot, 0); | | 1816 | va, pmap_prot, accessprot, 0); |
1817 | | | 1817 | |
1818 | /* ignore except read/write */ | | 1818 | /* ignore except read/write */ |
1819 | accessprot &= (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); | | 1819 | accessprot &= (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE); |
1820 | | | 1820 | |
1821 | /* no permission to read/write/execute for this page */ | | 1821 | /* no permission to read/write/execute for this page */ |
1822 | if ((pmap_prot & accessprot) != accessprot) { | | 1822 | if ((pmap_prot & accessprot) != accessprot) { |
1823 | UVMHIST_LOG(pmaphist, "no permission to access", 0, 0, 0, 0); | | 1823 | UVMHIST_LOG(pmaphist, "no permission to access", 0, 0, 0, 0); |
1824 | goto done; | | 1824 | goto done; |
1825 | } | | 1825 | } |
1826 | | | 1826 | |
1827 | if ((pte & LX_BLKPAG_AF) && ((pte & LX_BLKPAG_AP) == LX_BLKPAG_AP_RW)) { | | 1827 | /* pte is readable and writable, but occured fault? probably copy(9) */ |
1828 | #if 1 /* XXX: DEBUG */ | | 1828 | if ((pte & LX_BLKPAG_AF) && ((pte & LX_BLKPAG_AP) == LX_BLKPAG_AP_RW)) |
1829 | if (!user) { | | | |
1830 | /* | | | |
1831 | * pte is readable and writable, but occured fault? | | | |
1832 | * unprivileged load/store, or else ? | | | |
1833 | */ | | | |
1834 | printf("%s: fault: va=%016lx pte=%08" PRIx64 | | | |
1835 | ": pte is rw." | | | |
1836 | " unprivileged load/store ? (onfault=%p)\n", | | | |
1837 | __func__, va, pte, curlwp->l_md.md_onfault); | | | |
1838 | } | | | |
1839 | #endif | | | |
1840 | goto done; | | 1829 | goto done; |
1841 | } | | | |
1842 | KASSERT(((pte & LX_BLKPAG_AF) == 0) || | | | |
1843 | ((pte & LX_BLKPAG_AP) == LX_BLKPAG_AP_RO)); | | | |
1844 | | | 1830 | |
1845 | pmap_pv_lock(md); | | 1831 | pmap_pv_lock(md); |
1846 | if ((pte & LX_BLKPAG_AF) == 0) { | | 1832 | if ((pte & LX_BLKPAG_AF) == 0) { |
1847 | /* pte has no AF bit, set referenced and AF bit */ | | 1833 | /* pte has no AF bit, set referenced and AF bit */ |
1848 | UVMHIST_LOG(pmaphist, | | 1834 | UVMHIST_LOG(pmaphist, |
1849 | "REFERENCED:" | | 1835 | "REFERENCED:" |
1850 | " va=%016lx, pa=%016lx, pte_prot=%08x, accessprot=%08x", | | 1836 | " va=%016lx, pa=%016lx, pte_prot=%08x, accessprot=%08x", |
1851 | va, pa, pmap_prot, accessprot); | | 1837 | va, pa, pmap_prot, accessprot); |
1852 | md->mdpg_flags |= VM_PROT_READ; /* set referenced */ | | 1838 | md->mdpg_flags |= VM_PROT_READ; /* set referenced */ |
1853 | pte |= LX_BLKPAG_AF; | | 1839 | pte |= LX_BLKPAG_AF; |
1854 | | | 1840 | |
1855 | PMAP_COUNT(fixup_referenced); | | 1841 | PMAP_COUNT(fixup_referenced); |
1856 | } | | 1842 | } |