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 Disable translation table walks usi...



details:   https://anonhg.NetBSD.org/src/rev/02bf7a1fdb37
branches:  trunk
changeset: 459710:02bf7a1fdb37
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Sep 22 13:57:55 2019 +0000

description:
Disable translation table walks using TTBR0 while changing its value and
when deactivating a pmap. Fixes stability issues on Ampere eMAG CPUs.

diffstat:

 sys/arch/aarch64/aarch64/pmap.c |  22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diffs (71 lines):

diff -r 44097ef756ab -r 02bf7a1fdb37 sys/arch/aarch64/aarch64/pmap.c
--- a/sys/arch/aarch64/aarch64/pmap.c   Sun Sep 22 13:08:10 2019 +0000
+++ b/sys/arch/aarch64/aarch64/pmap.c   Sun Sep 22 13:57:55 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.46 2019/09/20 05:35:27 ryo Exp $    */
+/*     $NetBSD: pmap.c,v 1.47 2019/09/22 13:57:55 jmcneill 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.46 2019/09/20 05:35:27 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.47 2019/09/22 13:57:55 jmcneill Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -1274,7 +1274,7 @@
 pmap_activate(struct lwp *l)
 {
        struct pmap *pm = l->l_proc->p_vmspace->vm_map.pmap;
-       uint64_t ttbr0;
+       uint64_t ttbr0, tcr;
 
        UVMHIST_FUNC(__func__);
        UVMHIST_CALLED(pmaphist);
@@ -1288,6 +1288,11 @@
 
        UVMHIST_LOG(pmaphist, "lwp=%p (pid=%d)", l, l->l_proc->p_pid, 0, 0);
 
+       /* Disable translation table walks using TTBR0 */
+       tcr = reg_tcr_el1_read();
+       reg_tcr_el1_write(tcr | TCR_EPD0);
+       __asm __volatile("isb" ::: "memory");
+
        /* XXX */
        CTASSERT(PID_MAX <= 65535);     /* 16bit ASID */
        if (pm->pm_asid == -1)
@@ -1296,6 +1301,11 @@
        ttbr0 = ((uint64_t)pm->pm_asid << 48) | pm->pm_l0table_pa;
        cpu_set_ttbr0(ttbr0);
 
+       /* Re-enable translation table walks using TTBR0 */
+       tcr = reg_tcr_el1_read();
+       reg_tcr_el1_write(tcr & ~TCR_EPD0);
+       __asm __volatile("isb" ::: "memory");
+
        pm->pm_activated = true;
 
        PMAP_COUNT(activate);
@@ -1305,6 +1315,7 @@
 pmap_deactivate(struct lwp *l)
 {
        struct pmap *pm = l->l_proc->p_vmspace->vm_map.pmap;
+       uint64_t tcr;
 
        UVMHIST_FUNC(__func__);
        UVMHIST_CALLED(pmaphist);
@@ -1314,6 +1325,11 @@
 
        UVMHIST_LOG(pmaphist, "lwp=%p, asid=%d", l, pm->pm_asid, 0, 0);
 
+       /* Disable translation table walks using TTBR0 */
+       tcr = reg_tcr_el1_read();
+       reg_tcr_el1_write(tcr | TCR_EPD0);
+       __asm __volatile("isb" ::: "memory");
+
        /* XXX */
        pm->pm_activated = false;
 



Home | Main Index | Thread Index | Old Index