]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drivers/perf: hisi: Relax the event ID check in the framework
authorYicong Yang <yangyicong@hisilicon.com>
Fri, 29 Aug 2025 10:14:19 +0000 (18:14 +0800)
committerWill Deacon <will@kernel.org>
Mon, 22 Sep 2025 12:14:37 +0000 (13:14 +0100)
Event ID is only using the attr::config bit [7, 0] but we check the
event range using the whole 64bit field. It blocks the usage of the
rest field of attr::config. Relax the check by only using the
bit [7, 0].

Acked-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Signed-off-by: Yushan Wang <wangyushan12@huawei.com>
Signed-off-by: Will Deacon <will@kernel.org>
drivers/perf/hisilicon/hisi_uncore_pmu.c
drivers/perf/hisilicon/hisi_uncore_pmu.h

index a449651f79c9f6c4dcef9334ef064657a10eabd0..6594d64b03a9e869997bc8c2d2265036abe774ab 100644 (file)
@@ -234,7 +234,7 @@ int hisi_uncore_pmu_event_init(struct perf_event *event)
                return -EINVAL;
 
        hisi_pmu = to_hisi_pmu(event->pmu);
-       if (event->attr.config > hisi_pmu->check_event)
+       if ((event->attr.config & HISI_EVENTID_MASK) > hisi_pmu->check_event)
                return -EINVAL;
 
        if (hisi_pmu->on_cpu == -1)
index 777675838b80812433aa2324422e84781bb9980f..e69660f72be677beccf34a0894d908b6ebd35552 100644 (file)
@@ -43,7 +43,8 @@
                return FIELD_GET(GENMASK_ULL(hi, lo), event->attr.config);  \
        }
 
-#define HISI_GET_EVENTID(ev) (ev->hw.config_base & 0xff)
+#define HISI_EVENTID_MASK              GENMASK(7, 0)
+#define HISI_GET_EVENTID(ev)           ((ev)->hw.config_base & HISI_EVENTID_MASK)
 
 #define HISI_PMU_EVTYPE_BITS           8
 #define HISI_PMU_EVTYPE_SHIFT(idx)     ((idx) % 4 * HISI_PMU_EVTYPE_BITS)