From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>,
"Richard Henderson" <rth@twiddle.net>
Subject: [Qemu-devel] [PULL 2/3] target-i386: avoid overflow in the tsc-frequency property
Date: Fri, 3 Jul 2015 17:47:38 -0300 [thread overview]
Message-ID: <1435956459-18454-3-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1435956459-18454-1-git-send-email-ehabkost@redhat.com>
From: Paolo Bonzini <pbonzini@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 <pbonzini@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
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
next prev parent reply other threads:[~2015-07-03 20:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-03 20:47 [Qemu-devel] [PULL 0/3] X86 queue, 2015-07-03 Eduardo Habkost
2015-07-03 20:47 ` [Qemu-devel] [PULL 1/3] i386: Introduce ARAT CPU feature Eduardo Habkost
2015-07-03 20:47 ` Eduardo Habkost [this message]
2015-07-03 20:47 ` [Qemu-devel] [PULL 3/3] target-i386: emulate CPUID level of real hardware Eduardo Habkost
2015-07-03 20:52 ` [Qemu-devel] [PULL 0/3] X86 queue, 2015-07-03 Andreas Färber
2015-07-05 18:33 ` Peter Maydell
2015-07-06 13:39 ` Eduardo Habkost
2015-07-09 18:58 ` Radim Krčmář
2015-07-09 19:07 ` [Qemu-devel] [PATCH build-fix] target-i386: emulate CPUID level of real hardware Radim Krčmář
2015-07-15 20:12 ` Eduardo Habkost
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1435956459-18454-3-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=afaerber@suse.de \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).