Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3900902ybb; Mon, 23 Mar 2020 09:45:43 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt6rP4J+fAQZ8mL9fy/A8ZxEz/X/9UD/WmetNhhgZ7XGCJ4w08+oNCFt3VpnJjbvtQzDfvU X-Received: by 2002:a05:6808:6d6:: with SMTP id m22mr169259oih.164.1584981942933; Mon, 23 Mar 2020 09:45:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584981942; cv=none; d=google.com; s=arc-20160816; b=xam4FHkB2pTWWlaFxbp28zCljYHwf3ajULj/lLbNd+XBKDT14wLp1Dvo/a3G0gqA6Y oFV8FCHJ9gosnRWvtDSYb1kKXKvfUn2M0lww/qqQ/IzV7lqnt2qaBlI9byUvES05cNTU qOZYE1WCxr9x6O7rTilmbLKwm2nB6wi3AS/9Vp1Wp8sM4SZj6I4P18CYZNRRwIQBP50I uyhruwsLxpXMc4CrX8HDFjRXilOCzYInA098DeyzxhAJ24r+oXeeR59/c/PyGqSGQC3u L72ZO+jnygxnxyXM1DlwaJEkB5bt8ac0OabHoaqu5iKMzZ5pOq/8hRxEL1Pe6cU767Zj RrdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=7+88dhlIX4HGTASRPHn33jYVXPfY5+5i7wRsAABL4gY=; b=misebgEaFMR0w5i3b42DryqVZn4gjpSvKR9SGZXI51qwdEX26F6yXCfa019zYYt27V meiH61O7aKBnZoPkmnYIjKRao7t9npwYzC924RYdPhEd7Sjjs9tEqnem9f7bAIVHdGWa 27w0X+Ji2pALPwyZsOdH6DgIKTAiZyq4O78aXAjXJ30dC580agYH4LIr+EQfvkw0W5Qk +AGk+y4hRQ2M2ZtEFmAaT4V1zCT4IivVI7kFC4Dl/1/vGRrC/qmTNbkXUfeE/0t6hUT9 ho82ASuufb8Uf+OuGczWgPQu/HJXnmLnaY4KqIPnEydVDBa8IQCpTpyJ1HJIwu0pZf52 LlsQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si10521872ots.148.2020.03.23.09.45.30; Mon, 23 Mar 2020 09:45:42 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727838AbgCWQou (ORCPT + 99 others); Mon, 23 Mar 2020 12:44:50 -0400 Received: from mga06.intel.com ([134.134.136.31]:57127 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727686AbgCWQot (ORCPT ); Mon, 23 Mar 2020 12:44:49 -0400 IronPort-SDR: gIg3r+Q83T7TZgiyL8OxMB2naREdc4tuoom1DfP32+qZ1tBX21qDoAmQLRCTFbRN8+iuZALAn9 SldYZfAKy7nQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2020 09:44:48 -0700 IronPort-SDR: Hm+eB0RfVMBxxIF+g7Epr9a3bkiwXrIn7Kxppf3oUdQ+3yzvX3qwOUw+bTO9FJ5fn651hqMx1T hvtlOT5il54A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,297,1580803200"; d="scan'208";a="246253181" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.202]) by orsmga003.jf.intel.com with ESMTP; 23 Mar 2020 09:44:48 -0700 Date: Mon, 23 Mar 2020 09:44:48 -0700 From: Sean Christopherson To: Jim Mattson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm list , LKML , Ben Gardon , Junaid Shahid , Liran Alon , Boris Ostrovsky , John Haxby , Miaohe Lin , Tom Lendacky Subject: Re: [PATCH v3 03/37] KVM: nVMX: Invalidate all EPTP contexts when emulating INVEPT for L1 Message-ID: <20200323164447.GQ28711@linux.intel.com> References: <20200320212833.3507-1-sean.j.christopherson@intel.com> <20200320212833.3507-4-sean.j.christopherson@intel.com> <20200323162807.GN28711@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 23, 2020 at 09:36:22AM -0700, Jim Mattson wrote: > On Mon, Mar 23, 2020 at 9:28 AM Sean Christopherson > wrote: > > > > On Mon, Mar 23, 2020 at 09:24:25AM -0700, Jim Mattson wrote: > > > On Fri, Mar 20, 2020 at 2:29 PM Sean Christopherson > > > wrote: > > > > > > > > Free all L2 (guest_mmu) roots when emulating INVEPT for L1. Outstanding > > > > changes to the EPT tables managed by L1 need to be recognized, and > > > > relying on KVM to always flush L2's EPTP context on nested VM-Enter is > > > > dangerous. > > > > > > > > Similar to handle_invpcid(), rely on kvm_mmu_free_roots() to do a remote > > > > TLB flush if necessary, e.g. if L1 has never entered L2 then there is > > > > nothing to be done. > > > > > > > > Nuking all L2 roots is overkill for the single-context variant, but it's > > > > the safe and easy bet. A more precise zap mechanism will be added in > > > > the future. Add a TODO to call out that KVM only needs to invalidate > > > > affected contexts. > > > > > > > > Fixes: b119019847fbc ("kvm: nVMX: Remove unnecessary sync_roots from handle_invept") > > > > > > The bug existed well before the commit indicated in the "Fixes" line. > > > > Ah, my bad. A cursory glance at commit b119019847fbc makes that quite > > obvious. This should be > > > > Fixes: bfd0a56b9000 ("nEPT: Nested INVEPT") > > Actually, I think that things were fine back then (though we > gratuitously flushed L1's TLB as a result of an emulated INVEPT). The > problem started when we stopped flushing the TLB on every emulated > VM-entry (i.e. L1 -> L2 transitions). I'm not sure what that commit > was, but I think you referenced it in an earlier email. Hmm, true. I was thinking it was the original commit because it didn't operate on guest_mmu, but guest_mmu didn't exist back then. So I think Fixes: 14c07ad89f4d ("x86/kvm/mmu: introduce guest_mmu") would be appropriate?