From: Zwane Mwaikambo <zwane@arm.linux.org.uk>

noexec_setup runs too late to take any effect, so parse it earlier. 
 
Signed-off-by: Zwane Mwaikambo <zwane@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/i386/kernel/setup.c     |    4 ++++
 25-akpm/arch/i386/mm/init.c          |    5 +----
 25-akpm/arch/x86_64/kernel/setup.c   |    3 +++
 25-akpm/arch/x86_64/kernel/setup64.c |    5 +----
 25-akpm/include/asm-i386/pgtable.h   |    2 ++
 25-akpm/include/asm-x86_64/pgtable.h |    1 +
 6 files changed, 12 insertions(+), 8 deletions(-)

diff -puN arch/i386/kernel/setup.c~nx-fix-noexec-kernel-parameter arch/i386/kernel/setup.c
--- 25/arch/i386/kernel/setup.c~nx-fix-noexec-kernel-parameter	2004-12-06 14:02:45.310736432 -0800
+++ 25-akpm/arch/i386/kernel/setup.c	2004-12-06 14:02:45.323734456 -0800
@@ -737,6 +737,10 @@ static void __init parse_cmdline_early (
 			}
 		}
 
+		else if (!memcmp(from, "noexec=", 7))
+			noexec_setup(from + 7);
+
+
 #ifdef  CONFIG_X86_SMP
 		/*
 		 * If the BIOS enumerates physical processors before logical,
diff -puN arch/i386/mm/init.c~nx-fix-noexec-kernel-parameter arch/i386/mm/init.c
--- 25/arch/i386/mm/init.c~nx-fix-noexec-kernel-parameter	2004-12-06 14:02:45.312736128 -0800
+++ 25-akpm/arch/i386/mm/init.c	2004-12-06 14:02:45.324734304 -0800
@@ -424,7 +424,7 @@ u64 __supported_pte_mask = ~_PAGE_NX;
  * on      Enable
  * off     Disable
  */
-static int __init noexec_setup(char *str)
+void __init noexec_setup(const char *str)
 {
 	if (!strncmp(str, "on",2) && cpu_has_nx) {
 		__supported_pte_mask |= _PAGE_NX;
@@ -433,11 +433,8 @@ static int __init noexec_setup(char *str
 		disable_nx = 1;
 		__supported_pte_mask &= ~_PAGE_NX;
 	}
-	return 1;
 }
 
-__setup("noexec=", noexec_setup);
-
 int nx_enabled = 0;
 #ifdef CONFIG_X86_PAE
 
diff -puN arch/x86_64/kernel/setup64.c~nx-fix-noexec-kernel-parameter arch/x86_64/kernel/setup64.c
--- 25/arch/x86_64/kernel/setup64.c~nx-fix-noexec-kernel-parameter	2004-12-06 14:02:45.314735824 -0800
+++ 25-akpm/arch/x86_64/kernel/setup64.c	2004-12-06 14:02:45.326734000 -0800
@@ -50,7 +50,7 @@ Control non executable mappings for 64bi
 on	Enable(default)
 off	Disable
 */ 
-static int __init nonx_setup(char *str)
+void __init nonx_setup(const char *str)
 {
 	if (!strcmp(str, "on")) {
                 __supported_pte_mask |= _PAGE_NX; 
@@ -59,11 +59,8 @@ static int __init nonx_setup(char *str)
 		do_not_nx = 1;
 		__supported_pte_mask &= ~_PAGE_NX;
         } 
-        return 1;
 } 
 
-__setup("noexec=", nonx_setup); 
-
 /*
  * Great future plan:
  * Declare PDA itself and support (irqstack,tss,pml4) as per cpu data.
diff -puN arch/x86_64/kernel/setup.c~nx-fix-noexec-kernel-parameter arch/x86_64/kernel/setup.c
--- 25/arch/x86_64/kernel/setup.c~nx-fix-noexec-kernel-parameter	2004-12-06 14:02:45.315735672 -0800
+++ 25-akpm/arch/x86_64/kernel/setup.c	2004-12-06 14:02:45.325734152 -0800
@@ -315,6 +315,9 @@ static __init void parse_cmdline_early (
 		if (!memcmp(from,"oops=panic", 10))
 			panic_on_oops = 1;
 
+		if (!memcmp(from, "noexec=", 7))
+			nonx_setup(from + 7);
+
 	next_char:
 		c = *(from++);
 		if (!c)
diff -puN include/asm-i386/pgtable.h~nx-fix-noexec-kernel-parameter include/asm-i386/pgtable.h
--- 25/include/asm-i386/pgtable.h~nx-fix-noexec-kernel-parameter	2004-12-06 14:02:45.317735368 -0800
+++ 25-akpm/include/asm-i386/pgtable.h	2004-12-06 14:02:45.322734608 -0800
@@ -353,6 +353,8 @@ extern pte_t *lookup_address(unsigned lo
  static inline int set_kernel_exec(unsigned long vaddr, int enable) { return 0;}
 #endif
 
+extern void noexec_setup(const char *str);
+
 #if defined(CONFIG_HIGHPTE)
 #define pte_offset_map(dir, address) \
 	((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address))
diff -puN include/asm-x86_64/pgtable.h~nx-fix-noexec-kernel-parameter include/asm-x86_64/pgtable.h
--- 25/include/asm-x86_64/pgtable.h~nx-fix-noexec-kernel-parameter	2004-12-06 14:02:45.318735216 -0800
+++ 25-akpm/include/asm-x86_64/pgtable.h	2004-12-06 14:02:45.324734304 -0800
@@ -20,6 +20,7 @@ extern unsigned long __supported_pte_mas
 
 #define swapper_pml4 init_level4_pgt
 
+extern void nonx_setup(const char *str);
 extern void paging_init(void);
 extern void clear_kernel_mapping(unsigned long addr, unsigned long size);
 
_