Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp665116rdh; Thu, 26 Oct 2023 12:08:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJKA2hWHi+XYs+hIYtkEb+5p20Y7DzCQxAERpfDeTd/VGVD4yEM4GwuVMFaEIuFsBgPoos X-Received: by 2002:a67:e114:0:b0:457:dbed:3a23 with SMTP id d20-20020a67e114000000b00457dbed3a23mr653138vsl.5.1698347321421; Thu, 26 Oct 2023 12:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698347321; cv=none; d=google.com; s=arc-20160816; b=afamHEDG9yDh26rbaW/MYKlMc0gyjjmw79FKrnnkOo0hHuVuMkTqHtEHA/K//17TEg kxtknE2Hdc9VKcI+be9ecLaM09YtKPgv+BeBk67bLtC12tyxCOwrZfaCLIsW+RGlsnbM n5NJudey4DQDW+C1hybAnhZmORnVD/R7cbJfyaaSPRnWxL/otRWyH7jRsTNhUXSrwKVv 5P/0vXgXbSVEwn6hzzFjeDh0awdHddINBCUTTzbKILr7PlLOFjBxeTsyoIFCLnVd9Wd4 P7PoBrfWjfbOdW2Bk5gR/d1tbdwpyMRLOUup4Iru1BEsgZ7TYgK+xONXnO/16iKy3v/c dIJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MgyzAcD5exBgiA8X5H64e7gj6FZ9RD2kMItLfrQZNSU=; fh=sP/t8HTKRedcCjlFp35ITDXBC/gSq191ytq5zIxPt60=; b=fXeoyeiXckDlXK7g2SYAt04vcRmpz/iBrhcR/MNoKX5bto6AKlDKjc51O672KNfjZS oYLCOt17HyzXZNwfJ5S9eccX/DL5ouGSMhN+SiKxhsX6CdgT9RUrfyuWD7Ad8QGOhzmV IjOioKqNfcV+2MbJs9/WsUYsNKSqLo/rB9/ZbIgfrO3/Se0V/ashMVm4XujcrgNvSIN7 KPwuRBOvTVNRR3VuUFA4OplQHs+qGzh3a/rtGhNNLXWog12CKdChtSP2nrj8ZhcZlGnk 9LdosabgGHbN18g0juhiLC2GrQWsX8Ml8NITH79ivh4eQVOA9iK3lvJLF918vIsapSh0 5xtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=I7bwyw67; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id d19-20020ab066d3000000b007b6c5086219si4uaq.65.2023.10.26.12.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 12:08:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=I7bwyw67; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 02B698246305; Thu, 26 Oct 2023 12:08:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230143AbjJZTHr (ORCPT + 99 others); Thu, 26 Oct 2023 15:07:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjJZTHp (ORCPT ); Thu, 26 Oct 2023 15:07:45 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 938EE1A7; Thu, 26 Oct 2023 12:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698347263; x=1729883263; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=EudwDoXQoHWpwZgKKjX9dS2pYiAfR24L11Z2/3zbV8w=; b=I7bwyw67MS/143mOrWdCXTROBUXP+2wztrsr9s+0RUjl7F79FQ/ZgV9t uobgbfWGSoK2enaQWMWDZcfr2w6k/LCR485K1vDoEfxswsku/2T/M2+jP r7Sb6Wr671IdmGkguFI/7p7lAF9K0POqZcNSVU4//xn0FCWGVgT32p2Tk PXShy7PN+K6DfQZoLM32+NWh745nUgI0QpSQSeqmbmCn+49KhYv43Jbnt h80YwvZzXUQMtf4smMLpCfq09cRXT+nFTtxwYbtUsrnWPzRB4rnx0gJ8o 2ACOU/lkX2CBAnEKr38eGOoT55eWlzx3mnZ14iVvsBybkAPQGuh4VOk6t g==; X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="366977002" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="366977002" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 12:07:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="709184493" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="709184493" Received: from paseron-mobl4.amr.corp.intel.com (HELO desk) ([10.209.17.113]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 12:07:42 -0700 Date: Thu, 26 Oct 2023 12:07:41 -0700 From: Pawan Gupta To: Nikolay Borisov Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Andy Lutomirski , Jonathan Corbet , Sean Christopherson , Paolo Bonzini , tony.luck@intel.com, ak@linux.intel.com, tim.c.chen@linux.intel.com, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, Alyssa Milburn , Daniel Sneddon , antonio.gomez.iglesias@linux.intel.com Subject: Re: [PATCH v3 6/6] KVM: VMX: Move VERW closer to VMentry for MDS mitigation Message-ID: <20231026190741.vwpyvp3nvyrlcmsp@desk> References: <20231025-delay-verw-v3-0-52663677ee35@linux.intel.com> <20231025-delay-verw-v3-6-52663677ee35@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 26 Oct 2023 12:08:22 -0700 (PDT) On Thu, Oct 26, 2023 at 07:14:18PM +0300, Nikolay Borisov wrote: > > if (static_branch_unlikely(&vmx_l1d_should_flush)) > > vmx_l1d_flush(vcpu); > > - else if (cpu_feature_enabled(X86_FEATURE_CLEAR_CPU_BUF)) > > - mds_clear_cpu_buffers(); > > else if (static_branch_unlikely(&mmio_stale_data_clear) && > > kvm_arch_has_assigned_device(vcpu->kvm)) > > + /* MMIO mitigation is mutually exclusive with MDS mitigation later in asm */ > > Mutually exclusive implies that you have one or the other but not both, > whilst I think the right formulation here is redundant? Because if mmio is > enabled mds_clear_cpu_buffers() will clear the buffers here and later > they'll be cleared again, no ? No, because when mmio_stale_data_clear is enabled, X86_FEATURE_CLEAR_CPU_BUF will not be set because of how mitigation is selected in mmio_select_mitigation(): mmio_select_mitigation() { ... /* * Enable CPU buffer clear mitigation for host and VMM if also affected * by MDS or TAA. Otherwise, enable mitigation for VMM only. */ if (boot_cpu_has_bug(X86_BUG_MDS) || (boot_cpu_has_bug(X86_BUG_TAA) && boot_cpu_has(X86_FEATURE_RTM))) setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF); else static_branch_enable(&mmio_stale_data_clear); > Alternatively you might augment this check to only execute iff > X86_FEATURE_CLEAR_CPU_BUF is not set? It already is like that due to the logic above. That is what the comment: /* MMIO mitigation is mutually exclusive with MDS mitigation later in asm */ ... is trying to convey. Suggestions welcome to improve the comment.