qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Jes.Sorensen@redhat.com
Subject: [Qemu-devel] [PATCH 4/6] x86/cpuid: Tighten parsing of tsc_freq=FREQ
Date: Tue, 22 Nov 2011 09:46:04 +0100	[thread overview]
Message-ID: <1321951566-11667-5-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1321951566-11667-1-git-send-email-armbru@redhat.com>

cpu_x86_find_by_name() uses strtosz_suffix_unit(), but screws up the
error checking.  It detects some failures, but not all.  Undetected
failures result in a zero tsc_khz value (error value -1 divided by
1000), which means "no tsc_freq set".

To reproduce, try "-cpu qemu64,tsc_freq=9999999T".
strtosz_suffix_unit() fails, because the value overflows int64_t,

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 target-i386/cpuid.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 21e5896..56c7671 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -692,7 +692,7 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
 
                 tsc_freq = strtosz_suffix_unit(val, &err,
                                                STRTOSZ_DEFSUFFIX_B, 1000);
-                if (!*val || *err) {
+                if (tsc_freq < 0 || *err) {
                     fprintf(stderr, "bad numerical value %s\n", val);
                     goto error;
                 }
-- 
1.7.6.4

  parent reply	other threads:[~2011-11-22  8:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-22  8:46 [Qemu-devel] [PATCH 0/6] Fix strtosz users, clean up its implementation Markus Armbruster
2011-11-22  8:46 ` [Qemu-devel] [PATCH 1/6] cutils: Drop broken support for zero strtosz default_suffix Markus Armbruster
2011-11-22  8:46 ` [Qemu-devel] [PATCH 2/6] vl: Tighten parsing of -numa's parameter mem Markus Armbruster
2011-11-22  8:46 ` [Qemu-devel] [PATCH 3/6] vl: Tighten parsing of -m argument Markus Armbruster
2011-11-22  8:46 ` Markus Armbruster [this message]
2011-11-22  8:46 ` [Qemu-devel] [PATCH 5/6] qemu-img: Tighten parsing of size arguments Markus Armbruster
2011-11-22  8:46 ` [Qemu-devel] [PATCH 6/6] cutils: Make strtosz & friends leave follow set to callers Markus Armbruster
2011-11-28 22:33 ` [Qemu-devel] [PATCH 0/6] Fix strtosz users, clean up its implementation Anthony Liguori

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=1321951566-11667-5-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=Jes.Sorensen@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).