From patchwork Tue Jan 5 11:02:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 70979 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o05B5GFs004407 for ; Tue, 5 Jan 2010 11:05:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754400Ab0AELEY (ORCPT ); Tue, 5 Jan 2010 06:04:24 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754367Ab0AELEX (ORCPT ); Tue, 5 Jan 2010 06:04:23 -0500 Received: from mga03.intel.com ([143.182.124.21]:4180 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754329Ab0AELEU (ORCPT ); Tue, 5 Jan 2010 06:04:20 -0500 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 05 Jan 2010 03:04:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.47,316,1257148800"; d="scan'208";a="229326942" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.36.76]) by azsmga001.ch.intel.com with ESMTP; 05 Jan 2010 03:04:18 -0800 Received: from yasker by syang10-desktop with local (Exim 4.69) (envelope-from ) id 1NS7BK-0003Dn-52; Tue, 05 Jan 2010 19:02:34 +0800 From: Sheng Yang To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, Sheng Yang , stable@kernel.org Subject: [PATCH 3/4] KVM: x86: Fix host_mapping_level() Date: Tue, 5 Jan 2010 19:02:28 +0800 Message-Id: <1262689349-12350-4-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1262689349-12350-1-git-send-email-sheng@linux.intel.com> References: <1262689349-12350-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 diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 15daf3c..43cf2ea 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -473,7 +473,7 @@ static int host_mapping_level(struct kvm *kvm, gfn_t gfn) addr = gfn_to_hva(kvm, gfn); if (kvm_is_error_hva(addr)) - return page_size; + return PT_PAGE_TABLE_LEVEL; down_read(¤t->mm->mmap_sem); vma = find_vma(current->mm, addr); @@ -511,11 +511,9 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn) if (host_level == PT_PAGE_TABLE_LEVEL) return host_level; - for (level = PT_DIRECTORY_LEVEL; level <= host_level; ++level) { - + for (level = PT_DIRECTORY_LEVEL; level <= host_level; ++level) if (has_wrprotected_page(vcpu->kvm, large_gfn, level)) break; - } return level - 1; }