Index: sys/arm64/include/pmc_mdep.h =================================================================== --- sys/arm64/include/pmc_mdep.h +++ sys/arm64/include/pmc_mdep.h @@ -38,7 +38,9 @@ #include union pmc_md_op_pmcallocate { - uint64_t __pad[4]; + uint32_t pm_has_raw_event; + uint32_t __pad32; + uint64_t __pad[3]; }; /* Logging */ Index: sys/dev/hwpmc/hwpmc_arm64.c =================================================================== --- sys/dev/hwpmc/hwpmc_arm64.c +++ 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_has_raw_event) { + 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);