From: Eduardo Habkost <ehabkost@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <rth@twiddle.net>,
"Andreas Färber" <afaerber@suse.de>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: [Qemu-devel] [PULL v2 2/2] target-i386: avoid overflow in the tsc-frequency property
Date: Tue, 7 Jul 2015 11:47:04 -0300 [thread overview]
Message-ID: <1436280424-5490-3-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1436280424-5490-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 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
next prev parent reply other threads:[~2015-07-07 14:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 14:47 [Qemu-devel] [PULL v2 0/2] X86 queue, 2015-07-07 Eduardo Habkost
2015-07-07 14:47 ` [Qemu-devel] [PULL v2 1/2] i386: Introduce ARAT CPU feature Eduardo Habkost
2015-07-07 14:47 ` Eduardo Habkost [this message]
2015-07-07 20:15 ` [Qemu-devel] [PULL v2 0/2] X86 queue, 2015-07-07 Peter Maydell
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=1436280424-5490-3-git-send-email-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=afaerber@suse.de \
--cc=mst@redhat.com \
--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).