@@ -254,8 +254,7 @@ int mapcache_domain_init(struct domain *d)
spin_lock_init(&dcache->lock);
return create_perdomain_mapping(d, (unsigned long)dcache->inuse,
- 2 * bitmap_pages + 1,
- NIL(l1_pgentry_t *), NULL);
+ 2 * bitmap_pages + 1, false);
}
int mapcache_vcpu_init(struct vcpu *v)
@@ -272,16 +271,15 @@ int mapcache_vcpu_init(struct vcpu *v)
if ( ents > dcache->entries )
{
/* Populate page tables. */
- int rc = create_perdomain_mapping(d, MAPCACHE_VIRT_START, ents,
- NIL(l1_pgentry_t *), NULL);
+ int rc = create_perdomain_mapping(d, MAPCACHE_VIRT_START, ents, false);
/* Populate bit maps. */
if ( !rc )
rc = create_perdomain_mapping(d, (unsigned long)dcache->inuse,
- nr, NULL, NIL(struct page_info *));
+ nr, true);
if ( !rc )
rc = create_perdomain_mapping(d, (unsigned long)dcache->garbage,
- nr, NULL, NIL(struct page_info *));
+ nr, true);
if ( rc )
return rc;
@@ -601,7 +601,7 @@ int hvm_domain_initialise(struct domain *d,
INIT_LIST_HEAD(&d->arch.hvm.mmcfg_regions);
INIT_LIST_HEAD(&d->arch.hvm.msix_tables);
- rc = create_perdomain_mapping(d, PERDOMAIN_VIRT_START, 0, NULL, NULL);
+ rc = create_perdomain_mapping(d, PERDOMAIN_VIRT_START, 0, false);
if ( rc )
goto fail;
@@ -601,8 +601,7 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg);
#define IS_NIL(ptr) (!((uintptr_t)(ptr) + sizeof(*(ptr))))
int create_perdomain_mapping(struct domain *d, unsigned long va,
- unsigned int nr, l1_pgentry_t **pl1tab,
- struct page_info **ppg);
+ unsigned int nr, bool populate);
void populate_perdomain_mapping(const struct vcpu *v, unsigned long va,
mfn_t *mfn, unsigned long nr);
void destroy_perdomain_mapping(const struct vcpu *v, unsigned long va,
@@ -6301,8 +6301,7 @@ static bool perdomain_l1e_needs_freeing(l1_pgentry_t l1e)
}
int create_perdomain_mapping(struct domain *d, unsigned long va,
- unsigned int nr, l1_pgentry_t **pl1tab,
- struct page_info **ppg)
+ unsigned int nr, bool populate)
{
struct page_info *pg;
l3_pgentry_t *l3tab;
@@ -6351,55 +6350,32 @@ int create_perdomain_mapping(struct domain *d, unsigned long va,
unmap_domain_page(l3tab);
- if ( !pl1tab && !ppg )
- {
- unmap_domain_page(l2tab);
- return 0;
- }
-
for ( l1tab = NULL; !rc && nr--; )
{
l2_pgentry_t *pl2e = l2tab + l2_table_offset(va);
if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) )
{
- if ( pl1tab && !IS_NIL(pl1tab) )
- {
- l1tab = alloc_xenheap_pages(0, MEMF_node(domain_to_node(d)));
- if ( !l1tab )
- {
- rc = -ENOMEM;
- break;
- }
- ASSERT(!pl1tab[l2_table_offset(va)]);
- pl1tab[l2_table_offset(va)] = l1tab;
- pg = virt_to_page(l1tab);
- }
- else
+ pg = alloc_domheap_page(d, MEMF_no_owner);
+ if ( !pg )
{
- pg = alloc_domheap_page(d, MEMF_no_owner);
- if ( !pg )
- {
- rc = -ENOMEM;
- break;
- }
- l1tab = __map_domain_page(pg);
+ rc = -ENOMEM;
+ break;
}
+ l1tab = __map_domain_page(pg);
clear_page(l1tab);
*pl2e = l2e_from_page(pg, __PAGE_HYPERVISOR_RW);
}
else if ( !l1tab )
l1tab = map_l1t_from_l2e(*pl2e);
- if ( ppg &&
+ if ( populate &&
!(l1e_get_flags(l1tab[l1_table_offset(va)]) & _PAGE_PRESENT) )
{
pg = alloc_domheap_page(d, MEMF_no_owner);
if ( pg )
{
clear_domain_page(page_to_mfn(pg));
- if ( !IS_NIL(ppg) )
- *ppg++ = pg;
l1tab[l1_table_offset(va)] =
l1e_from_page(pg, __PAGE_HYPERVISOR_RW | _PAGE_AVAIL0);
l2e_add_flags(*pl2e, _PAGE_AVAIL0);
@@ -6618,10 +6594,7 @@ void free_perdomain_mappings(struct domain *d)
unmap_domain_page(l1tab);
}
- if ( is_xen_heap_page(l1pg) )
- free_xenheap_page(page_to_virt(l1pg));
- else
- free_domheap_page(l1pg);
+ free_domheap_page(l1pg);
}
unmap_domain_page(l2tab);
@@ -278,9 +278,7 @@ int switch_compat(struct domain *d)
static int pv_create_gdt_ldt_l1tab(struct vcpu *v)
{
return create_perdomain_mapping(v->domain, GDT_VIRT_START(v),
- 1U << GDT_LDT_VCPU_SHIFT,
- NIL(l1_pgentry_t *),
- NULL);
+ 1U << GDT_LDT_VCPU_SHIFT, false);
}
static void pv_destroy_gdt_ldt_l1tab(struct vcpu *v)
@@ -731,8 +731,7 @@ void __init zap_low_mappings(void)
int setup_compat_arg_xlat(struct vcpu *v)
{
return create_perdomain_mapping(v->domain, ARG_XLAT_START(v),
- PFN_UP(COMPAT_ARG_XLAT_SIZE),
- NULL, NIL(struct page_info *));
+ PFN_UP(COMPAT_ARG_XLAT_SIZE), true);
}
void free_compat_arg_xlat(struct vcpu *v)
There are no longer any callers of create_perdomain_mapping() that request a reference to the used L1 tables, and hence the only difference between them is whether the caller wants the region to be populated, or just the paging structures to be allocated. Simplify the arguments to create_perdomain_mapping() to reflect the current usages: drop the last two arguments and instead introduce a boolean to signal whether the caller wants the region populated. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- xen/arch/x86/domain_page.c | 10 ++++---- xen/arch/x86/hvm/hvm.c | 2 +- xen/arch/x86/include/asm/mm.h | 3 +-- xen/arch/x86/mm.c | 43 +++++++---------------------------- xen/arch/x86/pv/domain.c | 4 +--- xen/arch/x86/x86_64/mm.c | 3 +-- 6 files changed, 16 insertions(+), 49 deletions(-)