Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/aarch64/aarch64 invalidate icache correctly.



details:   https://anonhg.NetBSD.org/src/rev/bb7eda41dc09
branches:  trunk
changeset: 445499:bb7eda41dc09
user:      ryo <ryo%NetBSD.org@localhost>
date:      Wed Oct 31 06:36:19 2018 +0000

description:
invalidate icache correctly.
l3pte_executable() should be used for only valid pte.

diffstat:

 sys/arch/aarch64/aarch64/pmap.c |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diffs (58 lines):

diff -r 56a91fa82b4c -r bb7eda41dc09 sys/arch/aarch64/aarch64/pmap.c
--- a/sys/arch/aarch64/aarch64/pmap.c   Wed Oct 31 06:26:25 2018 +0000
+++ b/sys/arch/aarch64/aarch64/pmap.c   Wed Oct 31 06:36:19 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.31 2018/10/18 09:01:51 skrll Exp $  */
+/*     $NetBSD: pmap.c,v 1.32 2018/10/31 06:36:19 ryo Exp $    */
 
 /*
  * Copyright (c) 2017 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.31 2018/10/18 09:01:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.32 2018/10/31 06:36:19 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -1302,7 +1302,7 @@
        unsigned int idx;
        int error = 0;
        const bool user = (pm != pmap_kernel());
-       bool executable;
+       bool need_sync_icache;
        bool l3only = true;
 
        UVMHIST_FUNC(__func__);
@@ -1405,7 +1405,7 @@
 #ifdef UVMHIST
        opte = pte;
 #endif
-       executable = l3pte_executable(pte, user);
+       need_sync_icache = (prot & VM_PROT_EXECUTE);
 
        if (l3pte_valid(pte)) {
                KASSERT(!kenter);       /* pmap_kenter_pa() cannot override */
@@ -1413,7 +1413,11 @@
                PMAP_COUNT(remappings);
 
                /* pte is Already mapped */
-               if (l3pte_pa(pte) != pa) {
+               if (l3pte_pa(pte) == pa) {
+                       if (need_sync_icache && l3pte_executable(pte, user))
+                               need_sync_icache = false;
+
+               } else {
                        struct vm_page *opg;
 
 #ifdef PMAPCOUNTERS
@@ -1492,7 +1496,7 @@
 
        pte = pa | attr;
 
-       if (!executable && (prot & VM_PROT_EXECUTE)) {
+       if (need_sync_icache) {
                /* non-exec -> exec */
                UVMHIST_LOG(pmaphist,
                    "icache_sync: pm=%p, va=%016lx, pte: %016lx -> %016lx",



Home | Main Index | Thread Index | Old Index