Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: x86: introduce kvm_check_has_quirk

The logic of the disabled_quirks field usually results in a double
negation. Wrap it in a simple function that checks the bit and
negates it.

Based on a patch from Xiao Guangrong.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

+7 -2
+1 -1
arch/x86/kvm/lapic.c
··· 1595 1595 for (i = 0; i < APIC_LVT_NUM; i++) 1596 1596 apic_set_reg(apic, APIC_LVTT + 0x10 * i, APIC_LVT_MASKED); 1597 1597 apic_update_lvtt(apic); 1598 - if (!(vcpu->kvm->arch.disabled_quirks & KVM_QUIRK_LINT0_REENABLED)) 1598 + if (kvm_check_has_quirk(vcpu->kvm, KVM_QUIRK_LINT0_REENABLED)) 1599 1599 apic_set_reg(apic, APIC_LVT0, 1600 1600 SET_APIC_DELIVERY_MODE(0, APIC_MODE_EXTINT)); 1601 1601 apic_manage_nmi_watchdog(apic, kvm_apic_get_reg(apic, APIC_LVT0));
+1 -1
arch/x86/kvm/svm.c
··· 1672 1672 * does not do it - this results in some delay at 1673 1673 * reboot 1674 1674 */ 1675 - if (!(vcpu->kvm->arch.disabled_quirks & KVM_QUIRK_CD_NW_CLEARED)) 1675 + if (kvm_check_has_quirk(vcpu->kvm, KVM_QUIRK_CD_NW_CLEARED)) 1676 1676 cr0 &= ~(X86_CR0_CD | X86_CR0_NW); 1677 1677 svm->vmcb->save.cr0 = cr0; 1678 1678 mark_dirty(svm->vmcb, VMCB_CR);
+5
arch/x86/kvm/x86.h
··· 147 147 return kvm_register_write(vcpu, reg, val); 148 148 } 149 149 150 + static inline bool kvm_check_has_quirk(struct kvm *kvm, u64 quirk) 151 + { 152 + return !(kvm->arch.disabled_quirks & quirk); 153 + } 154 + 150 155 void kvm_before_handle_nmi(struct kvm_vcpu *vcpu); 151 156 void kvm_after_handle_nmi(struct kvm_vcpu *vcpu); 152 157 void kvm_set_pending_timer(struct kvm_vcpu *vcpu);