kvm: x86: avoid warning about potential shift wrapping bug
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 24 Nov 2014 13:35:24 +0000 (14:35 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 24 Nov 2014 15:53:50 +0000 (16:53 +0100)
cs.base is declared as a __u64 variable and vector is a u32 so this
causes a static checker warning.  The user indeed can set "sipi_vector"
to any u32 value in kvm_vcpu_ioctl_x86_set_vcpu_events(), but the
value should really have 8-bit precision only.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/lapic.c
arch/x86/kvm/x86.c

index 76ff3e2d8fd28e7c74ca77b8f6d5b7c1a88e1f83..2896dbc18987980132f84b68a916cc685cfb7748 100644 (file)
@@ -880,7 +880,7 @@ int kvm_emulate_wbinvd(struct kvm_vcpu *vcpu);
 
 void kvm_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg);
 int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, int seg);
-void kvm_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, unsigned int vector);
+void kvm_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector);
 
 int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int idt_index,
                    int reason, bool has_error_code, u32 error_code);
index e0e5642dae41382155c7c428e937a46ff8e6682c..f739f804b3a2f8ef555dcb274705e63b5bffac25 100644 (file)
@@ -1954,7 +1954,7 @@ int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data)
 void kvm_apic_accept_events(struct kvm_vcpu *vcpu)
 {
        struct kvm_lapic *apic = vcpu->arch.apic;
-       unsigned int sipi_vector;
+       u8 sipi_vector;
        unsigned long pe;
 
        if (!kvm_vcpu_has_lapic(vcpu) || !apic->pending_events)
index c42bca47f7f55456fda5798f554d435d526fa250..08b5657e57edff93b5dfce0bee90b6f9b82cef1d 100644 (file)
@@ -7033,7 +7033,7 @@ void kvm_vcpu_reset(struct kvm_vcpu *vcpu)
        kvm_x86_ops->vcpu_reset(vcpu);
 }
 
-void kvm_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, unsigned int vector)
+void kvm_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector)
 {
        struct kvm_segment cs;