]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
memblock: Permit existing reserved regions to be marked RSRV_KERN
authorArd Biesheuvel <ardb@kernel.org>
Wed, 25 Feb 2026 12:39:48 +0000 (13:39 +0100)
committerArd Biesheuvel <ardb@kernel.org>
Thu, 9 Apr 2026 15:14:36 +0000 (17:14 +0200)
Permit existing memblock reservations to be marked as RSRV_KERN. This
will be used by the EFI code on x86 to distinguish between reservations
of boot services data regions that have actual significance to the
kernel and regions that are reserved temporarily to work around buggy
firmware.

Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
include/linux/memblock.h
mm/memblock.c

index 6ec5e9ac06992a0dd1412ec2f32c181af36eeabd..9eac4f26835903c855c6090efabf44a252f5b0a0 100644 (file)
@@ -155,6 +155,7 @@ int memblock_mark_mirror(phys_addr_t base, phys_addr_t size);
 int memblock_mark_nomap(phys_addr_t base, phys_addr_t size);
 int memblock_clear_nomap(phys_addr_t base, phys_addr_t size);
 int memblock_reserved_mark_noinit(phys_addr_t base, phys_addr_t size);
+int memblock_reserved_mark_kern(phys_addr_t base, phys_addr_t size);
 int memblock_mark_kho_scratch(phys_addr_t base, phys_addr_t size);
 int memblock_clear_kho_scratch(phys_addr_t base, phys_addr_t size);
 
index b3ddfdec7a8092549707763bc88df0ea85611307..2505ce8b319cc9d11d11e765d218de76fd5546a0 100644 (file)
@@ -1115,6 +1115,21 @@ int __init_memblock memblock_reserved_mark_noinit(phys_addr_t base, phys_addr_t
                                    MEMBLOCK_RSRV_NOINIT);
 }
 
+/**
+ * memblock_reserved_mark_kern - Mark a reserved memory region with flag
+ * MEMBLOCK_RSRV_KERN
+ *
+ * @base: the base phys addr of the region
+ * @size: the size of the region
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+int __init_memblock memblock_reserved_mark_kern(phys_addr_t base, phys_addr_t size)
+{
+       return memblock_setclr_flag(&memblock.reserved, base, size, 1,
+                                   MEMBLOCK_RSRV_KERN);
+}
+
 /**
  * memblock_mark_kho_scratch - Mark a memory region as MEMBLOCK_KHO_SCRATCH.
  * @base: the base phys addr of the region