aboutsummaryrefslogtreecommitdiff
path: root/exec.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2012-02-13 16:44:19 +0200
committerAvi Kivity <avi@redhat.com>2012-02-29 13:44:44 +0200
commit31ab2b4a46eb9761feae9457387eb5ee523f5afd (patch)
tree287c24aee211057bb9955c90fbf53fc8e3546c4c /exec.c
parent06ef3525e1f271b6a842781a05eace5cf63b95c2 (diff)
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>
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/exec.c b/exec.c
index bf34dc9e43..24423d5cb6 100644
--- a/exec.c
+++ b/exec.c
@@ -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)
{
- uint16_t *p = phys_page_find_alloc(index, 0);
- uint16_t s_index = phys_section_unassigned;
+ PhysPageEntry lp = phys_map;
+ PhysPageEntry *p;
+ int i;
MemoryRegionSection section;
target_phys_addr_t delta;
+ uint16_t s_index = phys_section_unassigned;
- if (p) {
- s_index = *p;
+ for (i = P_L2_LEVELS - 1; i >= 0; i--) {
+ 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];
index <<= TARGET_PAGE_BITS;
assert(section.offset_within_address_space <= index