Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp753856rdh; Thu, 26 Oct 2023 15:04:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvkJ7/DbdLT9vUATVapunrAeVcMtaKBnhIYQhaIwJ5p/hhp5kIZKq78apvG4Y+7UjpwSMX X-Received: by 2002:a05:620a:f05:b0:778:a66a:5a47 with SMTP id v5-20020a05620a0f0500b00778a66a5a47mr685529qkl.9.1698357844281; Thu, 26 Oct 2023 15:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698357844; cv=none; d=google.com; s=arc-20160816; b=qH7/61tHIgtLqHIfe7bIuL372NZfT+rfZMjpq5CjL5mr/UlWyxx1tmqy500JbogNbl Q0j8g8JnlSMhnDF1/oog80ifa6YGjq+e39wEvqJwkInDRuS8Prj4VAjyKtCUs2ahPN6z DOuCRWHAjAIgCwtml0tg2Nz+CQUYF1p3MRzcZ7rkd290egf1gnX4AEssasZJqkGi1IZ+ sG8wOmDIg1GZG8cOY2bbBRrHLjUWWuBY4ExgD5hNTv/JPLOD44JQOk/QFaUCGpCawoNB DsqQ5XPwPToYarRT4li2P5A/iu0xZNkv8yokxGH1eSyYOLnK6SKEo67enaXB6zw/tYl5 GHcA== 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=EwnaKbuUJ6px06Fjfmwlp3PQCD3ImvYkJOOCdRZ2CDg=; fh=WKr3UfMxhTZB20e6PBjls5vGIl/XClUxQy7NcuDEQJM=; b=pikdPCFiyIjJkDVEod+w6fB3a2/jasIEtXDdsLmoLUVbDbX7VejXEifUI89IRBVYQv qY32u1lOJKf/8puy++CZPhffr4epj1i4BhN7vYtwR7HFRnygrRYyO+nwScScgErgVJKZ SIYOgBBEK+j5OoF8UeOrHrLJKsuibzVJrMEst5IfxChMyt/eAw/c5W1sITaeKb7k4pp8 P0jVTRsT1A2L+zjpYZS1dhFqoUPcU+jKJP/KnYp2PixXe/bONUVo+7m1+FCP/+v12bSs Lgt8oIviFlJhVDOAG+CO9qkL2w7huILMIb6/yTO+BLf2Q+Zn1loF2AG/4xQHOGyVSMYL CWrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QIz6Jzgo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id x9-20020a05620a258900b007681446a032si90007qko.269.2023.10.26.15.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 15:04:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QIz6Jzgo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 3AE4080A18C8; Thu, 26 Oct 2023 15:04:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344906AbjJZWDo (ORCPT + 99 others); Thu, 26 Oct 2023 18:03:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232306AbjJZWDn (ORCPT ); Thu, 26 Oct 2023 18:03:43 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6D2F1B5; Thu, 26 Oct 2023 15:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698357821; x=1729893821; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=936dDUYVrUWFK2FNzC6j5Oz8gqYA3XKPjUuL+QseAcs=; b=QIz6Jzgo/ibHN4NoTRTfMQYiEFTtmmvJeWfztJ0RcwLrSaAoiB2DCF54 KX/FddQ++koLMe8q69rvS3NC4+3jFpb+HPHKTIWF6TgCzGqvYtcg0VRwP PJ8hmZuqEaYK7iepuRcwu80ieT7FgKJIitferZFdP2YZMqGtR2hF9e+iU OpPCxGUx36FYpwfNZQPiv2/eqR9fXxd1BqW1fcH5tksw5g+/rp98Rr/cS 2MEXQDF0Kny1rZH32EBcJuyvv0vZqSJQoYLrUFpLdsea9l1CyDMqvA2C6 3TUBLEKwksDclWqNgBYxC762y01H50+EwGhRJU4drd7XKZODa8VL2foAU g==; X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="367873190" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="367873190" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 15:03:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="762998863" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="762998863" Received: from paseron-mobl4.amr.corp.intel.com (HELO desk) ([10.209.17.113]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 15:03:31 -0700 Date: Thu, 26 Oct 2023 15:03:29 -0700 From: Pawan Gupta To: Sean Christopherson Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Andy Lutomirski , Jonathan Corbet , 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: <20231026220329.gejnqecu2sx5hxv5@desk> References: <20231025-delay-verw-v3-0-52663677ee35@linux.intel.com> <20231025-delay-verw-v3-6-52663677ee35@linux.intel.com> <20231026204810.chvljddk6noxsuqi@desk> 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 fry.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 (fry.vger.email [0.0.0.0]); Thu, 26 Oct 2023 15:04:01 -0700 (PDT) On Thu, Oct 26, 2023 at 02:22:58PM -0700, Sean Christopherson wrote: > On Thu, Oct 26, 2023, Pawan Gupta wrote: > > On Thu, Oct 26, 2023 at 12:30:55PM -0700, Sean Christopherson wrote: > > > > if (static_branch_unlikely(&vmx_l1d_should_flush)) > > > > vmx_l1d_flush(vcpu); > > > > > > There's an existing bug here. vmx_1ld_flush() is not guaranteed to do a flush in > > > "conditional mode", and is not guaranteed to do a ucode-based flush > > > > AFAICT, it is based on the condition whether after a VMexit any > > sensitive data could have been touched or not. If L1TF mitigation > > doesn't consider certain data sensitive and skips L1D flush, executing > > VERW isn't giving any protection, since that data can anyways be leaked > > from L1D using L1TF. > > That assumes vcpu->arch.l1tf_flush_l1d is 100% precise and accurate, which is most > definitely not the case. You're also preventing the admin from choosing between > being super paranoind (always flush L1D) and mostly paranoid (conditionally flush > L1D, always flush CPU buffers). > AIUI, flushing the L1D is crazy expensive compared to flushing the CPU buffers, > so it's entirely plausible for someone to want to choose the mostly paranoid > option. Sure, if it helps an admin. I was asking about the problematic scenario out of curiosity. BTW, the changes you suggested are definitely worth doing. > Side topic, isn't the NMI path missing a call to kvm_set_cpu_l1tf_flush_l1d()? Yes, it is missing. Not sure if it was omitted intentionally. > > This is certainly better, but I don't know what scenario is this helping with. > > Heh, that's host I feel about moving VERW to just before VM-Enter. I have a hard > time believing there's meaningful sensitive that's accessed in __vmx_vcpu_run(). > The closest thing is probably CR2, but that's a very dubious vector since CR2 will > hold a guest value for most VM-Enters. Yes, kernel->user case has a better chance of leaking anything. > I'm not against moving VERW close to VM-Enter because it's relatively straightforward, > but if we're going to be super paranoid, why not go all the way and not have to > worry about what ifs? Right. The VMenter changes are mostly done to be consistent with what is being done for kernel->user.