From patchwork Wed May 12 08:40:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 98954 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4C8gAgJ031556 for ; Wed, 12 May 2010 08:42:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755051Ab0ELIlr (ORCPT ); Wed, 12 May 2010 04:41:47 -0400 Received: from mga01.intel.com ([192.55.52.88]:44920 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754955Ab0ELIlp (ORCPT ); Wed, 12 May 2010 04:41:45 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 12 May 2010 01:38:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.53,213,1272870000"; d="scan'208";a="797698012" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.36.64]) by fmsmga001.fm.intel.com with ESMTP; 12 May 2010 01:41:20 -0700 Received: from yasker by syang10-desktop with local (Exim 4.71) (envelope-from ) id 1OC7Ui-00061e-7o; Wed, 12 May 2010 16:40:44 +0800 From: Sheng Yang To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, Sheng Yang Subject: [PATCH][v2 2/3] KVM: Clean up duplicate assignment Date: Wed, 12 May 2010 16:40:41 +0800 Message-Id: <1273653642-23132-3-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1273653642-23132-1-git-send-email-sheng@linux.intel.com> References: <1273653642-23132-1-git-send-email-sheng@linux.intel.com> 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 (demeter.kernel.org [140.211.167.41]); Wed, 12 May 2010 08:42:11 +0000 (UTC) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 95bee9d..5412185 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -2450,10 +2450,9 @@ static int init_kvm_mmu(struct kvm_vcpu *vcpu) static void destroy_kvm_mmu(struct kvm_vcpu *vcpu) { ASSERT(vcpu); - if (VALID_PAGE(vcpu->arch.mmu.root_hpa)) { + if (VALID_PAGE(vcpu->arch.mmu.root_hpa)) + /* mmu.free() should set root_hpa = INVALID_PAGE */ vcpu->arch.mmu.free(vcpu); - vcpu->arch.mmu.root_hpa = INVALID_PAGE; - } } int kvm_mmu_reset_context(struct kvm_vcpu *vcpu) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2cae460..764f89b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -486,7 +486,7 @@ int __kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) return 1; kvm_x86_ops->set_cr4(vcpu, cr4); - vcpu->arch.cr4 = cr4; + kvm_mmu_reset_context(vcpu); return 0; @@ -720,8 +720,6 @@ static int set_efer(struct kvm_vcpu *vcpu, u64 efer) kvm_x86_ops->set_efer(vcpu, efer); - vcpu->arch.efer = efer; - vcpu->arch.mmu.base_role.nxe = (efer & EFER_NX) && !tdp_enabled; kvm_mmu_reset_context(vcpu);