Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4801298ooa; Tue, 14 Aug 2018 10:44:28 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzfiT+k83ogR3Ue/CNDxPFV9Nv+0H73rSgqCASzVTsg7nms8GWiiQiHHEHUghIi2UrYfnmV X-Received: by 2002:a17:902:47c2:: with SMTP id d2-v6mr21036759plh.139.1534268668431; Tue, 14 Aug 2018 10:44:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268668; cv=none; d=google.com; s=arc-20160816; b=RxYdnNMchVBk8Rw6SyGMHVGBAfmvBNf/k7HKN3BDx+OqQMk0fw2F73ngDzxc9q3Gmz CCpD0FgcTZKW+EaEm2wMUk+Ofi6KsIAQUwn4xwh5fnV0XTG0GMgB48nhOn3F5tPwlOTC bSRTlsdCuC1BBlU8QG8xsMKVDqBesol5AiqOzoxboROmfHOdK0HuVVfbpnW5eFmOhmR3 ScyNJ8A8uRDYb6JnGkJ0bE5szPIGW2px49SmL42l0j37AHnwT0YFgrC/ttjOhbOINxy0 aQaCs+cLYIEHXWstg6XdOOsiwCEM4Ig0XGIzgOJOAvNCVKWy8jv8MQrLCe6DTCA+sF+5 vDKA== 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=8UsJScCMbtmS3ceh+Ojw4b2CilujvqfuVuD8YonOADY=; b=WHlOEYKUT0LYPugAdT0ds5Gj1aFhIq7DtX6eHL7dDUifeVM2fWMihk2R14JOTqrBWF unILfHt+vgM3P45qZSplsPakTouwh5UeAiy8CapQKju1/Ytpg067KS+RjaNSrb16n6OJ EEFpLiKNbEjYz/9cFtQyHjVqmunFjExoBPWiTxIzmK/LO62ouZTOBPiSXdZMeIOPdonx rNzy/wECpFGqzsEzu+gKDUz+6iOXP44w399CDr0rk9EPAWy4i8Pt/syCM6mfbp7j/qS/ KATP197SQuw9LyjXOuNut/qu6yZvkngM09oxOYR8dIj7LPkIAz7QwcMVwyOvwrbu1ip3 P0Ww== 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 j63-v6si19215859pgd.425.2018.08.14.10.44.13; Tue, 14 Aug 2018 10:44:28 -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 S2390545AbeHNUbd (ORCPT + 99 others); Tue, 14 Aug 2018 16:31:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59814 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728642AbeHNUbc (ORCPT ); Tue, 14 Aug 2018 16:31:32 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9F56940B; Tue, 14 Aug 2018 17:43:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , Jiri Kosina , Josh Poimboeuf , David Woodhouse Subject: [PATCH 4.9 075/107] x86/kvm: Allow runtime control of L1D flush Date: Tue, 14 Aug 2018 19:17:38 +0200 Message-Id: <20180814171525.353800323@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: Thomas Gleixner commit 895ae47f9918833c3a880fbccd41e0692b37e7d9 upstream All mitigation modes can be switched at run time with a static key now: - Use sysfs_streq() instead of strcmp() to handle the trailing new line from sysfs writes correctly. - Make the static key management handle multiple invocations properly. - Set the module parameter file to RW Signed-off-by: Thomas Gleixner Tested-by: Jiri Kosina Reviewed-by: Greg Kroah-Hartman Reviewed-by: Josh Poimboeuf Link: https://lkml.kernel.org/r/20180713142322.954525119@linutronix.de Signed-off-by: David Woodhouse Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/bugs.c | 2 +- arch/x86/kvm/vmx.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -638,7 +638,7 @@ void x86_spec_ctrl_setup_ap(void) #define pr_fmt(fmt) "L1TF: " fmt #if IS_ENABLED(CONFIG_KVM_INTEL) -enum vmx_l1d_flush_state l1tf_vmx_mitigation __ro_after_init = VMENTER_L1D_FLUSH_AUTO; +enum vmx_l1d_flush_state l1tf_vmx_mitigation = VMENTER_L1D_FLUSH_AUTO; EXPORT_SYMBOL_GPL(l1tf_vmx_mitigation); #endif --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -235,12 +235,15 @@ static int vmx_setup_l1d_flush(enum vmx_ l1tf_vmx_mitigation = l1tf; - if (l1tf == VMENTER_L1D_FLUSH_NEVER) - return 0; + if (l1tf != VMENTER_L1D_FLUSH_NEVER) + static_branch_enable(&vmx_l1d_should_flush); + else + static_branch_disable(&vmx_l1d_should_flush); - static_branch_enable(&vmx_l1d_should_flush); if (l1tf == VMENTER_L1D_FLUSH_ALWAYS) static_branch_enable(&vmx_l1d_flush_always); + else + static_branch_disable(&vmx_l1d_flush_always); return 0; } @@ -250,7 +253,7 @@ static int vmentry_l1d_flush_parse(const if (s) { for (i = 0; i < ARRAY_SIZE(vmentry_l1d_param); i++) { - if (!strcmp(s, vmentry_l1d_param[i].option)) + if (sysfs_streq(s, vmentry_l1d_param[i].option)) return vmentry_l1d_param[i].cmd; } } @@ -294,7 +297,7 @@ static const struct kernel_param_ops vme .set = vmentry_l1d_flush_set, .get = vmentry_l1d_flush_get, }; -module_param_cb(vmentry_l1d_flush, &vmentry_l1d_flush_ops, NULL, S_IRUGO); +module_param_cb(vmentry_l1d_flush, &vmentry_l1d_flush_ops, NULL, 0644); #define NR_AUTOLOAD_MSRS 8