From patchwork Tue Jan 5 10:12:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 70956 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 o05AEdXE029546 for ; Tue, 5 Jan 2010 10:14:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753658Ab0AEKOe (ORCPT ); Tue, 5 Jan 2010 05:14:34 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751396Ab0AEKOd (ORCPT ); Tue, 5 Jan 2010 05:14:33 -0500 Received: from mga01.intel.com ([192.55.52.88]:46882 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753207Ab0AEKOc (ORCPT ); Tue, 5 Jan 2010 05:14:32 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 05 Jan 2010 02:14:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.47,501,1257148800"; d="scan'208";a="528548853" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.36.76]) by fmsmga002.fm.intel.com with ESMTP; 05 Jan 2010 02:13:54 -0800 Received: from yasker by syang10-desktop with local (Exim 4.69) (envelope-from ) id 1NS6P8-000329-Vr; Tue, 05 Jan 2010 18:12:46 +0800 From: Sheng Yang To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, Sheng Yang Subject: [PATCH 2/3] KVM: x86: Fix host_mapping_level() Date: Tue, 5 Jan 2010 18:12:40 +0800 Message-Id: <1262686361-11630-3-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1262686361-11630-1-git-send-email-sheng@linux.intel.com> References: <1262686361-11630-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 c43c2ab..4f499d7 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -477,7 +477,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); @@ -515,11 +515,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; }