From: Julien Grall Date: Fri, 20 May 2022 12:09:26 +0000 (+0100) Subject: xen/arm: mm: Re-implement early_fdt_map() using map_pages_to_xen() X-Git-Tag: archive/raspbian/4.17.0-1+rpi1^2~33^2~597 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=f8c818848fa64b1957411faea7cee22d677cebcc;p=xen.git xen/arm: mm: Re-implement early_fdt_map() using map_pages_to_xen() Now that map_pages_to_xen() has been extended to support 2MB mappings, we can replace the create_mappings() calls by map_pages_to_xen() calls. The mapping can also be marked read-only as Xen should not modify the host Device Tree during boot. Signed-off-by: Julien Grall Signed-off-by: Julien Grall Reviewed-by: Hongda Deng Reviewed-by: Stefano Stabellini --- diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 64a79d45b3..03f970e4d1 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -574,6 +574,7 @@ void * __init early_fdt_map(paddr_t fdt_paddr) paddr_t offset; void *fdt_virt; uint32_t size; + int rc; /* * Check whether the physical FDT address is set and meets the minimum @@ -589,8 +590,12 @@ void * __init early_fdt_map(paddr_t fdt_paddr) /* The FDT is mapped using 2MB superpage */ BUILD_BUG_ON(BOOT_FDT_VIRT_START % SZ_2M); - create_mappings(xen_second, BOOT_FDT_VIRT_START, paddr_to_pfn(base_paddr), - SZ_2M >> PAGE_SHIFT, SZ_2M); + rc = map_pages_to_xen(BOOT_FDT_VIRT_START, maddr_to_mfn(base_paddr), + SZ_2M >> PAGE_SHIFT, + PAGE_HYPERVISOR_RO | _PAGE_BLOCK); + if ( rc ) + panic("Unable to map the device-tree.\n"); + offset = fdt_paddr % SECOND_SIZE; fdt_virt = (void *)BOOT_FDT_VIRT_START + offset; @@ -604,9 +609,12 @@ void * __init early_fdt_map(paddr_t fdt_paddr) if ( (offset + size) > SZ_2M ) { - create_mappings(xen_second, BOOT_FDT_VIRT_START + SZ_2M, - paddr_to_pfn(base_paddr + SZ_2M), - SZ_2M >> PAGE_SHIFT, SZ_2M); + rc = map_pages_to_xen(BOOT_FDT_VIRT_START + SZ_2M, + maddr_to_mfn(base_paddr + SZ_2M), + SZ_2M >> PAGE_SHIFT, + PAGE_HYPERVISOR_RO | _PAGE_BLOCK); + if ( rc ) + panic("Unable to map the device-tree\n"); } return fdt_virt;