From patchwork Thu Dec 30 08:35:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 440411 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBUMBEmV000490 for ; Thu, 30 Dec 2010 22:12:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752176Ab0L3Ie3 (ORCPT ); Thu, 30 Dec 2010 03:34:29 -0500 Received: from mga02.intel.com ([134.134.136.20]:63413 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751903Ab0L3Ie3 (ORCPT ); Thu, 30 Dec 2010 03:34:29 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 30 Dec 2010 00:34:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.60,248,1291622400"; d="scan'208";a="691916191" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.13.17]) by orsmga001.jf.intel.com with ESMTP; 30 Dec 2010 00:34:28 -0800 Received: from yasker by syang10-desktop with local (Exim 4.72) (envelope-from ) id 1PYDzQ-0007vd-C2; Thu, 30 Dec 2010 16:36:04 +0800 From: Sheng Yang To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, Sheng Yang Subject: [PATCH] KVM: VMX: Fix 32bit Windows blue screen with EPT Date: Thu, 30 Dec 2010 16:35:59 +0800 Message-Id: <1293698159-30452-1-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.7.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 30 Dec 2010 22:12:17 +0000 (UTC) different. Commit d95bfcdd7cda4dfdac9588e684bc7c75794a075e "KVM: Fetch guest cr3 from hardware on demand" caused 32bit Windows guest blue screen when using with EPT. This patch fixes it by decache CR3 before CR0 change, for both paging to nonpaging, and nonpaging to paging switch. Signed-off-by: Sheng Yang --- But I haven't found the exactly point affected by this, any clue? arch/x86/kvm/vmx.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index f107315..0b8cfc1 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1921,8 +1921,7 @@ static void ept_update_paging_mode_cr0(unsigned long *hw_cr0, unsigned long cr0, struct kvm_vcpu *vcpu) { - ulong cr3; - + kvm_read_cr3(vcpu); if (!(cr0 & X86_CR0_PG)) { /* From paging/starting to nonpaging */ vmcs_write32(CPU_BASED_VM_EXEC_CONTROL, @@ -1937,11 +1936,8 @@ static void ept_update_paging_mode_cr0(unsigned long *hw_cr0, vmcs_read32(CPU_BASED_VM_EXEC_CONTROL) & ~(CPU_BASED_CR3_LOAD_EXITING | CPU_BASED_CR3_STORE_EXITING)); - /* Must fetch cr3 before updating cr0 */ - cr3 = kvm_read_cr3(vcpu); vcpu->arch.cr0 = cr0; vmx_set_cr4(vcpu, kvm_read_cr4(vcpu)); - vmx_set_cr3(vcpu, cr3); } if (!(cr0 & X86_CR0_WP))