From patchwork Tue Aug 6 08:39:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 2839259 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 87D369F479 for ; Tue, 6 Aug 2013 08:40:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C788A2018C for ; Tue, 6 Aug 2013 08:40:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2387620182 for ; Tue, 6 Aug 2013 08:40:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754435Ab3HFIkZ (ORCPT ); Tue, 6 Aug 2013 04:40:25 -0400 Received: from mout.web.de ([212.227.15.3]:51188 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754483Ab3HFIkQ (ORCPT ); Tue, 6 Aug 2013 04:40:16 -0400 Received: from localhost.localdomain ([95.157.58.223]) by smtp.web.de (mrweb001) with ESMTPSA (Nemesis) id 0LjaR6-1VhtVH0IHY-00bbiD for ; Tue, 06 Aug 2013 10:40:15 +0200 From: Jan Kiszka To: Gleb Natapov , Paolo Bonzini Cc: kvm , Xiao Guangrong , Jun Nakajima , Yang Zhang , Arthur Chunqi Li Subject: [PATCH v2 5/8] KVM: nVMX: Fix guest CR3 read-back on VM-exit Date: Tue, 6 Aug 2013 10:39:59 +0200 Message-Id: <0816baee846f9c8f4d54c6738b2582a95f9c56a3.1375778397.git.jan.kiszka@web.de> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-Provags-ID: V03:K0:RGTDUj0bkQNXeKgSlDBICa/tKva8V2vWuzgJNHbX5WOOqIwGQG1 ha9/M/XmGOVR/HjR1z5aWGzOMEoiSaXHnQMvnOfo7kfKRHcHcgm0wgn4hNgbYYQw7SE1V2R zaCfaF9KcoLGeYuTkUUcom+3u6heBy27dTSc72RBPZCb0iMClPrLW6MURCFLvZFP9PULNQU ry/EOx6i5nQNk1cOMtzsA== 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 If nested EPT is enabled, the L2 guest may change CR3 without any exits. We therefore have to read the current value from the VMCS when switching to L1. However, if paging wasn't enabled, L0 tracks L2's CR3, and GUEST_CR3 rather contains the real-mode identity map. So we need to retrieve CR3 from the architectural state after conditionally updating it - and this is what kvm_read_cr3 does. Signed-off-by: Jan Kiszka --- arch/x86/kvm/vmx.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index b482d47..09666aa 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -8106,7 +8106,7 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) * Additionally, restore L2's PDPTR to vmcs12. */ if (enable_ept) { - vmcs12->guest_cr3 = vmcs_read64(GUEST_CR3); + vmcs12->guest_cr3 = kvm_read_cr3(vcpu); vmcs12->guest_pdptr0 = vmcs_read64(GUEST_PDPTR0); vmcs12->guest_pdptr1 = vmcs_read64(GUEST_PDPTR1); vmcs12->guest_pdptr2 = vmcs_read64(GUEST_PDPTR2);