Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4803081ooa; Tue, 14 Aug 2018 10:45:51 -0700 (PDT) X-Google-Smtp-Source: AA+uWPx26AF1EyDAWoA0fltVuatxZqK5PVA2jmXXMwTjKsIfuyKjY7BPS6+MY5E8c1iLCEpFrsKr X-Received: by 2002:a17:902:6845:: with SMTP id f5-v6mr21180961pln.173.1534268751532; Tue, 14 Aug 2018 10:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268751; cv=none; d=google.com; s=arc-20160816; b=C3EwodE+qUrNMddV+OhATFvjl7Ih3Ox/hGwfHx4FFhvoXvBbb4twh/qIQZoh2QnxHe HctVjdb4i2HWDd93gmS0wQ+bwbSU5WeMm+MYayEdSOZhDi8mZaiY3V3K+CYSXuk7QyZp cF392X1jZDohjr2qv3U49pNCWkh9WzZZXMBzZ1kfITscU/kFqzhoOslpqR3dOiSjya/v QLzWPs4RT3SO3e/t3NT6YQblh8zeBBMlTvzwV8Oapcg16MQoXq37uGfi8VUxcNwrtDp8 /WKeYBwat0neoxLmQCOT742gfWRYGlErdwBa2pqupVXgA1UlGHx56lFMqgIlvdK9L215 bW0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=f1xRm7BS7FkXoo/9vH+S2xIXw+k7axoBbdKjbleGpcc=; b=fibQN2JExsvhxKMXlrkc+TivqIX7OFVIuv3aZXbCatX3H4htSwcr5QnVrr/Y5+WWzz BICPRnd1j0UWz4YwjzpfRT9u93SqTDcIDSyzo67Z2ybw+X9UqEcd5HZi8fTjAhJPv8PP b/2dJyH/MDE6/JOrUSnhMCI2oo1PwcuOMITXsYTEtrpB/iIlHqcobEpwMsriOCUBBqC+ FfRZvSPAX7oaj7Qz3NbzmYmhGWR3/3adeRINX/aN9YT9VV9YhUQdVUj60iN5zwrjR+5v DK0tf8/YhmcglgF2SC4q9WG/3Cj/bLzMTLoTF7sBLdyaM1knOT3PQFu5KBOVX1hGuNx6 U0Yw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f62-v6si23810210pfb.218.2018.08.14.10.45.36; Tue, 14 Aug 2018 10:45:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390776AbeHNUcv (ORCPT + 99 others); Tue, 14 Aug 2018 16:32:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60068 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728642AbeHNUcu (ORCPT ); Tue, 14 Aug 2018 16:32:50 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3590F40B; Tue, 14 Aug 2018 17:44:37 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konrad Rzeszutek Wilk , Thomas Gleixner , David Woodhouse Subject: [PATCH 4.9 057/107] x86/KVM: Warn user if KVM is loaded SMT and L1TF CPU bug being present Date: Tue, 14 Aug 2018 19:17:20 +0200 Message-Id: <20180814171524.572304091@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171520.883143803@linuxfoundation.org> References: <20180814171520.883143803@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Konrad Rzeszutek Wilk commit 26acfb666a473d960f0fd971fe68f3e3ad16c70b upstream If the L1TF CPU bug is present we allow the KVM module to be loaded as the major of users that use Linux and KVM have trusted guests and do not want a broken setup. Cloud vendors are the ones that are uncomfortable with CVE 2018-3620 and as such they are the ones that should set nosmt to one. Setting 'nosmt' means that the system administrator also needs to disable SMT (Hyper-threading) in the BIOS, or via the 'nosmt' command line parameter, or via the /sys/devices/system/cpu/smt/control. See commit 05736e4ac13c ("cpu/hotplug: Provide knobs to control SMT"). Other mitigations are to use task affinity, cpu sets, interrupt binding, etc - anything to make sure that _only_ the same guests vCPUs are running on sibling threads. Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Thomas Gleixner Signed-off-by: David Woodhouse Signed-off-by: Greg Kroah-Hartman --- Documentation/kernel-parameters.txt | 6 ++++++ arch/x86/kvm/vmx.c | 19 +++++++++++++++++++ kernel/cpu.c | 1 + 3 files changed, 26 insertions(+) --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -1989,6 +1989,12 @@ bytes respectively. Such letter suffixes for all guests. Default is 1 (enabled) if in 64-bit or 32-bit PAE mode. + kvm-intel.nosmt=[KVM,Intel] If the L1TF CPU bug is present (CVE-2018-3620) + and the system has SMT (aka Hyper-Threading) enabled then + don't allow guests to be created. + + Default is 0 (allow guests to be created). + kvm-intel.ept= [KVM,Intel] Disable extended page tables (virtualized MMU) support on capable Intel chips. Default is 1 (enabled) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -69,6 +69,9 @@ static const struct x86_cpu_id vmx_cpu_i }; MODULE_DEVICE_TABLE(x86cpu, vmx_cpu_id); +static bool __read_mostly nosmt; +module_param(nosmt, bool, S_IRUGO); + static bool __read_mostly enable_vpid = 1; module_param_named(vpid, enable_vpid, bool, 0444); @@ -9298,6 +9301,20 @@ free_vcpu: return ERR_PTR(err); } +#define L1TF_MSG "SMT enabled with L1TF CPU bug present. Refer to CVE-2018-3620 for details.\n" + +static int vmx_vm_init(struct kvm *kvm) +{ + if (boot_cpu_has(X86_BUG_L1TF) && cpu_smt_control == CPU_SMT_ENABLED) { + if (nosmt) { + pr_err(L1TF_MSG); + return -EOPNOTSUPP; + } + pr_warn(L1TF_MSG); + } + return 0; +} + static void __init vmx_check_processor_compat(void *rtn) { struct vmcs_config vmcs_conf; @@ -11367,6 +11384,8 @@ static struct kvm_x86_ops vmx_x86_ops __ .cpu_has_accelerated_tpr = report_flexpriority, .has_emulated_msr = vmx_has_emulated_msr, + .vm_init = vmx_vm_init, + .vcpu_create = vmx_create_vcpu, .vcpu_free = vmx_free_vcpu, .vcpu_reset = vmx_vcpu_reset, --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -358,6 +358,7 @@ EXPORT_SYMBOL_GPL(cpu_hotplug_enable); #ifdef CONFIG_HOTPLUG_SMT enum cpuhp_smt_control cpu_smt_control __read_mostly = CPU_SMT_ENABLED; +EXPORT_SYMBOL_GPL(cpu_smt_control); static int __init smt_cmdline_disable(char *str) {