ARM: 8167/1: extend the reserved memory for initrd to be page aligned
authorYalin Wang <Yalin.Wang@sonymobile.com>
Fri, 26 Sep 2014 02:07:09 +0000 (03:07 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 2 Oct 2014 20:29:17 +0000 (21:29 +0100)
This patch extends the start and end address of initrd to be page aligned,
so that we can free all memory including the un-page aligned head or tail
page of initrd, if the start or end address of initrd are not page
aligned, the page can't be freed by free_initrd_mem() function.

Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/mm/init.c
arch/arm64/mm/init.c

index 659c75d808dc28baf4755a0d2e3f062265cab3c9..9221645dd192dbbfc0b0ae479642583487f99c76 100644 (file)
@@ -636,6 +636,11 @@ static int keep_initrd;
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
        if (!keep_initrd) {
+               if (start == initrd_start)
+                       start = round_down(start, PAGE_SIZE);
+               if (end == initrd_end)
+                       end = round_up(end, PAGE_SIZE);
+
                poison_init_mem((void *)start, PAGE_ALIGN(end) - start);
                free_reserved_area((void *)start, (void *)end, -1, "initrd");
        }
index 5472c24018766ea5348d2d0cb56f9a932f46356a..c5512f6948146f3e1336cff9843a6dc6f0a88b54 100644 (file)
@@ -334,8 +334,14 @@ static int keep_initrd;
 
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-       if (!keep_initrd)
+       if (!keep_initrd) {
+               if (start == initrd_start)
+                       start = round_down(start, PAGE_SIZE);
+               if (end == initrd_end)
+                       end = round_up(end, PAGE_SIZE);
+
                free_reserved_area((void *)start, (void *)end, 0, "initrd");
+       }
 }
 
 static int __init keepinitrd_setup(char *__unused)