Commit 10f0bf6b authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] don't abuse empty_zero_page (x86)

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.
parent 8a87e758
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 ) ( 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 16-bit realmode code of the kernel to the 32-bit part. References/settings
to it mainly are in: to it mainly are in:
...@@ -76,9 +76,3 @@ Offset Type Description ...@@ -76,9 +76,3 @@ Offset Type Description
0x2d0 - 0x600 E820MAP 0x2d0 - 0x600 E820MAP
0x600 - 0x7ff EDDBUF (setup.S) for disk signature read sector 0x600 - 0x7ff EDDBUF (setup.S) for disk signature read sector
0x600 - 0x7eb EDDBUF (setup.S) for edd data 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 )
...@@ -612,7 +612,7 @@ disk_sig_done: ...@@ -612,7 +612,7 @@ disk_sig_done:
# int 13h ah=08h "Legacy Get Device Parameters" # int 13h ah=08h "Legacy Get Device Parameters"
# #
# A buffer of size EDDMAXNR*(EDDEXTSIZE+EDDPARMSIZE) is reserved for our use # 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 # used to store the device number, interface support map and version
# results from fn41. The next four bytes are used to store the legacy # 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 # cylinders, heads, and sectors from fn08. The following 74 bytes are used to
...@@ -625,9 +625,9 @@ disk_sig_done: ...@@ -625,9 +625,9 @@ disk_sig_done:
# the structure, and the fn41 and fn08 results are stored at offsets # the structure, and the fn41 and fn08 results are stored at offsets
# from there. This removes the need to increment the pointer for # from there. This removes the need to increment the pointer for
# every store, and leaves it ready for the fn48 call. # 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. # 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. # for later use, as they would get overwritten otherwise.
# This code is sensitive to the size of the structs in edd.h # This code is sensitive to the size of the structs in edd.h
edd_start: edd_start:
......
...@@ -18,12 +18,7 @@ ...@@ -18,12 +18,7 @@
#include <asm/cache.h> #include <asm/cache.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/asm_offsets.h> #include <asm/asm_offsets.h>
#include <asm/setup.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 */
/* /*
* References to members of the new_cpu_data structure. * References to members of the new_cpu_data structure.
...@@ -195,22 +190,15 @@ ENTRY(startup_32_smp) ...@@ -195,22 +190,15 @@ ENTRY(startup_32_smp)
call setup_idt call setup_idt
/* /*
* Copy bootup parameters out of the way. First 2kB of * Copy bootup parameters out of the way.
* _empty_zero_page is for boot parameters, second 2kB
* is for the command line.
*
* Note: %esi still has the pointer to the real-mode data. * Note: %esi still has the pointer to the real-mode data.
*/ */
movl $empty_zero_page,%edi movl $boot_params,%edi
movl $512,%ecx movl $(PARAM_SIZE/4),%ecx
cld cld
rep rep
movsl movsl
xorl %eax,%eax movl boot_params+NEW_CL_POINTER,%esi
movl $512,%ecx
rep
stosl
movl empty_zero_page+NEW_CL_POINTER,%esi
andl %esi,%esi andl %esi,%esi
jnz 2f # New command line protocol jnz 2f # New command line protocol
cmpw $(OLD_CL_MAGIC),OLD_CL_MAGIC_ADDR cmpw $(OLD_CL_MAGIC),OLD_CL_MAGIC_ADDR
...@@ -218,8 +206,8 @@ ENTRY(startup_32_smp) ...@@ -218,8 +206,8 @@ ENTRY(startup_32_smp)
movzwl OLD_CL_OFFSET,%esi movzwl OLD_CL_OFFSET,%esi
addl $(OLD_CL_BASE_ADDR),%esi addl $(OLD_CL_BASE_ADDR),%esi
2: 2:
movl $empty_zero_page+2048,%edi movl $saved_command_line,%edi
movl $512,%ecx movl $(COMMAND_LINE_SIZE/4),%ecx
rep rep
movsl movsl
1: 1:
......
...@@ -130,6 +130,8 @@ unsigned long saved_videomode; ...@@ -130,6 +130,8 @@ unsigned long saved_videomode;
static char command_line[COMMAND_LINE_SIZE]; static char command_line[COMMAND_LINE_SIZE];
char saved_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 code_resource = { "Kernel code", 0x100000, 0 };
static struct resource data_resource = { "Kernel data", 0, 0 }; static struct resource data_resource = { "Kernel data", 0, 0 };
...@@ -456,7 +458,7 @@ EXPORT_SYMBOL(edd_disk80_sig); ...@@ -456,7 +458,7 @@ EXPORT_SYMBOL(edd_disk80_sig);
#endif #endif
/** /**
* copy_edd() - Copy the BIOS EDD information * 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) static inline void copy_edd(void)
...@@ -485,12 +487,11 @@ static void __init setup_memory_region(void) ...@@ -485,12 +487,11 @@ static void __init setup_memory_region(void)
static void __init parse_cmdline_early (char ** cmdline_p) 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 len = 0;
int userdef = 0; int userdef = 0;
/* Save unparsed command line copy for /proc/cmdline */ /* 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'; saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
for (;;) { for (;;) {
......
...@@ -474,9 +474,6 @@ void __init mem_init(void) ...@@ -474,9 +474,6 @@ void __init mem_init(void)
high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
#endif #endif
/* clear the zero-page */
memset(empty_zero_page, 0, PAGE_SIZE);
/* this will put all low memory onto the freelists */ /* this will put all low memory onto the freelists */
totalram_pages += __free_all_bootmem(); totalram_pages += __free_all_bootmem();
......
...@@ -16,10 +16,22 @@ ...@@ -16,10 +16,22 @@
#define MAXMEM_PFN PFN_DOWN(MAXMEM) #define MAXMEM_PFN PFN_DOWN(MAXMEM)
#define MAX_NONPAE_PFN (1 << 20) #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 * 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 SCREEN_INFO (*(struct screen_info *) (PARAM+0))
#define EXT_MEM_K (*(unsigned short *) (PARAM+2)) #define EXT_MEM_K (*(unsigned short *) (PARAM+2))
#define ALT_MEM_K (*(unsigned long *) (PARAM+0x1e0)) #define ALT_MEM_K (*(unsigned long *) (PARAM+0x1e0))
...@@ -47,7 +59,7 @@ ...@@ -47,7 +59,7 @@
#define DISK80_SIGNATURE (*(unsigned int*) (PARAM+DISK80_SIG_BUFFER)) #define DISK80_SIGNATURE (*(unsigned int*) (PARAM+DISK80_SIG_BUFFER))
#define EDD_NR (*(unsigned char *) (PARAM+EDDNR)) #define EDD_NR (*(unsigned char *) (PARAM+EDDNR))
#define EDD_BUF ((struct edd_info *) (PARAM+EDDBUF)) #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 */ #endif /* _i386_SETUP_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment