From 1e8f338d7f227fc9e1cace1280fe89ab11bfc33b Mon Sep 17 00:00:00 2001 From: Mitchell Horne Date: Mon, 30 Aug 2021 14:02:23 -0300 Subject: hwpmc: consistently validate PMC class in allocation method It is always a good idea. In one case, attempting to allocate N+1 PMCs from a class with N hardware counters would incorrectly attempt to allocate from the next class in the list. Without this validation, this can lead to all kinds of strange behaviour. Since powerpc_allocate_pmc() is used by both the mpc7xxx and ppc970 classes, add a new global to track which is active (it will never be both). Reviewed by: luporl, ray MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31387 (cherry picked from commit 315cd55dba61416495a847f0eed6e522421e2347) --- sys/dev/hwpmc/hwpmc_powerpc.h | 1 + 1 file changed, 1 insertion(+) (limited to 'sys/dev/hwpmc/hwpmc_powerpc.h') diff --git a/sys/dev/hwpmc/hwpmc_powerpc.h b/sys/dev/hwpmc/hwpmc_powerpc.h index 551f59b60528..25b041327b84 100644 --- a/sys/dev/hwpmc/hwpmc_powerpc.h +++ b/sys/dev/hwpmc/hwpmc_powerpc.h @@ -82,6 +82,7 @@ extern size_t ppc_event_codes_size; extern int ppc_event_first; extern int ppc_event_last; extern int ppc_max_pmcs; +extern enum pmc_class ppc_class; extern void (*powerpc_set_pmc)(int cpu, int ri, int config); extern pmc_value_t (*powerpc_pmcn_read)(unsigned int pmc); -- cgit v1.2.3