From 06ef227e5158cca6710e6c268d6a7f65a5e2811b Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 24 Jun 2015 14:11:27 +0200 Subject: target-i386: avoid overflow in the tsc-frequency property The TSC frequency fits comfortably in an int when expressed in kHz, but it may overflow when converted to Hz. In this case, tsc-frequency returns a negative value because x86_cpuid_get_tsc_freq does a 32-bit multiplication before assigning to int64_t. For simplicity just make tsc_khz a 64-bit value. Spotted by Coverity. Signed-off-by: Paolo Bonzini Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- target-i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'target-i386/cpu.h') diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 0bfe64c5b9..14dced08a7 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -962,7 +962,7 @@ typedef struct CPUX86State { uint8_t has_error_code; uint32_t sipi_vector; bool tsc_valid; - int tsc_khz; + int64_t tsc_khz; void *kvm_xsave_buf; uint64_t mcg_cap; -- cgit v1.2.3