Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/tprof RW fields in performance monitor registers are...



details:   https://anonhg.NetBSD.org/src/rev/ae68264ff221
branches:  trunk
changeset: 833893:ae68264ff221
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Mon Jul 16 10:56:42 2018 +0000

description:
RW fields in performance monitor registers are reset to architecturally
UNKNOWN values. Initialize the PMU to a known state - all interrupts and
counters disabled, performance monitor disabled, and user access disabled.

diffstat:

 sys/dev/tprof/tprof_armv7.c |  16 ++++++++++++++--
 sys/dev/tprof/tprof_armv8.c |  16 ++++++++++++++--
 2 files changed, 28 insertions(+), 4 deletions(-)

diffs (74 lines):

diff -r 0b5a56a6149d -r ae68264ff221 sys/dev/tprof/tprof_armv7.c
--- a/sys/dev/tprof/tprof_armv7.c       Mon Jul 16 10:49:52 2018 +0000
+++ b/sys/dev/tprof/tprof_armv7.c       Mon Jul 16 10:56:42 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tprof_armv7.c,v 1.1 2018/07/15 23:47:29 jmcneill Exp $ */
+/* $NetBSD: tprof_armv7.c,v 1.2 2018/07/16 10:56:42 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tprof_armv7.c,v 1.1 2018/07/15 23:47:29 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tprof_armv7.c,v 1.2 2018/07/16 10:56:42 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -227,6 +227,18 @@
 int
 armv7_pmu_init(void)
 {
+       /* Disable user mode access to performance monitors */
+       armreg_pmuserenr_write(0);
+
+       /* Disable interrupts */
+       armreg_pmintenclr_write(~0U);
+
+       /* Disable counters */
+       armreg_pmcntenclr_write(~0U);
+
+       /* Disable performance monitor */
+       armreg_pmcr_write(0);
+
        return tprof_backend_register("tprof_armv7", &tprof_armv7_pmu_ops,
            TPROF_BACKEND_VERSION);
 }
diff -r 0b5a56a6149d -r ae68264ff221 sys/dev/tprof/tprof_armv8.c
--- a/sys/dev/tprof/tprof_armv8.c       Mon Jul 16 10:49:52 2018 +0000
+++ b/sys/dev/tprof/tprof_armv8.c       Mon Jul 16 10:56:42 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tprof_armv8.c,v 1.1 2018/07/15 16:05:24 jmcneill Exp $ */
+/* $NetBSD: tprof_armv8.c,v 1.2 2018/07/16 10:56:42 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.1 2018/07/15 16:05:24 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.2 2018/07/16 10:56:42 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -220,6 +220,18 @@
 int
 armv8_pmu_init(void)
 {
+        /* Disable EL0 access to performance monitors */
+       reg_pmuserenr_el0_write(0);
+
+       /* Disable interrupts */
+       reg_pmintenclr_el1_write(~0U);
+
+       /* Disable counters */
+       reg_pmcntenclr_el0_write(~0U);
+
+       /* Disable performance monitor */
+       reg_pmcr_el0_write(0);
+
        return tprof_backend_register("tprof_armv8", &tprof_armv8_pmu_ops,
            TPROF_BACKEND_VERSION);
 }



Home | Main Index | Thread Index | Old Index