Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4802858ooa; Tue, 14 Aug 2018 10:45:39 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyYJi2bxRX9+E1vtOI+idW1zWevfOAFVF6stUAJ6m4vVK1jeXVGgw7sy2teRdvJuYwLHcnz X-Received: by 2002:a63:4f1a:: with SMTP id d26-v6mr22349664pgb.121.1534268739150; Tue, 14 Aug 2018 10:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268739; cv=none; d=google.com; s=arc-20160816; b=eQcEhyCsSePvesU6Potvy6qC4hpZtJxmxiFiLMXZykeFC1z9MUTrD1Jj2YblVjH7LX UiO90I3t7ISwvml17zL/W54t2ebDz6ROdik8XZBL5s3qz16KqVBeGxLd9T16uBXY72hv J00Xp32Dbbw/5P28kZc5T805mU2Y1HB6fttDXRwR3FZGMXwMP5XhcZDS+RjE0Yr3dP+Q JGGeph8NgNbKkndwLY2GyWkR/zsScbQ9ZfyM4brlXLgPh0NeAaN8hH20J5NFfJHyFUDx 9Uz2lFuN9M/ZjhSz4oNSIe3WtDLKHOSXB07qi4TKaN+FKog9BxYG3REKYR6vXlK41mlL 2hZA== 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=tEN/Czsmm8EEhEC47is3yHojulhWF11iGy3MxWLItpA=; b=dDXqJM09IAQE+Z4DNNe/JzZNa2h6hz/MPpCNlbwTA7j1rpoldQwMexp7SfYgnhjjST aJI1d4BDe+/6bCWvlIMlgnHkLsBTtUex2vtkqqC/83MYxz03e6tNqJxdl1FlS/kRhfx2 QYm06vWLZB+i8BMeaaREbh8vvP5bMLLTsn/HwlLOcuig3eRady1MlE7ZKTXLWzVBOy5g 843iolMPLUqHfwnmSUtA9NVPeOStKdXb04qE8P4iotx+zjIZz3KuZXuAz0fSqnM660cm bqfpXYAxCzJyPYfDNd2xdR80rnk4vfEVUHuoPBF7R1TW+kfW5Phz257xusHKR3/3DTuU wtcQ== 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 w14-v6si17335802pgv.462.2018.08.14.10.45.24; Tue, 14 Aug 2018 10:45:39 -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 S2390671AbeHNUcL (ORCPT + 99 others); Tue, 14 Aug 2018 16:32:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59936 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728642AbeHNUcL (ORCPT ); Tue, 14 Aug 2018 16:32:11 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9CC29C8D; Tue, 14 Aug 2018 17:43:59 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolai Stange , Thomas Gleixner , David Woodhouse Subject: [PATCH 4.9 085/107] x86/KVM/VMX: Move the l1tf_flush_l1d test to vmx_l1d_flush() Date: Tue, 14 Aug 2018 19:17:48 +0200 Message-Id: <20180814171525.970338209@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: Nicolai Stange commit 5b6ccc6c3b1a477fbac9ec97a0b4c1c48e765209 upstream Currently, vmx_vcpu_run() checks if l1tf_flush_l1d is set and invokes vmx_l1d_flush() if so. This test is unncessary for the "always flush L1D" mode. Move the check to vmx_l1d_flush()'s conditional mode code path. Notes: - vmx_l1d_flush() is likely to get inlined anyway and thus, there's no extra function call. - This inverts the (static) branch prediction, but there hadn't been any explicit likely()/unlikely() annotations before and so it stays as is. Signed-off-by: Nicolai Stange Signed-off-by: Thomas Gleixner Signed-off-by: David Woodhouse Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -8667,12 +8667,16 @@ static void vmx_l1d_flush(struct kvm_vcp * 'always' */ if (static_branch_likely(&vmx_l1d_flush_cond)) { + bool flush_l1d = vcpu->arch.l1tf_flush_l1d; + /* * Clear the flush bit, it gets set again either from * vcpu_run() or from one of the unsafe VMEXIT * handlers. */ vcpu->arch.l1tf_flush_l1d = false; + if (!flush_l1d) + return; } vcpu->stat.l1d_flush++; @@ -9162,10 +9166,8 @@ static void __noclone vmx_vcpu_run(struc vmx->__launched = vmx->loaded_vmcs->launched; - if (static_branch_unlikely(&vmx_l1d_should_flush)) { - if (vcpu->arch.l1tf_flush_l1d) - vmx_l1d_flush(vcpu); - } + if (static_branch_unlikely(&vmx_l1d_should_flush)) + vmx_l1d_flush(vcpu); asm( /* Store host registers */