From: Michael Frank <mhf@linuxmail.org>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] 2.6.2: Shutdown kernel on zone-alignment failure
Date: Sun, 8 Feb 2004 04:36:14 +0800 [thread overview]
Message-ID: <200402080436.14366.mhf@linuxmail.org> (raw)
In-Reply-To: <200402080430.52947.mhf@linuxmail.org>
The last msg repeated the alignment patch. Here is it.
diff -uN -r -X /home/mhf/sys/dont/dontdiff linux-2.6.2-Vanilla/include/linux/kernel.h linux-2.6.2-mhf177/include/linux/kernel.h
--- linux-2.6.2-Vanilla/include/linux/kernel.h 2004-02-06 19:37:44.000000000 +0800
+++ linux-2.6.2-mhf177/include/linux/kernel.h 2004-02-08 02:12:17.000000000 +0800
@@ -104,6 +104,15 @@
extern void bust_spinlocks(int yes);
extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
+
+/* If force_bug set, a BUG() will be forced when bug handler/console initialized.
+ * This is useful when something fatal happens very early during kernel init.
+ * To use:
+ * printk("FATAL ERROR: my error message - will force kernel BUG\n");
+ * force_bug = 1;
+ */
+extern int force_bug;
+
extern int panic_on_oops;
extern int system_running;
extern int tainted;
diff -uN -r -X /home/mhf/sys/dont/dontdiff linux-2.6.2-Vanilla/init/main.c linux-2.6.2-mhf177/init/main.c
--- linux-2.6.2-Vanilla/init/main.c 2004-02-06 19:37:45.000000000 +0800
+++ linux-2.6.2-mhf177/init/main.c 2004-02-08 02:19:15.000000000 +0800
@@ -96,6 +96,7 @@
* set up)
*/
int system_running;
+int force_bug;
/*
* Boot command-line arguments
@@ -454,6 +455,13 @@
vfs_caches_init(num_physpages);
radix_tree_init();
signals_init();
+ /*
+ * Something went badly wrong during the early initialisation process,
+ * so lets die before doing any damage or wasting people's time
+ * running a half dead kernel.
+ */
+ if (force_bug)
+ BUG();
/* rootfs populating might need page-writeback */
page_writeback_init();
populate_rootfs();
diff -uN -r -X /home/mhf/sys/dont/dontdiff linux-2.6.2-Vanilla/mm/page_alloc.c linux-2.6.2-mhf177/mm/page_alloc.c
--- linux-2.6.2-Vanilla/mm/page_alloc.c 2004-02-06 19:37:45.000000000 +0800
+++ linux-2.6.2-mhf177/mm/page_alloc.c 2004-02-08 04:14:06.000000000 +0800
@@ -1179,7 +1179,9 @@
for (i = 0; i < MAX_NR_ZONES; i++)
realtotalpages -= zholes_size[i];
pgdat->node_present_pages = realtotalpages;
- printk("On node %d totalpages: %lu\n", pgdat->node_id, realtotalpages);
+ printk("On node %d totalpages: %lu, zones aligned at: 0x%lx\n",
+ pgdat->node_id, realtotalpages,
+ 1UL << (MAX_ORDER-1 + PAGE_SHIFT));
}
/*
@@ -1240,14 +1242,14 @@
unsigned long *zones_size, unsigned long *zholes_size)
{
unsigned long i, j;
- const unsigned long zone_required_alignment = 1UL << (MAX_ORDER-1);
int cpu, nid = pgdat->node_id;
struct page *lmem_map = pgdat->node_mem_map;
unsigned long zone_start_pfn = pgdat->node_start_pfn;
+ unsigned long zone_bad_alignment;
pgdat->nr_zones = 0;
init_waitqueue_head(&pgdat->kswapd_wait);
-
+
for (j = 0; j < MAX_NR_ZONES; j++) {
struct zone *zone = pgdat->node_zones + j;
unsigned long size, realsize;
@@ -1299,8 +1301,11 @@
pcp->batch = 1 * batch;
INIT_LIST_HEAD(&pcp->list);
}
- printk(" %s zone: %lu pages, LIFO batch:%lu\n",
- zone_names[j], realsize, batch);
+ if (realsize)
+ printk(" %s zone: %lu pages, LIFO batch:%lu, "
+ "physical start address at: 0x%lx\n",
+ zone_names[j], realsize, batch,
+ zone_start_pfn << PAGE_SHIFT);
INIT_LIST_HEAD(&zone->active_list);
INIT_LIST_HEAD(&zone->inactive_list);
atomic_set(&zone->refill_counter, 0);
@@ -1328,8 +1333,17 @@
zone->zone_mem_map = lmem_map;
zone->zone_start_pfn = zone_start_pfn;
- if ((zone_start_pfn) & (zone_required_alignment-1))
- printk("BUG: wrong zone alignment, it will crash\n");
+ /*
+ * Here the alignment of a zone is checked. Should alignment
+ * be wrong, all that can be done is to print an error message
+ * and defer the the BUG handler as it is not yet initialized.
+ */
+ if ((zone_bad_alignment = zone_start_pfn & ((1UL << (MAX_ORDER-1))-1))) {
+ printk(" %s zone: FATAL ERROR invalid zone alignment at: 0x%lx"
+ " - will force kernel BUG\n",
+ zone_names[j],zone_bad_alignment << PAGE_SHIFT);
+ force_bug = 1;
+ }
memmap_init(lmem_map, size, nid, j, zone_start_pfn);
prev parent reply other threads:[~2004-02-07 20:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-07 20:30 [PATCH] 2.6.2: Shutdown kernel on zone-alignment failure Michael Frank
2004-02-07 20:36 ` Michael Frank [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200402080436.14366.mhf@linuxmail.org \
--to=mhf@linuxmail.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.