Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4783473ooa; Tue, 14 Aug 2018 10:29:34 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyP2Ou5vHZPowVmXudnTdpCvSnuOlDy2Y6Tu8hroLpDHjtM0mE2v5ddLV2GGQ3cRIDZOk9r X-Received: by 2002:a63:d916:: with SMTP id r22-v6mr21543603pgg.381.1534267774092; Tue, 14 Aug 2018 10:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534267774; cv=none; d=google.com; s=arc-20160816; b=x1lRUySEbyr5lOJegMDmATo0W8RsIW86lj6173slQEqxl+xrr04R2GAs05RJm8ZSgX TbewiY6xh8cPINLi28DEN9Karnxy+3h3wpJDpubQGTe3U6cH9cj7UZZ/MFmmekeAgN3q EWWHBzGGjro02OYifBnOCiZvyehefL1OQ5MJOLkFskTkB8Li/p4smBrc/pRzSNwBjWmC uKqR6+YYCvVA7G01R1r6qARmHx9ZVVZQTI9VktiuoCaI2QsrT0OTnFl0UGLPckqMBcWa SnEMu3Kmv6t8zhw15xIWqmrg74nMn6jIuJdjXXypbGMc/VpFI9imzqJuM/CxPPlbnNQy YRyw== 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=6EvdcJ5pftdBYTy7A+kVs2RS8V4iQgf4f/IT/W2PMQw=; b=Srk/FXb0l//ceUGUZuQGfUltIuZ+9EOEQ2Mjcka+Fu/6WUW6IQMUrRCAWuhaZ5nCpM IPdZ5LNuYMTwV9aBFQVcPAx3Z6g14NxWsMvCLhd2H2aHarQjY0Ik9yYq7meIfpAhfBjN lIgRlSARnkdnBuTjn38ESTu0Jr3UKyPpQD4ZBzSfRJvesjvXdkXFg7EsrDY5ZuiNI2lZ L1rIF8SCNEWBysIVhB6FhJgZ9hLEp9rUYZUdmuJdi67pT4bNIGNxYzF5Yz4rF4JVdgzG 86Yd12IIQe4CknTPEPwG8KQaXHmR2KNsn0Ffg+BDtpuwABhG/AIZgLeODBYoyE2Sj4gM o+NQ== 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 l9-v6si17682659pgp.503.2018.08.14.10.29.18; Tue, 14 Aug 2018 10:29:34 -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 S2388650AbeHNUPM (ORCPT + 99 others); Tue, 14 Aug 2018 16:15:12 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52398 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388032AbeHNUPM (ORCPT ); Tue, 14 Aug 2018 16:15:12 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EB300CBB; Tue, 14 Aug 2018 17:27:05 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolai Stange , Thomas Gleixner Subject: [PATCH 4.18 63/79] x86/KVM/VMX: Move the l1tf_flush_l1d test to vmx_l1d_flush() Date: Tue, 14 Aug 2018 19:17:22 +0200 Message-Id: <20180814171340.315167477@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: Nicolai Stange 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: 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 @@ -9729,12 +9729,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++; @@ -10264,10 +10268,8 @@ static void __noclone vmx_vcpu_run(struc evmcs_rsp = static_branch_unlikely(&enable_evmcs) ? (unsigned long)¤t_evmcs->host_rsp : 0; - 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 */