From: "H. Peter Anvin" We just discovered that the accounting for initial memory usage (head.S: INIT_MAP_BEYOND_END) has been way, way off for a very long time. This patch makes the initial page table not round up to the nearest 4M boundary, but instead stop dead (and zero the rest of the final page table) as soon as it hits the configured limit. This patch is intended as a debugging aid. If it goes into the kernel, it should go in at the very beginning of a review cycle, as it may very well expose real failures (without Jeremy's patch to fix the accounting, it *will* crash.) Signed-off-by: H. Peter Anvin Cc: Jeremy Fitzhardinge Cc: Andi Kleen Signed-off-by: Andrew Morton --- arch/i386/kernel/head.S | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) diff -puN arch/i386/kernel/head.S~mm-only-i386-for-debugging-make-the-initial-page-table-setup-less-forgiving arch/i386/kernel/head.S --- a/arch/i386/kernel/head.S~mm-only-i386-for-debugging-make-the-initial-page-table-setup-less-forgiving +++ a/arch/i386/kernel/head.S @@ -146,15 +146,27 @@ page_pde_offset = (__PAGE_OFFSET >> 20); movl %ecx,page_pde_offset(%edx) /* Store kernel PDE entry */ addl $4,%edx movl $1024, %ecx + /* + * End condition: we must map up to and including + * INIT_MAP_BEYOND_END bytes beyond the end of our + * own page tables; 0x1000 is the size of the page + * table were about to write, and +0x007 is the + * attribute bits. + */ + leal (INIT_MAP_BEYOND_END+0x1000+0x007)(%edi),%ebp 11: stosl addl $0x1000,%eax - loop 11b - /* End condition: we must map up to and including INIT_MAP_BEYOND_END */ - /* bytes beyond the end of our own page tables; the +0x007 is the attribute bits */ - leal (INIT_MAP_BEYOND_END+0x007)(%edi),%ebp cmpl %ebp,%eax - jb 10b + jae 12f + loop 11b + jmp 10b +12: + /* Clear the remainder of the last page table */ + decl %ecx + xorl %eax,%eax + rep; stosl + movl %edi,(init_pg_tables_end - __PAGE_OFFSET) xorl %ebx,%ebx /* This is the boot CPU (BSP) */ _