Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp284167rdb; Tue, 19 Dec 2023 17:26:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFY79CBvCNMZvlkAjW6WtxCCGPYnglx+eFVDcQa0fdOXXZBv6EV4BQaPgpdRcE7aa9mXheO X-Received: by 2002:a17:90b:31ce:b0:28a:e560:7ae8 with SMTP id jv14-20020a17090b31ce00b0028ae5607ae8mr6826374pjb.31.1703035580488; Tue, 19 Dec 2023 17:26:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703035580; cv=none; d=google.com; s=arc-20160816; b=SIFO5PVFoyuSVRPSOWrYGHkz3EziZZHILiL+k239IuJWs3q7AVB2pCslPQeuDWK0kn dCuMDOqLxZ5nXF//gPKEiCN6z/2/RYilX/grSCmgnfqwjpzSG0Vcpc6BWhKURrPeLPhl /EEkB1mhpFuF+FgiFnKq0rjqe3FaQWIhTtcgx1z/6NraqEfjq6kF7ZirTdr5xGIQkL8x rFIAMdgdHfyMO3lQVFFD7PeJzzEh5zfKZRiHtG8KcGylJCsetgXh3o8Jrb8asW0nFlul WMqk4k4DSrSkIVkHolFE3g+/O6yvk1gvGWuOMxpqad2sD4KWRUPJkpc675A8BXwdh3yl 5qAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=CuJR7p9brjpHXOOH1R++zWvl2pSpwXzedH3a2Pa2aVQ=; fh=hD2zoyUPh0+medhNybsfMIgEOjVXCMh4lnXTolpFOyA=; b=aWmVK96Jug2geoTs8RXNowJG1+/QbWpeef6zEXbtC3w/02hBIrYp1DWpGTeMdOa/R0 30/QHmcgJVxRV/12SyUrwfapbTqNESZIbyArBgkI5q3w1zVUgBIn6DYmYZagdh2UQUru qQ2J+4gZLEQwYWDp2LXxcxqQtL/YJ6x6raHPsSeVGqvMGebbKo4nu1sZwAAnVaHFZb3H becB0O2UgYyV8T6jpLQUNxTLdM/SzbENXqufLlT3Au0AbHyeiDc+rnCeEjjdX+nSHDpm qD7gd/VM7zZ2MBQzc/xiXozmGiL+eyDS3O5tYgUGmK8ZiIjBY35/zmof31J0y1OC31Xy Lwcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mgR2rS8W; spf=pass (google.com: domain of linux-kernel+bounces-6233-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6233-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ck24-20020a17090afe1800b0028b21fcb42bsi2023519pjb.173.2023.12.19.17.26.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 17:26:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6233-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mgR2rS8W; spf=pass (google.com: domain of linux-kernel+bounces-6233-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6233-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B1AABB24D1B for ; Wed, 20 Dec 2023 01:26:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EA20613E; Wed, 20 Dec 2023 01:26:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="mgR2rS8W" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF6C5567C; Wed, 20 Dec 2023 01:26:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703035567; x=1734571567; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=BB5xrxsz+BnW5YoyU869JFzcyH3wK7pydPymvf+6dm8=; b=mgR2rS8W867+Znl9NISgZMQM9uZBiieLYR3b07Ey7INDjUHqQKa0+n5f 9tGJ+TR5TzyBE8IsRaEFb/iNvTb4KWCHLbUsS4UIgXhEnnOJQFymBPxl6 gsGlqnOWJHX7nZ3qFaHVYtEsi0CXP5dp+fZxcMfezNaU//30x7vr6WNPT fxa+KEGCzYoruxSzenvJTR0CNpUQk3M/2tiNjz3XCgTRLGUf72HqxYKQ3 BqqjeNlxxpWs4J67ZZ0D0CdzUetSBoETqWWni4opH6N2Aw4qAkjigYW/Z wQiYRHpXiBeB9LTsQ+fgNIoWxEL30eFswuApwlqDgMVRW9jX1IMsQs6gI g==; X-IronPort-AV: E=McAfee;i="6600,9927,10929"; a="9207136" X-IronPort-AV: E=Sophos;i="6.04,290,1695711600"; d="scan'208";a="9207136" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2023 17:26:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10929"; a="899553838" X-IronPort-AV: E=Sophos;i="6.04,290,1695711600"; d="scan'208";a="899553838" Received: from ihur-mobl1.amr.corp.intel.com (HELO desk) ([10.209.1.244]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2023 17:26:05 -0800 Date: Tue, 19 Dec 2023 17:25:57 -0800 From: Pawan Gupta To: Josh Poimboeuf 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: <20231220012557.7myc7xy24tveaid6@desk> References: <20231027-delay-verw-v4-0-9a3622d4bcf7@linux.intel.com> <20231027-delay-verw-v4-6-9a3622d4bcf7@linux.intel.com> <20231201200247.vui6enzdj5nzctf4@treble> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231201200247.vui6enzdj5nzctf4@treble> On Fri, Dec 01, 2023 at 12:02:47PM -0800, Josh Poimboeuf wrote: > 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(). Right. Thanks for the review.