Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/arch/aarch64/aarch64 Pull up following revision(s) (r...



details:   https://anonhg.NetBSD.org/src/rev/97c3af365b3d
branches:  netbsd-9
changeset: 1000877:97c3af365b3d
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Sep 23 07:00:35 2019 +0000

description:
Pull up following revision(s) (requested by jmcneill in ticket #229):

        sys/arch/aarch64/aarch64/pmap.c: revision 1.47

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 9caca0ce626a -r 97c3af365b3d sys/arch/aarch64/aarch64/pmap.c
--- a/sys/arch/aarch64/aarch64/pmap.c   Sun Sep 22 14:29:48 2019 +0000
+++ b/sys/arch/aarch64/aarch64/pmap.c   Mon Sep 23 07:00:35 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.41.2.1 2019/09/22 10:32:38 martin Exp $     */
+/*     $NetBSD: pmap.c,v 1.41.2.2 2019/09/23 07:00:35 martin 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.41.2.1 2019/09/22 10:32:38 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.41.2.2 2019/09/23 07:00:35 martin Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -1271,7 +1271,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);
@@ -1285,6 +1285,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)
@@ -1293,6 +1298,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);
@@ -1302,6 +1312,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);
@@ -1311,6 +1322,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