KVM: x86: Mark expected switch fall-throughs
Subsystems (4)
PATCH 1/1 KVM: x86: Mark expected switch fall-throughs
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.
This patch fixes the following warnings:
arch/x86/kvm/lapic.c:1037:27: warning: this statement may fall through [-Wimplicit-fallthrough=] arch/x86/kvm/lapic.c:1876:3: warning: this statement may fall through [-Wimplicit-fallthrough=] arch/x86/kvm/hyperv.c:1637:6: warning: this statement may fall through [-Wimplicit-fallthrough=] arch/x86/kvm/svm.c:4396:6: warning: this statement may fall through [-Wimplicit-fallthrough=] arch/x86/kvm/mmu.c:4372:36: warning: this statement may fall through [-Wimplicit-fallthrough=] arch/x86/kvm/x86.c:3835:6: warning: this statement may fall through [-Wimplicit-fallthrough=] arch/x86/kvm/x86.c:7938:23: warning: this statement may fall through [-Wimplicit-fallthrough=] arch/x86/kvm/vmx/vmx.c:2015:6: warning: this statement may fall through [-Wimplicit-fallthrough=] arch/x86/kvm/vmx/vmx.c:1773:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
Warning level 3 was used: -Wimplicit-fallthrough=3
This patch is part of the ongoing efforts to enabling -Wimplicit-fallthrough.
--- arch/x86/kvm/hyperv.c | 2 +- arch/x86/kvm/lapic.c | 2 ++ arch/x86/kvm/mmu.c | 1 + arch/x86/kvm/svm.c | 2 +- arch/x86/kvm/vmx/vmx.c | 4 ++-- arch/x86/kvm/x86.c | 3 +++ 6 files changed, 10 insertions(+), 4 deletions(-)
arch/x86/kvm/hyperv.c +1 -1
@@ -1636,7 +1636,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) ret =kvm_hvcall_signal_event (vcpu, fast, ingpa);if (ret !=HV_STATUS_INVALID_PORT_ID )break ; -/* maybe userspace knows this conn_id: fall through */ +/* fall through - maybe userspace knows this conn_id. */ case HVCALL_POST_MESSAGE :/* don't bother userspace if it has no way to handle it */ if (unlikely (rep || !vcpu_to_synic (vcpu)->active)) {
arch/x86/kvm/lapic.c +2 -0
@@ -1035,6 +1035,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,switch (delivery_mode) {case APIC_DM_LOWEST : vcpu->arch.apic_arb_prio++; +/* fall through */ case APIC_DM_FIXED :if (unlikely (trig_mode && !level))break ;
@@ -1874,6 +1875,7 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)case APIC_LVT0 :apic_manage_nmi_watchdog (apic, val); +/* fall through */ case APIC_LVTTHMR :case APIC_LVTPC :case APIC_LVT1 :
arch/x86/kvm/mmu.c +1 -0
@@ -4371,6 +4371,7 @@ __reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,rsvd_bits (maxphyaddr,51 ); rsvd_check->rsvd_bits_mask[1 ][4 ] = rsvd_check->rsvd_bits_mask[0 ][4 ]; +/* fall through */ case PT64_ROOT_4LEVEL : rsvd_check->rsvd_bits_mask[0 ][3 ] = exb_bit_rsvd | nonleaf_bit8_rsvd | rsvd_bits(7, 7) |
arch/x86/kvm/svm.c +1 -1
@@ -4395,7 +4395,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)case MSR_IA32_APICBASE :if (kvm_vcpu_apicv_active (vcpu))avic_update_vapic_bar (to_svm (vcpu), data); -/* Follow through */ +/* Fall through */ default :return kvm_set_msr_common (vcpu, msr); }
arch/x86/kvm/vmx/vmx.c +2 -2
@@ -1773,7 +1773,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)if (!msr_info->host_initiated && !guest_cpuid_has (vcpu,X86_FEATURE_RDTSCP ))return 1 ; -/* Otherwise falls through */ +/* Else, falls through */ default : msr =find_msr_entry (vmx, msr_info->index);if (msr) {
@@ -2014,7 +2014,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)/* Check reserved bit, higher 32 bits should be zero */ if ((data >>32 ) !=0 )return 1 ; -/* Otherwise falls through */ +/* Else, falls through */ default : msr =find_msr_entry (vmx, msr_index);if (msr) {
arch/x86/kvm/x86.c +3 -0
@@ -3834,6 +3834,8 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,case KVM_CAP_HYPERV_SYNIC2 :if (cap->args[0 ])return -EINVAL ; +/* fall through */ +case KVM_CAP_HYPERV_SYNIC :if (!irqchip_in_kernel (vcpu->kvm))return -EINVAL ;
@@ -7937,6 +7939,7 @@ static inline int vcpu_block(struct kvm *kvm, struct kvm_vcpu *vcpu) vcpu->arch.pv.pv_unhalted = false; vcpu->arch.mp_state =KVM_MP_STATE_RUNNABLE ; +/* fall through */ case KVM_MP_STATE_RUNNABLE : vcpu->arch.apf.halted = false;break ;
Signature · 1 line
2.20.1
Paolo Bonzini
maintainerarch/x86/kvm/vmx/vmx.c static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) · line 1779
Quoted 13 lines · Gustavo A. R. Silva
arch/x86/kvm/vmx/vmx.c +1
-1@@ -1773,7 +1773,7 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)if (!msr_info->host_initiated && !guest_cpuid_has (vcpu,X86_FEATURE_RDTSCP ))return 1 ; -/* Otherwise falls through */ +/* Else, falls through */ default : msr =find_msr_entry (vmx, msr_info->index);if (msr) {
I would say this is a compiler QoI issue and in general there were other cases like this one where the comments in the KVM source are reasonable, but I guess it's okay. Patch queued.
Paolo