From patchwork Wed Mar 3 19:12:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 83423 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 o23JDiBY008230 for ; Wed, 3 Mar 2010 19:13:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754907Ab0CCTNZ (ORCPT ); Wed, 3 Mar 2010 14:13:25 -0500 Received: from va3ehsobe003.messaging.microsoft.com ([216.32.180.13]:54367 "EHLO VA3EHSOBE003.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753630Ab0CCTNQ (ORCPT ); Wed, 3 Mar 2010 14:13:16 -0500 Received: from mail166-va3-R.bigfish.com (10.7.14.246) by VA3EHSOBE003.bigfish.com (10.7.40.23) with Microsoft SMTP Server id 8.1.240.5; Wed, 3 Mar 2010 19:13:13 +0000 Received: from mail166-va3 (localhost [127.0.0.1]) by mail166-va3-R.bigfish.com (Postfix) with ESMTP id 4F3121C5011D; Wed, 3 Mar 2010 19:13:13 +0000 (UTC) X-SpamScore: 3 X-BigFish: VPS3(z1039oz936eMab9bhzz1202hzzz32i6bh87h2a8h61h) X-Spam-TCS-SCL: 0:0 X-FB-DOMAIN-IP-MATCH: fail Received: from mail166-va3 (localhost.localdomain [127.0.0.1]) by mail166-va3 (MessageSwitch) id 126764358570303_27406; Wed, 3 Mar 2010 19:13:05 +0000 (UTC) Received: from VA3EHSMHS014.bigfish.com (unknown [10.7.14.253]) by mail166-va3.bigfish.com (Postfix) with ESMTP id 831171B90053; Wed, 3 Mar 2010 19:13:03 +0000 (UTC) Received: from ausb3extmailp02.amd.com (163.181.251.22) by VA3EHSMHS014.bigfish.com (10.7.99.24) with Microsoft SMTP Server (TLS) id 14.0.482.39; Wed, 3 Mar 2010 19:12:55 +0000 Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with SMTP id o23JGF39003834; Wed, 3 Mar 2010 13:16:18 -0600 X-WSS-ID: 0KYQ019-02-H59-02 X-M-MSG: Received: from sausexbh2.amd.com (SAUSEXBH2.amd.com [163.181.22.102]) by ausb3twp02.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 2868EC8640; Wed, 3 Mar 2010 13:12:45 -0600 (CST) Received: from sausexmb1.amd.com ([163.181.3.156]) by sausexbh2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 3 Mar 2010 13:12:50 -0600 Received: from seurexmb1.amd.com ([165.204.9.130]) by sausexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 3 Mar 2010 13:12:49 -0600 Received: from lemmy.osrc.amd.com ([165.204.15.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 3 Mar 2010 20:12:42 +0100 Received: by lemmy.osrc.amd.com (Postfix, from userid 41430) id BAB5FC9AF6; Wed, 3 Mar 2010 20:12:42 +0100 (CET) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: Alexander Graf , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: [PATCH 10/18] KVM: MMU: Introduce generic walk_addr function Date: Wed, 3 Mar 2010 20:12:13 +0100 Message-ID: <1267643541-451-11-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.7.0 In-Reply-To: <1267643541-451-1-git-send-email-joerg.roedel@amd.com> References: <1267643541-451-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 03 Mar 2010 19:12:42.0719 (UTC) FILETIME=[7FD226F0:01CABB05] MIME-Version: 1.0 X-Reverse-DNS: ausb3extmailp02.amd.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, 03 Mar 2010 19:13:45 +0000 (UTC) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 8608439..6c55a31 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -112,9 +112,10 @@ static unsigned FNAME(gpte_access)(struct kvm_vcpu *vcpu, pt_element_t gpte) /* * Fetch a guest pte for a guest virtual address */ -static int FNAME(walk_addr)(struct guest_walker *walker, - struct kvm_vcpu *vcpu, gva_t addr, - int write_fault, int user_fault, int fetch_fault) +static int FNAME(walk_addr_generic)(struct guest_walker *walker, + struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, + gva_t addr, int write_fault, + int user_fault, int fetch_fault) { pt_element_t pte; gfn_t table_gfn; @@ -125,10 +126,12 @@ static int FNAME(walk_addr)(struct guest_walker *walker, trace_kvm_mmu_pagetable_walk(addr, write_fault, user_fault, fetch_fault); walk: - walker->level = vcpu->arch.mmu.root_level; - pte = vcpu->arch.mmu.get_cr3(vcpu); + + walker->level = mmu->root_level; + pte = mmu->get_cr3(vcpu); + #if PTTYPE == 64 - if (vcpu->arch.mmu.root_level == PT32E_ROOT_LEVEL) { + if (walker->level == PT32E_ROOT_LEVEL) { pte = kvm_pdptr_read(vcpu, (addr >> 30) & 3); trace_kvm_mmu_paging_element(pte, walker->level); if (!is_present_gpte(pte)) @@ -137,7 +140,7 @@ walk: } #endif ASSERT((!is_long_mode(vcpu) && is_pae(vcpu)) || - (vcpu->arch.mmu.get_cr3(vcpu) & CR3_NONPAE_RESERVED_BITS) == 0); + (mmu->get_cr3(vcpu) & CR3_NONPAE_RESERVED_BITS) == 0); pt_access = ACC_ALL; @@ -158,8 +161,7 @@ walk: if (!is_present_gpte(pte)) goto not_present; - rsvd_fault = is_rsvd_bits_set(&vcpu->arch.mmu, pte, - walker->level); + rsvd_fault = is_rsvd_bits_set(mmu, pte, walker->level); if (rsvd_fault) goto access_error; @@ -195,7 +197,7 @@ walk: (PTTYPE == 64 || is_pse(vcpu))) || ((walker->level == PT_PDPE_LEVEL) && (pte & PT_PAGE_SIZE_MASK) && - vcpu->arch.mmu.root_level == PT64_ROOT_LEVEL)) { + mmu->root_level == PT64_ROOT_LEVEL)) { int lvl = walker->level; walker->gfn = gpte_to_gfn_lvl(pte, lvl); @@ -253,6 +255,14 @@ err: return 0; } +static int FNAME(walk_addr)(struct guest_walker *walker, + struct kvm_vcpu *vcpu, gva_t addr, + int write_fault, int user_fault, int fetch_fault) +{ + return FNAME(walk_addr_generic)(walker, vcpu, &vcpu->arch.mmu, addr, + write_fault, user_fault, fetch_fault); +} + static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *page, u64 *spte, const void *pte) {