From 61337cea225813137d425ab112950f409ae51884 Mon Sep 17 00:00:00 2001 From: jmcneill Date: Sat, 19 Jun 2021 13:40:00 +0000 Subject: [PATCH] Do not try to initialize PMU if ID_AA64DFR0_EL1 reports a non-standard PMU implementation. --- sys/arch/aarch64/aarch64/cpu.c | 8 ++++++-- sys/arch/aarch64/include/armreg.h | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/arch/aarch64/aarch64/cpu.c b/sys/arch/aarch64/aarch64/cpu.c index 4a1d110b707d..e08b0a02611a 100644 --- a/sys/arch/aarch64/aarch64/cpu.c +++ b/sys/arch/aarch64/aarch64/cpu.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.59 2021/03/09 16:44:27 ryo Exp $ */ +/* $NetBSD: cpu.c,v 1.60 2021/06/19 13:40:00 jmcneill Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.59 2021/03/09 16:44:27 ryo Exp $"); +__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.60 2021/06/19 13:40:00 jmcneill Exp $"); #include "locators.h" #include "opt_arm_debug.h" @@ -486,6 +486,10 @@ cpu_init_counter(struct cpu_info *ci) /* Performance Monitors Extension not implemented. */ return; } + if (pmuver == ID_AA64DFR0_EL1_PMUVER_IMPL) { + /* Non-standard Performance Monitors are not supported. */ + return; + } reg_pmcr_el0_write(PMCR_E | PMCR_C); reg_pmcntenset_el0_write(PMCNTEN_C); diff --git a/sys/arch/aarch64/include/armreg.h b/sys/arch/aarch64/include/armreg.h index aa15564d9c86..c6439990bec3 100644 --- a/sys/arch/aarch64/include/armreg.h +++ b/sys/arch/aarch64/include/armreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: armreg.h,v 1.56 2021/06/19 13:38:21 jmcneill Exp $ */ +/* $NetBSD: armreg.h,v 1.57 2021/06/19 13:40:00 jmcneill Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -248,6 +248,7 @@ AARCH64REG_READ_INLINE(id_aa64dfr0_el1) #define ID_AA64DFR0_EL1_PMUVER_NONE 0 #define ID_AA64DFR0_EL1_PMUVER_V3 1 #define ID_AA64DFR0_EL1_PMUVER_NOV3 2 +#define ID_AA64DFR0_EL1_PMUVER_IMPL 15 #define ID_AA64DFR0_EL1_TRACEVER __BITS(4,7) #define ID_AA64DFR0_EL1_TRACEVER_NONE 0 #define ID_AA64DFR0_EL1_TRACEVER_IMPL 1