Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4582400pxj; Wed, 12 May 2021 08:38:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJqS5dEWD/fVSbYzC8HMZEPi59JSl4ebMGzJkBKdkwx1qMhJQHIE0imOTk5klJ6U3HF01d X-Received: by 2002:a19:7dc4:: with SMTP id y187mr25614049lfc.525.1620833927637; Wed, 12 May 2021 08:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620833927; cv=none; d=google.com; s=arc-20160816; b=Qqd9wxWGYf9zeqIX0oqVh2JBEcY+BToeiy37ceE0qxGz91rCMTeb9YBJQfGTrjsA51 Du3KywY9FAFqPCKsu1toN8j7EvLJLnKvg6NQ6/62/wsddnJrLo+XTRPRD9qG7bX4dnDc qQzGkjRGfq8FzZZoHiPN2iQaXbGAGY5zkmv1Pos+pniusTTlVnyv/NaqsX953DCmb4wE AViLOWr7zOGyvdugsjUcB3ZJ7JJF5X3wYEfkTQrZzXlL/o0Ir5b2rCTWLnKwY6Dyw50g k/DEio6tJokQK52Yfo0mME3Li3AqrDNcT3YuJVGdglYzYZ6yPbwusyiKttqQdEcIM4nZ Zaig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qsiJ19kiq6xCSqct1c7tLGrWkEPTPMtrTuIJVrxhBKY=; b=xVvn/YM2ATX/k8J9sMAca0E1AUX+TGMHYNHf4vOCfo0GdDheeSccbdpeobYietThRV xSln7keP8AKYqA5D8NNkExvXIEqW+a8URoPbTjN9Kdwb7fSZpm2vYW4p7GLF4Mn3vQ7f M4CpKYTS0b6kYYBlG2c0VlrtOrapcL98QTEDGHBmOa5ViUGQDIj+IhhECOvUG4fP+tOF OvJJ9Q3pDRxkXPfGYPLFOrKX+yAARup4OXw4fyD68I1vZ+FOXZZifq4zqRDohtcZbiEf W0z4NeqWJhnvGFjeF+Bkw5BvEfy1RmQWA564WEcQxTSFADiws3jPPEVUPS4COHuEXsz4 /UPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V2EHU1M4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si316987lfl.235.2021.05.12.08.38.17; Wed, 12 May 2021 08:38:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V2EHU1M4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234854AbhELPhP (ORCPT + 99 others); Wed, 12 May 2021 11:37:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:49672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234331AbhELPQ3 (ORCPT ); Wed, 12 May 2021 11:16:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F11466197B; Wed, 12 May 2021 15:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620831982; bh=x2ErDLcgKwxy1OQvmdn6un1x+lLKszGhXqvNZQIyXAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V2EHU1M4z7jLq357mY9wiarkslFKMPigSb19v3S1QJKon9VmpL0N5Mp7ZtU4+2cxA 98rUK/1r5kkbiw0QDt8tYUtPpwSzD1IHAOISkZpIA57oySWYnHOKW5WZ8jfDBcdoUX Yn90uRygHucn7XX9OT5uBiMfOliE2LkkS0OLaDWM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Paolo Bonzini Subject: [PATCH 5.10 093/530] KVM: nSVM: Set the shadow root level to the TDP level for nested NPT Date: Wed, 12 May 2021 16:43:23 +0200 Message-Id: <20210512144822.860319502@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson commit a3322d5cd87fef5ec0037fd1b14068a533f9a60f upstream. Override the shadow root level in the MMU context when configuring NPT for shadowing nested NPT. The level is always tied to the TDP level of the host, not whatever level the guest happens to be using. Fixes: 096586fda522 ("KVM: nSVM: Correctly set the shadow NPT root level in its MMU role") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20210305011101.3597423-2-seanjc@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/mmu/mmu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -4617,12 +4617,17 @@ void kvm_init_shadow_npt_mmu(struct kvm_ struct kvm_mmu *context = &vcpu->arch.guest_mmu; union kvm_mmu_role new_role = kvm_calc_shadow_npt_root_page_role(vcpu); - context->shadow_root_level = new_role.base.level; - __kvm_mmu_new_pgd(vcpu, nested_cr3, new_role.base, false, false); - if (new_role.as_u64 != context->mmu_role.as_u64) + if (new_role.as_u64 != context->mmu_role.as_u64) { shadow_mmu_init_context(vcpu, context, cr0, cr4, efer, new_role); + + /* + * Override the level set by the common init helper, nested TDP + * always uses the host's TDP configuration. + */ + context->shadow_root_level = new_role.base.level; + } } EXPORT_SYMBOL_GPL(kvm_init_shadow_npt_mmu);