From 75b87b6e89109255394bbfd5bca5d74a7bd09644 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Wed, 27 May 2020 10:22:38 -0400 Subject: [PATCH 4/5] Try to reserve rescue memory below 4GB. Some devices require DMA memory in this range. Fall back to higher allocations if necessary. --- sys/arm64/arm64/rescue_machdep.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sys/arm64/arm64/rescue_machdep.c b/sys/arm64/arm64/rescue_machdep.c index 3b4a58ea4f17..dc61e89ee775 100644 --- a/sys/arm64/arm64/rescue_machdep.c +++ b/sys/arm64/arm64/rescue_machdep.c @@ -209,11 +209,21 @@ rescue_kernel_init(void *arg __unused) } rescue_va = kmem_alloc_contig(kernel_arena, RESCUE_RESERV_SIZE, - M_WAITOK, 0, ~(vm_paddr_t)0, - RESCUE_RESERV_ALIGN, RESCUE_RESERV_BOUNDARY, VM_MEMATTR_DEFAULT); + M_WAITOK, 0, (vm_paddr_t)1 << 32, RESCUE_RESERV_ALIGN, + RESCUE_RESERV_BOUNDARY, VM_MEMATTR_DEFAULT); if (rescue_va == 0) { - printf("rescue: failed to reserve contiguous memory\n"); - goto out; + /* + * Some devices require memory below 4GB for DMA, so the rescue + * kernel may fail to boot. + */ + printf("rescue: warning: failed to allocate below 4GB\n"); + rescue_va = kmem_alloc_contig(kernel_arena, RESCUE_RESERV_SIZE, + M_WAITOK, 0, ~(vm_paddr_t)0, RESCUE_RESERV_ALIGN, + RESCUE_RESERV_BOUNDARY, VM_MEMATTR_DEFAULT); + if (rescue_va == 0) { + printf("rescue: failed to reserve contiguous memory\n"); + goto out; + } } rescue_pa = pmap_kextract(rescue_va); -- 2.36.1