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 since pmap_activate_efirt() rewrite...



details:   https://anonhg.NetBSD.org/src/rev/af27c0fb5378
branches:  trunk
changeset: 365842:af27c0fb5378
user:      ryo <ryo%NetBSD.org@localhost>
date:      Wed Apr 27 23:38:31 2022 +0000

description:
since pmap_activate_efirt() rewrites TTBR0, it is necessary to pmap_activate() again after pmap_deactivate_efirt() to restore the original TTBR0.

- Fix to do pmap_{de,}activate() before/after pmap_{,de}activate_efirt().
- moved kpreempt_{disable,enable}() to the caller since everything between
  arm_efirt_md_enter() and arm_efirt_md_exit() should be kpreempt disabled.

ok skrll@

diffstat:

 sys/arch/aarch64/aarch64/efi_machdep.c |  24 +++++++++++++++++++-----
 sys/arch/aarch64/aarch64/pmap.c        |   8 ++------
 2 files changed, 21 insertions(+), 11 deletions(-)

diffs (104 lines):

diff -r 0a94aeccb956 -r af27c0fb5378 sys/arch/aarch64/aarch64/efi_machdep.c
--- a/sys/arch/aarch64/aarch64/efi_machdep.c    Wed Apr 27 23:15:30 2022 +0000
+++ b/sys/arch/aarch64/aarch64/efi_machdep.c    Wed Apr 27 23:38:31 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efi_machdep.c,v 1.11 2022/04/02 11:16:06 skrll Exp $ */
+/* $NetBSD: efi_machdep.c,v 1.12 2022/04/27 23:38:31 ryo Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.11 2022/04/02 11:16:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.12 2022/04/27 23:38:31 ryo Exp $");
 
 #include <sys/param.h>
 #include <uvm/uvm_extern.h>
@@ -106,9 +106,12 @@
 int
 arm_efirt_md_enter(void)
 {
-       struct lwp *l = curlwp;
+       struct lwp *l;
        int err;
 
+       kpreempt_disable();
+       l = curlwp;
+
        /* Save FPU state */
        arm_efirt_state.fpu_used = fpu_used_p(l) != 0;
        if (arm_efirt_state.fpu_used)
@@ -126,8 +129,12 @@
        if (err)
                return err;
 
-       if (efi_userva)
+       if (efi_userva) {
+               if ((l->l_flag & LW_SYSTEM) == 0) {
+                       pmap_deactivate(l);
+               }
                pmap_activate_efirt();
+       }
 
        return 0;
 }
@@ -137,8 +144,13 @@
 {
        struct lwp *l = curlwp;
 
-       if (efi_userva)
+       if (efi_userva) {
                pmap_deactivate_efirt();
+               if ((l->l_flag & LW_SYSTEM) == 0) {
+                       pmap_activate(l);
+               }
+       }
+
 
        /* Disable FP access */
        reg_cpacr_el1_write(CPACR_FPEN_NONE);
@@ -150,4 +162,6 @@
 
        /* Remove custom fault handler */
        cpu_unset_onfault();
+
+       kpreempt_enable();
 }
diff -r 0a94aeccb956 -r af27c0fb5378 sys/arch/aarch64/aarch64/pmap.c
--- a/sys/arch/aarch64/aarch64/pmap.c   Wed Apr 27 23:15:30 2022 +0000
+++ b/sys/arch/aarch64/aarch64/pmap.c   Wed Apr 27 23:38:31 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.135 2022/04/17 15:20:36 skrll Exp $ */
+/*     $NetBSD: pmap.c,v 1.136 2022/04/27 23:38:31 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.135 2022/04/17 15:20:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.136 2022/04/27 23:38:31 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -1495,8 +1495,6 @@
 void
 pmap_activate_efirt(void)
 {
-       kpreempt_disable();
-
        struct cpu_info *ci = curcpu();
        struct pmap *pm = &efirt_pmap;
        struct pmap_asid_info * const pai = PMAP_PAI(pm, cpu_tlb_info(ci));
@@ -1577,8 +1575,6 @@
        pm->pm_activated = false;
 
        PMAP_COUNT(deactivate);
-
-       kpreempt_enable();
 }
 #endif
 



Home | Main Index | Thread Index | Old Index