Skip to content

Commit 0d9fad9

Browse files
Kars-de-Jonggeertu
authored andcommitted
m68k: mm: Fix systems with memory at end of 32-bit address space
The calculation of end addresses of memory chunks overflowed to 0 when a memory chunk is located at the end of 32-bit address space. This is the case for the HP300 architecture. Link: https://lore.kernel.org/linux-m68k/CACz-3rhUo5pgNwdWHaPWmz+30Qo9xCg70wNxdf7o5x-6tXq8QQ@mail.gmail.com/ Signed-off-by: Kars de Jong <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent fe15c26 commit 0d9fad9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

arch/m68k/mm/motorola.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ void __init paging_init(void)
437437
}
438438

439439
min_addr = m68k_memory[0].addr;
440-
max_addr = min_addr + m68k_memory[0].size;
440+
max_addr = min_addr + m68k_memory[0].size - 1;
441441
memblock_add_node(m68k_memory[0].addr, m68k_memory[0].size, 0,
442442
MEMBLOCK_NONE);
443443
for (i = 1; i < m68k_num_memory;) {
@@ -452,21 +452,21 @@ void __init paging_init(void)
452452
}
453453
memblock_add_node(m68k_memory[i].addr, m68k_memory[i].size, i,
454454
MEMBLOCK_NONE);
455-
addr = m68k_memory[i].addr + m68k_memory[i].size;
455+
addr = m68k_memory[i].addr + m68k_memory[i].size - 1;
456456
if (addr > max_addr)
457457
max_addr = addr;
458458
i++;
459459
}
460460
m68k_memoffset = min_addr - PAGE_OFFSET;
461-
m68k_virt_to_node_shift = fls(max_addr - min_addr - 1) - 6;
461+
m68k_virt_to_node_shift = fls(max_addr - min_addr) - 6;
462462

463463
module_fixup(NULL, __start_fixup, __stop_fixup);
464464
flush_icache();
465465

466-
high_memory = phys_to_virt(max_addr);
466+
high_memory = phys_to_virt(max_addr) + 1;
467467

468468
min_low_pfn = availmem >> PAGE_SHIFT;
469-
max_pfn = max_low_pfn = max_addr >> PAGE_SHIFT;
469+
max_pfn = max_low_pfn = (max_addr >> PAGE_SHIFT) + 1;
470470

471471
/* Reserve kernel text/data/bss and the memory allocated in head.S */
472472
memblock_reserve(m68k_memory[0].addr, availmem - m68k_memory[0].addr);

0 commit comments

Comments
 (0)