diff mbox series

[kvm-unit-tests,1/4] x86/pmu: Enable PEBS on fixed counters iff baseline PEBS is support

Message ID 20240306230153.786365-2-seanjc@google.com (mailing list archive)
State New, archived
Headers show
Series x86/pmu: PEBS fixes and new testcases | expand

Commit Message

Sean Christopherson March 6, 2024, 11:01 p.m. UTC
Enabling PEBS for fixed counters is only allowed if "Extended PEBS" is
supported, and unfortunately "Extended PEBS" is bundled with a pile of
other PEBS features under the "Baseline" umbrella.  KVM emulates this
correctly and disallows enabling PEBS on fixed counters if the vCPU
doesn't have Baseline PEBS support.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/pmu_pebs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Mi, Dapeng March 7, 2024, 9:22 a.m. UTC | #1
On 3/7/2024 7:01 AM, Sean Christopherson wrote:
> Enabling PEBS for fixed counters is only allowed if "Extended PEBS" is
> supported, and unfortunately "Extended PEBS" is bundled with a pile of
> other PEBS features under the "Baseline" umbrella.  KVM emulates this
> correctly and disallows enabling PEBS on fixed counters if the vCPU
> doesn't have Baseline PEBS support.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
>   x86/pmu_pebs.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/x86/pmu_pebs.c b/x86/pmu_pebs.c
> index f7b52b90..050617cd 100644
> --- a/x86/pmu_pebs.c
> +++ b/x86/pmu_pebs.c
> @@ -356,13 +356,13 @@ static void check_pebs_counters(u64 pebs_data_cfg)
>   	unsigned int idx;
>   	u64 bitmask = 0;
>   
> -	for (idx = 0; idx < pmu.nr_fixed_counters; idx++)
> +	for (idx = 0; has_baseline && idx < pmu.nr_fixed_counters; idx++)
>   		check_one_counter(FIXED, idx, pebs_data_cfg);
>   
>   	for (idx = 0; idx < max_nr_gp_events; idx++)
>   		check_one_counter(GP, idx, pebs_data_cfg);
>   
> -	for (idx = 0; idx < pmu.nr_fixed_counters; idx++)
> +	for (idx = 0; has_baseline && idx < pmu.nr_fixed_counters; idx++)
>   		bitmask |= BIT_ULL(FIXED_CNT_INDEX + idx);
>   	for (idx = 0; idx < max_nr_gp_events; idx += 2)
>   		bitmask |= BIT_ULL(idx);

Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
diff mbox series

Patch

diff --git a/x86/pmu_pebs.c b/x86/pmu_pebs.c
index f7b52b90..050617cd 100644
--- a/x86/pmu_pebs.c
+++ b/x86/pmu_pebs.c
@@ -356,13 +356,13 @@  static void check_pebs_counters(u64 pebs_data_cfg)
 	unsigned int idx;
 	u64 bitmask = 0;
 
-	for (idx = 0; idx < pmu.nr_fixed_counters; idx++)
+	for (idx = 0; has_baseline && idx < pmu.nr_fixed_counters; idx++)
 		check_one_counter(FIXED, idx, pebs_data_cfg);
 
 	for (idx = 0; idx < max_nr_gp_events; idx++)
 		check_one_counter(GP, idx, pebs_data_cfg);
 
-	for (idx = 0; idx < pmu.nr_fixed_counters; idx++)
+	for (idx = 0; has_baseline && idx < pmu.nr_fixed_counters; idx++)
 		bitmask |= BIT_ULL(FIXED_CNT_INDEX + idx);
 	for (idx = 0; idx < max_nr_gp_events; idx += 2)
 		bitmask |= BIT_ULL(idx);