From patchwork Mon Jul 9 12:10:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 169838 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D5B6E2C0209 for ; Mon, 9 Jul 2012 23:26:52 +1000 (EST) Received: from localhost ([::1]:45296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoDzG-0003KA-Ky for incoming@patchwork.ozlabs.org; Mon, 09 Jul 2012 09:26:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoDz9-0003Jy-Sg for qemu-devel@nongnu.org; Mon, 09 Jul 2012 09:26:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SoDz3-0002C7-8F for qemu-devel@nongnu.org; Mon, 09 Jul 2012 09:26:43 -0400 Received: from cantor2.suse.de ([195.135.220.15]:39023 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoDz2-0002Bi-UZ for qemu-devel@nongnu.org; Mon, 09 Jul 2012 09:26:37 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id C7BEEA2FB8; Mon, 9 Jul 2012 15:26:35 +0200 (CEST) From: Alexander Graf To: qemu-devel qemu-devel Date: Mon, 9 Jul 2012 14:10:48 +0200 Message-Id: <1341835849-3078-3-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1341835849-3078-1-git-send-email-agraf@suse.de> References: <1341835849-3078-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: Avi Kivity , Ryan Harper , Anthony Liguori , KVM list , =?utf-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH 2/3] KVM: Use -cpu best as default on x86 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 When running QEMU without -cpu parameter, the user usually wants a sane default. So far, we're using the qemu64/qemu32 CPU type, which basically means "the maximum TCG can emulate". That's a really good default when using TCG, but when running with KVM we much rather want a default saying "the maximum performance I can get". Fortunately we just added an option that gives us the best performance while still staying safe on the testability side of things: -cpu best. So all we need to do is make -cpu best the default when the user doesn't explicitly specify a CPU type. This fixes a lot of subtle breakage in the GNU toolchain (libgmp) which hicks up on QEMU's non-existent CPU models. This patch also adds a new pc-1.2 machine type to stay backwards compatible with older versions of QEMU. Signed-off-by: Alexander Graf --- v1 -> v2: - rebase v2 -> v3: - fix typo in commit message --- hw/pc_piix.c | 34 ++++++++++++++++++++++++++-------- 1 files changed, 26 insertions(+), 8 deletions(-) diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 0c0096f..a955bf8 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -127,7 +127,8 @@ static void pc_init1(MemoryRegion *system_memory, const char *initrd_filename, const char *cpu_model, int pci_enabled, - int kvmclock_enabled) + int kvmclock_enabled, + int may_cpu_best) { int i; ram_addr_t below_4g_mem_size, above_4g_mem_size; @@ -149,6 +150,9 @@ static void pc_init1(MemoryRegion *system_memory, MemoryRegion *rom_memory; void *fw_cfg = NULL; + if (!cpu_model && kvm_enabled() && may_cpu_best) { + cpu_model = "best"; + } pc_cpus_init(cpu_model); if (kvmclock_enabled) { @@ -298,7 +302,21 @@ static void pc_init_pci(ram_addr_t ram_size, get_system_io(), ram_size, boot_device, kernel_filename, kernel_cmdline, - initrd_filename, cpu_model, 1, 1); + initrd_filename, cpu_model, 1, 1, 1); +} + +static void pc_init_pci_oldcpu(ram_addr_t ram_size, + const char *boot_device, + const char *kernel_filename, + const char *kernel_cmdline, + const char *initrd_filename, + const char *cpu_model) +{ + pc_init1(get_system_memory(), + get_system_io(), + ram_size, boot_device, + kernel_filename, kernel_cmdline, + initrd_filename, cpu_model, 1, 1, 0); } static void pc_init_pci_no_kvmclock(ram_addr_t ram_size, @@ -312,7 +330,7 @@ static void pc_init_pci_no_kvmclock(ram_addr_t ram_size, get_system_io(), ram_size, boot_device, kernel_filename, kernel_cmdline, - initrd_filename, cpu_model, 1, 0); + initrd_filename, cpu_model, 1, 0, 0); } static void pc_init_isa(ram_addr_t ram_size, @@ -328,7 +346,7 @@ static void pc_init_isa(ram_addr_t ram_size, get_system_io(), ram_size, boot_device, kernel_filename, kernel_cmdline, - initrd_filename, cpu_model, 0, 1); + initrd_filename, cpu_model, 0, 1, 0); } #ifdef CONFIG_XEN @@ -380,7 +398,7 @@ static QEMUMachine pc_machine_v1_2 = { static QEMUMachine pc_machine_v1_1 = { .name = "pc-1.1", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_oldcpu, .max_cpus = 255, .compat_props = (GlobalProperty[]) { PC_COMPAT_1_1, @@ -415,7 +433,7 @@ static QEMUMachine pc_machine_v1_1 = { static QEMUMachine pc_machine_v1_0 = { .name = "pc-1.0", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_oldcpu, .max_cpus = 255, .compat_props = (GlobalProperty[]) { PC_COMPAT_1_0, @@ -430,7 +448,7 @@ static QEMUMachine pc_machine_v1_0 = { static QEMUMachine pc_machine_v0_15 = { .name = "pc-0.15", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_oldcpu, .max_cpus = 255, .compat_props = (GlobalProperty[]) { PC_COMPAT_0_15, @@ -462,7 +480,7 @@ static QEMUMachine pc_machine_v0_15 = { static QEMUMachine pc_machine_v0_14 = { .name = "pc-0.14", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_oldcpu, .max_cpus = 255, .compat_props = (GlobalProperty[]) { PC_COMPAT_0_14,