Skip to contentSkip to conversation

perf/x86/intel: Annotate x86_pmu::hybrid_pmu with __counted_by_ptr

PATCH Applied Thorsten Blum 5 participants 5 messages Sep 4 – Sep 25

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf/x86/intel: Annotate x86_pmu::hybrid_pmu with __counted_by_ptr

Add __counted_by_ptr() to x86_pmu::hybrid_pmu to improve access bounds checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE.

---
 arch/x86/events/perf_event.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/perf_event.h +1 -1
index 71ed5b2acea2..b66691a4fc31 100644
@@ -1050,7 +1050,7 @@ struct x86_pmu {
 	 * unique capabilities.
 	 */
 	int				num_hybrid_pmus;
-	struct x86_hybrid_pmu		*hybrid_pmu;
+	struct x86_hybrid_pmu		*hybrid_pmu __counted_by_ptr(num_hybrid_pmus);
 	enum intel_cpu_type (*get_hybrid_cpu_type)	(void);
 };
 
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines

Add __counted_by_ptr() to x86_pmu::hybrid_pmu to improve access bounds checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Thorsten Blum
Quoted 14 lines · Thorsten Blum

Add __counted_by_ptr() to x86_pmu::hybrid_pmu to improve access bounds checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE.

---
 arch/x86/events/perf_event.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/perf_event.h +0 -0
index 71ed5b2acea2..b66691a4fc31 100644

arch/x86/events/perf_event.h struct x86_pmu { · line 1053

Quoted 5 lines
arch/x86/events/perf_event.h +1 -1
@@ -1050,7 +1050,7 @@ struct x86_pmu {
         * unique capabilities.
         */
        int                             num_hybrid_pmus;
-       struct x86_hybrid_pmu           *hybrid_pmu;
+       struct x86_hybrid_pmu           *hybrid_pmu __counted_by_ptr(num_hybrid_pmus);

Thanks,
Ian

Quoted 3 lines
arch/x86/events/perf_event.h +0 -0
        enum intel_cpu_type (*get_hybrid_cpu_type)      (void);
 };
 
Reviewed-by
#3 lore raw

Thanks.

Quoted 27 lines · Ian Rogers
Quoted 13 lines · Thorsten Blum

Add __counted_by_ptr() to x86_pmu::hybrid_pmu to improve access bounds checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE.

---
 arch/x86/events/perf_event.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/perf_event.h +0 -0
index 71ed5b2acea2..b66691a4fc31 100644

arch/x86/events/perf_event.h struct x86_pmu { · line 1053

Quoted 5 lines
arch/x86/events/perf_event.h +1 -1
@@ -1050,7 +1050,7 @@ struct x86_pmu {
         * unique capabilities.
         */
        int                             num_hybrid_pmus;
-       struct x86_hybrid_pmu           *hybrid_pmu;
+       struct x86_hybrid_pmu           *hybrid_pmu __counted_by_ptr(num_hybrid_pmus);

Thanks,
Ian

Quoted 3 lines
arch/x86/events/perf_event.h +0 -0
        enum intel_cpu_type (*get_hybrid_cpu_type)      (void);
 };
 
merge bot Applied
#4 lore raw
In reply to Thorsten Blum
The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     52a6457f59adf70d624ef1b1bed8d55cb7b73af6
Gitweb:        https://git.kernel.org/tip/52a6457f59adf70d624ef1b1bed8d55cb7b73af6
Author:        Thorsten Blum <[email protected]>
AuthorDate:    Fri, 04 Sep 2026 16:17:00 +02:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Fri, 25 Sep 2026 12:45:52 +02:00

perf/x86/intel: Annotate x86_pmu::hybrid_pmu with __counted_by_ptr

Add __counted_by_ptr() to x86_pmu::hybrid_pmu to improve access bounds checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE.

---
 arch/x86/events/perf_event.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/perf_event.h +1 -1
index 6eb1bf4..5deca1a 100644
@@ -1245,7 +1245,7 @@ struct x86_pmu {
 	 * unique capabilities.
 	 */
 	int				num_hybrid_pmus;
-	struct x86_hybrid_pmu		*hybrid_pmu;
+	struct x86_hybrid_pmu		*hybrid_pmu __counted_by_ptr(num_hybrid_pmus);
 	enum intel_cpu_type (*get_hybrid_cpu_type)	(void);
 };