[PATCH] m68k: mm: Set min_low_pfn to the start of RAM

From: Daniel Palmer

Date: Thu Dec 03 2026 - 18:57:02 EST


Currently min_low_pfn is the first page after the kernel image.

Freeing the init sections causes some memory at the tail of the kernel
image to be freed and become available to be allocated.

Since commit b12d66278dd6 ("dma-direct: check for overflows on 32 bit DMA addresses")
dma_capable() checks the memory that is about to be used for DMA isn't
below min_low_pfn so if memory allocated from the freed init sections
is passed in it'll be rejected because it is below min_low_pfn resulting
in DMA not working for SCSI etc.

The kernel image itself is protected by memblock_reserve() so we can
just set min_low_pfn to the lowest RAM pfn without having to worry
about the kernel get stomped on.

This also means the workaround the virt machine had is no longer
needed so get rid of that too.

Fixes: b12d66278dd6 ("dma-direct: check for overflows on 32 bit DMA addresses")
Tested-by: Daniel Palmer <daniel@xxxxxxxxx> # Amiga 4000, MVME147
Tested-by: Denis Ahrens <denis@xxxxxxx> # MVME177
Tested-by: Steffen A. Mork <linux-dev@xxxxxxxxxx> # Amiga 2000, Amiga 3000 (FS-UAE)
Signed-off-by: Daniel Palmer <daniel@xxxxxxxx>
---
arch/m68k/mm/motorola.c | 2 +-
arch/m68k/virt/platform.c | 3 ---
2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index f3efa0d13963..ad7777541100 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -511,7 +511,7 @@ void __init paging_init(void)

high_memory = phys_to_virt(max_addr) + 1;

- min_low_pfn = availmem >> PAGE_SHIFT;
+ min_low_pfn = min_addr >> PAGE_SHIFT;
max_pfn = max_low_pfn = (max_addr >> PAGE_SHIFT) + 1;

/* Reserve kernel text/data/bss and the memory allocated in head.S */
diff --git a/arch/m68k/virt/platform.c b/arch/m68k/virt/platform.c
index 764f556b4b32..1b3b99dd9557 100644
--- a/arch/m68k/virt/platform.c
+++ b/arch/m68k/virt/platform.c
@@ -41,9 +41,6 @@ static int __init virt_platform_init(void)
if (!MACH_IS_VIRT)
return -ENODEV;

- /* We need this to have DMA'able memory provided to goldfish-tty */
- min_low_pfn = 0;
-
pdev1 = platform_device_register_simple("goldfish_tty",
PLATFORM_DEVID_NONE,
goldfish_tty_res,
--
2.55.0