From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxEgL-00034y-WE for qemu-devel@nongnu.org; Tue, 14 Feb 2012 04:28:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RxEgC-0003Wf-37 for qemu-devel@nongnu.org; Tue, 14 Feb 2012 04:28:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50325) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxEgB-0003WB-SA for qemu-devel@nongnu.org; Tue, 14 Feb 2012 04:28:08 -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 q1E9S7Pk014250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 14 Feb 2012 04:28:07 -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 q1E9S4WH002753 for ; Tue, 14 Feb 2012 04:28:07 -0500 From: Avi Kivity Date: Tue, 14 Feb 2012 11:27:48 +0200 Message-Id: <1329211670-11548-19-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 18/20] memory: change phys_page_set() to set multiple pages List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Avi Kivity --- exec.c | 41 +++++++++++++++++++++++------------------ 1 files changed, 23 insertions(+), 18 deletions(-) diff --git a/exec.c b/exec.c index f4cd867..98c0056 100644 --- a/exec.c +++ b/exec.c @@ -436,8 +436,9 @@ static void phys_map_nodes_reset(void) } -static void phys_page_set_level(PhysPageEntry *lp, target_phys_addr_t index, - uint16_t leaf, int level) +static void phys_page_set_level(PhysPageEntry *lp, target_phys_addr_t *index, + target_phys_addr_t *nb, uint16_t leaf, + int level) { PhysPageEntry *p; int i; @@ -453,20 +454,27 @@ static void phys_page_set_level(PhysPageEntry *lp, target_phys_addr_t index, } else { p = phys_map_nodes[lp->u.node]; } - lp = &p[(index >> (level * L2_BITS)) & (L2_SIZE - 1)]; + lp = &p[(*index >> (level * L2_BITS)) & (L2_SIZE - 1)]; - if (level == 0) { - lp->u.leaf = leaf; - } else { - phys_page_set_level(lp, index, leaf, level - 1); + while (*nb && lp < &p[L2_SIZE]) { + if (level == 0) { + lp->u.leaf = leaf; + ++*index; + --*nb; + } else { + phys_page_set_level(lp, index, nb, leaf, level - 1); + } + ++lp; } } -static void phys_page_set(target_phys_addr_t index, uint16_t leaf) +static void phys_page_set(target_phys_addr_t index, target_phys_addr_t nb, + uint16_t leaf) { - phys_map_node_reserve(P_L2_LEVELS); + /* Wildly overreserve - it doesn't matter much. */ + phys_map_node_reserve((nb + L2_SIZE - 1) / L2_SIZE * P_L2_LEVELS); - phys_page_set_level(&phys_map, index, leaf, P_L2_LEVELS - 1); + phys_page_set_level(&phys_map, &index, &nb, leaf, P_L2_LEVELS - 1); } static MemoryRegionSection phys_page_find(target_phys_addr_t index) @@ -2630,7 +2638,8 @@ static void register_subpage(MemoryRegionSection *section) if (!(existing.mr->subpage)) { subpage = subpage_init(base); subsection.mr = &subpage->iomem; - phys_page_set(base >> TARGET_PAGE_BITS, phys_section_add(&subsection)); + phys_page_set(base >> TARGET_PAGE_BITS, 1, + phys_section_add(&subsection)); } else { subpage = container_of(existing.mr, subpage_t, iomem); } @@ -2644,18 +2653,14 @@ static void register_multipage(MemoryRegionSection *section) { target_phys_addr_t start_addr = section->offset_within_address_space; ram_addr_t size = section->size; - target_phys_addr_t addr, end_addr; + target_phys_addr_t addr; uint16_t section_index = phys_section_add(section); assert(size); - end_addr = start_addr + (target_phys_addr_t)size; - addr = start_addr; - do { - phys_page_set(addr >> TARGET_PAGE_BITS, section_index); - addr += TARGET_PAGE_SIZE; - } while (addr != end_addr); + phys_page_set(addr >> TARGET_PAGE_BITS, size >> TARGET_PAGE_BITS, + section_index); } void cpu_register_physical_memory_log(MemoryRegionSection *section, -- 1.7.9