From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E584BC4167B for ; Fri, 1 Dec 2023 20:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379581AbjLAUDK (ORCPT ); Fri, 1 Dec 2023 15:03:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379565AbjLAUDK (ORCPT ); Fri, 1 Dec 2023 15:03:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4798CB2 for ; Fri, 1 Dec 2023 12:03:16 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAE5EC433C7; Fri, 1 Dec 2023 20:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701460995; bh=zlGJvgaDfOaydmVhAssBO1Q2xtvGzqBX82vPMeow6H8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kBUFM1U32mC5a5kuNSctBT/Fei8oX4ETaFZtXddMPB++K5JXpgPLe/pJmjPb6seMc LLxZ7zrTSEOFyYMDddaolGtJTT6BWMxR8MEtaIjW89DIZ/nl7F4kWfcABWasD/X6Uu RwJXWG5HphFmZXVTwMZQMLnJswrQI4jFBKkbwH64zOgUU1b/R/sUdgRDfwIglc3A1u /asI/HVmSEXQPIO0P7T8f2aCUej/5vQRM2qitHnCTk9KdHn8NE4aRHQwt61i1qdIfa GPVQzyWlFAWE83+BsHHiaWNaDYjK0qFsGyJMuztArG9nvN2VTEp4A9TFcgKPDCBU/A K6w/DEyCt32og== Date: Fri, 1 Dec 2023 12:02:47 -0800 From: Josh Poimboeuf To: Pawan Gupta Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Andy Lutomirski , Jonathan Corbet , Sean Christopherson , Paolo Bonzini , tony.luck@intel.com, ak@linux.intel.com, tim.c.chen@linux.intel.com, Andrew Cooper , Nikolay Borisov , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, Alyssa Milburn , Daniel Sneddon , antonio.gomez.iglesias@linux.intel.com, Greg Kroah-Hartman Subject: Re: [PATCH v4 6/6] KVM: VMX: Move VERW closer to VMentry for MDS mitigation Message-ID: <20231201200247.vui6enzdj5nzctf4@treble> References: <20231027-delay-verw-v4-0-9a3622d4bcf7@linux.intel.com> <20231027-delay-verw-v4-6-9a3622d4bcf7@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231027-delay-verw-v4-6-9a3622d4bcf7@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 27, 2023 at 07:39:12AM -0700, Pawan Gupta wrote: > - vmx_disable_fb_clear(vmx); > + /* > + * Optimize the latency of VERW in guests for MMIO mitigation. Skip > + * the optimization when MDS mitigation(later in asm) is enabled. > + */ > + if (!cpu_feature_enabled(X86_FEATURE_CLEAR_CPU_BUF)) > + vmx_disable_fb_clear(vmx); > > if (vcpu->arch.cr2 != native_read_cr2()) > native_write_cr2(vcpu->arch.cr2); > @@ -7248,7 +7256,8 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu, > > vmx->idt_vectoring_info = 0; > > - vmx_enable_fb_clear(vmx); > + if (!cpu_feature_enabled(X86_FEATURE_CLEAR_CPU_BUF)) > + vmx_enable_fb_clear(vmx); > It may be cleaner to instead check X86_FEATURE_CLEAR_CPU_BUF when setting vmx->disable_fb_clear in the first place, in vmx_update_fb_clear_dis(). -- Josh