X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=exec.c;h=98c00565306d70a7712e8ab48fe47cbf31312893;hb=2999097bf178536188b0f4caf937c4d347e96627;hp=f4cd867d51d0b99c8b286c63469eb6894cfa7569;hpb=f7bf546118837a64d4b04dd650e3f64eaa25e623;p=mirror_qemu.git diff --git a/exec.c b/exec.c index f4cd867d51..98c0056530 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,