Skip to contentSkip to conversation

KVM: VMX: Remove redundant CPU_BASED_TPR_SHADOW check in nested_vmx_check_tpr_shadow_controls()

PATCH Applied Peng Hao 2 participants 2 messages Oct 8 – Nov 13

Subsystems (3)
lore
Share & tools
lore

Peng Hao

author
#0 lore raw

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
index 151873407abd..a1f8adefbe35 100644
@@ -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
maintainer Applied
#1 lore raw
Quoted 4 lines · Peng Hao

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.

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

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