lkml.org 
[lkml]   [1999]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] check_memory (was Re: Perform minimal RAM test at boot)
Hi,

after my post(1) talking about the GPF caused by an incorrect mem= option
I see another post+patch(2) from Pavel Machek with similar problem.

I really _like_ this patch that move the bad GPF early on boot in a safe
place where filesystem are still a dream ;)

I started to play with it and now looks better:

o No more GPF but "controlled" panic
o faster
o cleaner :?

To give a try simply boot your 32Mbytes machine with mem=64M option
with and without the patch.

Follow the diff over a clean 2.3.24:
------------------------------------

diff -urN linux-2.3.24.ori/Documentation/Configure.help linux/Documentation/Configure.help
--- linux-2.3.24.ori/Documentation/Configure.help Sat Oct 30 18:53:41 1999
+++ linux/Documentation/Configure.help Sun Oct 31 01:54:24 1999
@@ -175,6 +175,16 @@
on the Alpha. The only time you would ever not say Y is to say M in
order to debug the code. Say Y unless you know what you are doing.

+Check memory on boot
+CONFIG_MEM_CHECK
+ If you say Y here, a simple memory check will be done early on boot.
+ This can be useful in the follow situations:
+ o mem=xxx option greater than installed physical memory
+ o wrong memory size detection
+ o fault memory
+ If the check fail, kernel react with a "controlled" panic asking to
+ check memory configuration, instead of a bad and crude GPF.
+
High Memory support
CONFIG_NOHIGHMEM
If you are compiling a kernel which will never run on a machine
diff -urN linux-2.3.24.ori/arch/i386/config.in linux/arch/i386/config.in
--- linux-2.3.24.ori/arch/i386/config.in Sat Oct 30 19:39:57 1999
+++ linux/arch/i386/config.in Sat Oct 30 19:49:32 1999
@@ -54,6 +54,7 @@
define_bool CONFIG_X86_PAE y
fi

+bool 'Boot memory check' CONFIG_MEM_CHECK
bool 'Math emulation' CONFIG_MATH_EMULATION
bool 'MTRR (Memory Type Range Register) support' CONFIG_MTRR
bool 'Symmetric multi-processing support' CONFIG_SMP
diff -urN linux-2.3.24.ori/init/main.c linux/init/main.c
--- linux-2.3.24.ori/init/main.c Sat Oct 30 00:10:55 1999
+++ linux/init/main.c Sun Oct 31 02:29:31 1999
@@ -7,6 +7,8 @@
* Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96
* Moan early if gcc is old, avoiding bogus kernels - Paul Gortmaker, May '96
* Simplified starting of init: Michael A. Griffith <grif@acm.org>
+ * Simple memory check: Luca Montecchiani <m.luca@iname.com>
+ * Pavel Machek <pavel@suse.cz>, Oct '99
*/

#define __KERNEL_SYSCALLS__
@@ -440,6 +442,33 @@

#endif

+#ifdef CONFIG_MEM_CHECK
+/*
+ * Perform simple memory check
+ */
+static void memory_check(void)
+{
+ void **p_current = NULL, **p_previous = NULL;
+
+ printk( "Memory: checking memory... " );
+ while ( (p_current = (void *) get_free_page(GFP_ATOMIC)) ) {
+ *p_current = p_previous;
+ p_previous = p_current;
+ }
+ printk( "OK.\n" );
+
+ printk( "Memory: releasing checked memory... " );
+ /* we do it in reversed order to be more suspicious ;) */
+ while ( p_previous ) {
+ p_current = *p_previous;
+ p_previous = *p_previous;
+ if ( ( p_current ) && ( !free_page( (unsigned long)p_current ) ) )
+ panic("Bad Memory: Check your mem= option or your hardware !");
+ }
+ printk( "OK.\n" );
+}
+#endif
+
/*
* Activate the first processor.
*/
@@ -499,6 +528,11 @@
proc_root_init();
#endif
mempages = num_physpages;
+
+#ifdef CONFIG_MEM_CHECK
+ /* Before mounting root so that we don't damage it */
+ memory_check();
+#endif

fork_init(mempages);
filescache_init();
------------------------------------
References:
(1) http://boudicca.tux.org/hypermail/linux-kernel/1999week44/0905.html
(2) http://boudicca.tux.org/hypermail/linux-kernel/1999week44/0878.html
thanks Pavel,
luca
--
------------------------------------------------------------------
E-mail......: Luca Montecchiani <m.luca@iname.com>
W.W.W.......: http://i.am/m.luca - http://luca.myip.org
Speakfreely.: sflwl -hlwl.fourmilab.ch luca@
I.C.Q.......: 17655604
-----------------------=(Linux since 1995)=-----------------------
Non esiste vento favorevole per il marinaio che non sa dove andare
Seneca[unhandled content-type:application/octet-stream]
\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.042 / U:1.608 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site