exec: pass hw address to phys_page_find

callers always shift by target page bits so let's just do this
internally.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Michael S. Tsirkin 2013-11-13 20:08:19 +02:00
parent 8b795765db
commit 97115a8d45
1 changed files with 4 additions and 4 deletions

8
exec.c
View File

@ -216,10 +216,11 @@ static void phys_page_set(AddressSpaceDispatch *d,
phys_page_set_level(&d->phys_map, &index, &nb, leaf, P_L2_LEVELS - 1); phys_page_set_level(&d->phys_map, &index, &nb, leaf, P_L2_LEVELS - 1);
} }
static MemoryRegionSection *phys_page_find(PhysPageEntry lp, hwaddr index, static MemoryRegionSection *phys_page_find(PhysPageEntry lp, hwaddr addr,
Node *nodes, MemoryRegionSection *sections) Node *nodes, MemoryRegionSection *sections)
{ {
PhysPageEntry *p; PhysPageEntry *p;
hwaddr index = addr >> TARGET_PAGE_BITS;
int i; int i;
for (i = P_L2_LEVELS; lp.skip && (i -= lp.skip) >= 0;) { for (i = P_L2_LEVELS; lp.skip && (i -= lp.skip) >= 0;) {
@ -245,8 +246,7 @@ static MemoryRegionSection *address_space_lookup_region(AddressSpaceDispatch *d,
MemoryRegionSection *section; MemoryRegionSection *section;
subpage_t *subpage; subpage_t *subpage;
section = phys_page_find(d->phys_map, addr >> TARGET_PAGE_BITS, section = phys_page_find(d->phys_map, addr, d->nodes, d->sections);
d->nodes, d->sections);
if (resolve_subpage && section->mr->subpage) { if (resolve_subpage && section->mr->subpage) {
subpage = container_of(section->mr, subpage_t, iomem); subpage = container_of(section->mr, subpage_t, iomem);
section = &d->sections[subpage->sub_section[SUBPAGE_IDX(addr)]]; section = &d->sections[subpage->sub_section[SUBPAGE_IDX(addr)]];
@ -802,7 +802,7 @@ static void register_subpage(AddressSpaceDispatch *d, MemoryRegionSection *secti
subpage_t *subpage; subpage_t *subpage;
hwaddr base = section->offset_within_address_space hwaddr base = section->offset_within_address_space
& TARGET_PAGE_MASK; & TARGET_PAGE_MASK;
MemoryRegionSection *existing = phys_page_find(d->phys_map, base >> TARGET_PAGE_BITS, MemoryRegionSection *existing = phys_page_find(d->phys_map, base,
next_map.nodes, next_map.sections); next_map.nodes, next_map.sections);
MemoryRegionSection subsection = { MemoryRegionSection subsection = {
.offset_within_address_space = base, .offset_within_address_space = base,