KVM: VMX: Remove redundant CPU_BASED_TPR_SHADOW check in nested_vmx_check_tpr_shadow_controls()
PATCH 1/1 KVM: VMX: Remove redundant CPU_BASED_TPR_SHADOW check in nested_vmx_check_tpr_shadow_controls()
The function returns early at the top if CPU_BASED_TPR_SHADOW is not set in vmcs12, so any code that reaches the warn_on_missed_cc block is guaranteed to have CPU_BASED_TPR_SHADOW set. The repeated check in the if condition is always true and can be dropped.
--- arch/x86/kvm/vmx/nested.c | 1 - 1 file changed, 1 deletion(-)
arch/x86/kvm/vmx/nested.c +0 -1
@@ -619,7 +619,6 @@ static int nested_vmx_check_tpr_shadow_controls(struct kvm_vcpu *vcpu,* if userspace hasn't yet configured memslots during state restore. */ if (warn_on_missed_cc && vcpu->wants_to_run && - nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW) && !nested_cpu_has_vid(vmcs12) && !nested_cpu_has2(vmcs12, SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES) && !kvm_read_guest(vcpu->kvm, vtpr_gpa, &vtpr, sizeof(vtpr)) &&
Signature · 1 line
2.43.7
Quoted 4 lines · Peng Hao
The function returns early at the top if
CPU_BASED_TPR_SHADOWis not set in vmcs12, so any code that reaches thewarn_on_missed_ccblock is guaranteed to haveCPU_BASED_TPR_SHADOWset. The repeated check in the if condition is always true and can be dropped.
Applied to kvm-x86 vmx, thanks!
[1/1] KVM: VMX: Remove redundant CPU_BASED_TPR_SHADOW check in nested_vmx_check_tpr_shadow_controls()
https://github.com/kvm-x86/linux/commit/098a8194caf5