Re: [Crash-utility] Re: [RFC]Patch to accomodate cpu_pda changes in x86_64 kernels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2006-01-31 at 21:38 +0530, Rachita Kothiyal wrote:
> On Tue, Jan 31, 2006 at 09:11:36AM -0500, Dave Anderson wrote:
> > 
> > Thanks for handling this.  I haven't looked at this, and correct me
> > if I'm wrong, but the kernel (what version exactly?) now has contains
> > a _cpu_pda[NR_CPUS] array containing pointers to the actual per-cpu
> > x8664_pda structures. 
> 
> Hi Dave,
> 
> This change was introduced 2.6.16-rc1 onwards.
> > 
> > Unless I'm missing something, that simplifies things and should work
> > just fine. But I can't test it here other than to verify that it's
> > backwards compatible.  Can you verify that?
> 
> Yes, this is infact more simpler and cleaner. I have incorporated the
> changes and regenerated the patch, which I am sending along. I have 
> also tested it on a 2.6.16-rc1 kernel, and it works fine.
> 
> Thanks
> Rachita

Hmm.. Lots of duplicated code. I hacked the same thing earlier to make
it work. I incorporated my changes into yours. 

Does this look better ?

(BTW, is there a way to combine CPU_PDA_READ() and _CPU_PDA_READ() by
abstracting some of it out ?)

Thanks,
Badari



Signed-off-by: Badari Pulavarty <pbadari@xxxxxxxxxx>
diff -Narup crash-4.0-2.19/defs.h crash-4.0-2.19.latest/defs.h
--- crash-4.0-2.19/defs.h	2006-01-11 06:16:11.000000000 -0800
+++ crash-4.0-2.19.latest/defs.h	2006-01-31 09:01:51.000000000 -0800
@@ -1840,6 +1840,16 @@ struct load_module {
 
 #define PAGEBASE(X)           (((ulong)(X)) & (ulong)machdep->pagemask)
 
+#define _CPU_PDA_READ(CPU, BUFFER) \
+	((STRNEQ("_cpu_pda", closest_symbol((symbol_value("_cpu_pda") +	\
+	     ((CPU) * sizeof(unsigned long)))))) &&			\
+       	(readmem(symbol_value("_cpu_pda") + ((CPU) * sizeof(unsigned long)),\
+	 KVADDR, &cpu_pda_addr, sizeof(unsigned long), "_cpu_pda addr",     \
+	FAULT_ON_ERROR)) &&						   \
+	(readmem(cpu_pda_addr, 		   \
+	        KVADDR, (BUFFER), SIZE(x8664_pda), "cpu_pda entry",	 \
+        	FAULT_ON_ERROR)))
+
 #define CPU_PDA_READ(CPU, BUFFER) \
 	(STRNEQ("cpu_pda", closest_symbol((symbol_value("cpu_pda") +	\
 	     ((CPU) * SIZE(x8664_pda))))) &&				\
diff -Narup crash-4.0-2.19/x86_64.c crash-4.0-2.19.latest/x86_64.c
--- crash-4.0-2.19/x86_64.c	2006-01-11 06:16:11.000000000 -0800
+++ crash-4.0-2.19.latest/x86_64.c	2006-01-31 09:00:55.000000000 -0800
@@ -367,9 +367,10 @@ x86_64_cpu_pda_init(void)
 {
 	int i, cpus, nr_pda, cpunumber;
 	char *cpu_pda_buf;
-	ulong level4_pgt, data_offset;
+	ulong level4_pgt, data_offset, cpu_pda_addr;
 	struct syment *sp, *nsp;
 	ulong offset, istacksize;
+	int __cpu_pda = 0;
 
 	STRUCT_SIZE_INIT(x8664_pda, "x8664_pda");
 	MEMBER_OFFSET_INIT(x8664_pda_pcurrent, "x8664_pda", "pcurrent");
@@ -383,12 +384,25 @@ x86_64_cpu_pda_init(void)
 
 	cpu_pda_buf = GETBUF(SIZE(x8664_pda));
 
-	if (!(nr_pda = get_array_length("cpu_pda", NULL, 0)))
-		nr_pda = NR_CPUS;
+	if (symbol_exists("_cpu_pda")) {
+		if (!(nr_pda = get_array_length("_cpu_pda", NULL, 0)))
+			nr_pda = NR_CPUS;
+		__cpu_pda = 1;
+	} else  {
+		if (!(nr_pda = get_array_length("cpu_pda", NULL, 0)))
+			nr_pda = NR_CPUS;
+	}
 
 	for (i = cpus = 0; i < nr_pda; i++) {
-		if (!CPU_PDA_READ(i, cpu_pda_buf))
-			break;
+		cpu_pda_addr = 0;
+		if (__cpu_pda) {
+			if (!_CPU_PDA_READ(i, cpu_pda_buf))
+				break;
+		} else {
+			if (!CPU_PDA_READ(i, cpu_pda_buf))
+				break;
+		}
+
 		if (VALID_MEMBER(x8664_pda_level4_pgt)) {
 			level4_pgt = ULONG(cpu_pda_buf + OFFSET(x8664_pda_level4_pgt));
 			if (!VALID_LEVEL4_PGT_ADDR(level4_pgt))
@@ -2718,19 +2732,32 @@ x86_64_get_smp_cpus(void)
 {
 	int i, cpus, nr_pda, cpunumber;
 	char *cpu_pda_buf;
-	ulong level4_pgt;
+	ulong level4_pgt, cpu_pda_addr;
+	int __cpu_pda = 0;
 
 	if (!VALID_STRUCT(x8664_pda))
 		return 1;
 
 	cpu_pda_buf = GETBUF(SIZE(x8664_pda));
 
-	if (!(nr_pda = get_array_length("cpu_pda", NULL, 0)))
-               nr_pda = NR_CPUS;
+	if (symbol_exists("_cpu_pda")) {
+		if (!(nr_pda = get_array_length("_cpu_pda", NULL, 0)))
+			nr_pda = NR_CPUS;
+		__cpu_pda = 1;
+	} else  {
+		if (!(nr_pda = get_array_length("cpu_pda", NULL, 0)))
+			nr_pda = NR_CPUS;
+	}
 
 	for (i = cpus = 0; i < nr_pda; i++) {
-		if (!CPU_PDA_READ(i, cpu_pda_buf))
-			break;
+		cpu_pda_addr = 0;
+		if (__cpu_pda) {
+			if (!_CPU_PDA_READ(i, cpu_pda_buf))
+				break;
+		} else {
+			if (!CPU_PDA_READ(i, cpu_pda_buf))
+				break;
+		}
 
 		if (VALID_MEMBER(x8664_pda_level4_pgt)) {
 			level4_pgt = ULONG(cpu_pda_buf + OFFSET(x8664_pda_level4_pgt));
@@ -2828,7 +2855,10 @@ x86_64_display_cpu_data(void)
 		boot_cpu = TRUE;
 		cpus = 1;
 	}
-	cpu_pda = symbol_value("cpu_pda");
+	if (symbol_exists("_cpu_data")) 
+		cpu_pda = symbol_value("_cpu_pda");
+	else if (symbol_exists("cpu_data")) 
+		cpu_pda = symbol_value("cpu_pda");
 
         for (cpu = 0; cpu < cpus; cpu++) {
 		if (boot_cpu)

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux