From patchwork Tue Aug 6 08:40:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 2839262 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D1605BF535 for ; Tue, 6 Aug 2013 08:41:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 161442017B for ; Tue, 6 Aug 2013 08:40:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 615C520182 for ; Tue, 6 Aug 2013 08:40:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754134Ab3HFIkW (ORCPT ); Tue, 6 Aug 2013 04:40:22 -0400 Received: from mout.web.de ([212.227.15.3]:60874 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754875Ab3HFIkR (ORCPT ); Tue, 6 Aug 2013 04:40:17 -0400 Received: from localhost.localdomain ([95.157.58.223]) by smtp.web.de (mrweb001) with ESMTPSA (Nemesis) id 0Md4V8-1VOq9V40UU-00IADj for ; Tue, 06 Aug 2013 10:40:16 +0200 From: Jan Kiszka To: Gleb Natapov , Paolo Bonzini Cc: kvm , Xiao Guangrong , Jun Nakajima , Yang Zhang , Arthur Chunqi Li Subject: [PATCH v2 6/8] KVM: nVMX: Load nEPT state after EFER Date: Tue, 6 Aug 2013 10:40:00 +0200 Message-Id: X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-Provags-ID: V03:K0:MLi/WTlrY2ENSN9ng4za/Hm7mR6Bs7+1T8h1ARC5tktBrpyR0La BqzjARx4/uPnIKqbyu8Ax2UE2Dta5UTFQJO0+W0PxgnD+KrkqHy1E/4EBOsay8CFp/P+/dk S84MA3fWh55qSYEC/StgiPoKvzkxxuUsk1mHIDZOVIGUSaw0nJ8FMpI/GzogA54lfQspka2 657GXX/QpYDiIC3MyvzSQ== Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jan Kiszka We need to update EFER.NX before building the nEPT state via nested_ept_init_mmu_context. Otherwise, we risk to create an MMU context that claims to have NX disabled while the guest EPT used NX. This will cause spurious faults for L2. Signed-off-by: Jan Kiszka --- arch/x86/kvm/vmx.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 09666aa..8f69203 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -7733,11 +7733,6 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) vmx_flush_tlb(vcpu); } - if (nested_cpu_has_ept(vmcs12)) { - kvm_mmu_unload(vcpu); - nested_ept_init_mmu_context(vcpu); - } - if (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_EFER) vcpu->arch.efer = vmcs12->guest_ia32_efer; else if (vmcs12->vm_entry_controls & VM_ENTRY_IA32E_MODE) @@ -7747,6 +7742,11 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) /* Note: modifies VM_ENTRY/EXIT_CONTROLS and GUEST/HOST_IA32_EFER */ vmx_set_efer(vcpu, vcpu->arch.efer); + if (nested_cpu_has_ept(vmcs12)) { + kvm_mmu_unload(vcpu); + nested_ept_init_mmu_context(vcpu); + } + /* * This sets GUEST_CR0 to vmcs12->guest_cr0, with possibly a modified * TS bit (for lazy fpu) and bits which we consider mandatory enabled.