]> Git Repo - linux.git/commitdiff
ARM, xtensa: highmem: avoid clobbering non-page aligned memory reservations
authorArd Biesheuvel <[email protected]>
Sat, 31 Oct 2020 09:43:45 +0000 (11:43 +0200)
committerMike Rapoport <[email protected]>
Wed, 4 Nov 2020 08:42:57 +0000 (10:42 +0200)
free_highpages() iterates over the free memblock regions in high
memory, and marks each page as available for the memory management
system.

Until commit cddb5ddf2b76 ("arm, xtensa: simplify initialization of
high memory pages") it rounded beginning of each region upwards and end of
each region downwards.

However, after that commit free_highmem() rounds the beginning and end of
each region downwards, and we may end up freeing a page that is
memblock_reserve()d, resulting in memory corruption.

Restore the original rounding of the region boundaries to avoid freeing
reserved pages.

Fixes: cddb5ddf2b76 ("arm, xtensa: simplify initialization of high memory pages")
Link: https://lore.kernel.org/r/[email protected]/
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Ard Biesheuvel <[email protected]>
Co-developed-by: Mike Rapoport <[email protected]>
Signed-off-by: Mike Rapoport <[email protected]>
Acked-by: Max Filippov <[email protected]>
arch/arm/mm/init.c
arch/xtensa/mm/init.c

index d57112a276f5ac79da2100970e8ca8c6a78af54a..c23dbf8bebeeb7f4387b90e7827c6a570d940566 100644 (file)
@@ -354,8 +354,8 @@ static void __init free_highpages(void)
        /* set highmem page free */
        for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE,
                                &range_start, &range_end, NULL) {
-               unsigned long start = PHYS_PFN(range_start);
-               unsigned long end = PHYS_PFN(range_end);
+               unsigned long start = PFN_UP(range_start);
+               unsigned long end = PFN_DOWN(range_end);
 
                /* Ignore complete lowmem entries */
                if (end <= max_low)
index c6fc83efee0c94148a0da0608fec7d6e02ee140d..8731b7ad930884e26778e7c24751b0c1ce74877c 100644 (file)
@@ -89,8 +89,8 @@ static void __init free_highpages(void)
        /* set highmem page free */
        for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE,
                                &range_start, &range_end, NULL) {
-               unsigned long start = PHYS_PFN(range_start);
-               unsigned long end = PHYS_PFN(range_end);
+               unsigned long start = PFN_UP(range_start);
+               unsigned long end = PFN_DOWN(range_end);
 
                /* Ignore complete lowmem entries */
                if (end <= max_low)
This page took 0.052095 seconds and 4 git commands to generate.