@@ -668,7 +668,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt)
unsigned int flags;
l3_pgentry_t *pl3e = NULL;
l2_pgentry_t *pl2e = NULL;
- l1_pgentry_t *pl1e;
+ l1_pgentry_t *pl1e = NULL;
int rc;
/*
@@ -715,7 +715,8 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt)
}
else
{
- pl1e = l2e_to_l1e(*pl2e) + l1_table_offset(linear);
+ pl1e = map_xen_pagetable_new(l2e_get_mfn(*pl2e));
+ pl1e += l1_table_offset(linear);
flags = l1e_get_flags(*pl1e);
if ( !(flags & _PAGE_PRESENT) )
{
@@ -726,6 +727,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt)
}
}
+ UNMAP_XEN_PAGETABLE_NEW(pl1e);
UNMAP_XEN_PAGETABLE_NEW(pl2e);
UNMAP_XEN_PAGETABLE_NEW(pl3e);
@@ -774,19 +776,22 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt)
if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) )
{
- pl1e = alloc_xen_pagetable();
- if ( !pl1e )
+ mfn_t l1t_mfn = alloc_xen_pagetable_new();
+
+ if ( mfn_eq(l1t_mfn, INVALID_MFN) )
{
rc = -ENOMEM;
goto out;
}
+
+ pl1e = map_xen_pagetable_new(l1t_mfn);
clear_page(pl1e);
- l2e_write(pl2e, l2e_from_paddr(__pa(pl1e), __PAGE_HYPERVISOR));
+ l2e_write(pl2e, l2e_from_mfn(l1t_mfn, __PAGE_HYPERVISOR));
}
else
{
ASSERT(!(l2e_get_flags(*pl2e) & _PAGE_PSE));
- pl1e = l2e_to_l1e(*pl2e);
+ pl1e = map_xen_pagetable_new(l2e_get_mfn(*pl2e));
}
pl1e += l1_table_offset(linear);
@@ -802,6 +807,7 @@ static int clone_mapping(const void *ptr, root_pgentry_t *rpt)
rc = 0;
out:
+ UNMAP_XEN_PAGETABLE_NEW(pl1e);
UNMAP_XEN_PAGETABLE_NEW(pl2e);
UNMAP_XEN_PAGETABLE_NEW(pl3e);
return rc;