From 209c729d3302bd2403d9dd4bfa74a803311d4b2b Mon Sep 17 00:00:00 2001 From: kettenis Date: Mon, 5 Sep 2022 19:18:56 +0000 Subject: [PATCH] Don't ignore memory blocks smaller than 64KB. Some EFI implementations (such as the one on the x13s) allocate memory with the EfiBootSevicesData type in a semi-random fashion. Ignoring small regions with that type results in different memory maps between boots of the same kernel. This causes problems with upcoming hibernate support. The decision to ignore small regions was made because we do this on amd64 to work arounmd broken BIOS implementations and because of fears that we would run out of physical memory segments in UVM. We have some reasons to believe that we can trust the EFI memory map on arm64 and the risk of running out of physical memory segments is mitigated by the fact that we try to merge memory regions before loading them into UVM. If for some reason we see a significant drop in physical memory on certain machines, we should probably increase the number of items in the array we use to store memory regions and/or increase the number of physical memory segments in UVM. ok mlarkin@ --- sys/arch/arm64/arm64/machdep.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sys/arch/arm64/arm64/machdep.c b/sys/arch/arm64/arm64/machdep.c index baa6c2c7d22..41be380880d 100644 --- a/sys/arch/arm64/arm64/machdep.c +++ b/sys/arch/arm64/arm64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.71 2022/08/29 17:13:57 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.72 2022/09/05 19:18:56 kettenis Exp $ */ /* * Copyright (c) 2014 Patrick Wildt * Copyright (c) 2021 Mark Kettenis @@ -963,8 +963,7 @@ initarm(struct arm64_bootparams *abp) /* * Load all memory marked as EfiConventionalMemory, * EfiBootServicesCode or EfiBootServicesData. - * Don't bother with blocks smaller than 64KB. The - * initial 64MB memory block should be marked as + * The initial 64MB memory block should be marked as * EfiLoaderData so it won't be added here. */ for (i = 0; i < mmap_size / mmap_desc_size; i++) { @@ -974,10 +973,9 @@ initarm(struct arm64_bootparams *abp) desc->VirtualStart, desc->NumberOfPages, desc->Attribute); #endif - if ((desc->Type == EfiConventionalMemory || - desc->Type == EfiBootServicesCode || - desc->Type == EfiBootServicesData) && - desc->NumberOfPages >= 16) { + if (desc->Type == EfiConventionalMemory || + desc->Type == EfiBootServicesCode || + desc->Type == EfiBootServicesData) { reg.addr = desc->PhysicalStart; reg.size = ptoa(desc->NumberOfPages); memreg_add(®); -- 2.20.1