Re: [PATCH v2 3/8] KVM: VMX: Add helper to check reserved bits in IA32_PERF_GLOBAL_CTRL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 03, 2019 at 02:30:39PM -0700, Oliver Upton wrote:
> Create a helper function to check the validity of a proposed value for
> IA32_PERF_GLOBAL_CTRL from the existing check in intel_pmu_set_msr().

Clobbered my updated commit message. Will fix with the other comment
below.

> Suggested-by: Jim Mattson <jmattson@xxxxxxxxxx>
> Co-developed-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx>
> Signed-off-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx>
> Signed-off-by: Oliver Upton <oupton@xxxxxxxxxx>
> ---
>  arch/x86/kvm/pmu.h           | 6 ++++++
>  arch/x86/kvm/vmx/pmu_intel.c | 2 +-
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h
> index 58265f761c3b..779427b44c2f 100644
> --- a/arch/x86/kvm/pmu.h
> +++ b/arch/x86/kvm/pmu.h
> @@ -79,6 +79,12 @@ static inline bool pmc_is_enabled(struct kvm_pmc *pmc)
>  	return kvm_x86_ops->pmu_ops->pmc_is_enabled(pmc);
>  }
>  
> +static inline bool kvm_is_valid_perf_global_ctrl(struct kvm_pmu *pmu,
> +						 u64 data)
> +{
> +	return pmu->global_ctrl == data || !(pmu->global_ctrl_mask & data);

Going to resend this one more time. Just had a conversation with Jim
offline and decided that the 'pmu->global_ctrl == data' check (as seen
in intel_pmu_set_msr()) isn't really providing us anything here.

> +}
> +
>  /* returns general purpose PMC with the specified MSR. Note that it can be
>   * used for both PERFCTRn and EVNTSELn; that is why it accepts base as a
>   * paramenter to tell them apart.
> diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c
> index 4dea0e0e7e39..963766d631ad 100644
> --- a/arch/x86/kvm/vmx/pmu_intel.c
> +++ b/arch/x86/kvm/vmx/pmu_intel.c
> @@ -223,7 +223,7 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>  	case MSR_CORE_PERF_GLOBAL_CTRL:
>  		if (pmu->global_ctrl == data)
>  			return 0;
> -		if (!(data & pmu->global_ctrl_mask)) {
> +		if (kvm_is_valid_perf_global_ctrl(pmu, data)) {
>  			global_ctrl_changed(pmu, data);
>  			return 0;
>  		}
> -- 
> 2.23.0.187.g17f5b7556c-goog
> 



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux