Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4837983ooa; Tue, 14 Aug 2018 11:13:52 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxb/SVH695kknDxH5kTh2HOJn3ThKYv2hksghkndcBnUolWJMNpDeBehDvAsNi78YAx7Sp7 X-Received: by 2002:a17:902:7584:: with SMTP id j4-v6mr21550258pll.184.1534270432375; Tue, 14 Aug 2018 11:13:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534270432; cv=none; d=google.com; s=arc-20160816; b=FTybqOFzL/6Mzg2ztNppNZ5L0+3ptFzeWrOBv7zwWfTbVOApKPQCgS7VLU6WQznAJ/ /xDmIsJzzwbd88jnuQNqCZWqMEAsym99BVRU8BtLtvHE2sJWgjuisT6O3ivOL6cxcWnl BXKwDAou9q03658022ZWU7u3HVzc5xKoMKlaNG4gGJYV+6hANUBquQ48TkDjRFpUIC4y kajDk2iBpiOrERwRIwYuxWGhxOh5LazplUuPpZGrbbddUt3e9Rh4Iq1lZPJliKCCGStR vvPQ+kJ8AyBUsbXdajND1Y2g0i1/0LQyj27aIoGqG3cV5wJOOsBjj8jLl7P9wVSlejLt xUVQ== 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=PTesR90xAUMMPLaTj9qcXIZMsSvVBZN5ARMxF9+7TGI=; b=ErnI2gmlV+Ipac32blhoQblqU1jlQzCtCPby/Bv9WwWZ5DI+TlDepJist6wpnEEZUR iNDR+qbhkXx8oRtl+O+eXTsRZ6h3L3B7YX6d/mGAJE/TMzhMfTpjeny4w6QMcu+9ieZ0 ji+RVvRdLvOj+4OdeQ3V8u5Fq3BKEhpz8naarq5NGOBtOrOuWsiz9iBe9Ot5DXRJdQTR /0EyAFMbt+lvU+vGjPCjJKL+J0w1O49r6h1cXC31PxUZmM8LCnKunfeTTtgWgTbrfoq6 gfO3s9BR0lM25T0ztfgcwOfq7zYXhApGRiRRys0i7QVHVTY+ERe4AF29yA4a/7rxkEGA V5kg== 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 2-v6si22872838pfd.39.2018.08.14.11.13.37; Tue, 14 Aug 2018 11:13:52 -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 S2388425AbeHNUO0 (ORCPT + 99 others); Tue, 14 Aug 2018 16:14:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51958 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387440AbeHNUOZ (ORCPT ); Tue, 14 Aug 2018 16:14:25 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C9C16CD8; Tue, 14 Aug 2018 17:26:18 +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 Subject: [PATCH 4.18 50/79] x86/kvm: Add static key for flush always Date: Tue, 14 Aug 2018 19:17:09 +0200 Message-Id: <20180814171339.168012604@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171336.799314117@linuxfoundation.org> References: <20180814171336.799314117@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner Avoid the conditional in the L1D flush control path. 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.790914912@linutronix.de Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -192,6 +192,7 @@ module_param(ple_window_max, uint, 0444) extern const ulong vmx_return; static DEFINE_STATIC_KEY_FALSE(vmx_l1d_should_flush); +static DEFINE_STATIC_KEY_FALSE(vmx_l1d_flush_always); /* Storage for pre module init parameter parsing */ static enum vmx_l1d_flush_state __read_mostly vmentry_l1d_flush_param = VMENTER_L1D_FLUSH_AUTO; @@ -232,8 +233,12 @@ static int vmx_setup_l1d_flush(enum vmx_ l1tf_vmx_mitigation = l1tf; - if (l1tf != VMENTER_L1D_FLUSH_NEVER) - static_branch_enable(&vmx_l1d_should_flush); + if (l1tf == VMENTER_L1D_FLUSH_NEVER) + return 0; + + static_branch_enable(&vmx_l1d_should_flush); + if (l1tf == VMENTER_L1D_FLUSH_ALWAYS) + static_branch_enable(&vmx_l1d_flush_always); return 0; } @@ -9687,7 +9692,6 @@ static void *vmx_l1d_flush_pages; static void vmx_l1d_flush(struct kvm_vcpu *vcpu) { int size = PAGE_SIZE << L1D_CACHE_ORDER; - bool always; /* * This code is only executed when the the flush mode is 'cond' or @@ -9697,8 +9701,10 @@ static void vmx_l1d_flush(struct kvm_vcp * it. The flush bit gets set again either from vcpu_run() or from * one of the unsafe VMEXIT handlers. */ - always = l1tf_vmx_mitigation == VMENTER_L1D_FLUSH_ALWAYS; - vcpu->arch.l1tf_flush_l1d = always; + if (static_branch_unlikely(&vmx_l1d_flush_always)) + vcpu->arch.l1tf_flush_l1d = true; + else + vcpu->arch.l1tf_flush_l1d = false; vcpu->stat.l1d_flush++;