From patchwork Tue Feb 14 09:27:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 141090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8D40EB6FDA for ; Tue, 14 Feb 2012 21:16:19 +1100 (EST) Received: from localhost ([::1]:34752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxEhQ-0005tX-Vf for incoming@patchwork.ozlabs.org; Tue, 14 Feb 2012 04:29:24 -0500 Received: from eggs.gnu.org ([140.186.70.92]:39690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxEgI-0002zB-2Q for qemu-devel@nongnu.org; Tue, 14 Feb 2012 04:28:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RxEgB-0003W9-Jy for qemu-devel@nongnu.org; Tue, 14 Feb 2012 04:28:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57508) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxEgB-0003Va-89 for qemu-devel@nongnu.org; Tue, 14 Feb 2012 04:28:07 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1E9S6Av002946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 14 Feb 2012 04:28:06 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q1E9S4WF002753 for ; Tue, 14 Feb 2012 04:28:06 -0500 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 8DAC5250BB8; Tue, 14 Feb 2012 11:27:58 +0200 (IST) From: Avi Kivity To: qemu-devel@nongnu.org Date: Tue, 14 Feb 2012 11:27:44 +0200 Message-Id: <1329211670-11548-15-git-send-email-avi@redhat.com> In-Reply-To: <1329211670-11548-1-git-send-email-avi@redhat.com> References: <1329211670-11548-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 14/20] memory: give phys_page_find() its own tree search loop X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We'll change phys_page_find_alloc() soon, but phys_page_find() doesn't need to bear the consequences. Signed-off-by: Avi Kivity --- exec.c | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/exec.c b/exec.c index bf34dc9..24423d5 100644 --- a/exec.c +++ b/exec.c @@ -459,14 +459,23 @@ static uint16_t *phys_page_find_alloc(target_phys_addr_t index, int alloc) static MemoryRegionSection phys_page_find(target_phys_addr_t index) { - uint16_t *p = phys_page_find_alloc(index, 0); - uint16_t s_index = phys_section_unassigned; + PhysPageEntry lp = phys_map; + PhysPageEntry *p; + int i; MemoryRegionSection section; target_phys_addr_t delta; + uint16_t s_index = phys_section_unassigned; - if (p) { - s_index = *p; + for (i = P_L2_LEVELS - 1; i >= 0; i--) { + if (lp.u.node == PHYS_MAP_NODE_NIL) { + goto not_found; + } + p = phys_map_nodes[lp.u.node]; + lp = p[(index >> (i * L2_BITS)) & (L2_SIZE - 1)]; } + + s_index = lp.u.leaf; +not_found: section = phys_sections[s_index]; index <<= TARGET_PAGE_BITS; assert(section.offset_within_address_space <= index