From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxEgI-0002zC-Nl for qemu-devel@nongnu.org; Tue, 14 Feb 2012 04:28:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RxEgB-0003WO-Sn for qemu-devel@nongnu.org; Tue, 14 Feb 2012 04:28:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxEgB-0003Vq-JQ for qemu-devel@nongnu.org; Tue, 14 Feb 2012 04:28:07 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1E9S6IX014246 (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-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q1E9S2hg012767 for ; Tue, 14 Feb 2012 04:28:06 -0500 From: Avi Kivity Date: Tue, 14 Feb 2012 11:27:46 +0200 Message-Id: <1329211670-11548-17-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> Subject: [Qemu-devel] [PATCH 16/20] memory: replace phys_page_find_alloc() with phys_page_set() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org By giving the function the value we want to set, we make it more flexible for the next patch. Signed-off-by: Avi Kivity --- exec.c | 15 ++++----------- 1 files changed, 4 insertions(+), 11 deletions(-) diff --git a/exec.c b/exec.c index e382858..26e70c3 100644 --- a/exec.c +++ b/exec.c @@ -429,7 +429,7 @@ static void phys_map_nodes_reset(void) phys_map_nodes_nb = 0; } -static uint16_t *phys_page_find_alloc(target_phys_addr_t index, int alloc) +static void phys_page_set(target_phys_addr_t index, uint16_t leaf) { PhysPageEntry *lp, *p; int i, j; @@ -439,9 +439,6 @@ static uint16_t *phys_page_find_alloc(target_phys_addr_t index, int alloc) /* Level 1..N. */ for (i = P_L2_LEVELS - 1; i >= 0; i--) { if (lp->u.node == PHYS_MAP_NODE_NIL) { - if (!alloc) { - return NULL; - } p = phys_map_node_alloc(&lp->u.node); if (i == 0) { for (j = 0; j < L2_SIZE; j++) { @@ -454,7 +451,7 @@ static uint16_t *phys_page_find_alloc(target_phys_addr_t index, int alloc) lp = &p[(index >> (i * L2_BITS)) & (L2_SIZE - 1)]; } - return &lp->u.leaf; + lp->u.leaf = leaf; } static MemoryRegionSection phys_page_find(target_phys_addr_t index) @@ -2611,7 +2608,6 @@ static void register_subpage(MemoryRegionSection *section) .offset_within_address_space = base, .size = TARGET_PAGE_SIZE, }; - uint16_t *ptr; target_phys_addr_t start, end; assert(existing.mr->subpage || existing.mr == &io_mem_unassigned); @@ -2619,8 +2615,7 @@ static void register_subpage(MemoryRegionSection *section) if (!(existing.mr->subpage)) { subpage = subpage_init(base); subsection.mr = &subpage->iomem; - ptr = phys_page_find_alloc(base >> TARGET_PAGE_BITS, 1); - *ptr = phys_section_add(&subsection); + phys_page_set(base >> TARGET_PAGE_BITS, phys_section_add(&subsection)); } else { subpage = container_of(existing.mr, subpage_t, iomem); } @@ -2643,9 +2638,7 @@ static void register_multipage(MemoryRegionSection *section) addr = start_addr; do { - uint16_t *p = phys_page_find_alloc(addr >> TARGET_PAGE_BITS, 1); - assert(*p == phys_section_unassigned); - *p = section_index; + phys_page_set(addr >> TARGET_PAGE_BITS, section_index); addr += TARGET_PAGE_SIZE; } while (addr != end_addr); } -- 1.7.9