qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL v2 2/2] target-i386: avoid overflow in the tsc-freque


From: Eduardo Habkost
Subject: [Qemu-devel] [PULL v2 2/2] target-i386: avoid overflow in the tsc-frequency property
Date: Tue, 7 Jul 2015 11:47:04 -0300

From: Paolo Bonzini <address@hidden>

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 <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
 target-i386/cpu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 0bfe64c..14dced0 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;
-- 
2.1.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]