Blame SOURCES/bt-mislabeling.patch

344a76
--- crash-7.0.9/defs.h.orig
344a76
+++ crash-7.0.9/defs.h
344a76
@@ -5180,14 +5180,15 @@ struct x86_64_pt_regs_offsets {
344a76
 };
344a76
 
344a76
 #define MAX_EXCEPTION_STACKS 7
344a76
-#define NMI_STACK 2    /* ebase[] index to NMI exception stack */
344a76
-#define DEBUG_STACK 3  /* ebase[] index to DEBUG exception stack */
344a76
+#define NMI_STACK (machdep->machspec->stkinfo.NMI_stack_index)
344a76
 
344a76
 struct x86_64_stkinfo {
344a76
 	ulong ebase[NR_CPUS][MAX_EXCEPTION_STACKS];
344a76
 	int esize[MAX_EXCEPTION_STACKS];
344a76
 	ulong ibase[NR_CPUS];
344a76
 	int isize;
344a76
+	int NMI_stack_index;
344a76
+	char *exception_stacks[MAX_EXCEPTION_STACKS];
344a76
 };
344a76
 
344a76
 struct machine_specific {
344a76
--- crash-7.0.9/x86_64.c.orig
344a76
+++ crash-7.0.9/x86_64.c
344a76
@@ -114,6 +114,7 @@ static void x86_64_get_active_set(void);
344a76
 static int x86_64_get_kvaddr_ranges(struct vaddr_range *);
344a76
 static int x86_64_verify_paddr(uint64_t);
344a76
 static void GART_init(void);
344a76
+static void x86_64_exception_stacks_init(void);
344a76
 
344a76
 struct machine_specific x86_64_machine_specific = { 0 };
344a76
 
344a76
@@ -798,6 +799,14 @@ x86_64_dump_machdep_table(ulong arg)
344a76
 		ms->stkinfo.esize[5], 
344a76
 		ms->stkinfo.esize[6], 
344a76
 		machdep->flags & NO_TSS ? " (NO TSS) " : " ");
344a76
+
344a76
+	fprintf(fp, "                           NMI_stack_index: %d\n", 
344a76
+		ms->stkinfo.NMI_stack_index);
344a76
+        fprintf(fp, "                           exception_stacks:\n");
344a76
+        for (i = 0; i < MAX_EXCEPTION_STACKS; i++)
344a76
+		fprintf(fp, "                             [%d]: %s\n", i, 
344a76
+			ms->stkinfo.exception_stacks[i]);
344a76
+
344a76
 	fprintf(fp, "                           ebase[%s][%d]:",
344a76
 		arg ? "NR_CPUS" : "cpus", MAX_EXCEPTION_STACKS);
344a76
 	cpus = arg ? NR_CPUS : kt->cpus;
344a76
@@ -1059,17 +1068,6 @@ x86_64_per_cpu_init(void)
344a76
 	verify_spinlock();
344a76
 }
344a76
 
344a76
-static char *
344a76
-x86_64_exception_stacks[MAX_EXCEPTION_STACKS] = {
344a76
-	"STACKFAULT",
344a76
-	"DOUBLEFAULT",
344a76
-	"NMI",
344a76
-	"DEBUG",
344a76
-	"MCE",
344a76
-	"(unknown)",
344a76
-	"(unknown)"
344a76
-};
344a76
-
344a76
 /*
344a76
  *  Gather the ist addresses for each CPU.
344a76
  */
344a76
@@ -1086,6 +1084,8 @@ x86_64_ist_init(void)
344a76
 	tss_sp = per_cpu_symbol_search("per_cpu__init_tss");
344a76
 	ist_sp = per_cpu_symbol_search("per_cpu__orig_ist");
344a76
 
344a76
+	x86_64_exception_stacks_init();
344a76
+
344a76
 	if (!tss_sp && symbol_exists("init_tss")) {
344a76
 		init_tss = symbol_value("init_tss");
344a76
 	
344a76
@@ -1135,7 +1135,7 @@ x86_64_ist_init(void)
344a76
 					if (ms->stkinfo.ebase[c][i] != estacks[i])
344a76
 						error(WARNING, 
344a76
 						    "cpu %d %s stack: init_tss: %lx orig_ist: %lx\n", c,  
344a76
-							x86_64_exception_stacks[i],
344a76
+							ms->stkinfo.exception_stacks[i],
344a76
 							ms->stkinfo.ebase[c][i], estacks[i]);
344a76
 					ms->stkinfo.ebase[c][i] = estacks[i];
344a76
 				}
344a76
@@ -1165,22 +1165,12 @@ x86_64_ist_init(void)
344a76
                                 break;
344a76
 			cnt++;
344a76
 			if ((THIS_KERNEL_VERSION >= LINUX(2,6,18)) &&
344a76
-			    (i == DEBUG_STACK))
344a76
+			    STREQ(ms->stkinfo.exception_stacks[i], "DEBUG"))
344a76
 				ms->stkinfo.esize[i] = esize*2;
344a76
 			else
344a76
 				ms->stkinfo.esize[i] = esize;
344a76
 			ms->stkinfo.ebase[c][i] -= ms->stkinfo.esize[i];
344a76
 		}
344a76
-		/*
344a76
-		 * RT kernel only uses 3 exception stacks for the 5 types.
344a76
-		 */
344a76
-		if ((c == 0) && (cnt == 3)) {
344a76
-			x86_64_exception_stacks[0] = "RT";
344a76
-			x86_64_exception_stacks[1] = "RT";
344a76
-			x86_64_exception_stacks[2] = "RT";
344a76
-			x86_64_exception_stacks[3] = "(unknown)";
344a76
-			x86_64_exception_stacks[4] = "(unknown)";
344a76
-		}
344a76
 	}
344a76
 
344a76
 	/*
344a76
@@ -2351,7 +2341,7 @@ x86_64_eframe_search(struct bt_info *bt)
344a76
                                 	break;
344a76
                                 bt->hp->esp = ms->stkinfo.ebase[c][i];
344a76
                                 fprintf(fp, "CPU %d %s EXCEPTION STACK:",
344a76
-					c, x86_64_exception_stacks[i]);
344a76
+					c, ms->stkinfo.exception_stacks[i]);
344a76
 
344a76
 				if (hide_offline_cpu(c)) {
344a76
 					fprintf(fp, " [OFFLINE]\n\n");
344a76
@@ -3084,7 +3074,7 @@ in_exception_stack:
344a76
 
344a76
 		if (!BT_REFERENCE_CHECK(bt))
344a76
 			fprintf(fp, "--- <%s exception stack> ---\n",
344a76
-				x86_64_exception_stacks[estack_index]);
344a76
+				ms->stkinfo.exception_stacks[estack_index]);
344a76
 
344a76
 		/*
344a76
 		 * Find the CPU-saved, or handler-saved registers
344a76
@@ -3133,7 +3123,7 @@ in_exception_stack:
344a76
 				fprintf(ofp, 
344a76
      				    "    [ %s exception stack recursion: "
344a76
 				    "prior stack location overwritten ]\n",
344a76
-					x86_64_exception_stacks[estack_index]);
344a76
+					ms->stkinfo.exception_stacks[estack_index]);
344a76
 				return;
344a76
 			}
344a76
 
344a76
@@ -4540,12 +4530,12 @@ skip_stage:
344a76
 		bt->stacktop = ms->stkinfo.ebase[bt->tc->processor][estack] +
344a76
                 	ms->stkinfo.esize[estack];
344a76
 		console("x86_64_get_dumpfile_stack_frame: searching %s estack at %lx\n", 
344a76
-			x86_64_exception_stacks[estack], bt->stackbase);
344a76
+			ms->stkinfo.exception_stacks[estack], bt->stackbase);
344a76
 		if (!(bt->stackbase)) 
344a76
 			goto skip_stage;
344a76
 		bt->stackbuf = ms->irqstack;
344a76
 		alter_stackbuf(bt);
344a76
-		in_nmi_stack = STREQ(x86_64_exception_stacks[estack], "NMI");
344a76
+		in_nmi_stack = STREQ(ms->stkinfo.exception_stacks[estack], "NMI");
344a76
 		goto next_stack;
344a76
 
344a76
 	}
344a76
@@ -4772,6 +4762,69 @@ x86_64_display_idt_table(void)
344a76
 	FREEBUF(idt_table_buf);
344a76
 }
344a76
 
344a76
+static void
344a76
+x86_64_exception_stacks_init(void)
344a76
+{
344a76
+        char *idt_table_buf;
344a76
+        char buf[BUFSIZE];
344a76
+	int i;
344a76
+        ulong *ip, ist;
344a76
+	long size;
344a76
+	struct machine_specific *ms;
344a76
+
344a76
+	ms = machdep->machspec;
344a76
+
344a76
+	ms->stkinfo.NMI_stack_index = -1;
344a76
+	for (i = 0; i < MAX_EXCEPTION_STACKS; i++)
344a76
+		ms->stkinfo.exception_stacks[i] = "(unknown)";
344a76
+
344a76
+	if (!kernel_symbol_exists("idt_table"))
344a76
+		return;
344a76
+
344a76
+        if (INVALID_SIZE(gate_struct))
344a76
+                size = 16;
344a76
+	else
344a76
+		size = SIZE(gate_struct);
344a76
+
344a76
+        idt_table_buf = GETBUF(size * 256);
344a76
+        readmem(symbol_value("idt_table"), KVADDR, idt_table_buf,
344a76
+                size * 256, "idt_table", FAULT_ON_ERROR);
344a76
+        ip = (ulong *)idt_table_buf;
344a76
+
344a76
+	if (CRASHDEBUG(1))
344a76
+		fprintf(fp, "exception IST:\n");
344a76
+
344a76
+	for (i = 0; i < 256; i++, ip += 2) {
344a76
+		ist = ((*ip) >> 32) & 0x7;
344a76
+		if (ist) {
344a76
+                        x86_64_extract_idt_function(ip, buf, NULL);
344a76
+			if (CRASHDEBUG(1))
344a76
+				fprintf(fp, "  %ld: %s\n", ist, buf);
344a76
+			if (strstr(buf, "nmi")) {
344a76
+				ms->stkinfo.NMI_stack_index = ist-1; 
344a76
+				ms->stkinfo.exception_stacks[ist-1] = "NMI";
344a76
+			}
344a76
+			if (strstr(buf, "debug"))
344a76
+				ms->stkinfo.exception_stacks[ist-1] = "DEBUG";
344a76
+			if (strstr(buf, "stack"))
344a76
+				ms->stkinfo.exception_stacks[ist-1] = "STACKFAULT";
344a76
+			if (strstr(buf, "double"))
344a76
+				ms->stkinfo.exception_stacks[ist-1] = "DOUBLEFAULT";
344a76
+			if (strstr(buf, "machine"))
344a76
+				ms->stkinfo.exception_stacks[ist-1] = "MCE";
344a76
+		}
344a76
+	}
344a76
+
344a76
+	if (CRASHDEBUG(1)) {
344a76
+		fprintf(fp, "exception stacks:\n");
344a76
+		for (i = 0; i < MAX_EXCEPTION_STACKS; i++) 
344a76
+			fprintf(fp, "  [%d]: %s\n", i, ms->stkinfo.exception_stacks[i]);
344a76
+	}
344a76
+
344a76
+	FREEBUF(idt_table_buf);
344a76
+}
344a76
+
344a76
+
344a76
 /*
344a76
  *  Extract the function name out of the IDT entry.
344a76
  */
344a76
@@ -5103,9 +5156,9 @@ x86_64_display_machine_stats(void)
344a76
 		if (machdep->machspec->stkinfo.ebase[0][i] == 0)
344a76
 			break;
344a76
 		fprintf(fp, "%11s STACK SIZE: %d\n",
344a76
-			x86_64_exception_stacks[i],
344a76
+			machdep->machspec->stkinfo.exception_stacks[i],
344a76
 			machdep->machspec->stkinfo.esize[i]);
344a76
-		sprintf(buf, "%s STACKS:\n", x86_64_exception_stacks[i]);
344a76
+		sprintf(buf, "%s STACKS:\n", machdep->machspec->stkinfo.exception_stacks[i]);
344a76
 		fprintf(fp, "%24s", buf);
344a76
 		for (c = 0; c < kt->cpus; c++) {
344a76
 			if (machdep->machspec->stkinfo.ebase[c][i] == 0)
344a76
344a76
--- crash-7.0.9/memory.c.orig
344a76
+++ crash-7.0.9/memory.c
344a76
@@ -8632,8 +8632,7 @@ static char *
344a76
 vaddr_to_kmem_cache(ulong vaddr, char *buf, int verbose)
344a76
 {
344a76
 	physaddr_t paddr;
344a76
-	ulong page;
344a76
-	ulong cache;
344a76
+	ulong page, cache, page_flags;
344a76
 
344a76
         if (!kvtop(NULL, vaddr, &paddr, 0)) {
344a76
 		if (verbose)
344a76
@@ -8651,6 +8650,14 @@ vaddr_to_kmem_cache(ulong vaddr, char *b
344a76
 		return NULL;
344a76
 	}
344a76
 
344a76
+	if (vt->PG_slab) {
344a76
+		readmem(page+OFFSET(page_flags), KVADDR,
344a76
+			&page_flags, sizeof(ulong), "page.flags",
344a76
+			FAULT_ON_ERROR);
344a76
+		if (!(page_flags & (1 << vt->PG_slab)))
344a76
+			return NULL;
344a76
+	}
344a76
+
344a76
 	if ((vt->flags & KMALLOC_SLUB) ||
344a76
 	    ((vt->flags & KMALLOC_COMMON) && 
344a76
 	     VALID_MEMBER(page_slab) && VALID_MEMBER(page_first_page))) {