]> git.hungrycats.org Git - linux/commitdiff
[PATCH] don't abuse empty_zero_page (x86)
authorAndrew Morton <akpm@osdl.org>
Thu, 18 Mar 2004 23:00:00 +0000 (15:00 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 18 Mar 2004 23:00:00 +0000 (15:00 -0800)
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.

Documentation/i386/zero-page.txt
arch/i386/boot/setup.S
arch/i386/kernel/head.S
arch/i386/kernel/setup.c
arch/i386/mm/init.c
include/asm-i386/setup.h

index 7df3080b519049492606c38e120ff871420f50ea..8d2a1f173bf776fb99aa8b2cf016d9e297c3cc84 100644 (file)
@@ -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 )
index 7ed058ddc51fd14e7147616cabf16d895879cab2..014c9f47cc09e60bc904a7d0a6677e4a237d4a12 100644 (file)
@@ -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:
index 779e2fc5a90349f89d897265cc91f3993d0c7fd8..14a4618fbdeec4e09d24bda58507c3580c198479 100644 (file)
 #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:
index ee195edf051e86322fe9799d417c37cab1a52ff7..b8dd09cd2c2fdde435704ff0cc5feacfbcc530d9 100644 (file)
@@ -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(void)
 
 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 (;;) {
index 2c2e03bd843491288fcf7091bd1b743fd9468c91..a9923661f3172e59afbd2a06bd55f40b02d734dc 100644 (file)
@@ -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();
 
index bac2c9f0f7d88171c1068313cf27382e4ef122b7..e17ba1cd8bc686872b43cdc6103b627c4e649192 100644 (file)
 #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 */