x86/mm: correctly initialize M2P entries on boot
PATCH 1/1 x86/mm: correctly initialize M2P entries on boot
Since guest resource management work it's now possible to have a page assigned to a domain without a valid M2P entry. Some pathes in the code rely on the fact a GFN returned from mfn_to_gfn() for such a page is not valid as well, i.e. see arch_iommu_populate_page_table().
For systems without 512GB contiguous RAM M2P entries were already correctly initialized on boot with INVALID_M2P_ENTRY (~0UL) but on systems where M2P could be covered by a single 1GB page directory 0x77 poison was used instead. That eventually resulted in a crash during IOMMU construction on systems without shared PTs enabled.
While here fixup compat M2P entries as well.
--- xen/arch/x86/x86_64/mm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
xen/arch/x86/x86_64/mm.c +4 -2
@@ -574,8 +574,9 @@ void __init paging_init(void)page_to_mfn (l1_pg),1UL << (2 *PAGETABLE_ORDER ), PAGE_HYPERVISOR); +/* Fill with INVALID_M2P_ENTRY. */ memset ((void *)(RDWR_MPT_VIRT_START + (i <<L2_PAGETABLE_SHIFT )), -0x77 ,1UL <<L3_PAGETABLE_SHIFT ); +0xFF ,1UL <<L3_PAGETABLE_SHIFT );ASSERT (!l2_table_offset (va));/* NB. Cannot be GLOBAL: guest user mode should not see it. */
@@ -666,9 +667,10 @@ void __init paging_init(void)page_to_mfn (l1_pg),1UL <<PAGETABLE_ORDER , PAGE_HYPERVISOR); +/* Fill with INVALID_M2P_ENTRY. */ memset ((void *)(RDWR_COMPAT_MPT_VIRT_START + (i <<L2_PAGETABLE_SHIFT )), -0x55 , +0xFF ,1UL <<L2_PAGETABLE_SHIFT );/* NB. Cannot be GLOBAL as the ptes get copied into per-VM space. */ l2e_write (l2_ro_mpt,l2e_from_page (l1_pg, _PAGE_PSE|_PAGE_PRESENT));
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 2 lines · Igor Druzhinin
Since guest resource management work it's now possible to have a page assigned to a domain without a valid M2P entry. Some pathes in the code
paths
Quoted 9 lines
rely on the fact a GFN returned from
mfn_to_gfn()for such a page is not valid as well, i.e. seearch_iommu_populate_page_table().For systems without 512GB contiguous RAM M2P entries were already correctly initialized on boot with
INVALID_M2P_ENTRY(~0UL) but on systems where M2P could be covered by a single 1GB page directory0x77poison was used instead. That eventually resulted in a crash during IOMMU construction on systems without shared PTs enabled.
Quoted 3 lines
While here fixup compat M2P entries as well.
Signed-off-by Igor Druzhinin <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel