@@ -5562,6 +5562,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
if ( l3e_get_flags(*pl3e) & _PAGE_PSE )
{
l2_pgentry_t *l2t;
+ mfn_t mfn;
if ( l2_table_offset(v) == 0 &&
l1_table_offset(v) == 0 &&
@@ -5578,13 +5579,15 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
}
/* PAGE1GB: shatter the superpage and fall through. */
- l2t = alloc_xen_pagetable();
- if ( !l2t )
+ mfn = alloc_xen_pagetable_new();
+ if ( mfn_eq(mfn, INVALID_MFN) )
{
ASSERT(rc == -ENOMEM);
goto out;
}
+ l2t = map_xen_pagetable_new(mfn);
+
for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ )
l2e_write(l2t + i,
l2e_from_pfn(l3e_get_pfn(*pl3e) +
@@ -5595,14 +5598,16 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
if ( (l3e_get_flags(*pl3e) & _PAGE_PRESENT) &&
(l3e_get_flags(*pl3e) & _PAGE_PSE) )
{
- l3e_write_atomic(pl3e, l3e_from_mfn(virt_to_mfn(l2t),
- __PAGE_HYPERVISOR));
- l2t = NULL;
+ l3e_write_atomic(pl3e, l3e_from_mfn(mfn, __PAGE_HYPERVISOR));
+ UNMAP_XEN_PAGETABLE_NEW(l2t);
}
if ( locking )
spin_unlock(&map_pgdir_lock);
if ( l2t )
- free_xen_pagetable(l2t);
+ {
+ UNMAP_XEN_PAGETABLE_NEW(l2t);
+ free_xen_pagetable_new(mfn);
+ }
}
/*
@@ -5637,15 +5642,18 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
else
{
l1_pgentry_t *l1t;
+ mfn_t mfn;
/* PSE: shatter the superpage and try again. */
- l1t = alloc_xen_pagetable();
- if ( !l1t )
+ mfn = alloc_xen_pagetable_new();
+ if ( mfn_eq(mfn, INVALID_MFN) )
{
ASSERT(rc == -ENOMEM);
goto out;
}
+ l1t = map_xen_pagetable_new(mfn);
+
for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
l1e_write(&l1t[i],
l1e_from_pfn(l2e_get_pfn(*pl2e) + i,
@@ -5655,14 +5663,17 @@ int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int nf)
if ( (l2e_get_flags(*pl2e) & _PAGE_PRESENT) &&
(l2e_get_flags(*pl2e) & _PAGE_PSE) )
{
- l2e_write_atomic(pl2e, l2e_from_mfn(virt_to_mfn(l1t),
+ l2e_write_atomic(pl2e, l2e_from_mfn(mfn,
__PAGE_HYPERVISOR));
- l1t = NULL;
+ UNMAP_XEN_PAGETABLE_NEW(l1t);
}
if ( locking )
spin_unlock(&map_pgdir_lock);
if ( l1t )
- free_xen_pagetable(l1t);
+ {
+ UNMAP_XEN_PAGETABLE_NEW(l1t);
+ free_xen_pagetable_new(mfn);
+ }
}
}
else