diff --git a/sys/arm64/include/pmc_mdep.h b/sys/arm64/include/pmc_mdep.h --- a/sys/arm64/include/pmc_mdep.h +++ b/sys/arm64/include/pmc_mdep.h @@ -38,7 +38,10 @@ #include union pmc_md_op_pmcallocate { - uint64_t __pad[4]; + uint32_t pm_md_flags; +#define PM_MD_RAW_EVENT 0x1 + uint32_t __pad32; + uint64_t __pad[3]; }; /* Logging */ diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c --- a/sys/dev/hwpmc/hwpmc_arm64.c +++ b/sys/dev/hwpmc/hwpmc_arm64.c @@ -181,11 +181,14 @@ } pe = a->pm_ev; - config = (uint32_t)pe - PMC_EV_ARMV8_FIRST; - if (config > (PMC_EV_ARMV8_LAST - PMC_EV_ARMV8_FIRST)) - return (EINVAL); + /* Adjust the config value if needed. */ + config = (uint32_t)pe; + if ((a->pm_md.pm_md_flags & PM_MD_RAW_EVENT) == 0) { + config -= PMC_EV_ARMV8_FIRST; + if (config > (PMC_EV_ARMV8_LAST - PMC_EV_ARMV8_FIRST)) + return (EINVAL); + } pm->pm_md.pm_arm64.pm_arm64_evsel = config; - PMCDBG2(MDP, ALL, 2, "arm64-allocate ri=%d -> config=0x%x", ri, config); return (0);