Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6468087ybe; Wed, 18 Sep 2019 04:07:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqw76ccSZbsvl+zHCplm4jBjygEEddYZOpHrZWoQYDdtton4hFe5LwlXk9kYQKxomUgs6Svw X-Received: by 2002:a50:e791:: with SMTP id b17mr539441edn.11.1568804855032; Wed, 18 Sep 2019 04:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568804855; cv=none; d=google.com; s=arc-20160816; b=0A+qREA2NeScd3VPZHpU2t42ixGTJNB/OyNVFgyFV4iPr+2asIuSNsVSsHSHltiQqE i8J/OOkGq7gw9Fs6HoMhpCEKPANSvMim0y9Bf/fRXwPnQ8w6H1dJFuw2eKNFaFiPZKYB yS6kaV5ZyWiMlFdMAZAfvgT87OMtm/qJtCUHamq0jPpseWPhkxcJvIXmc6A6vuhyFGJX Oet9zlgsc5lMdtK/KrC7/Bwho9HThwZNl+zDx4+zGMFWqED9lFWl4nwsSQhK2REWLnMG T0sViZ0nMjmx6YEG3TgSiYZp/Z0coWBzN46zvfbL3VedrKp7xzIjZQxy3ksuJGKV/9v1 7vTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V9ZlQeba8WbmsamVfN7rzsPdHoCL5tbDxsGcoRyFkQE=; b=iYR/ukqv9tjnopugsD/qeiHnyhQX2LNRzqX8iilJifrYvUjvElLEHkGU9T2Fk/Ix9L rrK8sK31PBf5rY7PyMtY9UV9a/CMyi3qaAN3KLer5OLnolQPwezIGhzJyJmz9hj8kBVc ComkTg2yJZGhiN1w8B3auLsT8Fi8oWt5OVkufMNVnwtXelroyLggpXzqLWmiLm8VVBN3 wTV22+9khq2W2FosLjWJPsWaSeVnfiwQMDwf7tRtVnJpCMzhDs7bD1yP9hnIoUwPCiuL NEDoJzSntGV6HFAxsGooY3opGTBP3emozAJNT3Obs40sP2WT1CDe9+AOUIHgWHfqsnkV IMKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bKWxzQSg; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c8si3386587edb.82.2019.09.18.04.07.11; Wed, 18 Sep 2019 04:07:35 -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; dkim=pass header.i=@kernel.org header.s=default header.b=bKWxzQSg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727921AbfIRG1h (ORCPT + 99 others); Wed, 18 Sep 2019 02:27:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:49452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729403AbfIRG1c (ORCPT ); Wed, 18 Sep 2019 02:27:32 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C012C21924; Wed, 18 Sep 2019 06:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568788051; bh=ql6h+HcwawHyRy276sJpNsFQFGRe1iBHEAJ5B3IWtIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bKWxzQSgAZxIGgVAzakUoGfYdzIeOMkePN34s8ne9N6ZkHVNoL3tKI38zGg60cn43 NWvyBGb9kp40dKSvnYFWaU9Y8GBwZVnr6Zi9hlCWjhIbQBwPjhPy/9/ZR9Xocc5Zmo HZ/OVW+CkoQDSOwZatCh+R9OXD5FeBj5i/UjlNSE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Junaid Shahid , Xiao Guangrong , Nadav HarEl , Jun Nakajima , Xinhao Xu , Yang Zhang , Gleb Natapov , Paolo Bonzini , Jim Mattson Subject: [PATCH 5.2 80/85] kvm: nVMX: Remove unnecessary sync_roots from handle_invept Date: Wed, 18 Sep 2019 08:19:38 +0200 Message-Id: <20190918061237.910306483@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190918061234.107708857@linuxfoundation.org> References: <20190918061234.107708857@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jim Mattson commit b119019847fbcac36ed1384f166c91f177d070e7 upstream. When L0 is executing handle_invept(), the TDP MMU is active. Emulating an L1 INVEPT does require synchronizing the appropriate shadow EPT root(s), but a call to kvm_mmu_sync_roots in this context won't do that. Similarly, the hardware TLB and paging-structure-cache entries associated with the appropriate shadow EPT root(s) must be flushed, but requesting a TLB_FLUSH from this context won't do that either. How did this ever work? KVM always does a sync_roots and TLB flush (in the correct context) when transitioning from L1 to L2. That isn't the best choice for nested VM performance, but it effectively papers over the mistakes here. Remove the unnecessary operations and leave a comment to try to do better in the future. Reported-by: Junaid Shahid Fixes: bfd0a56b90005f ("nEPT: Nested INVEPT") Cc: Xiao Guangrong Cc: Nadav Har'El Cc: Jun Nakajima Cc: Xinhao Xu Cc: Yang Zhang Cc: Gleb Natapov Cc: Paolo Bonzini Reviewed-by Peter Shier Reviewed-by: Junaid Shahid Signed-off-by: Jim Mattson Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx/nested.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -4708,13 +4708,11 @@ static int handle_invept(struct kvm_vcpu switch (type) { case VMX_EPT_EXTENT_GLOBAL: + case VMX_EPT_EXTENT_CONTEXT: /* - * TODO: track mappings and invalidate - * single context requests appropriately + * TODO: Sync the necessary shadow EPT roots here, rather than + * at the next emulated VM-entry. */ - case VMX_EPT_EXTENT_CONTEXT: - kvm_mmu_sync_roots(vcpu); - kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu); break; default: BUG_ON(1);