From nobody Mon May 6 11:19:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507326893565975.0351904176538; Fri, 6 Oct 2017 14:54:53 -0700 (PDT) Received: from localhost ([::1]:47262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0aZu-0004rE-QL for importer@patchew.org; Fri, 06 Oct 2017 17:54:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0aYA-0003pW-TM for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:52:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e0aY9-0001YG-Jl for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:52:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39306) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e0aY9-0001X7-DU for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:52:53 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 65E0A85543 for ; Fri, 6 Oct 2017 21:52:52 +0000 (UTC) Received: from localhost (ovpn-116-25.gru2.redhat.com [10.97.116.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19CA96047D; Fri, 6 Oct 2017 21:52:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 65E0A85543 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 6 Oct 2017 18:52:38 -0300 Message-Id: <20171006215244.27104-2-ehabkost@redhat.com> In-Reply-To: <20171006215244.27104-1-ehabkost@redhat.com> References: <20171006215244.27104-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 06 Oct 2017 21:52:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/7] qemu-doc: Document minimum kernel version for KVM in x86_64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The default set of KVM CPU features require the host kernel to support them. KVM_PV_EOI is the newest one, and was included on Linux v3.6 (Linux commit ae7a2a3f). Running on an old host might break management software expectations because the latest machine-type won't be runnable while older machine-types might be runnable. Document v3.6 as the minimum kernel version for KVM on x86_64. Signed-off-by: Eduardo Habkost --- qemu-doc.texi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qemu-doc.texi b/qemu-doc.texi index ecd186a159..be45b6b6f6 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -37,6 +37,7 @@ * QEMU System emulator for non PC targets:: * QEMU Guest Agent:: * QEMU User space emulator:: +* System requirements:: * Implementation notes:: * Deprecated features:: * License:: @@ -2348,6 +2349,14 @@ Act as if the host page size was 'pagesize' bytes Run the emulation in single step mode. @end table =20 +@node System requirements +@chapter System requirements + +@section KVM kernel module + +On x86_64 hosts, the default set of CPU features enabled by the KVM accele= rator +require the host to be running Linux v3.6 or newer. + =20 @include qemu-tech.texi =20 --=20 2.13.6 From nobody Mon May 6 11:19:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507327020508921.4397726744082; Fri, 6 Oct 2017 14:57:00 -0700 (PDT) Received: from localhost ([::1]:47273 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0abt-0006d9-QN for importer@patchew.org; Fri, 06 Oct 2017 17:56:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0aYE-0003r5-R5 for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:52:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e0aYE-0001cm-2d for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:52:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43522) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e0aYD-0001by-T8 for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:52:58 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE9B420271 for ; Fri, 6 Oct 2017 21:52:56 +0000 (UTC) Received: from localhost (ovpn-116-25.gru2.redhat.com [10.97.116.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id C496770904; Fri, 6 Oct 2017 21:52:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CE9B420271 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 6 Oct 2017 18:52:39 -0300 Message-Id: <20171006215244.27104-3-ehabkost@redhat.com> In-Reply-To: <20171006215244.27104-1-ehabkost@redhat.com> References: <20171006215244.27104-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 06 Oct 2017 21:52:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/7] target/i386: x86_cpu_expand_feature() helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" x86_cpu_expand_features() needs to ensure it won't touch user-configured features when changing cpu->features. Make a helper for that, and use it when handling cpu->max_features. Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 98732cd65f..90c969363e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3486,6 +3486,25 @@ static void x86_cpu_enable_xsave_components(X86CPU *= cpu) * any CPUID data based on host capabilities. */ =20 +/** + * x86_cpu_expand_feature: + * + * Change cpu->features, being careful to not override features explicitly + * configured bv the user. + * + * @w: the feature word to be changed + * @mask: the bits to be changed in cpu->features[w] + * @value: the new value for the bits in (cpu->features[w] & @mask) + */ +static void x86_cpu_expand_feature(X86CPU *cpu, FeatureWord w, + uint32_t mask, uint32_t value) +{ + assert((value & mask) =3D=3D value); + mask &=3D ~cpu->env.user_features[w]; + cpu->env.features[w] &=3D ~mask; + cpu->env.features[w] |=3D value & mask; +} + /* Expand CPU configuration data, based on configured features * and host/accelerator capabilities when appropriate. */ @@ -3503,12 +3522,8 @@ static void x86_cpu_expand_features(X86CPU *cpu, Err= or **errp) */ if (cpu->max_features) { for (w =3D 0; w < FEATURE_WORDS; w++) { - /* Override only features that weren't set explicitly - * by the user. - */ - env->features[w] |=3D - x86_cpu_get_supported_feature_word(w, cpu->migratable) & - ~env->user_features[w]; + uint32_t f =3D x86_cpu_get_supported_feature_word(w, cpu->migr= atable); + x86_cpu_expand_feature(cpu, w, ~0, f); } } =20 --=20 2.13.6 From nobody Mon May 6 11:19:42 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507327102605596.616366564706; Fri, 6 Oct 2017 14:58:22 -0700 (PDT) Received: from localhost ([::1]:47276 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0adB-0007o7-UU for importer@patchew.org; Fri, 06 Oct 2017 17:58:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0aYM-0003y9-Jx for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e0aYH-0001g0-OH for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43732) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e0aYH-0001eu-Gd for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:01 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 831A04ACCB for ; Fri, 6 Oct 2017 21:53:00 +0000 (UTC) Received: from localhost (ovpn-116-25.gru2.redhat.com [10.97.116.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 432B05C54B; Fri, 6 Oct 2017 21:52:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 831A04ACCB Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 6 Oct 2017 18:52:40 -0300 Message-Id: <20171006215244.27104-4-ehabkost@redhat.com> In-Reply-To: <20171006215244.27104-1-ehabkost@redhat.com> References: <20171006215244.27104-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 06 Oct 2017 21:53:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/7] target/i386: Use global variables to control KVM defaults X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The compatibility rules for KVM defaults are implemented today using x86_cpu_change_kvm_default(), and representing the arguments to x86_cpu_change_kvm_default() inside compat_props would be a challenge. But the compat system doesn't need to be that complex. From the 10 entries at kvm_default_props, only 3 of them need to be affected by machine-type compat code. It's much simpler and obvious to just have 3 boolean properties that will control compatibility mode, and handle them manually at the same place where kvm_default_props is applied to the CPU object. This introduces 3 global properties to control the KVM defaults for x2apic, kvm-pv-eoi, and svm. The global variables are just an intermediate step to convert this to 3 X86CPU properties to be controlled using MachineClass::compat_props. Signed-off-by: Eduardo Habkost --- target/i386/cpu.h | 14 ++++++-------- hw/i386/pc_piix.c | 6 +++--- target/i386/cpu.c | 37 +++++++++++++++++-------------------- 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index b086b1528b..0184f98241 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1700,15 +1700,13 @@ void apic_handle_tpr_access_report(DeviceState *d, = target_ulong ip, TPRAccess access); =20 =20 -/* Change the value of a KVM-specific default - * - * If value is NULL, no default will be set and the original - * value from the CPU model table will be kept. - * - * It is valid to call this function only for properties that - * are already present in the kvm_default_props table. +/* + * Compat globals to control features automatically enabled/disabled by KV= M. + * TODO: convert them to X86CPU fields set by MachineClass::compat_props */ -void x86_cpu_change_kvm_default(const char *prop, const char *value); +extern bool kvm_auto_disable_svm; +extern bool kvm_auto_enable_x2apic; +extern bool kvm_auto_enable_pv_eoi; =20 /* mpx_helper.c */ void cpu_sync_bndcs_hflags(CPUX86State *env); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 31646e63c4..3e466b3896 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -328,7 +328,7 @@ static void pc_compat_2_2(MachineState *machine) static void pc_compat_2_1(MachineState *machine) { pc_compat_2_2(machine); - x86_cpu_change_kvm_default("svm", NULL); + kvm_auto_disable_svm =3D false; } =20 static void pc_compat_2_0(MachineState *machine) @@ -339,7 +339,7 @@ static void pc_compat_2_0(MachineState *machine) static void pc_compat_1_7(MachineState *machine) { pc_compat_2_0(machine); - x86_cpu_change_kvm_default("x2apic", NULL); + kvm_auto_enable_x2apic =3D false; } =20 static void pc_compat_1_6(MachineState *machine) @@ -367,7 +367,7 @@ static void pc_compat_1_3(MachineState *machine) static void pc_compat_1_2(MachineState *machine) { pc_compat_1_3(machine); - x86_cpu_change_kvm_default("kvm-pv-eoi", NULL); + kvm_auto_enable_pv_eoi =3D false; } =20 /* PC compat function for pc-0.10 to pc-0.13 */ diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 90c969363e..f8d317f1f9 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1577,15 +1577,16 @@ static PropValue kvm_default_props[] =3D { { "kvm-nopiodelay", "on" }, { "kvm-asyncpf", "on" }, { "kvm-steal-time", "on" }, - { "kvm-pv-eoi", "on" }, { "kvmclock-stable-bit", "on" }, - { "x2apic", "on" }, { "acpi", "off" }, { "monitor", "off" }, - { "svm", "off" }, { NULL, NULL }, }; =20 +bool kvm_auto_disable_svm =3D true; +bool kvm_auto_enable_x2apic =3D true; +bool kvm_auto_enable_pv_eoi =3D true; + /* TCG-specific defaults that override all CPU models when using TCG */ static PropValue tcg_default_props[] =3D { @@ -1594,22 +1595,6 @@ static PropValue tcg_default_props[] =3D { }; =20 =20 -void x86_cpu_change_kvm_default(const char *prop, const char *value) -{ - PropValue *pv; - for (pv =3D kvm_default_props; pv->prop; pv++) { - if (!strcmp(pv->prop, prop)) { - pv->value =3D value; - break; - } - } - - /* It is valid to call this function only for properties that - * are already present in the kvm_default_props table. - */ - assert(pv->prop); -} - static uint32_t x86_cpu_get_supported_feature_word(FeatureWord w, bool migratable_only); =20 @@ -2439,7 +2424,19 @@ static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefi= nition *def, Error **errp) /* Special cases not set in the X86CPUDefinition structs: */ if (kvm_enabled()) { if (!kvm_irqchip_in_kernel()) { - x86_cpu_change_kvm_default("x2apic", "off"); + object_property_set_bool(OBJECT(cpu), false, "x2apic", + &error_abort); + } else if (kvm_auto_enable_x2apic) { + object_property_set_bool(OBJECT(cpu), true, "x2apic", + &error_abort); + } + if (kvm_auto_disable_svm) { + object_property_set_bool(OBJECT(cpu), false, "svm", + &error_abort); + } + if (kvm_auto_enable_pv_eoi) { + object_property_set_bool(OBJECT(cpu), true, "kvm-pv-eoi", + &error_abort); } =20 x86_cpu_apply_props(cpu, kvm_default_props); --=20 2.13.6 From nobody Mon May 6 11:19:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 150732691530925.44091103573203; Fri, 6 Oct 2017 14:55:15 -0700 (PDT) Received: from localhost ([::1]:47263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0aaH-00058p-PR for importer@patchew.org; Fri, 06 Oct 2017 17:55:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0aYN-0003yY-4O for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e0aYM-0001iu-Fy for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43856) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e0aYM-0001ih-9h for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:06 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D42E4ACCB for ; Fri, 6 Oct 2017 21:53:05 +0000 (UTC) Received: from localhost (ovpn-116-25.gru2.redhat.com [10.97.116.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFC1060BEC; Fri, 6 Oct 2017 21:53:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4D42E4ACCB Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 6 Oct 2017 18:52:41 -0300 Message-Id: <20171006215244.27104-5-ehabkost@redhat.com> In-Reply-To: <20171006215244.27104-1-ehabkost@redhat.com> References: <20171006215244.27104-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 06 Oct 2017 21:53:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 4/7] kvm: Define KVM_FEAT_* even if CONFIG_KVM is not defined X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This will allow us to avoid #ifdefs in code that use those macros in target/i386/cpu.c. Signed-off-by: Eduardo Habkost --- target/i386/kvm_i386.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target/i386/kvm_i386.h b/target/i386/kvm_i386.h index 1de9876cd9..8984cb02a1 100644 --- a/target/i386/kvm_i386.h +++ b/target/i386/kvm_i386.h @@ -36,6 +36,15 @@ */ #define KVM_CPUID_FEATURES 0 =20 +#define KVM_FEATURE_CLOCKSOURCE 0 +#define KVM_FEATURE_NOP_IO_DELAY 0 +#define KVM_FEATURE_MMU_OP 0 +#define KVM_FEATURE_CLOCKSOURCE2 0 +#define KVM_FEATURE_ASYNC_PF 0 +#define KVM_FEATURE_STEAL_TIME 0 +#define KVM_FEATURE_PV_EOI 0 +#define KVM_FEATURE_PV_UNHALT 0 + #endif /* CONFIG_KVM */ =20 bool kvm_allows_irq0_override(void); --=20 2.13.6 From nobody Mon May 6 11:19:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507327156824815.5341191695129; Fri, 6 Oct 2017 14:59:16 -0700 (PDT) Received: from localhost ([::1]:47279 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0aeH-0008Nu-7s for importer@patchew.org; Fri, 06 Oct 2017 17:59:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0aYP-00040M-C4 for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e0aYO-0001js-HK for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48724) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e0aYO-0001jT-8i for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:08 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3BAB081F01 for ; Fri, 6 Oct 2017 21:53:07 +0000 (UTC) Received: from localhost (ovpn-116-25.gru2.redhat.com [10.97.116.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id C78005C54B; Fri, 6 Oct 2017 21:53:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3BAB081F01 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 6 Oct 2017 18:52:42 -0300 Message-Id: <20171006215244.27104-6-ehabkost@redhat.com> In-Reply-To: <20171006215244.27104-1-ehabkost@redhat.com> References: <20171006215244.27104-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 06 Oct 2017 21:53:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 5/7] target/i386: Handle kvm_auto_* compat in x86_cpu_expand_features() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" x86_cpu_expand_features() is run after global properties are applied, so we will be able to convert the kvm_auto_* global variables to QOM properties controlled by MachineClass::compat_props. When doing that, we need to use x86_cpu_expand_feature() so we don't override properties set explicitly by the user. Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index f8d317f1f9..83e234cef4 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2423,22 +2423,6 @@ static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefi= nition *def, Error **errp) =20 /* Special cases not set in the X86CPUDefinition structs: */ if (kvm_enabled()) { - if (!kvm_irqchip_in_kernel()) { - object_property_set_bool(OBJECT(cpu), false, "x2apic", - &error_abort); - } else if (kvm_auto_enable_x2apic) { - object_property_set_bool(OBJECT(cpu), true, "x2apic", - &error_abort); - } - if (kvm_auto_disable_svm) { - object_property_set_bool(OBJECT(cpu), false, "svm", - &error_abort); - } - if (kvm_auto_enable_pv_eoi) { - object_property_set_bool(OBJECT(cpu), true, "kvm-pv-eoi", - &error_abort); - } - x86_cpu_apply_props(cpu, kvm_default_props); } else if (tcg_enabled()) { x86_cpu_apply_props(cpu, tcg_default_props); @@ -3511,6 +3495,31 @@ static void x86_cpu_expand_features(X86CPU *cpu, Err= or **errp) FeatureWord w; GList *l; Error *local_err =3D NULL; + X86CPUClass *xcc =3D X86_CPU_GET_CLASS(cpu); + + /* + * Note: "base" is a static CPU model and shouldn't auto-enable KVM + * defaults, so we check xcc->cpu_def here. + */ + if (xcc->cpu_def && kvm_enabled()) { + /* KVM-specific defaults that depend on compatibility globals: */ + + if (!kvm_irqchip_in_kernel()) { + x86_cpu_expand_feature(cpu, FEAT_1_ECX, CPUID_EXT_X2APIC, 0); + } else if (kvm_auto_enable_x2apic) { + x86_cpu_expand_feature(cpu, FEAT_1_ECX, CPUID_EXT_X2APIC, + CPUID_EXT_X2APIC); + } + + if (kvm_auto_disable_svm) { + x86_cpu_expand_feature(cpu, FEAT_8000_0001_ECX, CPUID_EXT3_SVM= , 0); + } + + if (kvm_auto_enable_pv_eoi) { + x86_cpu_expand_feature(cpu, FEAT_KVM, (1 << KVM_FEATURE_PV_EOI= ), + (1 << KVM_FEATURE_PV_EOI)); + } + } =20 /*TODO: Now cpu->max_features doesn't overwrite features * set using QOM properties, and we can convert --=20 2.13.6 From nobody Mon May 6 11:19:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507326916477222.24700571866708; Fri, 6 Oct 2017 14:55:16 -0700 (PDT) Received: from localhost ([::1]:47264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0aaO-0005FP-M3 for importer@patchew.org; Fri, 06 Oct 2017 17:55:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0aYR-00042L-FW for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e0aYQ-0001kS-BY for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47102) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e0aYQ-0001k8-2L for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:10 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1601E883B8 for ; Fri, 6 Oct 2017 21:53:09 +0000 (UTC) Received: from localhost (ovpn-116-25.gru2.redhat.com [10.97.116.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C6BC70904; Fri, 6 Oct 2017 21:53:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1601E883B8 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 6 Oct 2017 18:52:43 -0300 Message-Id: <20171006215244.27104-7-ehabkost@redhat.com> In-Reply-To: <20171006215244.27104-1-ehabkost@redhat.com> References: <20171006215244.27104-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 06 Oct 2017 21:53:09 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 6/7] pc: Use compat_props to control KVM defaults compatibility X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Replace the kvm_auto_* global variables with QOM properties controlled by MachineClass::compat_props. This will help us eliminate the pc_compat_*() function chain in the future. Signed-off-by: Eduardo Habkost --- include/hw/i386/pc.h | 8 ++++++++ target/i386/cpu.h | 17 +++++++++-------- hw/i386/pc_piix.c | 7 ++++--- target/i386/cpu.c | 18 ++++++++++-------- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 087d184ef5..d2742dd0bc 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -753,6 +753,10 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_= t *); .driver =3D "core2duo" "-" TYPE_X86_CPU,\ .property =3D "vmx",\ .value =3D "on",\ + },{\ + .driver =3D TYPE_X86_CPU,\ + .property =3D "x-kvm-auto-disable-svm",\ + .value =3D "off",\ }, =20 #define PC_COMPAT_2_0 \ @@ -831,6 +835,10 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_= t *); .driver =3D "hpet",\ .property =3D HPET_INTCAP,\ .value =3D stringify(4),\ + },{\ + .driver =3D TYPE_X86_CPU,\ + .property =3D "x-kvm-auto-enable-x2apic",\ + .value =3D "off",\ }, =20 #define PC_COMPAT_1_6 \ diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 0184f98241..7e5bf86921 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1267,6 +1267,15 @@ struct X86CPU { /* Stop SMI delivery for migration compatibility with old machines */ bool kvm_no_smi_migration; =20 + /* KVM automatically disables SVM if not explicitly enabled by user */ + bool kvm_auto_disable_svm; + + /* KVM automatically enables x2apic if not explicitly disabled by user= */ + bool kvm_auto_enable_x2apic; + + /* KVM automatically enables kvm-pv-eoi if not explicitly disabled by = user */ + bool kvm_auto_enable_pv_eoi; + /* Number of physical address bits supported */ uint32_t phys_bits; =20 @@ -1700,14 +1709,6 @@ void apic_handle_tpr_access_report(DeviceState *d, t= arget_ulong ip, TPRAccess access); =20 =20 -/* - * Compat globals to control features automatically enabled/disabled by KV= M. - * TODO: convert them to X86CPU fields set by MachineClass::compat_props - */ -extern bool kvm_auto_disable_svm; -extern bool kvm_auto_enable_x2apic; -extern bool kvm_auto_enable_pv_eoi; - /* mpx_helper.c */ void cpu_sync_bndcs_hflags(CPUX86State *env); =20 diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 3e466b3896..e0ce633876 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -328,7 +328,6 @@ static void pc_compat_2_2(MachineState *machine) static void pc_compat_2_1(MachineState *machine) { pc_compat_2_2(machine); - kvm_auto_disable_svm =3D false; } =20 static void pc_compat_2_0(MachineState *machine) @@ -339,7 +338,6 @@ static void pc_compat_2_0(MachineState *machine) static void pc_compat_1_7(MachineState *machine) { pc_compat_2_0(machine); - kvm_auto_enable_x2apic =3D false; } =20 static void pc_compat_1_6(MachineState *machine) @@ -367,7 +365,6 @@ static void pc_compat_1_3(MachineState *machine) static void pc_compat_1_2(MachineState *machine) { pc_compat_1_3(machine); - kvm_auto_enable_pv_eoi =3D false; } =20 /* PC compat function for pc-0.10 to pc-0.13 */ @@ -705,6 +702,10 @@ DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3, .driver =3D "VGA",\ .property =3D "mmio",\ .value =3D "off",\ + },{\ + .driver =3D TYPE_X86_CPU,\ + .property =3D "x-kvm-auto-enable-pv-eoi",\ + .value =3D "off",\ }, =20 static void pc_i440fx_1_2_machine_options(MachineClass *m) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 83e234cef4..2160738a37 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1583,10 +1583,6 @@ static PropValue kvm_default_props[] =3D { { NULL, NULL }, }; =20 -bool kvm_auto_disable_svm =3D true; -bool kvm_auto_enable_x2apic =3D true; -bool kvm_auto_enable_pv_eoi =3D true; - /* TCG-specific defaults that override all CPU models when using TCG */ static PropValue tcg_default_props[] =3D { @@ -3502,20 +3498,20 @@ static void x86_cpu_expand_features(X86CPU *cpu, Er= ror **errp) * defaults, so we check xcc->cpu_def here. */ if (xcc->cpu_def && kvm_enabled()) { - /* KVM-specific defaults that depend on compatibility globals: */ + /* KVM-specific defaults that depend on compatibility properties: = */ =20 if (!kvm_irqchip_in_kernel()) { x86_cpu_expand_feature(cpu, FEAT_1_ECX, CPUID_EXT_X2APIC, 0); - } else if (kvm_auto_enable_x2apic) { + } else if (cpu->kvm_auto_enable_x2apic) { x86_cpu_expand_feature(cpu, FEAT_1_ECX, CPUID_EXT_X2APIC, CPUID_EXT_X2APIC); } =20 - if (kvm_auto_disable_svm) { + if (cpu->kvm_auto_disable_svm) { x86_cpu_expand_feature(cpu, FEAT_8000_0001_ECX, CPUID_EXT3_SVM= , 0); } =20 - if (kvm_auto_enable_pv_eoi) { + if (cpu->kvm_auto_enable_pv_eoi) { x86_cpu_expand_feature(cpu, FEAT_KVM, (1 << KVM_FEATURE_PV_EOI= ), (1 << KVM_FEATURE_PV_EOI)); } @@ -4162,6 +4158,12 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_BOOL("l3-cache", X86CPU, enable_l3_cache, true), DEFINE_PROP_BOOL("kvm-no-smi-migration", X86CPU, kvm_no_smi_migration, false), + DEFINE_PROP_BOOL("x-kvm-auto-disable-svm", + X86CPU, kvm_auto_disable_svm, true), + DEFINE_PROP_BOOL("x-kvm-auto-enable-x2apic", + X86CPU, kvm_auto_enable_x2apic, true), + DEFINE_PROP_BOOL("x-kvm-auto-enable-pv-eoi", + X86CPU, kvm_auto_enable_pv_eoi, true), DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true), DEFINE_PROP_BOOL("tcg-cpuid", X86CPU, expose_tcg, true), =20 --=20 2.13.6 From nobody Mon May 6 11:19:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507327024323222.98256374428956; Fri, 6 Oct 2017 14:57:04 -0700 (PDT) Received: from localhost ([::1]:47274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0ac6-0006mw-MT for importer@patchew.org; Fri, 06 Oct 2017 17:56:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e0aYY-000497-Ss for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e0aYU-0001ll-0c for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44024) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e0aYT-0001lL-OK for qemu-devel@nongnu.org; Fri, 06 Oct 2017 17:53:13 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1CAD6408E; Fri, 6 Oct 2017 21:53:12 +0000 (UTC) Received: from localhost (ovpn-116-25.gru2.redhat.com [10.97.116.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78BDC5D753; Fri, 6 Oct 2017 21:53:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C1CAD6408E Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 6 Oct 2017 18:52:44 -0300 Message-Id: <20171006215244.27104-8-ehabkost@redhat.com> In-Reply-To: <20171006215244.27104-1-ehabkost@redhat.com> References: <20171006215244.27104-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 06 Oct 2017 21:53:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 7/7] target/i386: Enable kvm_pv_unhalt by default X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Alexander Graf , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Original description of a patch by Alexander Graf that did something similar: Commit f010bc643a (target-i386: add feature kvm_pv_unhalt) introduced the kvm_pv_unhalt feature but didn't enable it by default. Without kvm_pv_unhalt we see a measurable degradation in scheduling performance, so enabling it by default does make sense IMHO. This patch just flips it to default to on by default. [With kvm_pv_unhalt disabled] $ perf bench sched messaging -l 10000 Total time: 8.573 [sec] [With kvm_pv_unhalt enabled] $ perf bench sched messaging -l 10000 Total time: 4.416 [sec] This patch does the same as that patch, but using a kvm_auto_enable_pv_unhalt flag to keep compatibility on older machine-types. kvm_pv_unhalt support was added to Linux on v3.12 (Linux commit 6aef266c6e17b798a1740cf70cd34f90664740b3), so update the system requirements section in qemu-doc.texi accordingly. Suggested-by: Alexander Graf Cc: Alexander Graf Signed-off-by: Eduardo Habkost --- include/hw/i386/pc.h | 4 ++++ target/i386/cpu.h | 3 +++ target/i386/cpu.c | 7 +++++++ qemu-doc.texi | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index d2742dd0bc..19b42de224 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -375,6 +375,10 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_= t *); .driver =3D TYPE_X86_CPU,\ .property =3D "x-hv-max-vps",\ .value =3D "0x40",\ + },{\ + .driver =3D TYPE_X86_CPU,\ + .property =3D "x-kvm-auto-enable-pv-unhalt",\ + .value =3D "off",\ }, =20 #define PC_COMPAT_2_9 \ diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 7e5bf86921..db1eecff00 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1276,6 +1276,9 @@ struct X86CPU { /* KVM automatically enables kvm-pv-eoi if not explicitly disabled by = user */ bool kvm_auto_enable_pv_eoi; =20 + /* KVM automatically enables kvm-pv-unhalt if not explicitly disabled = */ + bool kvm_auto_enable_pv_unhalt; + /* Number of physical address bits supported */ uint32_t phys_bits; =20 diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 2160738a37..7461c2a25e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3515,6 +3515,11 @@ static void x86_cpu_expand_features(X86CPU *cpu, Err= or **errp) x86_cpu_expand_feature(cpu, FEAT_KVM, (1 << KVM_FEATURE_PV_EOI= ), (1 << KVM_FEATURE_PV_EOI)); } + + if (cpu->kvm_auto_enable_pv_unhalt) { + x86_cpu_expand_feature(cpu, FEAT_KVM, (1 << KVM_FEATURE_PV_UNH= ALT), + (1 << KVM_FEATURE_PV_UNHALT)); + } } =20 /*TODO: Now cpu->max_features doesn't overwrite features @@ -4164,6 +4169,8 @@ static Property x86_cpu_properties[] =3D { X86CPU, kvm_auto_enable_x2apic, true), DEFINE_PROP_BOOL("x-kvm-auto-enable-pv-eoi", X86CPU, kvm_auto_enable_pv_eoi, true), + DEFINE_PROP_BOOL("x-kvm-auto-enable-pv-unhalt", + X86CPU, kvm_auto_enable_pv_unhalt, true), DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true), DEFINE_PROP_BOOL("tcg-cpuid", X86CPU, expose_tcg, true), =20 diff --git a/qemu-doc.texi b/qemu-doc.texi index be45b6b6f6..73c831383a 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -2355,7 +2355,7 @@ Run the emulation in single step mode. @section KVM kernel module =20 On x86_64 hosts, the default set of CPU features enabled by the KVM accele= rator -require the host to be running Linux v3.6 or newer. +require the host to be running Linux v3.12 or newer. =20 =20 @include qemu-tech.texi --=20 2.13.6