From patchwork Fri Jun 17 14:00:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 100809 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B36BAB6FD0 for ; Sat, 18 Jun 2011 00:22:50 +1000 (EST) Received: from localhost ([::1]:43445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXZwd-00052K-3R for incoming@patchwork.ozlabs.org; Fri, 17 Jun 2011 10:22:47 -0400 Received: from eggs.gnu.org ([140.186.70.92]:58277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXZaf-0007jn-MI for qemu-devel@nongnu.org; Fri, 17 Jun 2011 10:00:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QXZaY-0007hE-Mp for qemu-devel@nongnu.org; Fri, 17 Jun 2011 10:00:04 -0400 Received: from ch1ehsobe002.messaging.microsoft.com ([216.32.181.182]:22071 helo=CH1EHSOBE005.bigfish.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QXZaY-0007gg-5O for qemu-devel@nongnu.org; Fri, 17 Jun 2011 09:59:58 -0400 Received: from mail153-ch1-R.bigfish.com (216.32.181.172) by CH1EHSOBE005.bigfish.com (10.43.70.55) with Microsoft SMTP Server id 14.1.225.22; Fri, 17 Jun 2011 13:59:55 +0000 Received: from mail153-ch1 (localhost.localdomain [127.0.0.1]) by mail153-ch1-R.bigfish.com (Postfix) with ESMTP id E840B13A8240; Fri, 17 Jun 2011 13:59:53 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzzz1202hzz8275bhz32i668h839h61h) X-Forefront-Antispam-Report: CIP:163.181.249.108; KIP:(null); UIP:(null); IPVD:NLI; H:ausb3twp01.amd.com; RD:none; EFVD:NLI Received: from mail153-ch1 (localhost.localdomain [127.0.0.1]) by mail153-ch1 (MessageSwitch) id 1308319193411346_20850; Fri, 17 Jun 2011 13:59:53 +0000 (UTC) Received: from CH1EHSMHS016.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.252]) by mail153-ch1.bigfish.com (Postfix) with ESMTP id 5571EE6804C; Fri, 17 Jun 2011 13:59:53 +0000 (UTC) Received: from ausb3twp01.amd.com (163.181.249.108) by CH1EHSMHS016.bigfish.com (10.43.70.16) with Microsoft SMTP Server id 14.1.225.22; Fri, 17 Jun 2011 13:59:43 +0000 X-WSS-ID: 0LMXTJG-01-260-02 X-M-MSG: Received: from sausexedgep02.amd.com (sausexedgep02-ext.amd.com [163.181.249.73]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ausb3twp01.amd.com (Axway MailGate 3.8.1) with ESMTP id 2893A10282B1; Fri, 17 Jun 2011 08:59:40 -0500 (CDT) Received: from sausexhtp02.amd.com (163.181.3.152) by sausexedgep02.amd.com (163.181.36.59) with Microsoft SMTP Server (TLS) id 8.3.106.1; Fri, 17 Jun 2011 09:00:11 -0500 Received: from storexhtp02.amd.com (172.24.4.4) by sausexhtp02.amd.com (163.181.3.152) with Microsoft SMTP Server (TLS) id 8.3.83.0; Fri, 17 Jun 2011 08:59:41 -0500 Received: from gwo.osrc.amd.com (165.204.16.204) by storexhtp02.amd.com (172.24.4.4) with Microsoft SMTP Server id 8.3.83.0; Fri, 17 Jun 2011 09:59:40 -0400 Received: from lemmy.osrc.amd.com (lemmy.osrc.amd.com [165.204.15.93]) by gwo.osrc.amd.com (Postfix) with ESMTP id DD07549C5E9; Fri, 17 Jun 2011 14:59:39 +0100 (BST) Received: by lemmy.osrc.amd.com (Postfix, from userid 1000) id 0EBF9FFCC7; Fri, 17 Jun 2011 16:00:16 +0200 (CEST) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti Date: Fri, 17 Jun 2011 16:00:13 +0200 Message-ID: <1308319214-8474-2-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1308319214-8474-1-git-send-email-joerg.roedel@amd.com> References: <1308319214-8474-1-git-send-email-joerg.roedel@amd.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP2+, XP SP1+ (seldom 98) X-Received-From: 216.32.181.182 Cc: Joerg Roedel , Anthony Liguori , qemu-devel , kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 1/2] qemu-x86: Add tsc_khz option to -cpu X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org To let the user configure the desired tsc frequency for the guest if running in KVM. Signed-off-by: Joerg Roedel --- target-i386/cpu.h | 1 + target-i386/cpuid.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 0b039d4..a381c34 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -753,6 +753,7 @@ typedef struct CPUX86State { uint32_t cpuid_kvm_features; uint32_t cpuid_svm_features; bool tsc_valid; + int tsc_khz; /* in order to simplify APIC support, we leave this pointer to the user */ diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c index 79e7580..2b59e66 100644 --- a/target-i386/cpuid.c +++ b/target-i386/cpuid.c @@ -224,6 +224,7 @@ typedef struct x86_def_t { int family; int model; int stepping; + int tsc_khz; uint32_t features, ext_features, ext2_features, ext3_features; uint32_t kvm_features, svm_features; uint32_t xlevel; @@ -704,6 +705,14 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) } else if (!strcmp(featurestr, "model_id")) { pstrcpy(x86_cpu_def->model_id, sizeof(x86_cpu_def->model_id), val); + } else if (!strcmp(featurestr, "tsc_khz")) { + char *err; + numvalue = strtoul(val, &err, 0); + if (!*val || *err) { + fprintf(stderr, "bad numerical value %s\n", val); + goto error; + } + x86_cpu_def->tsc_khz = numvalue; } else { fprintf(stderr, "unrecognized feature %s\n", featurestr); goto error; @@ -872,6 +881,7 @@ int cpu_x86_register (CPUX86State *env, const char *cpu_model) env->cpuid_svm_features = def->svm_features; env->cpuid_ext4_features = def->ext4_features; env->cpuid_xlevel2 = def->xlevel2; + env->tsc_khz = def->tsc_khz; if (!kvm_enabled()) { env->cpuid_features &= TCG_FEATURES; env->cpuid_ext_features &= TCG_EXT_FEATURES;