memory: give phys_page_find() its own tree search loop

We'll change phys_page_find_alloc() soon, but phys_page_find()
doesn't need to bear the consequences.

Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
Avi Kivity 2012-02-13 16:44:19 +02:00
parent 06ef3525e1
commit 31ab2b4a46

17
exec.c
View File

@ -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) static MemoryRegionSection phys_page_find(target_phys_addr_t index)
{ {
uint16_t *p = phys_page_find_alloc(index, 0); PhysPageEntry lp = phys_map;
uint16_t s_index = phys_section_unassigned; PhysPageEntry *p;
int i;
MemoryRegionSection section; MemoryRegionSection section;
target_phys_addr_t delta; target_phys_addr_t delta;
uint16_t s_index = phys_section_unassigned;
if (p) { for (i = P_L2_LEVELS - 1; i >= 0; i--) {
s_index = *p; 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]; section = phys_sections[s_index];
index <<= TARGET_PAGE_BITS; index <<= TARGET_PAGE_BITS;
assert(section.offset_within_address_space <= index assert(section.offset_within_address_space <= index