Re: [PATCH] ARM: allow, but warn, when issuing ioremap() on RAM

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Colin Cross
Date: Tuesday, October 19, 2010 - 1:13 am

On Mon, Oct 11, 2010 at 8:25 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:

If memblock_remove is used on the end of memory with this patch,
mem_init accesses off the end of the array of page structures because
of the discrepancy between memblock.memory and membank on the number
of the last pfn.   memblock.memory is used to determine the memory
zones in arm_bootmem_free, which eventually  is used to create the
array of page structures, but mem_init iterates over membank and calls
pfn_to_page on pfns up to bank_pfn_end.

Converting show_mem and mem_init to use memblock.memory fixes it:

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 52192f4..6c2b8a0 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -81,18 +81,16 @@ void show_mem(void)
 {
        int free = 0, total = 0, reserved = 0;
        int shared = 0, cached = 0, slab = 0, i;
-       struct meminfo * mi = &meminfo;

        printk("Mem-info:\n");
        show_free_areas();

-       for_each_bank (i, mi) {
-               struct membank *bank = &mi->bank[i];
+       for (i = 0; i < memblock.memory.cnt; i++) {
                unsigned int pfn1, pfn2;
                struct page *page, *end;

-               pfn1 = bank_pfn_start(bank);
-               pfn2 = bank_pfn_end(bank);
+               pfn1 = memblock_start_pfn(&memblock.memory, i);
+               pfn2 = memblock_end_pfn(&memblock.memory, i);

                page = pfn_to_page(pfn1);
                end  = pfn_to_page(pfn2 - 1) + 1;
@@ -520,13 +518,12 @@ void __init mem_init(void)

        reserved_pages = free_pages = 0;

-       for_each_bank(i, &meminfo) {
-               struct membank *bank = &meminfo.bank[i];
+       for (i = 0; i < memblock.memory.cnt; i++) {
                unsigned int pfn1, pfn2;
                struct page *page, *end;

-               pfn1 = bank_pfn_start(bank);
-               pfn2 = bank_pfn_end(bank);
+               pfn1 = memblock_start_pfn(&memblock.memory, i);
+               pfn2 = memblock_end_pfn(&memblock.memory, i);

                page = pfn_to_page(pfn1);
                end  = pfn_to_page(pfn2 - 1) + 1;
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] ARM: allow, but warn, when issuing ioremap() on RAM, Felipe Contreras, (Thu Oct 7, 2:44 am)
Re: [PATCH v2] ARM: allow, but warn, when issuing ioremap( ..., Uwe Kleine-König, (Thu Oct 7, 11:00 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Thu Oct 7, 12:22 pm)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Fri Oct 8, 10:53 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Fri Oct 8, 4:04 pm)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Fri Oct 8, 4:44 pm)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Fri Oct 8, 5:10 pm)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Fri Oct 8, 5:25 pm)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Sat Oct 9, 1:56 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Sat Oct 9, 2:21 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Sat Oct 9, 5:05 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Sat Oct 9, 6:52 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Sat Oct 9, 7:37 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Sat Oct 9, 9:45 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Guennadi Liakhovetski, (Sat Oct 9, 11:59 am)
RE: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Pedanekar, Hemant, (Sun Oct 10, 7:23 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Uwe Kleine-König, (Mon Oct 11, 1:35 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Mon Oct 11, 2:02 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Uwe Kleine-König, (Mon Oct 11, 2:24 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Mon Oct 11, 3:15 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Mon Oct 11, 3:52 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Mon Oct 11, 8:25 am)
RE: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Woodruff, Richard, (Wed Oct 13, 9:17 am)
RE: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Woodruff, Richard, (Thu Oct 14, 8:29 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Felipe Contreras, (Thu Oct 14, 10:44 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Benjamin Herrenschmidt, (Fri Oct 15, 7:36 pm)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Benjamin Herrenschmidt, (Fri Oct 15, 7:39 pm)
RE: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Woodruff, Richard, (Sun Oct 17, 6:05 am)
RE: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Benjamin Herrenschmidt, (Sun Oct 17, 4:17 pm)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Colin Cross, (Tue Oct 19, 1:13 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Tue Oct 19, 11:12 am)
Re: [PATCH] ARM: allow, but warn, when issuing ioremap() o ..., Russell King - ARM Linux, (Tue Oct 19, 12:21 pm)
Re: About multi-line printk and the need (not) to repeat l ..., Uwe Kleine-König, (Tue Nov 23, 3:39 am)
Re: About multi-line printk and the need (not) to repeat l ..., Uwe Kleine-König, (Tue Nov 23, 3:58 am)
Re: About multi-line printk and the need (not) to repeat l ..., Russell King - ARM Linux, (Tue Nov 23, 3:33 pm)
Re: About multi-line printk and the need (not) to repeat l ..., Uwe Kleine-König, (Wed Nov 24, 1:17 am)
[PATCH 0/6] add some KERN_CONT markers to continuation lines, Uwe Kleine-König, (Wed Nov 24, 1:56 am)
[PATCH 1/6] ARM: add some KERN_CONT markers to continuatio ..., =?UTF-8?q?Uwe=20Klei ..., (Wed Nov 24, 1:57 am)
[PATCH 2/6] block: add some KERN_CONT markers to continuat ..., =?UTF-8?q?Uwe=20Klei ..., (Wed Nov 24, 1:57 am)
[PATCH 3/6] net: add some KERN_CONT markers to continuatio ..., =?UTF-8?q?Uwe=20Klei ..., (Wed Nov 24, 1:57 am)
[PATCH 4/6] init: add some KERN_CONT markers to continuati ..., =?UTF-8?q?Uwe=20Klei ..., (Wed Nov 24, 1:57 am)
[PATCH 5/6] mm: add some KERN_CONT markers to continuation ..., =?UTF-8?q?Uwe=20Klei ..., (Wed Nov 24, 1:57 am)
[PATCH 6/6] tty/vt: add some KERN_CONT markers to continua ..., =?UTF-8?q?Uwe=20Klei ..., (Wed Nov 24, 1:57 am)
Re: About multi-line printk and the need (not) to repeat l ..., Michał Mirosław, (Wed Nov 24, 2:09 am)