From patchwork Thu Apr 22 21:15:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Northup X-Patchwork-Id: 94541 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 o3MLFexO025364 for ; Thu, 22 Apr 2010 21:15:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758826Ab0DVVP1 (ORCPT ); Thu, 22 Apr 2010 17:15:27 -0400 Received: from smtp-out.google.com ([74.125.121.35]:37669 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758816Ab0DVVPU (ORCPT ); Thu, 22 Apr 2010 17:15:20 -0400 Received: from kpbe16.cbf.corp.google.com (kpbe16.cbf.corp.google.com [172.25.105.80]) by smtp-out.google.com with ESMTP id o3MLFGkL015635 for ; Thu, 22 Apr 2010 23:15:17 +0200 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1271970917; bh=FgTYQzV6SeoyX+eUfFD8LcBMHbU=; h=MIME-Version:Date:Message-ID:Subject:From:To:Content-Type; b=QIb+aBOzSw9Dw8g+DqtHNOHxq+wpeYVizXA7r5nc5UY7PEYOZBYyZtkwtJhFbIX11 2vJzwbnyjPvwg1up9o0lg== DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:date:message-id:subject:from:to:content-type:x-system-of-record; b=xev52MSpX3GuFxcT5FinQY4LD9utH9pcCD7M8yYhoYBKY4Pv7vSxgagBfUgC3qbXw FMog74sl7HdzArbknJC7A== Received: from qyk37 (qyk37.prod.google.com [10.241.83.165]) by kpbe16.cbf.corp.google.com with ESMTP id o3MLEx35013671 for ; Thu, 22 Apr 2010 14:15:15 -0700 Received: by qyk37 with SMTP id 37so4361687qyk.8 for ; Thu, 22 Apr 2010 14:15:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.216.142 with HTTP; Thu, 22 Apr 2010 14:15:14 -0700 (PDT) Date: Thu, 22 Apr 2010 14:15:14 -0700 Received: by 10.229.211.210 with SMTP id gp18mr1334962qcb.31.1271970914752; Thu, 22 Apr 2010 14:15:14 -0700 (PDT) Message-ID: Subject: [PATCH RFC] KVM MMU: fix hashing for TDP and non-paging modes From: Eric Northup To: kvm@vger.kernel.org X-System-Of-Record: true 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]); Thu, 22 Apr 2010 21:15:44 +0000 (UTC) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index ddfa865..9696d65 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -2059,10 +2059,12 @@ static int mmu_alloc_roots(struct kvm_vcpu *vcpu) hpa_t root = vcpu->arch.mmu.root_hpa; ASSERT(!VALID_PAGE(root)); - if (tdp_enabled) - direct = 1; if (mmu_check_root(vcpu, root_gfn)) return 1; + if (tdp_enabled) { + direct = 1; + root_gfn = 0; + } sp = kvm_mmu_get_page(vcpu, root_gfn, 0, PT64_ROOT_LEVEL, direct, ACC_ALL, NULL); @@ -2072,8 +2074,6 @@ static int mmu_alloc_roots(struct kvm_vcpu *vcpu) return 0; } direct = !is_paging(vcpu); - if (tdp_enabled) - direct = 1; for (i = 0; i < 4; ++i) { hpa_t root = vcpu->arch.mmu.pae_root[i]; @@ -2089,6 +2089,10 @@ static int mmu_alloc_roots(struct kvm_vcpu *vcpu) root_gfn = 0; if (mmu_check_root(vcpu, root_gfn)) return 1; + if (tdp_enabled) { + direct = 1; + root_gfn = i << 30; + } sp = kvm_mmu_get_page(vcpu, root_gfn, i << 30, PT32_ROOT_LEVEL, direct, ACC_ALL, NULL);