diff options
| author | jmcneill <jmcneill@NetBSD.org> | 2022-05-16 09:42:32 +0000 |
|---|---|---|
| committer | jmcneill <jmcneill@NetBSD.org> | 2022-05-16 09:42:32 +0000 |
| commit | 2f55ecbf2f3ee853c746146dd6ef581a64e0a7b0 (patch) | |
| tree | 003fb4ec812ea154fb76220853c32224e934a988 /sys/dev | |
| parent | 000f631a0973aa59ebce59687d8db145045df363 (diff) | |
tprof: armv8: Only attach to known PMU types.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/tprof/tprof_armv8.c | 16 | ||||
| -rw-r--r-- | sys/dev/tprof/tprof_armv8.h | 3 |
2 files changed, 16 insertions, 3 deletions
diff --git a/sys/dev/tprof/tprof_armv8.c b/sys/dev/tprof/tprof_armv8.c index f0efa56db59..6c791239a2c 100644 --- a/sys/dev/tprof/tprof_armv8.c +++ b/sys/dev/tprof/tprof_armv8.c @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_armv8.c,v 1.13 2021/12/03 10:54:19 skrll Exp $ */ +/* $NetBSD: tprof_armv8.c,v 1.14 2022/05/16 09:42:32 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.13 2021/12/03 10:54:19 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tprof_armv8.c,v 1.14 2022/05/16 09:42:32 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -220,9 +220,21 @@ armv8_pmu_init_cpu(void *arg1, void *arg2) reg_pmcntenclr_el0_write(PMCNTEN_P); } +bool +armv8_pmu_detect(void) +{ + const uint64_t dfr0 = reg_id_aa64dfr0_el1_read(); + const u_int pmuver = __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_PMUVER); + + return pmuver != ID_AA64DFR0_EL1_PMUVER_NONE && + pmuver != ID_AA64DFR0_EL1_PMUVER_IMPL; +} + int armv8_pmu_init(void) { + KASSERT(armv8_pmu_detect()); + uint64_t xc = xc_broadcast(0, armv8_pmu_init_cpu, NULL, NULL); xc_wait(xc); diff --git a/sys/dev/tprof/tprof_armv8.h b/sys/dev/tprof/tprof_armv8.h index 730ada8e330..ad62a46cc55 100644 --- a/sys/dev/tprof/tprof_armv8.h +++ b/sys/dev/tprof/tprof_armv8.h @@ -1,4 +1,4 @@ -/* $NetBSD: tprof_armv8.h,v 1.1 2018/07/15 16:05:24 jmcneill Exp $ */ +/* $NetBSD: tprof_armv8.h,v 1.2 2022/05/16 09:42:32 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca> @@ -29,6 +29,7 @@ #ifndef _DEV_TPROF_TPROF_ARMV8_H #define _DEV_TPROF_TPROF_ARMV8_H +bool armv8_pmu_detect(void); int armv8_pmu_intr(void *); int armv8_pmu_init(void); |
