From patchwork Wed Oct 17 19:40:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 192128 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 CC61D2C0092 for ; Thu, 18 Oct 2012 06:39:11 +1100 (EST) Received: from localhost ([::1]:45179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOZSP-0004YA-VZ for incoming@patchwork.ozlabs.org; Wed, 17 Oct 2012 15:39:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41687) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOZSH-0004Y1-Nh for qemu-devel@nongnu.org; Wed, 17 Oct 2012 15:39:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOZSG-0002h4-2A for qemu-devel@nongnu.org; Wed, 17 Oct 2012 15:39:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47248) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOZSF-0002h0-Pm for qemu-devel@nongnu.org; Wed, 17 Oct 2012 15:38:59 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9HJcv9K022703 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 17 Oct 2012 15:38:58 -0400 Received: from redhat.com (vpn1-5-63.ams2.redhat.com [10.36.5.63]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id q9HJctNp016176; Wed, 17 Oct 2012 15:38:55 -0400 Date: Wed, 17 Oct 2012 21:40:59 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <20121017194059.GA11781@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Anthony Liguori , Eduardo Habkost , Don Slutz , qemu-devel@nongnu.org, Igor Mammedov , Andreas =?iso-8859-1?Q?F=E4rber?= Subject: [Qemu-devel] [PATCH] qemu: enable PV EOI for qemu 1.3 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 Enable KVM PV EOI by default. You can still disable it with -kvm_pv_eoi cpu flag. To avoid breaking cross-version migration, enable only for qemu 1.3 or newer machine type. Signed-off-by: Michael S. Tsirkin --- hw/pc.h | 2 ++ hw/pc_piix.c | 14 +++++++++++++- target-i386/cpu.c | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/hw/pc.h b/hw/pc.h index 9923d96..344a545 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -210,4 +210,6 @@ void pc_system_firmware_init(MemoryRegion *rom_memory); int e820_add_entry(uint64_t, uint64_t, uint32_t); +void enable_kvm_pv_eoi(void); + #endif diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 82364ab..9d4cf48 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -301,6 +301,18 @@ static void pc_init_pci(ram_addr_t ram_size, initrd_filename, cpu_model, 1, 1); } +static void pc_init_pci_pv_eoi(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) +{ + enable_kvm_pv_eoi(); + pc_init_pci(ram_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} + static void pc_init_pci_no_kvmclock(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, @@ -353,7 +365,7 @@ static QEMUMachine pc_machine_v1_3 = { .name = "pc-1.3", .alias = "pc", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_pv_eoi, .max_cpus = 255, .is_default = 1, }; diff --git a/target-i386/cpu.c b/target-i386/cpu.c index f3708e6..a4a8a02 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1097,6 +1097,8 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque, cpu->env.tsc_khz = value / 1000; } +static bool kvm_pv_eoi_enabled; + static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) { unsigned int i; @@ -1135,6 +1137,8 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) (1 << KVM_FEATURE_ASYNC_PF) | (1 << KVM_FEATURE_STEAL_TIME) | (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT); + if (kvm_pv_eoi_enabled) + plus_kvm_features |= (0x1 << KVM_FEATURE_PV_EOI); #else plus_kvm_features = 0; #endif @@ -1953,3 +1957,14 @@ static void x86_cpu_register_types(void) } type_init(x86_cpu_register_types) + +/* Called from hw/pc_piix.c but there is no header + * both files include to put this into. + * Put it here to silence compiler warning. + */ +void enable_kvm_pv_eoi(void); + +void enable_kvm_pv_eoi(void) +{ + kvm_pv_eoi_enabled = true; +}