From: Brian Gerst <bgerst@didntduck.org>

Don't abuse empty_zero_page as temporary storage for boot parameters and
command line.  This is a holdover from the days before discardable init
sections.


---

 25-akpm/Documentation/i386/zero-page.txt |   10 ++--------
 25-akpm/arch/i386/boot/setup.S           |    6 +++---
 25-akpm/arch/i386/kernel/head.S          |   26 +++++++-------------------
 25-akpm/arch/i386/kernel/setup.c         |    7 ++++---
 25-akpm/arch/i386/mm/init.c              |    3 ---
 25-akpm/include/asm-i386/setup.h         |   18 +++++++++++++++---
 6 files changed, 31 insertions(+), 39 deletions(-)

diff -puN arch/i386/boot/setup.S~empty_zero_page-cleanup arch/i386/boot/setup.S
--- 25/arch/i386/boot/setup.S~empty_zero_page-cleanup	2004-03-14 23:52:09.537159648 -0800
+++ 25-akpm/arch/i386/boot/setup.S	2004-03-14 23:52:09.547158128 -0800
@@ -612,7 +612,7 @@ disk_sig_done:
 #    int 13h ah=08h "Legacy Get Device Parameters"
 #
 # A buffer of size EDDMAXNR*(EDDEXTSIZE+EDDPARMSIZE) is reserved for our use
-# in the empty_zero_page at EDDBUF.  The first four bytes of which are
+# in the boot_params at EDDBUF.  The first four bytes of which are
 # used to store the device number, interface support map and version
 # results from fn41.  The next four bytes are used to store the legacy
 # cylinders, heads, and sectors from fn08. The following 74 bytes are used to
@@ -625,9 +625,9 @@ disk_sig_done:
 # the structure, and the fn41 and fn08 results are stored at offsets
 # from there.  This removes the need to increment the pointer for
 # every store, and leaves it ready for the fn48 call.
-# A second one-byte buffer, EDDNR, in the empty_zero_page stores
+# A second one-byte buffer, EDDNR, in boot_params stores
 # the number of BIOS devices which exist, up to EDDMAXNR.
-# In setup.c, copy_edd() stores both empty_zero_page buffers away
+# In setup.c, copy_edd() stores both boot_params buffers away
 # for later use, as they would get overwritten otherwise.
 # This code is sensitive to the size of the structs in edd.h
 edd_start:
diff -puN arch/i386/kernel/head.S~empty_zero_page-cleanup arch/i386/kernel/head.S
--- 25/arch/i386/kernel/head.S~empty_zero_page-cleanup	2004-03-14 23:52:09.538159496 -0800
+++ 25-akpm/arch/i386/kernel/head.S	2004-03-14 23:52:09.548157976 -0800
@@ -18,12 +18,7 @@
 #include <asm/cache.h>
 #include <asm/thread_info.h>
 #include <asm/asm_offsets.h>
-
-#define OLD_CL_MAGIC_ADDR	0x90020
-#define OLD_CL_MAGIC		0xA33F
-#define OLD_CL_BASE_ADDR	0x90000
-#define OLD_CL_OFFSET		0x90022
-#define NEW_CL_POINTER		0x228	/* Relative to real mode data */
+#include <asm/setup.h>
 
 /*
  * References to members of the new_cpu_data structure.
@@ -195,22 +190,15 @@ ENTRY(startup_32_smp)
 	call setup_idt
 
 /*
- * Copy bootup parameters out of the way. First 2kB of
- * _empty_zero_page is for boot parameters, second 2kB
- * is for the command line.
- *
+ * Copy bootup parameters out of the way.
  * Note: %esi still has the pointer to the real-mode data.
  */
-	movl $empty_zero_page,%edi
-	movl $512,%ecx
+	movl $boot_params,%edi
+	movl $(PARAM_SIZE/4),%ecx
 	cld
 	rep
 	movsl
-	xorl %eax,%eax
-	movl $512,%ecx
-	rep
-	stosl
-	movl empty_zero_page+NEW_CL_POINTER,%esi
+	movl boot_params+NEW_CL_POINTER,%esi
 	andl %esi,%esi
 	jnz 2f			# New command line protocol
 	cmpw $(OLD_CL_MAGIC),OLD_CL_MAGIC_ADDR
@@ -218,8 +206,8 @@ ENTRY(startup_32_smp)
 	movzwl OLD_CL_OFFSET,%esi
 	addl $(OLD_CL_BASE_ADDR),%esi
 2:
-	movl $empty_zero_page+2048,%edi
-	movl $512,%ecx
+	movl $saved_command_line,%edi
+	movl $(COMMAND_LINE_SIZE/4),%ecx
 	rep
 	movsl
 1:
diff -puN arch/i386/kernel/setup.c~empty_zero_page-cleanup arch/i386/kernel/setup.c
--- 25/arch/i386/kernel/setup.c~empty_zero_page-cleanup	2004-03-14 23:52:09.540159192 -0800
+++ 25-akpm/arch/i386/kernel/setup.c	2004-03-14 23:52:09.549157824 -0800
@@ -130,6 +130,8 @@ unsigned long saved_videomode;
 static char command_line[COMMAND_LINE_SIZE];
        char saved_command_line[COMMAND_LINE_SIZE];
 
+unsigned char __initdata boot_params[PARAM_SIZE];
+
 static struct resource code_resource = { "Kernel code", 0x100000, 0 };
 static struct resource data_resource = { "Kernel data", 0, 0 };
 
@@ -456,7 +458,7 @@ EXPORT_SYMBOL(edd_disk80_sig);
 #endif
 /**
  * copy_edd() - Copy the BIOS EDD information
- *              from empty_zero_page into a safe place.
+ *              from boot_params into a safe place.
  *
  */
 static inline void copy_edd(void)
@@ -485,12 +487,11 @@ static void __init setup_memory_region(v
 
 static void __init parse_cmdline_early (char ** cmdline_p)
 {
-	char c = ' ', *to = command_line, *from = COMMAND_LINE;
+	char c = ' ', *to = command_line, *from = saved_command_line;
 	int len = 0;
 	int userdef = 0;
 
 	/* Save unparsed command line copy for /proc/cmdline */
-	memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
 	saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
 
 	for (;;) {
diff -puN arch/i386/mm/init.c~empty_zero_page-cleanup arch/i386/mm/init.c
--- 25/arch/i386/mm/init.c~empty_zero_page-cleanup	2004-03-14 23:52:09.541159040 -0800
+++ 25-akpm/arch/i386/mm/init.c	2004-03-14 23:52:09.550157672 -0800
@@ -474,9 +474,6 @@ void __init mem_init(void)
 	high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
 #endif
 
-	/* clear the zero-page */
-	memset(empty_zero_page, 0, PAGE_SIZE);
-
 	/* this will put all low memory onto the freelists */
 	totalram_pages += __free_all_bootmem();
 
diff -puN Documentation/i386/zero-page.txt~empty_zero_page-cleanup Documentation/i386/zero-page.txt
--- 25/Documentation/i386/zero-page.txt~empty_zero_page-cleanup	2004-03-14 23:52:09.543158736 -0800
+++ 25-akpm/Documentation/i386/zero-page.txt	2004-03-14 23:52:09.550157672 -0800
@@ -1,7 +1,7 @@
-Summary of empty_zero_page layout (kernel point of view)
+Summary of boot_params layout (kernel point of view)
      ( collected by Hans Lermen and Martin Mares )
  
-The contents of empty_zero_page are used to pass parameters from the
+The contents of boot_params are used to pass parameters from the
 16-bit realmode code of the kernel to the 32-bit part. References/settings
 to it mainly are in:
 
@@ -76,9 +76,3 @@ Offset	Type		Description
 0x2d0 - 0x600		E820MAP
 0x600 - 0x7ff		EDDBUF (setup.S) for disk signature read sector
 0x600 - 0x7eb		EDDBUF (setup.S) for edd data
-
-0x800	string, 2K max	COMMAND_LINE, the kernel commandline as
-			copied using CL_OFFSET.
-			Note: this will be copied once more by setup.c
-			into a local buffer which is only 256 bytes long.
-			( #define COMMAND_LINE_SIZE 256 )
diff -puN include/asm-i386/setup.h~empty_zero_page-cleanup include/asm-i386/setup.h
--- 25/include/asm-i386/setup.h~empty_zero_page-cleanup	2004-03-14 23:52:09.544158584 -0800
+++ 25-akpm/include/asm-i386/setup.h	2004-03-14 23:52:09.550157672 -0800
@@ -16,10 +16,22 @@
 #define MAXMEM_PFN	PFN_DOWN(MAXMEM)
 #define MAX_NONPAE_PFN	(1 << 20)
 
+#define PARAM_SIZE 2048
+#define COMMAND_LINE_SIZE 256
+
+#define OLD_CL_MAGIC_ADDR	0x90020
+#define OLD_CL_MAGIC		0xA33F
+#define OLD_CL_BASE_ADDR	0x90000
+#define OLD_CL_OFFSET		0x90022
+#define NEW_CL_POINTER		0x228	/* Relative to real mode data */
+
+#ifndef __ASSEMBLY__
 /*
  * This is set up by the setup-routine at boot-time
  */
-#define PARAM	((unsigned char *)empty_zero_page)
+extern unsigned char boot_params[PARAM_SIZE];
+
+#define PARAM	(boot_params)
 #define SCREEN_INFO (*(struct screen_info *) (PARAM+0))
 #define EXT_MEM_K (*(unsigned short *) (PARAM+2))
 #define ALT_MEM_K (*(unsigned long *) (PARAM+0x1e0))
@@ -47,7 +59,7 @@
 #define DISK80_SIGNATURE (*(unsigned int*) (PARAM+DISK80_SIG_BUFFER))
 #define EDD_NR     (*(unsigned char *) (PARAM+EDDNR))
 #define EDD_BUF     ((struct edd_info *) (PARAM+EDDBUF))
-#define COMMAND_LINE ((char *) (PARAM+2048))
-#define COMMAND_LINE_SIZE 256
+
+#endif /* __ASSEMBLY__ */
 
 #endif /* _i386_SETUP_H */

_