提交 2999097b 编写于 作者: A Avi Kivity

memory: change phys_page_set() to set multiple pages

Signed-off-by: NAvi Kivity <avi@redhat.com>
上级 f7bf5461
...@@ -436,8 +436,9 @@ static void phys_map_nodes_reset(void) ...@@ -436,8 +436,9 @@ static void phys_map_nodes_reset(void)
} }
static void phys_page_set_level(PhysPageEntry *lp, target_phys_addr_t index, static void phys_page_set_level(PhysPageEntry *lp, target_phys_addr_t *index,
uint16_t leaf, int level) target_phys_addr_t *nb, uint16_t leaf,
int level)
{ {
PhysPageEntry *p; PhysPageEntry *p;
int i; int i;
...@@ -453,20 +454,27 @@ static void phys_page_set_level(PhysPageEntry *lp, target_phys_addr_t index, ...@@ -453,20 +454,27 @@ static void phys_page_set_level(PhysPageEntry *lp, target_phys_addr_t index,
} else { } else {
p = phys_map_nodes[lp->u.node]; 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) { while (*nb && lp < &p[L2_SIZE]) {
lp->u.leaf = leaf; if (level == 0) {
} else { lp->u.leaf = leaf;
phys_page_set_level(lp, index, leaf, level - 1); ++*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) static MemoryRegionSection phys_page_find(target_phys_addr_t index)
...@@ -2630,7 +2638,8 @@ static void register_subpage(MemoryRegionSection *section) ...@@ -2630,7 +2638,8 @@ static void register_subpage(MemoryRegionSection *section)
if (!(existing.mr->subpage)) { if (!(existing.mr->subpage)) {
subpage = subpage_init(base); subpage = subpage_init(base);
subsection.mr = &subpage->iomem; 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 { } else {
subpage = container_of(existing.mr, subpage_t, iomem); subpage = container_of(existing.mr, subpage_t, iomem);
} }
...@@ -2644,18 +2653,14 @@ static void register_multipage(MemoryRegionSection *section) ...@@ -2644,18 +2653,14 @@ static void register_multipage(MemoryRegionSection *section)
{ {
target_phys_addr_t start_addr = section->offset_within_address_space; target_phys_addr_t start_addr = section->offset_within_address_space;
ram_addr_t size = section->size; 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); uint16_t section_index = phys_section_add(section);
assert(size); assert(size);
end_addr = start_addr + (target_phys_addr_t)size;
addr = start_addr; addr = start_addr;
do { phys_page_set(addr >> TARGET_PAGE_BITS, size >> TARGET_PAGE_BITS,
phys_page_set(addr >> TARGET_PAGE_BITS, section_index); section_index);
addr += TARGET_PAGE_SIZE;
} while (addr != end_addr);
} }
void cpu_register_physical_memory_log(MemoryRegionSection *section, void cpu_register_physical_memory_log(MemoryRegionSection *section,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册