From fa2b872b0b89f4676642038ace75c0e361a9eef9 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 14 Feb 2018 08:51:08 -0500 Subject: [PATCH] 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. Backports commit 06ef227e5158cca6710e6c268d6a7f65a5e2811b from qemu --- qemu/target-i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu/target-i386/cpu.h b/qemu/target-i386/cpu.h index abf62aa7..c45912f3 100644 --- a/qemu/target-i386/cpu.h +++ b/qemu/target-i386/cpu.h @@ -954,7 +954,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;