From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCU9X-0000Bi-0z for qemu-devel@nongnu.org; Tue, 07 Jul 2015 10:47:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCU9R-0000dI-GA for qemu-devel@nongnu.org; Tue, 07 Jul 2015 10:47:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54467) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCU9R-0000dE-8G for qemu-devel@nongnu.org; Tue, 07 Jul 2015 10:47:13 -0400 From: Eduardo Habkost Date: Tue, 7 Jul 2015 11:47:04 -0300 Message-Id: <1436280424-5490-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1436280424-5490-1-git-send-email-ehabkost@redhat.com> References: <1436280424-5490-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PULL v2 2/2] target-i386: avoid overflow in the tsc-frequency property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel@nongnu.org, Paolo Bonzini , Richard Henderson , =?UTF-8?q?Andreas=20F=C3=A4rber?= , "Michael S. Tsirkin" From: Paolo Bonzini 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(-) 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