From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZB7sG-0006iM-5i for qemu-devel@nongnu.org; Fri, 03 Jul 2015 16:47:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZB7sF-0003Yz-6a for qemu-devel@nongnu.org; Fri, 03 Jul 2015 16:47:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZB7sF-0003Ye-1T for qemu-devel@nongnu.org; Fri, 03 Jul 2015 16:47:51 -0400 From: Eduardo Habkost Date: Fri, 3 Jul 2015 17:47:38 -0300 Message-Id: <1435956459-18454-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1435956459-18454-1-git-send-email-ehabkost@redhat.com> References: <1435956459-18454-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PULL 2/3] target-i386: avoid overflow in the tsc-frequency property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Peter Maydell Cc: Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Richard Henderson 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 d2eaea8..bbeef22 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -961,7 +961,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