aboutsummaryrefslogtreecommitdiff
path: root/target-i386/cpu.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-06-24 14:11:27 +0200
committerEduardo Habkost <ehabkost@redhat.com>2015-07-07 10:47:16 -0300
commit06ef227e5158cca6710e6c268d6a7f65a5e2811b (patch)
tree13fa89ccf2c3e436248763e896907c758957cbe0 /target-i386/cpu.h
parent28b8e4d0bf93ba176b4b7be819d537383c5a9060 (diff)
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 <pbonzini@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'target-i386/cpu.h')
-rw-r--r--target-i386/cpu.h2
1 files changed, 1 insertions, 1 deletions
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;