public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: print out in e820_update_range()
@ 2009-03-15  7:59 Yinghai Lu
  2009-03-15  8:07 ` Ingo Molnar
  2009-03-15  9:54 ` [tip:x86/mm] x86: print out more info " Yinghai Lu
  0 siblings, 2 replies; 5+ messages in thread
From: Yinghai Lu @ 2009-03-15  7:59 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin; +Cc: linux-kernel@vger.kernel.org


Impact: to find crazy calling

try to print out more info, to catch wrong calling

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 arch/x86/kernel/e820.c |   56 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 35 insertions(+), 21 deletions(-)

Index: linux-2.6/arch/x86/kernel/e820.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/e820.c
+++ linux-2.6/arch/x86/kernel/e820.c
@@ -131,6 +131,31 @@ void __init e820_add_region(u64 start, u
 	__e820_add_region(&e820, start, size, type);
 }
 
+static void __init e820_print_type(u32 type)
+{
+	switch (type) {
+	case E820_RAM:
+	case E820_RESERVED_KERN:
+		printk(KERN_CONT "(usable)");
+		break;
+	case E820_RESERVED:
+		printk(KERN_CONT "(reserved)");
+		break;
+	case E820_ACPI:
+		printk(KERN_CONT "(ACPI data)");
+		break;
+	case E820_NVS:
+		printk(KERN_CONT "(ACPI NVS)");
+		break;
+	case E820_UNUSABLE:
+		printk(KERN_CONT "(unusable)");
+		break;
+	default:
+		printk(KERN_CONT "type %u", type);
+		break;
+	}
+}
+
 void __init e820_print_map(char *who)
 {
 	int i;
@@ -140,27 +165,8 @@ void __init e820_print_map(char *who)
 		       (unsigned long long) e820.map[i].addr,
 		       (unsigned long long)
 		       (e820.map[i].addr + e820.map[i].size));
-		switch (e820.map[i].type) {
-		case E820_RAM:
-		case E820_RESERVED_KERN:
-			printk(KERN_CONT "(usable)\n");
-			break;
-		case E820_RESERVED:
-			printk(KERN_CONT "(reserved)\n");
-			break;
-		case E820_ACPI:
-			printk(KERN_CONT "(ACPI data)\n");
-			break;
-		case E820_NVS:
-			printk(KERN_CONT "(ACPI NVS)\n");
-			break;
-		case E820_UNUSABLE:
-			printk("(unusable)\n");
-			break;
-		default:
-			printk(KERN_CONT "type %u\n", e820.map[i].type);
-			break;
-		}
+		e820_print_type(e820.map[i].type);
+		printk(KERN_CONT "\n");
 	}
 }
 
@@ -437,6 +443,14 @@ static u64 __init __e820_update_range(st
 		size = ULLONG_MAX - start;
 
 	end = start + size;
+	printk(KERN_DEBUG "e820 update range: %016Lx - %016Lx ",
+		       (unsigned long long) start,
+		       (unsigned long long) end);
+	e820_print_type(old_type);
+	printk(KERN_CONT " ==> ");
+	e820_print_type(new_type);
+	printk(KERN_CONT "\n");
+
 	for (i = 0; i < e820x->nr_map; i++) {
 		struct e820entry *ei = &e820x->map[i];
 		u64 final_start, final_end;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86: print out in e820_update_range()
  2009-03-15  7:59 [PATCH] x86: print out in e820_update_range() Yinghai Lu
@ 2009-03-15  8:07 ` Ingo Molnar
  2009-03-15 18:03   ` Yinghai Lu
  2009-03-15  9:54 ` [tip:x86/mm] x86: print out more info " Yinghai Lu
  1 sibling, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2009-03-15  8:07 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Thomas Gleixner, H. Peter Anvin, linux-kernel@vger.kernel.org


* Yinghai Lu <yinghai@kernel.org> wrote:

> Impact: to find crazy calling
> 
> try to print out more info, to catch wrong calling

Could we detect incorrect parameters more directly as well, via 
a check and a panic()?

	Ingo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip:x86/mm] x86: print out more info in e820_update_range()
  2009-03-15  7:59 [PATCH] x86: print out in e820_update_range() Yinghai Lu
  2009-03-15  8:07 ` Ingo Molnar
@ 2009-03-15  9:54 ` Yinghai Lu
  1 sibling, 0 replies; 5+ messages in thread
From: Yinghai Lu @ 2009-03-15  9:54 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, yinghai, tglx, mingo

Commit-ID:  c61cf4cfe7c73c7aa62dde3ff82cd475b9c41481
Gitweb:     http://git.kernel.org/tip/c61cf4cfe7c73c7aa62dde3ff82cd475b9c41481
Author:     Yinghai Lu <yinghai@kernel.org>
AuthorDate: Sun, 15 Mar 2009 00:59:19 -0700
Commit:     Ingo Molnar <mingo@elte.hu>
CommitDate: Sun, 15 Mar 2009 10:01:59 +0100

x86: print out more info in e820_update_range()

Impact: help debug e820 bugs

Try to print out more info, to catch wrong call parameters.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <49BCB557.3030000@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 arch/x86/kernel/e820.c |   56 ++++++++++++++++++++++++++++++------------------
 1 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 0c34ff4..fb638d9 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -131,6 +131,31 @@ void __init e820_add_region(u64 start, u64 size, int type)
 	__e820_add_region(&e820, start, size, type);
 }
 
+static void __init e820_print_type(u32 type)
+{
+	switch (type) {
+	case E820_RAM:
+	case E820_RESERVED_KERN:
+		printk(KERN_CONT "(usable)");
+		break;
+	case E820_RESERVED:
+		printk(KERN_CONT "(reserved)");
+		break;
+	case E820_ACPI:
+		printk(KERN_CONT "(ACPI data)");
+		break;
+	case E820_NVS:
+		printk(KERN_CONT "(ACPI NVS)");
+		break;
+	case E820_UNUSABLE:
+		printk(KERN_CONT "(unusable)");
+		break;
+	default:
+		printk(KERN_CONT "type %u", type);
+		break;
+	}
+}
+
 void __init e820_print_map(char *who)
 {
 	int i;
@@ -140,27 +165,8 @@ void __init e820_print_map(char *who)
 		       (unsigned long long) e820.map[i].addr,
 		       (unsigned long long)
 		       (e820.map[i].addr + e820.map[i].size));
-		switch (e820.map[i].type) {
-		case E820_RAM:
-		case E820_RESERVED_KERN:
-			printk(KERN_CONT "(usable)\n");
-			break;
-		case E820_RESERVED:
-			printk(KERN_CONT "(reserved)\n");
-			break;
-		case E820_ACPI:
-			printk(KERN_CONT "(ACPI data)\n");
-			break;
-		case E820_NVS:
-			printk(KERN_CONT "(ACPI NVS)\n");
-			break;
-		case E820_UNUSABLE:
-			printk("(unusable)\n");
-			break;
-		default:
-			printk(KERN_CONT "type %u\n", e820.map[i].type);
-			break;
-		}
+		e820_print_type(e820.map[i].type);
+		printk(KERN_CONT "\n");
 	}
 }
 
@@ -437,6 +443,14 @@ static u64 __init __e820_update_range(struct e820map *e820x, u64 start,
 		size = ULLONG_MAX - start;
 
 	end = start + size;
+	printk(KERN_DEBUG "e820 update range: %016Lx - %016Lx ",
+		       (unsigned long long) start,
+		       (unsigned long long) end);
+	e820_print_type(old_type);
+	printk(KERN_CONT " ==> ");
+	e820_print_type(new_type);
+	printk(KERN_CONT "\n");
+
 	for (i = 0; i < e820x->nr_map; i++) {
 		struct e820entry *ei = &e820x->map[i];
 		u64 final_start, final_end;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86: print out in e820_update_range()
  2009-03-15  8:07 ` Ingo Molnar
@ 2009-03-15 18:03   ` Yinghai Lu
  2009-03-15 18:55     ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Yinghai Lu @ 2009-03-15 18:03 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Thomas Gleixner, H. Peter Anvin, linux-kernel@vger.kernel.org

Ingo Molnar wrote:
> * Yinghai Lu <yinghai@kernel.org> wrote:
> 
>> Impact: to find crazy calling
>>
>> try to print out more info, to catch wrong calling
> 
> Could we detect incorrect parameters more directly as well, via 
> a check and a panic()?

only valid checking seems to be 
virt_to_phys(_text), virt_to_phys(_end)


if (new_type == E820_RESERVED && start >= virt_to_phys(_text) && start <= virt_to_phys(_end)) 
	panic("try to update to e820 range for kernel to RESERVED!");

YH

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86: print out in e820_update_range()
  2009-03-15 18:03   ` Yinghai Lu
@ 2009-03-15 18:55     ` Ingo Molnar
  0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2009-03-15 18:55 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Thomas Gleixner, H. Peter Anvin, linux-kernel@vger.kernel.org


* Yinghai Lu <yinghai@kernel.org> wrote:

> Ingo Molnar wrote:
> > * Yinghai Lu <yinghai@kernel.org> wrote:
> > 
> >> Impact: to find crazy calling
> >>
> >> try to print out more info, to catch wrong calling
> > 
> > Could we detect incorrect parameters more directly as well, via 
> > a check and a panic()?
> 
> only valid checking seems to be 
> virt_to_phys(_text), virt_to_phys(_end)
> 
> 
> if (new_type == E820_RESERVED && start >= virt_to_phys(_text) && start <= virt_to_phys(_end)) 
> 	panic("try to update to e820 range for kernel to RESERVED!");

hm, seems a bit too specialized.

	Ingo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-03-15 18:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-15  7:59 [PATCH] x86: print out in e820_update_range() Yinghai Lu
2009-03-15  8:07 ` Ingo Molnar
2009-03-15 18:03   ` Yinghai Lu
2009-03-15 18:55     ` Ingo Molnar
2009-03-15  9:54 ` [tip:x86/mm] x86: print out more info " Yinghai Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox