[PATCH] perf/x86/intel: Annotate x86_pmu::hybrid_pmu with __counted_by_ptr

Thorsten Blum posted 1 patch 3 weeks ago
There is a newer version of this series
arch/x86/events/perf_event.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] perf/x86/intel: Annotate x86_pmu::hybrid_pmu with __counted_by_ptr
Posted by Thorsten Blum 3 weeks ago
Add __counted_by_ptr() to x86_pmu::hybrid_pmu to improve access bounds
checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE.

Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 arch/x86/events/perf_event.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
index 71ed5b2acea2..b66691a4fc31 100644
--- a/arch/x86/events/perf_event.h
+++ b/arch/x86/events/perf_event.h
@@ -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);
 };
Re: [PATCH] perf/x86/intel: Annotate x86_pmu::hybrid_pmu with __counted_by_ptr
Posted by Ian Rogers 3 weeks ago
On Fri, Sep 4, 2026 at 7:17 AM Thorsten Blum <blum@kernel.org> wrote:
>
> Add __counted_by_ptr() to x86_pmu::hybrid_pmu to improve access bounds
> checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE.
>
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> ---
>  arch/x86/events/perf_event.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
> index 71ed5b2acea2..b66691a4fc31 100644
> --- a/arch/x86/events/perf_event.h
> +++ b/arch/x86/events/perf_event.h
> @@ -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);

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

>         enum intel_cpu_type (*get_hybrid_cpu_type)      (void);
>  };
>
Re: [PATCH] perf/x86/intel: Annotate x86_pmu::hybrid_pmu with __counted_by_ptr
Posted by Mi, Dapeng 2 weeks, 4 days ago
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>

Thanks.

On 9/4/2026 11:47 PM, Ian Rogers wrote:
> On Fri, Sep 4, 2026 at 7:17 AM Thorsten Blum <blum@kernel.org> wrote:
>> Add __counted_by_ptr() to x86_pmu::hybrid_pmu to improve access bounds
>> checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE.
>>
>> Signed-off-by: Thorsten Blum <blum@kernel.org>
>> ---
>>  arch/x86/events/perf_event.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
>> index 71ed5b2acea2..b66691a4fc31 100644
>> --- a/arch/x86/events/perf_event.h
>> +++ b/arch/x86/events/perf_event.h
>> @@ -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);
> Reviewed-by: Ian Rogers <irogers@google.com>
>
> Thanks,
> Ian
>
>>         enum intel_cpu_type (*get_hybrid_cpu_type)      (void);
>>  };
>>
[tip: perf/core] perf/x86/intel: Annotate x86_pmu::hybrid_pmu with __counted_by_ptr
Posted by tip-bot2 for Thorsten Blum 16 hours ago
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 <blum@kernel.org>
AuthorDate:    Fri, 04 Sep 2026 16:17:00 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
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.

Signed-off-by: Thorsten Blum <blum@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Link: https://patch.msgid.link/20260904141659.224248-2-blum@kernel.org
---
 arch/x86/events/perf_event.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
index 6eb1bf4..5deca1a 100644
--- a/arch/x86/events/perf_event.h
+++ b/arch/x86/events/perf_event.h
@@ -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);
 };