Skip to contentSkip to conversation

KVM: x86/pmu: Remove redundant check for MSR_IA32_DS_AREA set handler

PATCH Applied Jinrong Liang 2 participants 2 messages Apr 11, 2023 – Jun 2, 2023

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

PATCH 1/1 KVM: x86/pmu: Remove redundant check for MSR_IA32_DS_AREA set handler

From: Jinrong Liang <[email protected]>

After commit 2de154f541fc ("KVM: x86/pmu: Provide "error" semantics for unsupported-but-known PMU MSRs"), the guest_cpuid_has(DS) check is not necessary any more since if the guest supports X86_FEATURE_DS, it never returns 1. And if the guest does not support this feature, the set_msr handler will get false from kvm_pmu_is_valid_msr() before reaching this point. Therefore, the check will not be true in all cases and can be safely removed, which also simplifies the code and improves its readability.

---
 arch/x86/kvm/vmx/pmu_intel.c | 2 --
 1 file changed, 2 deletions(-)
arch/x86/kvm/vmx/pmu_intel.c +0 -2
index e8a3be0b9df9..b0d70a8b7613 100644
@@ -443,8 +443,6 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 		}
 		break;
 	case MSR_IA32_DS_AREA:
-		if (msr_info->host_initiated && data && !guest_cpuid_has(vcpu, X86_FEATURE_DS))
-			return 1;
 		if (is_noncanonical_address(data, vcpu))
 			return 1;
 		pmu->ds_area = data;
Signature · 1 line
2.31.1
maintainer Applied
#1 lore raw
Quoted 10 lines · Jinrong Liang

After commit 2de154f541fc ("KVM: x86/pmu: Provide "error" semantics for unsupported-but-known PMU MSRs"), the guest_cpuid_has(DS) check is not necessary any more since if the guest supports X86_FEATURE_DS, it never returns 1. And if the guest does not support this feature, the set_msr handler will get false from kvm_pmu_is_valid_msr() before reaching this point. Therefore, the check will not be true in all cases and can be safely removed, which also simplifies the code and improves its readability.

[...]

Applied to kvm-x86 vmx, thanks!

[1/1] KVM: x86/pmu: Remove redundant check for MSR_IA32_DS_AREA set handler

      https://github.com/kvm-x86/linux/commit/33ab767c2628

--
https://github.com/kvm-x86/linux/tree/next
https://github.com/kvm-x86/linux/tree/fixes