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 X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0048EC54FD0 for ; Mon, 23 Mar 2020 16:44:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CCA2D20714 for ; Mon, 23 Mar 2020 16:44:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727850AbgCWQou (ORCPT ); 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?