Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp50314ybm; Tue, 26 May 2020 10:28:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0UXm1fKiPdaOTD6Uh7ch5fIPru/Tscef1MPXxsIKxzXjVPw5kdHDA6CLAMUugHa6osqes X-Received: by 2002:a17:906:11c4:: with SMTP id o4mr2138183eja.163.1590514091304; Tue, 26 May 2020 10:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590514091; cv=none; d=google.com; s=arc-20160816; b=WwYC/wYkai9i1D6Cos7AvwV5zcZmziWLN/UI8Qy0+KdDaIkSYAmORIIc2S5Xsn8fYB fewckwQFa3+ZbTZVrvxAh/rrhS/qUHv6srUEibF7WjXPwIlX4uxqGT3yqj2uMPUwMxWX qh0tMU/4prZZWwnM4zjGDuYI4wmSiahnKN/zIgpT+PWw9dY3KTVv1Owm2qRdtEQOzmWj iSUnRiT+VYQqos6KeyNzdvUWQ0jAG+pFYXDG8We9LchlhJjAbipMj0cF8Q5JhYyqjwXa ruNCxvuz72gSUo+y6YwvvyOfeuKHyCrfwmDMxHsJEZMKkxJM60V8/5ljSLPn3A2KrRQY 9pCQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=r6PjKzkk2yRHO0Y6YwX+jWBfjJzVTcuDe7WydGv1u40=; b=sjOpxgYZlNRwyTs/aOLLThv64KJt6cqLXu3CjxW+a0c/lUg+IWiazThxYz56X/EslM cMGl8twAy7fnPAECkp6OgVvI4v2Xtbc3m+RdDwvTTDOUMKrQ/ErwfmMG02PadNa+7Ijc oUiLZDH1fdcy+x0Ee/KOHhVCKV6ubPWSjMllCalvnRJQYqwN32jc9c53XGZQ0RAkoU0J iVtq6aO231ER4wMLNpZdrIuChZcCQtG9bQiW/ynCUe4f+hO0g0Dae6iOG0upV4CclUvj enFqNrzqqrDt9BS8ITaGxzvk7wQ7irMDOF80c/6nyVJEE3y+azsgc6Z541XvNKOpvHgg p3+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iMMjgtcb; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dh8si253360edb.587.2020.05.26.10.27.48; Tue, 26 May 2020 10:28:11 -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=@redhat.com header.s=mimecast20190719 header.b=iMMjgtcb; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389183AbgEZRZL (ORCPT + 99 others); Tue, 26 May 2020 13:25:11 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:51294 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389179AbgEZRXY (ORCPT ); Tue, 26 May 2020 13:23:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590513803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r6PjKzkk2yRHO0Y6YwX+jWBfjJzVTcuDe7WydGv1u40=; b=iMMjgtcb1XgsLv2cxt96wKrivyUDIc08MFZzVNSUyhhpFeo52QGFO3QyYy78qjnryKO0BS HRdwT7ixRnUd0gOrd7jtbh/Ugw+Hk1H/OvbLinKtTiOjzlBUdalbh9Oz6s2GbSuptOsUY9 RXZu84qOl8Zp+qpIaR5TU5wtrGbgmCo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-112-dHBjXw6tMmGnJOfkVVMvOg-1; Tue, 26 May 2020 13:23:20 -0400 X-MC-Unique: dHBjXw6tMmGnJOfkVVMvOg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B82B8108BD11; Tue, 26 May 2020 17:23:19 +0000 (UTC) Received: from virtlab511.virt.lab.eng.bos.redhat.com (virtlab511.virt.lab.eng.bos.redhat.com [10.19.152.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF4915C1D6; Tue, 26 May 2020 17:23:16 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: vkuznets@redhat.com, mlevitsk@redhat.com, Sean Christopherson , Jim Mattson Subject: [PATCH 11/28] KVM: nSVM: move MMU setup to nested_prepare_vmcb_control Date: Tue, 26 May 2020 13:22:51 -0400 Message-Id: <20200526172308.111575-12-pbonzini@redhat.com> In-Reply-To: <20200526172308.111575-1-pbonzini@redhat.com> References: <20200526172308.111575-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Everything that is needed during nested state restore is now part of nested_prepare_vmcb_control. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/nested.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index af7c9ce8c5ad..7fbd7aaa4ce0 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -247,9 +247,6 @@ static void load_nested_vmcb_control(struct vcpu_svm *svm, static void nested_prepare_vmcb_save(struct vcpu_svm *svm, struct vmcb *nested_vmcb) { - if (nested_vmcb->control.nested_ctl & SVM_NESTED_CTL_NP_ENABLE) - nested_svm_init_mmu_context(&svm->vcpu); - /* Load the nested guest state */ svm->vmcb->save.es = nested_vmcb->save.es; svm->vmcb->save.cs = nested_vmcb->save.cs; @@ -263,9 +260,6 @@ static void nested_prepare_vmcb_save(struct vcpu_svm *svm, struct vmcb *nested_v svm_set_cr4(&svm->vcpu, nested_vmcb->save.cr4); (void)kvm_set_cr3(&svm->vcpu, nested_vmcb->save.cr3); - /* Guest paging mode is active - reset mmu */ - kvm_mmu_reset_context(&svm->vcpu); - svm->vmcb->save.cr2 = svm->vcpu.arch.cr2 = nested_vmcb->save.cr2; kvm_rax_write(&svm->vcpu, nested_vmcb->save.rax); kvm_rsp_write(&svm->vcpu, nested_vmcb->save.rsp); @@ -282,6 +276,12 @@ static void nested_prepare_vmcb_save(struct vcpu_svm *svm, struct vmcb *nested_v static void nested_prepare_vmcb_control(struct vcpu_svm *svm, struct vmcb *nested_vmcb) { + if (nested_vmcb->control.nested_ctl & SVM_NESTED_CTL_NP_ENABLE) + nested_svm_init_mmu_context(&svm->vcpu); + + /* Guest paging mode is active - reset mmu */ + kvm_mmu_reset_context(&svm->vcpu); + svm_flush_tlb(&svm->vcpu); if (nested_vmcb->control.int_ctl & V_INTR_MASKING_MASK) svm->vcpu.arch.hflags |= HF_VINTR_MASK; -- 2.26.2