Received: from eggs.gnu.org ([2001:4830:134:3::10]:39421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7jWg-0008Lv-QC for qemu-devel@nongnu.org; Wed, 24 Jun 2015 08:11:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z7jWc-0007s2-Nk for qemu-devel@nongnu.org; Wed, 24 Jun 2015 08:11:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33747) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7jWc-0007rx-I9 for qemu-devel@nongnu.org; Wed, 24 Jun 2015 08:11:30 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id A5A5FB1F96 for ; Wed, 24 Jun 2015 12:11:29 +0000 (UTC) From: Paolo Bonzini Date: Wed, 24 Jun 2015 14:11:27 +0200 Message-Id: <1435147887-2149-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] 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 Cc: ehabkost@redhat.com 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 --- 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 603aaf0..2125049 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -958,7 +958,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.4.3