From patchwork Fri Oct 3 19:39:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 396425 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 87ED0140174 for ; Sat, 4 Oct 2014 05:41:59 +1000 (EST) Received: from localhost ([::1]:41015 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xa8jl-00083N-OF for incoming@patchwork.ozlabs.org; Fri, 03 Oct 2014 15:41:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xa8iS-0006GI-4B for qemu-devel@nongnu.org; Fri, 03 Oct 2014 15:40:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xa8iK-0003Ae-9Y for qemu-devel@nongnu.org; Fri, 03 Oct 2014 15:40:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63539) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xa8iJ-0003AM-Rn for qemu-devel@nongnu.org; Fri, 03 Oct 2014 15:40:28 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s93JeIiC009292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Oct 2014 15:40:18 -0400 Received: from localhost (ovpn-113-54.phx2.redhat.com [10.3.113.54]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s93JeHB0010476; Fri, 3 Oct 2014 15:40:17 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Fri, 3 Oct 2014 16:39:51 -0300 Message-Id: <1412365191-22858-7-git-send-email-ehabkost@redhat.com> In-Reply-To: <1412365191-22858-1-git-send-email-ehabkost@redhat.com> References: <1412365191-22858-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , kvm@vger.kernel.org, Aurelien Jarno Subject: [Qemu-devel] [PATCH v3 6/6] target-i386: Disable SVM by default in KVM mode 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 Make SVM be disabled by default on all CPU models when in KVM mode. Nested SVM is enabled by default in the KVM kernel module, but it is probably less stable than nested VMX (which is already disabled by default). Add a new compat function, x86_cpu_compat_kvm_no_autodisable(), to keep compatibility on previous machine-types. Suggested-by: Paolo Bonzini Signed-off-by: Eduardo Habkost --- hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + target-i386/cpu.c | 6 ++++++ target-i386/cpu.h | 1 + 4 files changed, 9 insertions(+) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 1d5d57e..70027b9 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -306,6 +306,7 @@ static void pc_compat_2_1(MachineState *machine) { x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VMX, 0); x86_cpu_compat_set_features("core2duo", FEAT_1_ECX, CPUID_EXT_VMX, 0); + x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM); } static void pc_compat_2_0(MachineState *machine) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index c8f7a88..f923a9e 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -280,6 +280,7 @@ static void pc_compat_2_1(MachineState *machine) { x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VMX, 0); x86_cpu_compat_set_features("core2duo", FEAT_1_ECX, CPUID_EXT_VMX, 0); + x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM); } static void pc_compat_2_0(MachineState *machine) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index c336003..986a94f 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -463,6 +463,7 @@ static uint32_t kvm_default_features[FEATURE_WORDS] = { static uint32_t kvm_default_unset_features[FEATURE_WORDS] = { [FEAT_1_EDX] = CPUID_ACPI, [FEAT_1_ECX] = CPUID_EXT_MONITOR, + [FEAT_8000_0001_ECX] = CPUID_EXT3_SVM, }; void x86_cpu_compat_kvm_no_autoenable(FeatureWord w, uint32_t features) @@ -470,6 +471,11 @@ void x86_cpu_compat_kvm_no_autoenable(FeatureWord w, uint32_t features) kvm_default_features[w] &= ~features; } +void x86_cpu_compat_kvm_no_autodisable(FeatureWord w, uint32_t features) +{ + kvm_default_unset_features[w] &= ~features; +} + /* * Returns the set of feature flags that are supported and migratable by * QEMU, for a given FeatureWord. diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 8d932ae..8a9b70f 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -1305,6 +1305,7 @@ void x86_cpu_compat_set_features(const char *cpu_model, FeatureWord w, uint32_t feat_add, uint32_t feat_remove); void x86_cpu_compat_kvm_no_autoenable(FeatureWord w, uint32_t features); +void x86_cpu_compat_kvm_no_autodisable(FeatureWord w, uint32_t features); /* Return name of 32-bit register, from a R_* constant */