Module Name: src Committed By: jmcneill Date: Wed Oct 7 16:03:10 UTC 2020
Modified Files: src/sys/arch/aarch64/aarch64: cpu.c Log Message: Only touch PMC registers if Performance Monitor Extensions are present. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/arch/aarch64/aarch64/cpu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/aarch64/aarch64/cpu.c diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.54 src/sys/arch/aarch64/aarch64/cpu.c:1.55 --- src/sys/arch/aarch64/aarch64/cpu.c:1.54 Sat Jul 25 22:51:57 2020 +++ src/sys/arch/aarch64/aarch64/cpu.c Wed Oct 7 16:03:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.54 2020/07/25 22:51:57 riastradh Exp $ */ +/* $NetBSD: cpu.c,v 1.55 2020/10/07 16:03:10 jmcneill Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu <r...@nerv.org> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.54 2020/07/25 22:51:57 riastradh Exp $"); +__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.55 2020/10/07 16:03:10 jmcneill Exp $"); #include "locators.h" #include "opt_arm_debug.h" @@ -472,6 +472,13 @@ cpu_identify2(device_t self, struct cpu_ static void cpu_init_counter(struct cpu_info *ci) { + const uint64_t dfr0 = reg_id_aa64dfr0_el1_read(); + const u_int pmuver = __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_PMUVER); + if (pmuver == ID_AA64DFR0_EL1_PMUVER_NONE) { + /* Performance Monitors Extension not implemented. */ + return; + } + reg_pmcr_el0_write(PMCR_E | PMCR_C); reg_pmcntenset_el0_write(PMCNTEN_C);