mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
util/selfmap: Rewrite using qemu/interval-tree.h
We will want to be able to search the set of mappings. For this patch, the two users iterate the tree in order. Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
5f4e5b3409
commit
3ce3dd8ca9
4 changed files with 97 additions and 68 deletions
|
@ -2620,7 +2620,8 @@ static uintptr_t pgd_find_hole_fallback(uintptr_t guest_size, uintptr_t brk,
|
|||
static uintptr_t pgb_find_hole(uintptr_t guest_loaddr, uintptr_t guest_size,
|
||||
long align, uintptr_t offset)
|
||||
{
|
||||
GSList *maps, *iter;
|
||||
IntervalTreeRoot *maps;
|
||||
IntervalTreeNode *iter;
|
||||
uintptr_t this_start, this_end, next_start, brk;
|
||||
intptr_t ret = -1;
|
||||
|
||||
|
@ -2638,12 +2639,15 @@ static uintptr_t pgb_find_hole(uintptr_t guest_loaddr, uintptr_t guest_size,
|
|||
/* The first hole is before the first map entry. */
|
||||
this_start = mmap_min_addr;
|
||||
|
||||
for (iter = maps; iter;
|
||||
this_start = next_start, iter = g_slist_next(iter)) {
|
||||
for (iter = interval_tree_iter_first(maps, 0, -1);
|
||||
iter;
|
||||
this_start = next_start,
|
||||
iter = interval_tree_iter_next(iter, 0, -1)) {
|
||||
MapInfo *info = container_of(iter, MapInfo, itree);
|
||||
uintptr_t align_start, hole_size;
|
||||
|
||||
this_end = ((MapInfo *)iter->data)->start;
|
||||
next_start = ((MapInfo *)iter->data)->end;
|
||||
this_end = info->itree.start;
|
||||
next_start = info->itree.last + 1;
|
||||
align_start = ROUND_UP(this_start + offset, align);
|
||||
|
||||
/* Skip holes that are too small. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue