From 86f7743b596fcea904d31cd16d00183c3a661607 Mon Sep 17 00:00:00 2001 From: Raphael Poggi Date: Thu, 1 Sep 2016 14:07:49 +0200 Subject: [PATCH] [arm64] enable cycle counter --- arch/arm64/include/arch/arch_ops.h | 8 ++++++++ arch/arm64/mp.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/arch/arm64/include/arch/arch_ops.h b/arch/arm64/include/arch/arch_ops.h index ee18c1c5b..8d2d2c601 100644 --- a/arch/arm64/include/arch/arch_ops.h +++ b/arch/arm64/include/arch/arch_ops.h @@ -233,6 +233,14 @@ static inline uint32_t arch_cycle_count(void) : "=r" (count) ); return count; +#elif ARM_ISA_ARMV8 + uint32_t count; + + ISB; + __asm__ volatile("mrs %0, pmccntr_el0" + : "=r" (count) + ); + return count; #else //#warning no arch_cycle_count implementation return 0; diff --git a/arch/arm64/mp.c b/arch/arm64/mp.c index e3584c855..65358be97 100644 --- a/arch/arm64/mp.c +++ b/arch/arm64/mp.c @@ -81,6 +81,10 @@ enum handler_return arm_ipi_reschedule_handler(void *arg) void arch_mp_init_percpu(void) { + int pmcr_mask = 1; + + __asm__ volatile("msr pmcr_el0, %0":: "r"(pmcr_mask):); + register_int_handler(MP_IPI_GENERIC + GIC_IPI_BASE, &arm_ipi_generic_handler, 0); register_int_handler(MP_IPI_RESCHEDULE + GIC_IPI_BASE, &arm_ipi_reschedule_handler, 0);