Revision d17b5288 exec.c
b/exec.c | ||
---|---|---|
2767 | 2767 |
} |
2768 | 2768 |
#endif |
2769 | 2769 |
|
2770 |
static ram_addr_t find_ram_offset(ram_addr_t size) |
|
2771 |
{ |
|
2772 |
RAMBlock *block; |
|
2773 |
ram_addr_t last = 0; |
|
2774 |
|
|
2775 |
QLIST_FOREACH(block, &ram_list.blocks, next) |
|
2776 |
last = MAX(last, block->offset + block->length); |
|
2777 |
|
|
2778 |
return last; |
|
2779 |
} |
|
2780 |
|
|
2770 | 2781 |
ram_addr_t qemu_ram_alloc(ram_addr_t size) |
2771 | 2782 |
{ |
2772 | 2783 |
RAMBlock *new_block; |
... | ... | |
2800 | 2811 |
madvise(new_block->host, size, MADV_MERGEABLE); |
2801 | 2812 |
#endif |
2802 | 2813 |
} |
2803 |
new_block->offset = ram_list.last_offset;
|
|
2814 |
new_block->offset = find_ram_offset(size);
|
|
2804 | 2815 |
new_block->length = size; |
2805 | 2816 |
|
2806 | 2817 |
QLIST_INSERT_HEAD(&ram_list.blocks, new_block, next); |
2807 | 2818 |
|
2808 | 2819 |
ram_list.phys_dirty = qemu_realloc(ram_list.phys_dirty, |
2809 |
(ram_list.last_offset + size) >> TARGET_PAGE_BITS);
|
|
2810 |
memset(ram_list.phys_dirty + (ram_list.last_offset >> TARGET_PAGE_BITS),
|
|
2820 |
(new_block->offset + size) >> TARGET_PAGE_BITS);
|
|
2821 |
memset(ram_list.phys_dirty + (new_block->offset >> TARGET_PAGE_BITS),
|
|
2811 | 2822 |
0xff, size >> TARGET_PAGE_BITS); |
2812 | 2823 |
|
2813 |
ram_list.last_offset += size; |
|
2814 |
|
|
2815 | 2824 |
if (kvm_enabled()) |
2816 | 2825 |
kvm_setup_guest_memory(new_block->host, size); |
2817 | 2826 |
|
Also available in: Unified diff