Revision b7e95164
b/exec.c | ||
---|---|---|
154 | 154 |
return ret; |
155 | 155 |
} |
156 | 156 |
|
157 |
static void phys_map_nodes_reset(void) |
|
158 |
{ |
|
159 |
phys_map_nodes_nb = 0; |
|
160 |
} |
|
161 |
|
|
162 |
|
|
163 | 157 |
static void phys_page_set_level(PhysPageEntry *lp, hwaddr *index, |
164 | 158 |
hwaddr *nb, uint16_t leaf, |
165 | 159 |
int level) |
... | ... | |
755 | 749 |
uint16_t section); |
756 | 750 |
static subpage_t *subpage_init(AddressSpace *as, hwaddr base); |
757 | 751 |
|
758 |
static void destroy_l2_mapping(PhysPageEntry *lp, unsigned level) |
|
759 |
{ |
|
760 |
unsigned i; |
|
761 |
PhysPageEntry *p; |
|
762 |
|
|
763 |
if (lp->ptr == PHYS_MAP_NODE_NIL) { |
|
764 |
return; |
|
765 |
} |
|
766 |
|
|
767 |
p = phys_map_nodes[lp->ptr]; |
|
768 |
for (i = 0; i < L2_SIZE; ++i) { |
|
769 |
if (!p[i].is_leaf) { |
|
770 |
destroy_l2_mapping(&p[i], level - 1); |
|
771 |
} |
|
772 |
} |
|
773 |
lp->is_leaf = 0; |
|
774 |
lp->ptr = PHYS_MAP_NODE_NIL; |
|
775 |
} |
|
776 |
|
|
777 |
static void destroy_all_mappings(AddressSpaceDispatch *d) |
|
778 |
{ |
|
779 |
destroy_l2_mapping(&d->phys_map, P_L2_LEVELS - 1); |
|
780 |
phys_map_nodes_reset(); |
|
781 |
} |
|
782 |
|
|
783 | 752 |
static uint16_t phys_section_add(MemoryRegionSection *section) |
784 | 753 |
{ |
785 | 754 |
/* The physical section number is ORed with a page-aligned |
... | ... | |
812 | 781 |
MemoryRegionSection *section = &phys_sections[--phys_sections_nb]; |
813 | 782 |
phys_section_destroy(section->mr); |
814 | 783 |
} |
784 |
phys_map_nodes_nb = 0; |
|
815 | 785 |
} |
816 | 786 |
|
817 | 787 |
static void register_subpage(AddressSpaceDispatch *d, MemoryRegionSection *section) |
... | ... | |
1716 | 1686 |
{ |
1717 | 1687 |
AddressSpaceDispatch *d = container_of(listener, AddressSpaceDispatch, listener); |
1718 | 1688 |
|
1719 |
destroy_all_mappings(d); |
|
1720 | 1689 |
d->phys_map.ptr = PHYS_MAP_NODE_NIL; |
1721 | 1690 |
} |
1722 | 1691 |
|
... | ... | |
1783 | 1752 |
AddressSpaceDispatch *d = as->dispatch; |
1784 | 1753 |
|
1785 | 1754 |
memory_listener_unregister(&d->listener); |
1786 |
destroy_l2_mapping(&d->phys_map, P_L2_LEVELS - 1); |
|
1787 | 1755 |
g_free(d); |
1788 | 1756 |
as->dispatch = NULL; |
1789 | 1757 |
} |
Also available in: Unified diff