Skip to contentSkip to conversation

Made VMALLOC_END of type unsigned long.

PATCH New Andreas Fenkart 3 participants 20 messages Oct 1, 2009 – Jan 15, 2010 1 message not in the archive

Subsystems (14)
lore
Share & tools
lore
#1 lore raw

PATCH 1/4 Made VMALLOC_END of type unsigned long.

In reply to a message not in the archive

Here it is, rebased against commit
7fa07729e439a6184bd824746d06a49cca553f15.

I added macros simplifying the printout message, as your suggested. Patches are now split/merged differently so they describe one logical step.

Unfortunately the macros you suggested trigger a checkpatch.pl warning:

ERROR: Macros with complex values should be enclosed in parenthesis #628: FILE: arm/mm/init.c:628:
+#define MLM(b, t) b, t, ((t) - (b)) >> 20

Resolving these results in a compiler warning:
arch/arm/mm/init.c:649: warning: left-hand operand of comma expression has no effect

I resolved the compiler warning, since it likes an error too.

king regards

Andreas

#2 lore raw

PATCH 1/6 Add "virtual kernel memory..." printout.

Code based on parisc and x86_32.

---
 arch/arm/mm/init.c |   78 ++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 69 insertions(+), 9 deletions(-)
arch/arm/mm/init.c +69 -9
index f982606..a49f97c 100644
@@ -23,6 +23,7 @@
 #include <asm/setup.h>
 #include <asm/sizes.h>
 #include <asm/tlb.h>
+#include <asm/fixmap.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -542,7 +543,7 @@ static void __init free_unused_memmap_node(int node, struct meminfo *mi)
  */
 void __init mem_init(void)
 {
-	unsigned int codesize, datasize, initsize;
+	unsigned long reserved_pages, free_pages;
 	int i, node;
 
 #ifndef CONFIG_DISCONTIGMEM
@@ -578,6 +579,33 @@ void __init mem_init(void)
 	totalram_pages += totalhigh_pages;
 #endif
 
+	reserved_pages = free_pages = 0;
+
+	for_each_online_node(node) {
+		pg_data_t *n = NODE_DATA(node);
+		struct page *map = pgdat_page_nr(n, 0) - n->node_start_pfn;
+
+		for_each_nodebank(i, &meminfo, node) {
+			struct membank *bank = &meminfo.bank[i];
+			unsigned int pfn1, pfn2;
+			struct page *page, *end;
+
+			pfn1 = bank_pfn_start(bank);
+			pfn2 = bank_pfn_end(bank);
+
+			page = map + pfn1;
+			end  = map + pfn2;
+
+			do {
+				if (PageReserved(page))
+					reserved_pages++;
+				else if (!page_count(page))
+					free_pages++;
+				page++;
+			} while (page < end);
+		}
+	}
+
 	/*
 	 * Since our memory may not be contiguous, calculate the
 	 * real number of pages we have in this system
@@ -590,16 +618,48 @@ void __init mem_init(void)
 	}
 	printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
 
-	codesize = _etext - _text;
-	datasize = _end - _data;
-	initsize = __init_end - __init_begin;
-
-	printk(KERN_NOTICE "Memory: %luKB available (%dK code, "
-		"%dK data, %dK init, %luK highmem)\n",
-		nr_free_pages() << (PAGE_SHIFT-10), codesize >> 10,
-		datasize >> 10, initsize >> 10,
+	printk(KERN_NOTICE "Memory: %luk/%luk available, %luk reserved, %luK highmem\n",
+		nr_free_pages() << (PAGE_SHIFT-10),
+		free_pages << (PAGE_SHIFT-10),
+		reserved_pages << (PAGE_SHIFT-10),
 		(unsigned long) (totalhigh_pages << (PAGE_SHIFT-10)));
 
+#define MLK(b, t) b, t, ((t) - (b)) >> 10
+#define MLM(b, t) b, t, ((t) - (b)) >> 20
+#define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), SZ_1K)
+
+	printk(KERN_NOTICE "virtual kernel memory layout:\n"
+			"    vector  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
+			"    fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
+			"    vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
+			"    lowmem  : 0x%08lx - 0x%08lx   (%4ld MB)\n"
+#ifdef CONFIG_HIGHMEM
+			"    pkmap   : 0x%08lx - 0x%08lx   (%4ld MB)\n"
+#endif
+			"    modules : 0x%08lx - 0x%08lx   (%4ld MB)\n"
+			"      .init : 0x%p" " - 0x%p" "   (%4d kB)\n"
+			"      .text : 0x%p" " - 0x%p" "   (%4d kB)\n"
+			"      .data : 0x%p" " - 0x%p" "   (%4d kB)\n",
+
+			MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) +
+				(PAGE_SIZE)),
+			MLK(FIXADDR_START, FIXADDR_TOP),
+			MLM(VMALLOC_START, (unsigned long)VMALLOC_END),
+			MLM(PAGE_SIZE, (unsigned long)high_memory),
+#ifdef CONFIG_HIGHMEM
+			MLM(PKMAP_BASE, (PKMAP_BASE) + (LAST_PKMAP) *
+				(PAGE_SIZE)),
+#endif
+			MLM(MODULES_VADDR, MODULES_END),
+
+			MLK_ROUNDUP(__init_begin, __init_end),
+			MLK_ROUNDUP(_text, _etext),
+			MLK_ROUNDUP(_data, _edata));
+
+#undef MLK
+#undef MLM
+#undef MLK_ROUNDUP
+
 	if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
 		extern int sysctl_overcommit_memory;
 		/*
Signature · 1 line
1.6.4.3
#3 lore raw

PATCH 2/6 Make delimiters of DMA area globally visibly.

Adds DMA area to 'virtual memory map' startup message

---
 arch/arm/include/asm/memory.h |   19 +++++++++++--------
 arch/arm/mm/dma-mapping.c     |    3 ---
 arch/arm/mm/init.c            |    6 ++++++
 3 files changed, 17 insertions(+), 11 deletions(-)
arch/arm/include/asm/memory.h +11 -8
index cefedf0..38b6a78 100644
@@ -76,6 +76,17 @@
  */
 #define IOREMAP_MAX_ORDER	24
 
+/*
+ * Size of DMA-consistent memory region.  Must be multiple of 2M,
+ * between 2MB and 14MB inclusive.
+ */
+#ifndef CONSISTENT_DMA_SIZE
+#define CONSISTENT_DMA_SIZE 	SZ_2M
+#endif
+
+#define CONSISTENT_END		(0xffe00000UL)
+#define CONSISTENT_BASE		(CONSISTENT_END - CONSISTENT_DMA_SIZE)
+
 #else /* CONFIG_MMU */
 
 /*
@@ -113,14 +124,6 @@
 #endif /* !CONFIG_MMU */
 
 /*
- * Size of DMA-consistent memory region.  Must be multiple of 2M,
- * between 2MB and 14MB inclusive.
- */
-#ifndef CONSISTENT_DMA_SIZE
-#define CONSISTENT_DMA_SIZE SZ_2M
-#endif
-
-/*
  * Physical vs virtual RAM address space conversion.  These are
  * private definitions which should NOT be used outside memory.h
  * files.  Use virt_to_phys/phys_to_virt/__pa/__va instead.
arch/arm/mm/dma-mapping.c +0 -3
index b30925f..010ce4a 100644
@@ -29,9 +29,6 @@
 #error "CONSISTENT_DMA_SIZE must be multiple of 2MiB"
 #endif
 
-#define CONSISTENT_END	(0xffe00000)
-#define CONSISTENT_BASE	(CONSISTENT_END - CONSISTENT_DMA_SIZE)
-
 #define CONSISTENT_OFFSET(x)	(((unsigned long)(x) - CONSISTENT_BASE) >> PAGE_SHIFT)
 #define CONSISTENT_PTE_INDEX(x) (((unsigned long)(x) - CONSISTENT_BASE) >> PGDIR_SHIFT)
 #define NUM_CONSISTENT_PTES (CONSISTENT_DMA_SIZE >> PGDIR_SHIFT)
arch/arm/mm/init.c +6 -0
index a49f97c..22735f6 100644
@@ -631,6 +631,9 @@ void __init mem_init(void)
 	printk(KERN_NOTICE "virtual kernel memory layout:\n"
 			"    vector  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
 			"    fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
+#ifdef CONFIG_MMU
+			"    DMA     : 0x%08lx - 0x%08lx   (%4ld MB)\n"
+#endif
 			"    vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
 			"    lowmem  : 0x%08lx - 0x%08lx   (%4ld MB)\n"
 #ifdef CONFIG_HIGHMEM
@@ -644,6 +647,9 @@ void __init mem_init(void)
 			MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) +
 				(PAGE_SIZE)),
 			MLK(FIXADDR_START, FIXADDR_TOP),
+#ifdef CONFIG_MMU
+			MLM(CONSISTENT_BASE, CONSISTENT_END),
+#endif
 			MLM(VMALLOC_START, (unsigned long)VMALLOC_END),
 			MLM(PAGE_SIZE, (unsigned long)high_memory),
 #ifdef CONFIG_HIGHMEM
Signature · 1 line
1.6.4.3
#4 lore raw

PATCH 3/6 Change type of VMALLOC_END to unsigned long.

Makes it consistent with VMALLOC_START

---
 arch/arm/include/asm/memory.h                 |    4 ++--
 arch/arm/include/asm/pgtable-nommu.h          |    4 ++--
 arch/arm/mach-davinci/include/mach/hardware.h |    2 +-
 arch/arm/mach-ep93xx/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-gemini/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-iop32x/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-iop33x/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-ixp2000/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-ixp23xx/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-ixp4xx/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-kirkwood/include/mach/vmalloc.h |    2 +-
 arch/arm/mach-lh7a40x/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-loki/include/mach/vmalloc.h     |    2 +-
 arch/arm/mach-mmp/include/mach/vmalloc.h      |    2 +-
 arch/arm/mach-mv78xx0/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-nomadik/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-ns9xxx/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-orion5x/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-pxa/include/mach/vmalloc.h      |    2 +-
 arch/arm/mach-realview/include/mach/vmalloc.h |    2 +-
 arch/arm/mach-s3c24a0/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-sa1100/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-w90x900/include/mach/vmalloc.h  |    2 +-
 arch/arm/mm/init.c                            |    2 +-
 arch/arm/plat-mxc/include/mach/vmalloc.h      |    2 +-
 arch/arm/plat-s3c/include/mach/vmalloc.h      |    2 +-
 arch/arm/plat-stmp3xxx/include/mach/vmalloc.h |    2 +-
 27 files changed, 29 insertions(+), 29 deletions(-)
arch/arm/include/asm/memory.h +2 -2
index 38b6a78..0cc3c4b 100644
@@ -104,11 +104,11 @@
 #endif
 
 #ifndef PHYS_OFFSET
-#define PHYS_OFFSET 		(CONFIG_DRAM_BASE)
+#define PHYS_OFFSET 		UL(CONFIG_DRAM_BASE)
 #endif
 
 #ifndef END_MEM
-#define END_MEM     		(CONFIG_DRAM_BASE + CONFIG_DRAM_SIZE)
+#define END_MEM     		UL(CONFIG_DRAM_BASE + CONFIG_DRAM_SIZE)
 #endif
 
 #ifndef PAGE_OFFSET
arch/arm/include/asm/pgtable-nommu.h +2 -2
index b011f2e..013cfcd 100644
@@ -86,8 +86,8 @@ extern unsigned int kobjsize(const void *objp);
  * All 32bit addresses are effectively valid for vmalloc...
  * Sort of meaningless for non-VM targets.
  */
-#define	VMALLOC_START	0
-#define	VMALLOC_END	0xffffffff
+#define	VMALLOC_START	0UL
+#define	VMALLOC_END	0xffffffffUL
 
 #define FIRST_USER_ADDRESS      (0)
 
arch/arm/mach-davinci/include/mach/hardware.h +1 -1
index 41c8938..5fd3784 100644
@@ -30,7 +30,7 @@
 #define IO_PHYS				0x01c00000
 #define IO_OFFSET			0xfd000000 /* Virtual IO = 0xfec00000 */
 #define IO_SIZE				0x00400000
-#define IO_VIRT				(IO_PHYS + IO_OFFSET)
+#define IO_VIRT				UL(IO_PHYS + IO_OFFSET)
 #define io_v2p(va)			((va) - IO_OFFSET)
 #define __IO_ADDRESS(x)			((x) + IO_OFFSET)
 #define IO_ADDRESS(pa)			IOMEM(__IO_ADDRESS(pa))
arch/arm/mach-ep93xx/include/mach/vmalloc.h +1 -1
index aed21cd..1b3f25d 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-ep93xx/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe800000
+#define VMALLOC_END	0xfe800000UL
arch/arm/mach-gemini/include/mach/vmalloc.h +1 -1
index 83e536d..45371eb 100644
@@ -7,4 +7,4 @@
  * (at your option) any later version.
  */
 
-#define VMALLOC_END	0xF0000000
+#define VMALLOC_END	0xf0000000UL
arch/arm/mach-iop32x/include/mach/vmalloc.h +1 -1
index 85ceb09..c4862d4 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-iop32x/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe000000
+#define VMALLOC_END	0xfe000000UL
arch/arm/mach-iop33x/include/mach/vmalloc.h +1 -1
index f9f99de..48331dc 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-iop33x/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe000000
+#define VMALLOC_END	0xfe000000UL
arch/arm/mach-ixp2000/include/mach/vmalloc.h +1 -1
index d195e35..61c8dae 100644
@@ -17,4 +17,4 @@
  * The vmalloc() routines leaves a hole of 4kB between each vmalloced
  * area for the same reason. ;)
  */
-#define VMALLOC_END	    0xfb000000
+#define VMALLOC_END	    0xfb000000UL
arch/arm/mach-ixp23xx/include/mach/vmalloc.h +1 -1
index dd519f6..896c56a 100644
@@ -7,4 +7,4 @@
  * specific static I/O.
  */
 
-#define VMALLOC_END	(0xec000000)
+#define VMALLOC_END	(0xec000000UL)
arch/arm/mach-ixp4xx/include/mach/vmalloc.h +1 -1
index 7b3580b..9bcd64d 100644
@@ -1,5 +1,5 @@
 /*
  * arch/arm/mach-ixp4xx/include/mach/vmalloc.h
  */
-#define VMALLOC_END       (0xFF000000)
+#define VMALLOC_END       (0xff000000UL)
 
arch/arm/mach-kirkwood/include/mach/vmalloc.h +1 -1
index 8f48260..bf162ca 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-kirkwood/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe800000
+#define VMALLOC_END	0xfe800000UL
arch/arm/mach-lh7a40x/include/mach/vmalloc.h +1 -1
index 3fbd494..d62da73 100644
@@ -7,4 +7,4 @@
  *  version 2 as published by the Free Software Foundation.
  *
  */
-#define VMALLOC_END       (0xe8000000)
+#define VMALLOC_END       (0xe8000000UL)
arch/arm/mach-loki/include/mach/vmalloc.h +1 -1
index 8dc3bfc..5dcbd86 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-loki/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe800000
+#define VMALLOC_END	0xfe800000UL
arch/arm/mach-mmp/include/mach/vmalloc.h +1 -1
index b60ccaf..1d0bac0 100644
@@ -2,4 +2,4 @@
  * linux/arch/arm/mach-mmp/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe000000
+#define VMALLOC_END	0xfe000000UL
arch/arm/mach-mv78xx0/include/mach/vmalloc.h +1 -1
index 1c49543..ba26fe9 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-mv78xx0/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe000000
+#define VMALLOC_END	0xfe000000UL
arch/arm/mach-nomadik/include/mach/vmalloc.h +1 -1
index be12e31..f83d574 100644
@@ -1,2 +1,2 @@
 
-#define VMALLOC_END       0xe8000000
+#define VMALLOC_END       0xe8000000UL
arch/arm/mach-ns9xxx/include/mach/vmalloc.h +1 -1
index fe964d3..c865197 100644
@@ -11,6 +11,6 @@
 #ifndef __ASM_ARCH_VMALLOC_H
 #define __ASM_ARCH_VMALLOC_H
 
-#define VMALLOC_END     (0xf0000000)
+#define VMALLOC_END     (0xf0000000UL)
 
 #endif /* ifndef __ASM_ARCH_VMALLOC_H */
arch/arm/mach-orion5x/include/mach/vmalloc.h +1 -1
index 7147a29..06b50ae 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-orion5x/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END       0xfd800000
+#define VMALLOC_END       0xfd800000UL
arch/arm/mach-pxa/include/mach/vmalloc.h +1 -1
index e90c5ee..bfecfbf 100644
@@ -8,4 +8,4 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#define VMALLOC_END       (0xe8000000)
+#define VMALLOC_END       (0xe8000000UL)
arch/arm/mach-realview/include/mach/vmalloc.h +1 -1
index fe0de1b..a2a4c68 100644
@@ -18,4 +18,4 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#define VMALLOC_END		0xf8000000
+#define VMALLOC_END		0xf8000000UL
arch/arm/mach-s3c24a0/include/mach/vmalloc.h +1 -1
index 4d4fe48..9146568 100644
@@ -12,6 +12,6 @@
 #ifndef __ASM_ARCH_VMALLOC_H
 #define __ASM_ARCH_VMALLOC_H
 
-#define VMALLOC_END	  (0xE0000000)
+#define VMALLOC_END	  (0xe0000000UL)
 
 #endif /* __ASM_ARCH_VMALLOC_H */
arch/arm/mach-sa1100/include/mach/vmalloc.h +1 -1
index ec8fdc5..b3d0023 100644
@@ -1,4 +1,4 @@
 /*
  * arch/arm/mach-sa1100/include/mach/vmalloc.h
  */
-#define VMALLOC_END       (0xe8000000)
+#define VMALLOC_END       (0xe8000000UL)
arch/arm/mach-w90x900/include/mach/vmalloc.h +1 -1
index 2f9dfb9..b067e44 100644
@@ -18,6 +18,6 @@
 #ifndef __ASM_ARCH_VMALLOC_H
 #define __ASM_ARCH_VMALLOC_H
 
-#define VMALLOC_END	  (0xE0000000)
+#define VMALLOC_END	  (0xe0000000UL)
 
 #endif /* __ASM_ARCH_VMALLOC_H */
arch/arm/mm/init.c +1 -1
index 22735f6..2217041 100644
@@ -650,7 +650,7 @@ void __init mem_init(void)
 #ifdef CONFIG_MMU
 			MLM(CONSISTENT_BASE, CONSISTENT_END),
 #endif
-			MLM(VMALLOC_START, (unsigned long)VMALLOC_END),
+			MLM(VMALLOC_START, VMALLOC_END),
 			MLM(PAGE_SIZE, (unsigned long)high_memory),
 #ifdef CONFIG_HIGHMEM
 			MLM(PKMAP_BASE, (PKMAP_BASE) + (LAST_PKMAP) *
arch/arm/plat-mxc/include/mach/vmalloc.h +1 -1
index 62d9762..44243a2 100644
@@ -21,6 +21,6 @@
 #define __ASM_ARCH_MXC_VMALLOC_H__
 
 /* vmalloc ending address */
-#define VMALLOC_END       0xF4000000
+#define VMALLOC_END       0xf4000000UL
 
 #endif /* __ASM_ARCH_MXC_VMALLOC_H__ */
arch/arm/plat-s3c/include/mach/vmalloc.h +1 -1
index bfd2ca6..299d95f 100644
@@ -15,6 +15,6 @@
 #ifndef __ASM_ARCH_VMALLOC_H
 #define __ASM_ARCH_VMALLOC_H
 
-#define VMALLOC_END	  (0xE0000000)
+#define VMALLOC_END	  (0xe0000000UL)
 
 #endif /* __ASM_ARCH_VMALLOC_H */
arch/arm/plat-stmp3xxx/include/mach/vmalloc.h +1 -1
index 541b880..943c1a2 100644
@@ -9,4 +9,4 @@
  * http://www.opensource.org/licenses/gpl-license.html
  * http://www.gnu.org/copyleft/gpl.html
  */
-#define VMALLOC_END       (0xF0000000)
+#define VMALLOC_END       0xf0000000UL
Signature · 1 line
1.6.4.3
#5 lore raw

PATCH 4/6 Made totalhigh_pages unsigned long.

Makes it consistent with the extern declaration, used when CONFIG_HIGHMEM is set

---
 arch/arm/mm/init.c      |    2 +-
 include/linux/highmem.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mm/init.c +1 -1
index 2217041..4685611 100644
@@ -622,7 +622,7 @@ void __init mem_init(void)
 		nr_free_pages() << (PAGE_SHIFT-10),
 		free_pages << (PAGE_SHIFT-10),
 		reserved_pages << (PAGE_SHIFT-10),
-		(unsigned long) (totalhigh_pages << (PAGE_SHIFT-10)));
+		totalhigh_pages << (PAGE_SHIFT-10));
 
 #define MLK(b, t) b, t, ((t) - (b)) >> 10
 #define MLM(b, t) b, t, ((t) - (b)) >> 20
include/linux/highmem.h +1 -1
index 211ff44..ab2cc20 100644
@@ -46,7 +46,7 @@ void kmap_flush_unused(void);
 
 static inline unsigned int nr_free_highpages(void) { return 0; }
 
-#define totalhigh_pages 0
+#define totalhigh_pages 0UL
 
 #ifndef ARCH_HAS_KMAP
 static inline void *kmap(struct page *page)
Signature · 1 line
1.6.4.3
#6 lore raw

PATCH 5/6 Add checks to detect overlap of memory regions.

---
 arch/arm/mm/init.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
arch/arm/mm/init.c +20 -0
index 4685611..5c1a69c 100644
@@ -666,6 +666,26 @@ void __init mem_init(void)
 #undef MLM
 #undef MLK_ROUNDUP
 
+	/*
+	 * Check boundaries twice: Some fundamental inconsistencies can
+	 * be detected at build time already.
+	 */
+	BUILD_BUG_ON(VMALLOC_START			>= VMALLOC_END);
+	BUG_ON(VMALLOC_START				>= VMALLOC_END);
+
+#ifdef CONFIG_MMU
+	BUILD_BUG_ON(VMALLOC_END			> CONSISTENT_BASE);
+	BUG_ON(VMALLOC_END				> CONSISTENT_BASE);
+
+	BUILD_BUG_ON(TASK_SIZE 			> MODULES_VADDR);
+	BUG_ON(TASK_SIZE 				> MODULES_VADDR);
+#endif
+
+#ifdef CONFIG_HIGHMEM
+	BUILD_BUG_ON(PKMAP_BASE + LAST_PKMAP * PAGE_SIZE > PAGE_OFFSET);
+	BUG_ON(PKMAP_BASE + LAST_PKMAP * PAGE_SIZE	> PAGE_OFFSET);
+#endif
+
 	if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
 		extern int sysctl_overcommit_memory;
 		/*
Signature · 1 line
1.6.4.3
#7 lore raw

PATCH 6/6 Add PKMAP area description to memory.txt.

Also adapts delimiters of neighbouring modules area.

---
 Documentation/arm/memory.txt |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
Documentation/arm/memory.txt +5 -1
index 9d58c7c..eb0fae1 100644
@@ -59,7 +59,11 @@ PAGE_OFFSET	high_memory-1	Kernel direct-mapped RAM region.
 				This maps the platforms RAM, and typically
 				maps all platform RAM in a 1:1 relationship.
 
-TASK_SIZE	PAGE_OFFSET-1	Kernel module space
+PKMAP_BASE	PAGE_OFFSET-1	Permanent kernel mappings
+				One way of mapping HIGHMEM pages into kernel
+				space.
+
+MODULES_VADDR	MODULES_END-1	Kernel module space
 				Kernel modules inserted via insmod are
 				placed here using dynamic mappings.
 
Signature · 1 line
1.6.4.3
#11 lore raw

PATCH 1/4 Made VMALLOC_END of type unsigned long.

In reply to Andreas Fenkart
Quoted 7 lines · Andreas Fenkart

Here it is, rebased against commit
7fa07729e439a6184bd824746d06a49cca553f15.

I added macros simplifying the printout message, as your suggested. Patches are now split/merged differently so they describe one logical step.

Quoted 6 lines

Unfortunately the macros you suggested trigger a checkpatch.pl warning:

ERROR: Macros with complex values should be enclosed in parenthesis #628: FILE: arm/mm/init.c:628:
+#define MLM(b, t) b, t, ((t) - (b)) >> 20

This is a case where ignoring checkpatch.pl is the right thing to do. It doesn't know what is trying to be achieved, and is trying to apply an inappropriate rule.

I'd ignore this warning.

#10 lore raw

PATCH 3/6 Change type of VMALLOC_END to unsigned long.

In reply to Andreas Fenkart
Quoted 5 lines · Andreas Fenkart
arch/arm/include/asm/memory.h +0 -0
index 38b6a78..0cc3c4b 100644

arch/arm/include/asm/memory.h line 111

Quoted 10 lines
arch/arm/include/asm/memory.h +2 -2
@@ -104,11 +104,11 @@
 #endif
 
 #ifndef PHYS_OFFSET
-#define PHYS_OFFSET 		(CONFIG_DRAM_BASE)
+#define PHYS_OFFSET 		UL(CONFIG_DRAM_BASE)
 #endif
 
 #ifndef END_MEM
-#define END_MEM     		(CONFIG_DRAM_BASE + CONFIG_DRAM_SIZE)
+#define END_MEM     		UL(CONFIG_DRAM_BASE + CONFIG_DRAM_SIZE)

This is still not correct usage of UL(). This becomes:

CONFIG_DRAM_BASE + CONFIG_DRAM_SIZE##UL

or, in the case of these being defined as zero:

	0 + 0UL

That might end up ultimately being an unsigned long expression, but it would be far better to explicitly cast the right thing - the base.

Basically, UL() should not be used with an expression argument. UL()'s purpose is to allow the numerical value enclosed to be used in both C as an unsigned long constant, and also in assembly without the UL suffix (which would cause the assembler to error out.) It's not there as a generic "cast to unsigned long" operator.

arch/arm/mach-davinci/include/mach/hardware.h line 33

Quoted 10 lines
arch/arm/mach-davinci/include/mach/hardware.h +1 -1
index 41c8938..5fd3784 100644
@@ -30,7 +30,7 @@
 #define IO_PHYS				0x01c00000
 #define IO_OFFSET			0xfd000000 /* Virtual IO = 0xfec00000 */
 #define IO_SIZE				0x00400000
-#define IO_VIRT				(IO_PHYS + IO_OFFSET)
+#define IO_VIRT				UL(IO_PHYS + IO_OFFSET)

Same thing.

#9 lore raw

PATCH 4/6 Made totalhigh_pages unsigned long.

In reply to Andreas Fenkart
Quoted 2 lines · Andreas Fenkart

Makes it consistent with the extern declaration, used when CONFIG_HIGHMEM is set

The linux/highmem.h part needs to go to someone like Andrew Morton, cc'd LKML.

#8 lore raw

PATCH 5/6 Add checks to detect overlap of memory regions.

In reply to Andreas Fenkart

arch/arm/mm/init.c void __init mem_init(void) · line 674

Quoted 6 lines · Andreas Fenkart
arch/arm/mm/init.c +6 -0
+	/*
+	 * Check boundaries twice: Some fundamental inconsistencies can
+	 * be detected at build time already.
+	 */
+	BUILD_BUG_ON(VMALLOC_START			>= VMALLOC_END);
+	BUG_ON(VMALLOC_START				>= VMALLOC_END);

This one is now guaranteed by other parts of the code, and doesn't need to be checked anymore - we enforce a minimum size of 32M for the vmalloc region now.

#12 lore raw

cover Adding x86-like memory map printks to ARM.

In reply to a message not in the archive

This version has the following changes:

* Reworked UL() macro usage, as suggested

* Appended 'UL' to VMALLOC_END define of new machines:
mach-dove
mach-u300
mach-ux500

* Patch 'Make totalhigh_pages unsigned long' has been submitted separately

* Removed superfluous (VMALLOC_START < VMALLOC_END) boundary check

#13 lore raw

PATCH 1/5 Add "virtual kernel memory..." printout.

Code based on parisc and x86_32.

---
 arch/arm/mm/init.c |   78 ++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 69 insertions(+), 9 deletions(-)
arch/arm/mm/init.c +69 -9
index a04ffbb..29d5866 100644
@@ -23,6 +23,7 @@
 #include <asm/setup.h>
 #include <asm/sizes.h>
 #include <asm/tlb.h>
+#include <asm/fixmap.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -560,7 +561,7 @@ static void __init free_unused_memmap_node(int node, struct meminfo *mi)
  */
 void __init mem_init(void)
 {
-	unsigned int codesize, datasize, initsize;
+	unsigned long reserved_pages, free_pages;
 	int i, node;
 
 #ifndef CONFIG_DISCONTIGMEM
@@ -596,6 +597,33 @@ void __init mem_init(void)
 	totalram_pages += totalhigh_pages;
 #endif
 
+	reserved_pages = free_pages = 0;
+
+	for_each_online_node(node) {
+		pg_data_t *n = NODE_DATA(node);
+		struct page *map = pgdat_page_nr(n, 0) - n->node_start_pfn;
+
+		for_each_nodebank(i, &meminfo, node) {
+			struct membank *bank = &meminfo.bank[i];
+			unsigned int pfn1, pfn2;
+			struct page *page, *end;
+
+			pfn1 = bank_pfn_start(bank);
+			pfn2 = bank_pfn_end(bank);
+
+			page = map + pfn1;
+			end  = map + pfn2;
+
+			do {
+				if (PageReserved(page))
+					reserved_pages++;
+				else if (!page_count(page))
+					free_pages++;
+				page++;
+			} while (page < end);
+		}
+	}
+
 	/*
 	 * Since our memory may not be contiguous, calculate the
 	 * real number of pages we have in this system
@@ -608,16 +636,48 @@ void __init mem_init(void)
 	}
 	printk(" = %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
 
-	codesize = _etext - _text;
-	datasize = _end - _data;
-	initsize = __init_end - __init_begin;
-
-	printk(KERN_NOTICE "Memory: %luKB available (%dK code, "
-		"%dK data, %dK init, %luK highmem)\n",
-		nr_free_pages() << (PAGE_SHIFT-10), codesize >> 10,
-		datasize >> 10, initsize >> 10,
+	printk(KERN_NOTICE "Memory: %luk/%luk available, %luk reserved, %luK highmem\n",
+		nr_free_pages() << (PAGE_SHIFT-10),
+		free_pages << (PAGE_SHIFT-10),
+		reserved_pages << (PAGE_SHIFT-10),
 		totalhigh_pages << (PAGE_SHIFT-10));
 
+#define MLK(b, t) b, t, ((t) - (b)) >> 10
+#define MLM(b, t) b, t, ((t) - (b)) >> 20
+#define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), SZ_1K)
+
+	printk(KERN_NOTICE "virtual kernel memory layout:\n"
+			"    vector  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
+			"    fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
+			"    vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
+			"    lowmem  : 0x%08lx - 0x%08lx   (%4ld MB)\n"
+#ifdef CONFIG_HIGHMEM
+			"    pkmap   : 0x%08lx - 0x%08lx   (%4ld MB)\n"
+#endif
+			"    modules : 0x%08lx - 0x%08lx   (%4ld MB)\n"
+			"      .init : 0x%p" " - 0x%p" "   (%4d kB)\n"
+			"      .text : 0x%p" " - 0x%p" "   (%4d kB)\n"
+			"      .data : 0x%p" " - 0x%p" "   (%4d kB)\n",
+
+			MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) +
+				(PAGE_SIZE)),
+			MLK(FIXADDR_START, FIXADDR_TOP),
+			MLM(VMALLOC_START, (unsigned long)VMALLOC_END),
+			MLM(PAGE_SIZE, (unsigned long)high_memory),
+#ifdef CONFIG_HIGHMEM
+			MLM(PKMAP_BASE, (PKMAP_BASE) + (LAST_PKMAP) *
+				(PAGE_SIZE)),
+#endif
+			MLM(MODULES_VADDR, MODULES_END),
+
+			MLK_ROUNDUP(__init_begin, __init_end),
+			MLK_ROUNDUP(_text, _etext),
+			MLK_ROUNDUP(_data, _edata));
+
+#undef MLK
+#undef MLM
+#undef MLK_ROUNDUP
+
 	if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
 		extern int sysctl_overcommit_memory;
 		/*
Signature · 1 line
1.6.6
#14 lore raw

PATCH 2/5 Make delimiters of DMA area globally visibly.

Adds DMA area to 'virtual memory map' startup message

---
 arch/arm/include/asm/memory.h |   19 +++++++++++--------
 arch/arm/mm/dma-mapping.c     |    3 ---
 arch/arm/mm/init.c            |    6 ++++++
 3 files changed, 17 insertions(+), 11 deletions(-)
arch/arm/include/asm/memory.h +11 -8
index 5421d82..f5e693b 100644
@@ -76,6 +76,17 @@
  */
 #define IOREMAP_MAX_ORDER	24
 
+/*
+ * Size of DMA-consistent memory region.  Must be multiple of 2M,
+ * between 2MB and 14MB inclusive.
+ */
+#ifndef CONSISTENT_DMA_SIZE
+#define CONSISTENT_DMA_SIZE 	SZ_2M
+#endif
+
+#define CONSISTENT_END		(0xffe00000UL)
+#define CONSISTENT_BASE		(CONSISTENT_END - CONSISTENT_DMA_SIZE)
+
 #else /* CONFIG_MMU */
 
 /*
@@ -113,14 +124,6 @@
 #endif /* !CONFIG_MMU */
 
 /*
- * Size of DMA-consistent memory region.  Must be multiple of 2M,
- * between 2MB and 14MB inclusive.
- */
-#ifndef CONSISTENT_DMA_SIZE
-#define CONSISTENT_DMA_SIZE SZ_2M
-#endif
-
-/*
  * Physical vs virtual RAM address space conversion.  These are
  * private definitions which should NOT be used outside memory.h
  * files.  Use virt_to_phys/phys_to_virt/__pa/__va instead.
arch/arm/mm/dma-mapping.c +0 -3
index 26325cb..48eedab 100644
@@ -29,9 +29,6 @@
 #error "CONSISTENT_DMA_SIZE must be multiple of 2MiB"
 #endif
 
-#define CONSISTENT_END	(0xffe00000)
-#define CONSISTENT_BASE	(CONSISTENT_END - CONSISTENT_DMA_SIZE)
-
 #define CONSISTENT_OFFSET(x)	(((unsigned long)(x) - CONSISTENT_BASE) >> PAGE_SHIFT)
 #define CONSISTENT_PTE_INDEX(x) (((unsigned long)(x) - CONSISTENT_BASE) >> PGDIR_SHIFT)
 #define NUM_CONSISTENT_PTES (CONSISTENT_DMA_SIZE >> PGDIR_SHIFT)
arch/arm/mm/init.c +6 -0
index 29d5866..c06edd3 100644
@@ -649,6 +649,9 @@ void __init mem_init(void)
 	printk(KERN_NOTICE "virtual kernel memory layout:\n"
 			"    vector  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
 			"    fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
+#ifdef CONFIG_MMU
+			"    DMA     : 0x%08lx - 0x%08lx   (%4ld MB)\n"
+#endif
 			"    vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
 			"    lowmem  : 0x%08lx - 0x%08lx   (%4ld MB)\n"
 #ifdef CONFIG_HIGHMEM
@@ -662,6 +665,9 @@ void __init mem_init(void)
 			MLK(UL(CONFIG_VECTORS_BASE), UL(CONFIG_VECTORS_BASE) +
 				(PAGE_SIZE)),
 			MLK(FIXADDR_START, FIXADDR_TOP),
+#ifdef CONFIG_MMU
+			MLM(CONSISTENT_BASE, CONSISTENT_END),
+#endif
 			MLM(VMALLOC_START, (unsigned long)VMALLOC_END),
 			MLM(PAGE_SIZE, (unsigned long)high_memory),
 #ifdef CONFIG_HIGHMEM
Signature · 1 line
1.6.6
#15 lore raw

PATCH 3/5 Change type of VMALLOC_END to unsigned long.

Makes it consistent with VMALLOC_START

---
 arch/arm/include/asm/memory.h                 |    4 ++--
 arch/arm/include/asm/pgtable-nommu.h          |    4 ++--
 arch/arm/mach-davinci/include/mach/hardware.h |    2 +-
 arch/arm/mach-dove/include/mach/vmalloc.h     |    2 +-
 arch/arm/mach-ep93xx/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-gemini/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-iop32x/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-iop33x/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-ixp2000/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-ixp23xx/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-ixp4xx/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-kirkwood/include/mach/vmalloc.h |    2 +-
 arch/arm/mach-lh7a40x/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-loki/include/mach/vmalloc.h     |    2 +-
 arch/arm/mach-mmp/include/mach/vmalloc.h      |    2 +-
 arch/arm/mach-mv78xx0/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-nomadik/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-ns9xxx/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-orion5x/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-pxa/include/mach/vmalloc.h      |    2 +-
 arch/arm/mach-realview/include/mach/vmalloc.h |    2 +-
 arch/arm/mach-s3c24a0/include/mach/vmalloc.h  |    2 +-
 arch/arm/mach-sa1100/include/mach/vmalloc.h   |    2 +-
 arch/arm/mach-u300/include/mach/vmalloc.h     |    2 +-
 arch/arm/mach-ux500/include/mach/vmalloc.h    |    2 +-
 arch/arm/mach-w90x900/include/mach/vmalloc.h  |    2 +-
 arch/arm/mm/init.c                            |    2 +-
 arch/arm/plat-mxc/include/mach/vmalloc.h      |    2 +-
 arch/arm/plat-s3c/include/mach/vmalloc.h      |    2 +-
 arch/arm/plat-stmp3xxx/include/mach/vmalloc.h |    2 +-
 30 files changed, 32 insertions(+), 32 deletions(-)
arch/arm/include/asm/memory.h +2 -2
index f5e693b..4312ee5 100644
@@ -104,11 +104,11 @@
 #endif
 
 #ifndef PHYS_OFFSET
-#define PHYS_OFFSET 		(CONFIG_DRAM_BASE)
+#define PHYS_OFFSET 		UL(CONFIG_DRAM_BASE)
 #endif
 
 #ifndef END_MEM
-#define END_MEM     		(CONFIG_DRAM_BASE + CONFIG_DRAM_SIZE)
+#define END_MEM     		(UL(CONFIG_DRAM_BASE) + CONFIG_DRAM_SIZE)
 #endif
 
 #ifndef PAGE_OFFSET
arch/arm/include/asm/pgtable-nommu.h +2 -2
index b011f2e..013cfcd 100644
@@ -86,8 +86,8 @@ extern unsigned int kobjsize(const void *objp);
  * All 32bit addresses are effectively valid for vmalloc...
  * Sort of meaningless for non-VM targets.
  */
-#define	VMALLOC_START	0
-#define	VMALLOC_END	0xffffffff
+#define	VMALLOC_START	0UL
+#define	VMALLOC_END	0xffffffffUL
 
 #define FIRST_USER_ADDRESS      (0)
 
arch/arm/mach-davinci/include/mach/hardware.h +1 -1
index 41c8938..c45ba1f 100644
@@ -27,7 +27,7 @@
 /*
  * I/O mapping
  */
-#define IO_PHYS				0x01c00000
+#define IO_PHYS				0x01c00000UL
 #define IO_OFFSET			0xfd000000 /* Virtual IO = 0xfec00000 */
 #define IO_SIZE				0x00400000
 #define IO_VIRT				(IO_PHYS + IO_OFFSET)
arch/arm/mach-dove/include/mach/vmalloc.h +1 -1
index 8b2c974..a28792c 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-dove/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfd800000
+#define VMALLOC_END	0xfd800000UL
arch/arm/mach-ep93xx/include/mach/vmalloc.h +1 -1
index aed21cd..1b3f25d 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-ep93xx/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe800000
+#define VMALLOC_END	0xfe800000UL
arch/arm/mach-gemini/include/mach/vmalloc.h +1 -1
index 83e536d..45371eb 100644
@@ -7,4 +7,4 @@
  * (at your option) any later version.
  */
 
-#define VMALLOC_END	0xF0000000
+#define VMALLOC_END	0xf0000000UL
arch/arm/mach-iop32x/include/mach/vmalloc.h +1 -1
index 85ceb09..c4862d4 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-iop32x/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe000000
+#define VMALLOC_END	0xfe000000UL
arch/arm/mach-iop33x/include/mach/vmalloc.h +1 -1
index f9f99de..48331dc 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-iop33x/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe000000
+#define VMALLOC_END	0xfe000000UL
arch/arm/mach-ixp2000/include/mach/vmalloc.h +1 -1
index d195e35..61c8dae 100644
@@ -17,4 +17,4 @@
  * The vmalloc() routines leaves a hole of 4kB between each vmalloced
  * area for the same reason. ;)
  */
-#define VMALLOC_END	    0xfb000000
+#define VMALLOC_END	    0xfb000000UL
arch/arm/mach-ixp23xx/include/mach/vmalloc.h +1 -1
index dd519f6..896c56a 100644
@@ -7,4 +7,4 @@
  * specific static I/O.
  */
 
-#define VMALLOC_END	(0xec000000)
+#define VMALLOC_END	(0xec000000UL)
arch/arm/mach-ixp4xx/include/mach/vmalloc.h +1 -1
index 7b3580b..9bcd64d 100644
@@ -1,5 +1,5 @@
 /*
  * arch/arm/mach-ixp4xx/include/mach/vmalloc.h
  */
-#define VMALLOC_END       (0xFF000000)
+#define VMALLOC_END       (0xff000000UL)
 
arch/arm/mach-kirkwood/include/mach/vmalloc.h +1 -1
index 8f48260..bf162ca 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-kirkwood/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe800000
+#define VMALLOC_END	0xfe800000UL
arch/arm/mach-lh7a40x/include/mach/vmalloc.h +1 -1
index 3fbd494..d62da73 100644
@@ -7,4 +7,4 @@
  *  version 2 as published by the Free Software Foundation.
  *
  */
-#define VMALLOC_END       (0xe8000000)
+#define VMALLOC_END       (0xe8000000UL)
arch/arm/mach-loki/include/mach/vmalloc.h +1 -1
index 8dc3bfc..5dcbd86 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-loki/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe800000
+#define VMALLOC_END	0xfe800000UL
arch/arm/mach-mmp/include/mach/vmalloc.h +1 -1
index b60ccaf..1d0bac0 100644
@@ -2,4 +2,4 @@
  * linux/arch/arm/mach-mmp/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe000000
+#define VMALLOC_END	0xfe000000UL
arch/arm/mach-mv78xx0/include/mach/vmalloc.h +1 -1
index 1c49543..ba26fe9 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-mv78xx0/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END	0xfe000000
+#define VMALLOC_END	0xfe000000UL
arch/arm/mach-nomadik/include/mach/vmalloc.h +1 -1
index be12e31..f83d574 100644
@@ -1,2 +1,2 @@
 
-#define VMALLOC_END       0xe8000000
+#define VMALLOC_END       0xe8000000UL
arch/arm/mach-ns9xxx/include/mach/vmalloc.h +1 -1
index fe964d3..c865197 100644
@@ -11,6 +11,6 @@
 #ifndef __ASM_ARCH_VMALLOC_H
 #define __ASM_ARCH_VMALLOC_H
 
-#define VMALLOC_END     (0xf0000000)
+#define VMALLOC_END     (0xf0000000UL)
 
 #endif /* ifndef __ASM_ARCH_VMALLOC_H */
arch/arm/mach-orion5x/include/mach/vmalloc.h +1 -1
index 7147a29..06b50ae 100644
@@ -2,4 +2,4 @@
  * arch/arm/mach-orion5x/include/mach/vmalloc.h
  */
 
-#define VMALLOC_END       0xfd800000
+#define VMALLOC_END       0xfd800000UL
arch/arm/mach-pxa/include/mach/vmalloc.h +1 -1
index e90c5ee..bfecfbf 100644
@@ -8,4 +8,4 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#define VMALLOC_END       (0xe8000000)
+#define VMALLOC_END       (0xe8000000UL)
arch/arm/mach-realview/include/mach/vmalloc.h +1 -1
index fe0de1b..a2a4c68 100644
@@ -18,4 +18,4 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#define VMALLOC_END		0xf8000000
+#define VMALLOC_END		0xf8000000UL
arch/arm/mach-s3c24a0/include/mach/vmalloc.h +1 -1
index 4d4fe48..9146568 100644
@@ -12,6 +12,6 @@
 #ifndef __ASM_ARCH_VMALLOC_H
 #define __ASM_ARCH_VMALLOC_H
 
-#define VMALLOC_END	  (0xE0000000)
+#define VMALLOC_END	  (0xe0000000UL)
 
 #endif /* __ASM_ARCH_VMALLOC_H */
arch/arm/mach-sa1100/include/mach/vmalloc.h +1 -1
index ec8fdc5..b3d0023 100644
@@ -1,4 +1,4 @@
 /*
  * arch/arm/mach-sa1100/include/mach/vmalloc.h
  */
-#define VMALLOC_END       (0xe8000000)
+#define VMALLOC_END       (0xe8000000UL)
arch/arm/mach-u300/include/mach/vmalloc.h +1 -1
index b00c51a..ec423b9 100644
@@ -9,4 +9,4 @@
  * End must be above the I/O registers and on an even 2MiB boundary.
  * Author: Linus Walleij <[email protected]>
  */
-#define VMALLOC_END	0xfe800000
+#define VMALLOC_END	0xfe800000UL
arch/arm/mach-ux500/include/mach/vmalloc.h +1 -1
index 86cdbbc..a4945cb 100644
@@ -15,4 +15,4 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#define VMALLOC_END	0xf0000000
+#define VMALLOC_END	0xf0000000UL
arch/arm/mach-w90x900/include/mach/vmalloc.h +1 -1
index 2f9dfb9..b067e44 100644
@@ -18,6 +18,6 @@
 #ifndef __ASM_ARCH_VMALLOC_H
 #define __ASM_ARCH_VMALLOC_H
 
-#define VMALLOC_END	  (0xE0000000)
+#define VMALLOC_END	  (0xe0000000UL)
 
 #endif /* __ASM_ARCH_VMALLOC_H */
arch/arm/mm/init.c +1 -1
index c06edd3..f4d67bf 100644
@@ -668,7 +668,7 @@ void __init mem_init(void)
 #ifdef CONFIG_MMU
 			MLM(CONSISTENT_BASE, CONSISTENT_END),
 #endif
-			MLM(VMALLOC_START, (unsigned long)VMALLOC_END),
+			MLM(VMALLOC_START, VMALLOC_END),
 			MLM(PAGE_SIZE, (unsigned long)high_memory),
 #ifdef CONFIG_HIGHMEM
 			MLM(PKMAP_BASE, (PKMAP_BASE) + (LAST_PKMAP) *
arch/arm/plat-mxc/include/mach/vmalloc.h +1 -1
index 62d9762..44243a2 100644
@@ -21,6 +21,6 @@
 #define __ASM_ARCH_MXC_VMALLOC_H__
 
 /* vmalloc ending address */
-#define VMALLOC_END       0xF4000000
+#define VMALLOC_END       0xf4000000UL
 
 #endif /* __ASM_ARCH_MXC_VMALLOC_H__ */
arch/arm/plat-s3c/include/mach/vmalloc.h +1 -1
index bfd2ca6..299d95f 100644
@@ -15,6 +15,6 @@
 #ifndef __ASM_ARCH_VMALLOC_H
 #define __ASM_ARCH_VMALLOC_H
 
-#define VMALLOC_END	  (0xE0000000)
+#define VMALLOC_END	  (0xe0000000UL)
 
 #endif /* __ASM_ARCH_VMALLOC_H */
arch/arm/plat-stmp3xxx/include/mach/vmalloc.h +1 -1
index 541b880..943c1a2 100644
@@ -9,4 +9,4 @@
  * http://www.opensource.org/licenses/gpl-license.html
  * http://www.gnu.org/copyleft/gpl.html
  */
-#define VMALLOC_END       (0xF0000000)
+#define VMALLOC_END       0xf0000000UL
Signature · 1 line
1.6.6
#16 lore raw

PATCH 4/5 Add checks to detect overlap of memory regions.

---
 arch/arm/mm/init.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
arch/arm/mm/init.c +17 -0
index f4d67bf..3e73724 100644
@@ -684,6 +684,23 @@ void __init mem_init(void)
 #undef MLM
 #undef MLK_ROUNDUP
 
+	/*
+	 * Check boundaries twice: Some fundamental inconsistencies can
+	 * be detected at build time already.
+	 */
+#ifdef CONFIG_MMU
+	BUILD_BUG_ON(VMALLOC_END			> CONSISTENT_BASE);
+	BUG_ON(VMALLOC_END				> CONSISTENT_BASE);
+
+	BUILD_BUG_ON(TASK_SIZE				> MODULES_VADDR);
+	BUG_ON(TASK_SIZE 				> MODULES_VADDR);
+#endif
+
+#ifdef CONFIG_HIGHMEM
+	BUILD_BUG_ON(PKMAP_BASE + LAST_PKMAP * PAGE_SIZE > PAGE_OFFSET);
+	BUG_ON(PKMAP_BASE + LAST_PKMAP * PAGE_SIZE	> PAGE_OFFSET);
+#endif
+
 	if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
 		extern int sysctl_overcommit_memory;
 		/*
Signature · 1 line
1.6.6
#17 lore raw

PATCH 5/5 Add PKMAP area description to memory.txt.

Also adapts delimiters of neighbouring modules area.

---
 Documentation/arm/memory.txt |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
Documentation/arm/memory.txt +5 -1
index 9d58c7c..eb0fae1 100644
@@ -59,7 +59,11 @@ PAGE_OFFSET	high_memory-1	Kernel direct-mapped RAM region.
 				This maps the platforms RAM, and typically
 				maps all platform RAM in a 1:1 relationship.
 
-TASK_SIZE	PAGE_OFFSET-1	Kernel module space
+PKMAP_BASE	PAGE_OFFSET-1	Permanent kernel mappings
+				One way of mapping HIGHMEM pages into kernel
+				space.
+
+MODULES_VADDR	MODULES_END-1	Kernel module space
 				Kernel modules inserted via insmod are
 				placed here using dynamic mappings.
 
Signature · 1 line
1.6.6
#19 lore raw

cover Adding x86-like memory map printks to ARM.

In reply to Andreas Fenkart
Quoted 4 lines · Andreas Fenkart

This version has the following changes:

* Reworked UL() macro usage, as suggested

Quoted 9 lines

* Appended 'UL' to VMALLOC_END define of new machines:
mach-dove
mach-u300
mach-ux500

* Patch 'Make totalhigh_pages unsigned long' has been submitted separately

* Removed superfluous (VMALLOC_START < VMALLOC_END) boundary check

What I get from the Integrator/CP platform is this:

virtual kernel memory layout:

    vector  : 0xffff0000 - 0xffff1000   (   4 kB)                               
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)                               
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)                               
    vmalloc : 0xc8800000 - 0xd0000000   ( 120 MB)                               
    lowmem  : 0x00001000 - 0xc8000000   (3199 MB)                               
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)                               
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)                               
      .init : 0xc0008000 - 0xc0024000   ( 112 kB)                               
      .text : 0xc0024000 - 0xc0325000   (3076 kB)                               
      .data : 0xc0326000 - 0xc033f360   ( 101 kB)                               

which looks fine, except for the 'lowmem' entry - the start of it should be PAGE_OFFSET, not PAGE_SIZE. Apart from that, seems fine.

If you can correct that bug, and no one else has any objections, it can go into the patch system. Thanks.

#18 lore raw

PATCH 1/5 Add "virtual kernel memory..." printout.

In reply to Andreas Fenkart
Quoted 1 line · Andreas Fenkart

Code based on parisc and x86_32.

Oh, the only other thing to request is:

arch/arm/mm/init.c void __init mem_init(void) · line 649

Quoted 1 line
arch/arm/mm/init.c +1 -0
+	printk(KERN_NOTICE "virtual kernel memory layout:\n"

Can the first letter of the message be capitalised please?

#20 lore raw

cover Adding x86-like memory map printks to ARM.

In reply to Russell King - ARM Linux
Quoted 29 lines · Russell King
Quoted 4 lines · Andreas Fenkart

This version has the following changes:

* Reworked UL() macro usage, as suggested

Quoted 9 lines

* Appended 'UL' to VMALLOC_END define of new machines:
mach-dove
mach-u300
mach-ux500

* Patch 'Make totalhigh_pages unsigned long' has been submitted separately

* Removed superfluous (VMALLOC_START < VMALLOC_END) boundary check

What I get from the Integrator/CP platform is this:

virtual kernel memory layout:

    vector  : 0xffff0000 - 0xffff1000   (   4 kB)                               
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)                               
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)                               
    vmalloc : 0xc8800000 - 0xd0000000   ( 120 MB)                               
    lowmem  : 0x00001000 - 0xc8000000   (3199 MB)                               
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)                               
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)                               
      .init : 0xc0008000 - 0xc0024000   ( 112 kB)                               
      .text : 0xc0024000 - 0xc0325000   (3076 kB)                               
      .data : 0xc0326000 - 0xc033f360   ( 101 kB)                               
Quoted 5 lines

which looks fine, except for the 'lowmem' entry - the start of it should be PAGE_OFFSET, not PAGE_SIZE. Apart from that, seems fine.

If you can correct that bug, and no one else has any objections, it can go into the patch system. Thanks.

Almost forgot about this....

With Russell's corrected bug and his request to capitalize the first letter I get the following on the ep93xx platform:

Virtual kernel memory layout:

    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc6800000 - 0xfe800000   ( 896 MB)
    lowmem  : 0xc0000000 - 0xc6000000   (  96 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc0028000   ( 128 kB)
      .text : 0xc0028000 - 0xc03a0000   (3552 kB)
      .data : 0xc03ba000 - 0xc03e2aa0   ( 163 kB)

which looks fine. My only issue is, shouldn't the 'end' values all be -1.

Other than that you can add for ep93xx:

Regards,
Hartley