RE: RE: [PATCH] lkcd kernel patch for linux kernel 2.4. for x86_64

"Deepak Kumar Gupta, Noida" <[email protected]> Tue, 10 Aug 2004 10:29:53 +0530
Newsgroups gmane.linux.lkcd.general
Message-ID <1B3885BC15C7024C845AAC78314766C509AFBD42@exch-01.noida.hcltech.com>
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01C47E96.DEE9E562
Content-Type: text/plain;
	charset="iso-8859-1"

Hi Manny

I am sending the patch of Sanjay to you .. 

Regards
Deepak Kumar Gupta
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Contributing to the World by creating indispensable value !

System Software CoE @ HCLT-Noida
http://www.hcltechnologies.com
Ph. : +91-120-2510701/702 Ext : 3159
FAX : +91-120-2510713 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 


-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Manny Ye
Sent: Tuesday, August 10, 2004 12:58 AM
To: [email protected]
Subject: [lkcd-general] RE: [PATCH] lkcd kernel patch for linux kernel
2.4. for x86_64


Hi Sanjay,I'm trying to get lkcd to work with my x86_64 setup(AMD dual
processor).  I seem to have a problem with your patch, mainly I don't
believe the posted patch for x86_64 is complete.  it ends with :

lkcd_linux_x86_64/drivers/dump/dump_x86_64.c
 --- linux-2.4.21_lkcd/drivers/dump/dump_x86_64.c	1970-01-01
05:30:00.000000000 +0530
 +++ lkcd_linux_x86_64/drivers/dump/dump_x86_64.c	2004-07-02
20:59:48.000000000 +0530
 @@ -0,0 +

which means strange.  It's probably truncated. Can I get a complete copy of
your patch.  
I would really appreciate it.  Thanks!



Manny Ye



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Lkcd-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lkcd-general


------_=_NextPart_000_01C47E96.DEE9E562
Content-Type: application/octet-stream;
	name="lkcd-kernel-x86_64.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="lkcd-kernel-x86_64.patch"

diff -Naur linux-2.4.21_lkcd/arch/x86_64/boot/install.sh =
lkcd_linux_x86_64/arch/x86_64/boot/install.sh=0A=
--- linux-2.4.21_lkcd/arch/x86_64/boot/install.sh	2002-11-29 =
05:23:12.000000000 +0530=0A=
+++ lkcd_linux_x86_64/arch/x86_64/boot/install.sh	2004-07-01 =
20:36:03.000000000 +0530=0A=
@@ -16,7 +16,8 @@=0A=
 #   $1 - kernel version=0A=
 #   $2 - kernel image file=0A=
 #   $3 - kernel map file=0A=
-#   $4 - default install path (blank if root directory)=0A=
+#   $4 - kernel type file=0A=
+#   $5 - default install path (blank if root directory) =0A=
 #=0A=
 =0A=
 # User may have a custom install script=0A=
@@ -25,15 +26,21 @@=0A=
 =0A=
 # Default install - same as make zlilo=0A=
 =0A=
-if [ -f $4/vmlinuz ]; then=0A=
-	mv $4/vmlinuz $4/vmlinuz.old=0A=
+if [ -f $5/vmlinuz ]; then			=0A=
+	mv $5/vmlinuz $4/vmlinuz.old	=0A=
 fi=0A=
 =0A=
-if [ -f $4/System.map ]; then=0A=
-	mv $4/System.map $4/System.old=0A=
+if [ -f $5/System.map ]; then 	=0A=
+	mv $5/System.map $4/System.old=0A=
 fi=0A=
 =0A=
-cat $2 > $4/vmlinuz=0A=
-cp $3 $4/System.map=0A=
+if [ -f $5/Kerntypes ]; then=0A=
+	mv $5/Kerntypes $5/Kerntypes.old=0A=
+fi=0A=
+=0A=
+cat $2 > $5/vmlinuz=0A=
+cp $3 $5/System.map=0A=
+cp $4 $5/Kerntypes=0A=
+=0A=
 =0A=
 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi=0A=
diff -Naur linux-2.4.21_lkcd/arch/x86_64/boot/Makefile =
lkcd_linux_x86_64/arch/x86_64/boot/Makefile=0A=
--- linux-2.4.21_lkcd/arch/x86_64/boot/Makefile	2002-11-29 =
05:23:12.000000000 +0530=0A=
+++ lkcd_linux_x86_64/arch/x86_64/boot/Makefile	2004-07-01 =
20:37:47.000000000 +0530=0A=
@@ -35,12 +35,14 @@=0A=
 zlilo: $(CONFIGURE) $(BOOTIMAGE)=0A=
 	if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz =
$(INSTALL_PATH)/vmlinuz.old; fi=0A=
 	if [ -f $(INSTALL_PATH)/System.map ]; then mv =
$(INSTALL_PATH)/System.map $(INSTALL_PATH)/System.old; fi=0A=
+	if [ -f $(INSTALL_PATH)/Kerntypes ]; then mv =
$(INSTALL_PATH)/Kerntypes $(INSTALL_PATH)/Kerntypes.old; fi=0A=
 	cat $(BOOTIMAGE) > $(INSTALL_PATH)/vmlinuz=0A=
 	cp $(TOPDIR)/System.map $(INSTALL_PATH)/=0A=
+	cp $(TOPDIR)/Kerntypes $(INSTALL_PATH)/=0A=
 	if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi=0A=
 =0A=
 install: $(CONFIGURE) $(BOOTIMAGE)=0A=
-	sh -x ./install.sh $(KERNELRELEASE) $(BOOTIMAGE) $(TOPDIR)/System.map =
"$(INSTALL_PATH)"=0A=
+	sh -x ./install.sh $(KERNELRELEASE) $(BOOTIMAGE) $(TOPDIR)/System.map =
$(TOPDIR)/Kerntypes "$(INSTALL_PATH)"=0A=
 =0A=
 tools/build: tools/build.c=0A=
 	$(HOSTCC) $(HOSTCFLAGS) -o $@ $<=0A=
diff -Naur linux-2.4.21_lkcd/arch/x86_64/config.in =
lkcd_linux_x86_64/arch/x86_64/config.in=0A=
--- linux-2.4.21_lkcd/arch/x86_64/config.in	2003-06-13 =
20:21:32.000000000 +0530=0A=
+++ lkcd_linux_x86_64/arch/x86_64/config.in	2004-07-01 =
20:38:43.000000000 +0530=0A=
@@ -235,6 +235,12 @@=0A=
 mainmenu_option next_comment=0A=
 comment 'Kernel hacking'=0A=
 =0A=
+tristate 'Linux Kernel Crash Dump (LKCD) Support' CONFIG_DUMP=0A=
+if [ "$CONFIG_DUMP" !=3D "n" ]; then=0A=
+   dep_tristate '  LKCD RLE compression' CONFIG_DUMP_COMPRESS_RLE =
$CONFIG_DUMP=0A=
+   dep_tristate '  LKCD GZIP compression' CONFIG_DUMP_COMPRESS_GZIP =
$CONFIG_DUMP=0A=
+fi=0A=
+=0A=
 bool 'Kernel debugging' CONFIG_DEBUG_KERNEL=0A=
 if [ "$CONFIG_DEBUG_KERNEL" !=3D "n" ]; then=0A=
    bool '  Debug memory allocations' CONFIG_DEBUG_SLAB=0A=
diff -Naur linux-2.4.21_lkcd/arch/x86_64/kernel/irq.c =
lkcd_linux_x86_64/arch/x86_64/kernel/irq.c=0A=
--- linux-2.4.21_lkcd/arch/x86_64/kernel/irq.c	2002-11-29 =
05:23:12.000000000 +0530=0A=
+++ lkcd_linux_x86_64/arch/x86_64/kernel/irq.c	2004-07-01 =
21:11:56.000000000 +0530=0A=
@@ -1106,7 +1106,7 @@=0A=
 =0A=
 static struct proc_dir_entry * smp_affinity_entry [NR_IRQS];=0A=
 =0A=
-static unsigned long irq_affinity [NR_IRQS] =3D { [0 ... NR_IRQS-1] =
=3D ~0UL };=0A=
+unsigned long irq_affinity [NR_IRQS] =3D { [0 ... NR_IRQS-1] =3D ~0UL =
};=0A=
 static int irq_affinity_read_proc (char *page, char **start, off_t =
off,=0A=
 			int count, int *eof, void *data)=0A=
 {=0A=
diff -Naur linux-2.4.21_lkcd/arch/x86_64/kernel/nmi.c =
lkcd_linux_x86_64/arch/x86_64/kernel/nmi.c=0A=
--- linux-2.4.21_lkcd/arch/x86_64/kernel/nmi.c	2003-06-13 =
20:21:32.000000000 +0530=0A=
+++ lkcd_linux_x86_64/arch/x86_64/kernel/nmi.c	2004-07-01 =
21:12:15.000000000 +0530=0A=
@@ -18,6 +18,9 @@=0A=
 #include <linux/bootmem.h>=0A=
 #include <linux/smp_lock.h>=0A=
 #include <linux/interrupt.h>=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+#include <linux/dump.h>=0A=
+#endif=0A=
 #include <linux/mc146818rtc.h>=0A=
 #include <linux/kernel_stat.h>=0A=
 =0A=
@@ -354,6 +357,14 @@=0A=
 =0A=
 	if (nmi_watchdog_disabled)=0A=
 		return;=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+       /*=0A=
+        * Ignore watchdog when dumping is in progress.=0A=
+        * Todo: consider using the touch_nmi_watchdog() approach =
instead=0A=
+        */=0A=
+       if (dump_in_progress && cpu !=3D dumping_cpu) return;=0A=
+#endif=0A=
+=0A=
 =0A=
 	sum =3D apic_timer_irqs[cpu];=0A=
 =0A=
@@ -381,6 +392,10 @@=0A=
 			printk("NMI Watchdog detected LOCKUP on CPU%d, eip %16lx, =
registers:\n", cpu, regs->rip);=0A=
 			show_registers(regs);=0A=
 			printk("console shuts up ...\n");=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+                       dump("NMI Watchdog Detected", regs);=0A=
+#endif=0A=
+=0A=
 			console_silent();=0A=
 			spin_unlock(&nmi_print_lock);=0A=
 			bust_spinlocks(0);=0A=
diff -Naur linux-2.4.21_lkcd/arch/x86_64/kernel/smp.c =
lkcd_linux_x86_64/arch/x86_64/kernel/smp.c=0A=
--- linux-2.4.21_lkcd/arch/x86_64/kernel/smp.c	2003-06-13 =
20:21:32.000000000 +0530=0A=
+++ lkcd_linux_x86_64/arch/x86_64/kernel/smp.c	2004-07-01 =
21:14:10.000000000 +0530=0A=
@@ -16,6 +16,9 @@=0A=
 #include <linux/delay.h>=0A=
 #include <linux/spinlock.h>=0A=
 #include <linux/smp_lock.h>=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+#include <linux/dump.h>=0A=
+#endif=0A=
 #include <linux/kernel_stat.h>=0A=
 #include <linux/mc146818rtc.h>=0A=
 =0A=
@@ -143,6 +146,16 @@=0A=
 	 * No need to touch the target chip field=0A=
 	 */=0A=
 	cfg =3D __prepare_ICR(shortcut, vector);=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+       if (vector =3D=3D DUMP_VECTOR) {=0A=
+               /*=0A=
+                * Setup DUMP IPI to be delivered as an NMI=0A=
+                */=0A=
+               cfg =3D (cfg&~APIC_VECTOR_MASK)|APIC_DM_NMI;=0A=
+       }=0A=
+#endif  /* CONFIG_DUMP */=0A=
+=0A=
+=0A=
 =0A=
 	/*=0A=
 	 * Send the IPI. The write to APIC_ICR fires this off.=0A=
@@ -308,6 +321,11 @@=0A=
 static void flush_tlb_others (unsigned long cpumask, struct mm_struct =
*mm,=0A=
 						unsigned long va)=0A=
 {=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+       /* some cpu may not be running... LWS */=0A=
+       unsigned long ipi_mask;=0A=
+#endif=0A=
+=0A=
 	/*=0A=
 	 * A couple of (to be removed) sanity checks:=0A=
 	 *=0A=
@@ -317,8 +335,14 @@=0A=
 	 */=0A=
 	if (!cpumask)=0A=
 		BUG();=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+       /* Some cpus may be stopped...like at crash dump time... LWS =
*/=0A=
+       if ((ipi_mask =3D cpumask & cpu_online_map) =3D=3D 0)=0A=
+               return;=0A=
+#else=0A=
 	if ((cpumask & cpu_online_map) !=3D cpumask)=0A=
 		BUG();=0A=
+#endif=0A=
 	if (cpumask & (1 << smp_processor_id()))=0A=
 		BUG();=0A=
 	if (!mm)=0A=
@@ -334,12 +358,20 @@=0A=
 	=0A=
 	flush_mm =3D mm;=0A=
 	flush_va =3D va;=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+       atomic_set_mask(ipi_mask, &flush_cpumask);=0A=
+#else=0A=
 	atomic_set_mask(cpumask, &flush_cpumask);=0A=
+#endif=0A=
 	/*=0A=
 	 * We have to send the IPI only to=0A=
 	 * CPUs affected.=0A=
 	 */=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+       send_IPI_mask(ipi_mask, INVALIDATE_TLB_VECTOR);=0A=
+#else=0A=
 	send_IPI_mask(cpumask, INVALIDATE_TLB_VECTOR);=0A=
+#endif=0A=
 =0A=
 	while (flush_cpumask)=0A=
 		/* nothing. lockup detection does not belong here */;=0A=
@@ -409,6 +441,13 @@=0A=
 =0A=
 	do_flush_tlb_all_local();=0A=
 }=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+void dump_send_ipi(void)=0A=
+{=0A=
+       send_IPI_allbutself(DUMP_VECTOR);=0A=
+}=0A=
+#endif=0A=
+=0A=
 =0A=
 /*=0A=
  * this function sends a 'reschedule' IPI to another CPU.=0A=
@@ -418,7 +457,15 @@=0A=
 =0A=
 void smp_send_reschedule(int cpu)=0A=
 {=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+       /* only do this for on-line CPUs */=0A=
+       unsigned long cpumask =3D (1 << cpu) & cpu_online_map;=0A=
+       if (cpumask) {=0A=
+               send_IPI_mask(1 << cpu, RESCHEDULE_VECTOR);=0A=
+       }=0A=
+#else=0A=
 	send_IPI_mask(1 << cpu, RESCHEDULE_VECTOR);=0A=
+#endif=0A=
 }=0A=
 =0A=
 /*=0A=
@@ -477,8 +524,26 @@=0A=
 	send_IPI_allbutself(CALL_FUNCTION_VECTOR);=0A=
 =0A=
 	/* Wait for response */=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+       if (dump_in_progress) {=0A=
+               int i =3D 1 * 1000;   /* milliseconds to delay waiting =
for other CPU to star=0A=
+t IPI processing (1 second) */=0A=
+               while (atomic_read(&data.started) !=3D cpus && i--) =
{=0A=
+                       mdelay(1);=0A=
+                       barrier();=0A=
+               }=0A=
+               if (i <=3D 0) {=0A=
+                       spin_unlock_bh(&call_lock);=0A=
+                       return -ETIMEDOUT;=0A=
+               }=0A=
+       } else {=0A=
+               while (atomic_read(&data.started) !=3D cpus)=0A=
+                       barrier();=0A=
+       }=0A=
+#else=0A=
 	while (atomic_read(&data.started) !=3D cpus)=0A=
 		barrier();=0A=
+#endif=0A=
 =0A=
 	if (wait)=0A=
 		while (atomic_read(&data.finished) !=3D cpus)=0A=
diff -Naur linux-2.4.21_lkcd/arch/x86_64/kernel/traps.c =
lkcd_linux_x86_64/arch/x86_64/kernel/traps.c=0A=
--- linux-2.4.21_lkcd/arch/x86_64/kernel/traps.c	2003-06-13 =
20:21:32.000000000 +0530=0A=
+++ lkcd_linux_x86_64/arch/x86_64/kernel/traps.c	2004-07-01 =
21:17:26.000000000 +0530=0A=
@@ -22,6 +22,10 @@=0A=
 #include <linux/ptrace.h>=0A=
 #include <linux/timer.h>=0A=
 #include <linux/mm.h>=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+#include <linux/dump.h>=0A=
+#endif=0A=
+=0A=
 #include <linux/init.h>=0A=
 #include <linux/delay.h>=0A=
 #include <linux/spinlock.h>=0A=
@@ -83,6 +87,26 @@=0A=
 =0A=
 int kstack_depth_to_print =3D 40;=0A=
 =0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+#ifdef CONFIG_SMP=0A=
+void (*dump_trace_ptr)(struct pt_regs *) =3D NULL;=0A=
+/*=0A=
+ * This code mimics show_trace() etc in arch/i386/kernel/traps.c. We =
don't=0A=
+ * use them directly as they depend on 8K aligned kernel stacks that =
our=0A=
+ * saved stacks don't satisfy. However, there is move to relax the =
requirement=0A=
+ * on task_struct to be 8K-aligned. Once that happens, we could =
simpify this=0A=
+ * function.=0A=
+ */=0A=
+void show_this_cpu_state(int cpu, struct pt_regs * regs, struct =
task_struct *tsk)=0A=
+{=0A=
+//not implemented yet=0A=
+       return;=0A=
+}=0A=
+#endif /* CONFIG_SMP */=0A=
+#endif /* CONFIG_DUMP */=0A=
+=0A=
+=0A=
+=0A=
 #ifdef CONFIG_KALLSYMS=0A=
 #include <linux/kallsyms.h> =0A=
 int printk_address(unsigned long address)=0A=
@@ -363,6 +387,10 @@=0A=
 	show_registers(regs);=0A=
 	bust_spinlocks(0);=0A=
 	spin_unlock_irq(&die_lock);=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+       dump((char *)str, regs);=0A=
+#endif=0A=
+=0A=
 	do_exit(SIGSEGV);=0A=
 }=0A=
 =0A=
@@ -531,6 +559,22 @@=0A=
 	reason &=3D ~8;=0A=
 	outb(reason, 0x61);=0A=
 }=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+#ifdef CONFIG_SMP=0A=
+int (*dump_ipi_function_ptr)(struct pt_regs *) =3D NULL;=0A=
+static int dump_ipi(struct pt_regs *regs)=0A=
+{=0A=
+       if (!(dump_ipi_function_ptr && dump_ipi_function_ptr(regs))) =
{=0A=
+               return 0;=0A=
+       }=0A=
+       ack_APIC_irq();=0A=
+       return 1;=0A=
+}=0A=
+#else=0A=
+#define dump_ipi(regs) 0=0A=
+#endif=0A=
+#endif=0A=
+=0A=
 =0A=
 static void unknown_nmi_error(unsigned char reason, struct pt_regs * =
regs)=0A=
 {=0A=
@@ -544,6 +588,11 @@=0A=
 	unsigned char reason =3D inb(0x61);=0A=
 =0A=
 	++nmi_count(safe_smp_processor_id());=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+       if (dump_ipi(regs)) {=0A=
+               return;=0A=
+       }=0A=
+#endif=0A=
 	=0A=
 	if (!(reason & 0xc0)) {=0A=
 #if CONFIG_X86_LOCAL_APIC=0A=
diff -Naur linux-2.4.21_lkcd/arch/x86_64/kernel/x8664_ksyms.c =
lkcd_linux_x86_64/arch/x86_64/kernel/x8664_ksyms.c=0A=
--- linux-2.4.21_lkcd/arch/x86_64/kernel/x8664_ksyms.c	2003-06-13 =
20:21:32.000000000 +0530=0A=
+++ lkcd_linux_x86_64/arch/x86_64/kernel/x8664_ksyms.c	2004-07-01 =
20:45:36.000000000 +0530=0A=
@@ -223,3 +223,30 @@=0A=
 =0A=
 extern void int_ret_from_sys_call(void);=0A=
 EXPORT_SYMBOL(int_ret_from_sys_call); =0A=
+=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+extern void dump (char *, struct pt_regs *);=0A=
+EXPORT(dump); =0A=
+extern void get_current_regs( struct pt_regs *);=0A=
+EXPORT(get_current_regs);=0A=
+extern int (*dump_function_ptr)(char *, struct pt_regs *);=0A=
+EXPORT(dump_function_ptr);=0A=
+#ifdef CONFIG_SMP=0A=
+extern irq_desc_t irq_desc[];=0A=
+extern unsigned long irq_affinity[];=0A=
+EXPORT_SYMBOL(irq_affinity);=0A=
+EXPORT_SYMBOL(irq_desc);=0A=
+extern void dump_send_ipi(void);=0A=
+EXPORT_SYMBOL(dump_send_ipi);=0A=
+extern int (*dump_ipi_function_ptr)(struct pt_regs *);=0A=
+EXPORT_SYMBOL(dump_ipi_function_ptr);=0A=
+extern void (*dump_trace_ptr)(struct pt_regs *);=0A=
+EXPORT_SYMBOL(dump_trace_ptr);=0A=
+extern void show_this_cpu_state(int, struct pt_regs *, struct =
task_struct *);=0A=
+EXPORT_SYMBOL(show_this_cpu_state);=0A=
+#endif=0A=
+#ifdef CONFIG_HIGHMEM=0A=
+EXPORT_SYMBOL(kmap_prot);=0A=
+EXPORT_SYMBOL(kmap_pte);=0A=
+#endif=0A=
+#endif=0A=
diff -Naur linux-2.4.21_lkcd/arch/x86_64/mm/init.c =
lkcd_linux_x86_64/arch/x86_64/mm/init.c=0A=
--- linux-2.4.21_lkcd/arch/x86_64/mm/init.c	2003-06-13 =
20:21:32.000000000 +0530=0A=
+++ lkcd_linux_x86_64/arch/x86_64/mm/init.c	2004-07-01 =
20:46:11.000000000 +0530=0A=
@@ -338,7 +338,11 @@=0A=
 	free_area_init(zones_size);=0A=
 }=0A=
 =0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+int page_is_ram (unsigned long pagenr)=0A=
+#else=0A=
 static inline int page_is_ram (unsigned long pagenr)=0A=
+#endif=0A=
 {=0A=
 	int i;=0A=
 =0A=
diff -Naur linux-2.4.21_lkcd/drivers/dump/dump_x86_64.c =
lkcd_linux_x86_64/drivers/dump/dump_x86_64.c=0A=
--- linux-2.4.21_lkcd/drivers/dump/dump_x86_64.c	1970-01-01 =
05:30:00.000000000 +0530=0A=
+++ lkcd_linux_x86_64/drivers/dump/dump_x86_64.c	2004-07-02 =
20:59:48.000000000 +0530=0A=
@@ -0,0 +1,295 @@=0A=
+/*=0A=
+ * Architecture specific (x86_64) functions for Linux crash dumps.=0A=
+ *=0A=
+ * Created by: Matt Robinson ([email protected])=0A=
+ *=0A=
+ * modified for x86_64 by: Sanjay Kumar =
([email protected])=0A=
+ *=0A=
+ * Copyright 1999 Silicon Graphics, Inc. All rights reserved.=0A=
+ *=0A=
+ * 2.3 kernel modifications by: Matt D. Robinson =
([email protected])=0A=
+ * Copyright 2000 TurboLinux, Inc.  All rights reserved.=0A=
+ * =0A=
+ * This code is released under version 2 of the GNU GPL.=0A=
+ */=0A=
+=0A=
+/*=0A=
+ * The hooks for dumping the kernel virtual memory to disk are in =
this=0A=
+ * file.  Any time a modification is made to the virtual memory =
mechanism,=0A=
+ * these routines must be changed to use the new mechanisms.=0A=
+ */=0A=
+#include <linux/init.h>=0A=
+#include <linux/types.h>=0A=
+#include <linux/kernel.h>=0A=
+#include <linux/smp.h>=0A=
+#include <linux/fs.h>=0A=
+#include <linux/vmalloc.h>=0A=
+#include <linux/dump.h>=0A=
+#include <linux/mm.h>=0A=
+#include <asm/processor.h>=0A=
+#include <asm/hardirq.h>=0A=
+#include <linux/irq.h>=0A=
+=0A=
+static int alloc_dha_stack(void)=0A=
+{=0A=
+	int i;=0A=
+	void *ptr;=0A=
+	=0A=
+	if (dump_header_asm.dha_stack[0])=0A=
+		return 0;=0A=
+=0A=
+       	ptr =3D vmalloc(THREAD_SIZE * smp_num_cpus);=0A=
+	if (!ptr) {=0A=
+		printk("vmalloc for dha_stacks failed\n");=0A=
+		return -ENOMEM;=0A=
+	}=0A=
+=0A=
+	for (i =3D 0; i < smp_num_cpus; i++) {=0A=
+		dump_header_asm.dha_stack[i] =3D (uint64_t)((unsigned long)ptr + (i =
* THREAD_SIZE));=0A=
+	}=0A=
+	return 0;=0A=
+}=0A=
+=0A=
+static int free_dha_stack(void) =0A=
+{=0A=
+	if (dump_header_asm.dha_stack[0])=0A=
+		vfree((void*)dump_header_asm.dha_stack[0]);	=0A=
+	return 0;=0A=
+}=0A=
+=0A=
+static void=0A=
+save_this_cpu_state(int cpu, struct pt_regs *regs, struct task_struct =
*tsk)=0A=
+{=0A=
+	dump_header_asm.dha_smp_regs[cpu] =3D *regs;=0A=
+	dump_header_asm.dha_smp_current_task[cpu] =3D (uint64_t) tsk;=0A=
+=0A=
+	if (dump_header_asm.dha_stack[cpu]) {=0A=
+		memcpy((void*)dump_header_asm.dha_stack[cpu], tsk, THREAD_SIZE);=0A=
+	}=0A=
+	return;=0A=
+}=0A=
+=0A=
+#ifdef CONFIG_SMP=0A=
+static int dump_expect_ipi[NR_CPUS];=0A=
+static atomic_t waiting_for_dump_ipi;=0A=
+static int wait_for_dump_ipi =3D 1; /* always wait for ipi to to be =
handled */=0A=
+extern void (*dump_trace_ptr)(struct pt_regs *);=0A=
+static unsigned long saved_affinity[NR_IRQS];=0A=
+=0A=
+static int=0A=
+dump_ipi_handler(struct pt_regs *regs) =0A=
+{=0A=
+	int cpu =3D smp_processor_id();=0A=
+=0A=
+	if (!dump_expect_ipi[cpu]) {=0A=
+		return 0;=0A=
+	}=0A=
+	=0A=
+	save_this_cpu_state(cpu, regs, current);=0A=
+=0A=
+	dump_expect_ipi[cpu] =3D 0;=0A=
+	atomic_dec(&waiting_for_dump_ipi);=0A=
+	return 1;=0A=
+}=0A=
+=0A=
+/* save registers on other processors */=0A=
+void =0A=
+save_other_cpu_states(void)=0A=
+{=0A=
+	int i;=0A=
+=0A=
+	if (smp_num_cpus > 1) {=0A=
+		atomic_set(&waiting_for_dump_ipi, smp_num_cpus-1);=0A=
+		for (i =3D 0; i < NR_CPUS; i++)=0A=
+			dump_expect_ipi[i] =3D 1;=0A=
+		=0A=
+		dump_ipi_function_ptr =3D dump_ipi_handler;=0A=
+		dump_send_ipi();=0A=
+		/* may be we dont need to wait for NMI to be processed. =0A=
+		   just write out the header at the end of dumping, if=0A=
+		   this IPI is not processed untill then, there probably=0A=
+		   is a problem and we just fail to capture state of =0A=
+		   other cpus. */=0A=
+		if (wait_for_dump_ipi) {=0A=
+			while(atomic_read(&waiting_for_dump_ipi))=0A=
+				barrier();=0A=
+			dump_ipi_function_ptr =3D NULL;=0A=
+		}=0A=
+	}=0A=
+	return;=0A=
+}=0A=
+=0A=
+/* located in arch/i386/kernel/traps.c */=0A=
+extern void show_this_cpu_state(int cpu, struct pt_regs * regs, struct =
task_struct *tsk);=0A=
+=0A=
+void =0A=
+show_cpu_state(struct pt_regs * regs)=0A=
+{=0A=
+	int i;=0A=
+	__dump_configure_header(regs);	=0A=
+	for (i =3D 0; i < smp_num_cpus; i++) {=0A=
+		show_this_cpu_state(i, &dump_header_asm.dha_smp_regs[i], =0A=
+			(void*)dump_header_asm.dha_stack[i]);=0A=
+	}=0A=
+	return;=0A=
+}=0A=
+=0A=
+/*=0A=
+ * Non dumping cpus will spin here. If a cpu is handling an irq when =
ipi is=0A=
+ * received, we let go of it here while making sure that it hits =
schedule=0A=
+ * on the way up and make it spin there instead.=0A=
+ */=0A=
+static void=0A=
+__dump_spin(void *arg)=0A=
+{=0A=
+	if (in_irq()) {=0A=
+		current->need_resched =3D 1;=0A=
+	} else {=0A=
+		while (dump_in_progress) ;=0A=
+	}=0A=
+	return;=0A=
+}=0A=
+=0A=
+/*=0A=
+ * Routine to save the old irq affinities and change affinities of all =
irqs to=0A=
+ * the dumping cpu.=0A=
+ */=0A=
+static void=0A=
+__dump_set_irq_affinity(void)=0A=
+{=0A=
+	int i;=0A=
+	int cpu =3D smp_processor_id();=0A=
+=0A=
+	memcpy(saved_affinity, irq_affinity, NR_IRQS * sizeof(unsigned =
long));=0A=
+	for (i =3D 0; i < NR_IRQS; i++) {=0A=
+		if (irq_desc[i].handler =3D=3D NULL)=0A=
+			continue;=0A=
+		irq_affinity[i] =3D 1UL << cpu;=0A=
+		if (irq_desc[i].handler->set_affinity !=3D NULL)=0A=
+			irq_desc[i].handler->set_affinity(i, irq_affinity[i]);=0A=
+	}=0A=
+}=0A=
+=0A=
+/*=0A=
+ * Restore old irq affinities.=0A=
+ */=0A=
+static void=0A=
+__dump_reset_irq_affinity(void)=0A=
+{=0A=
+	int i;=0A=
+=0A=
+	memcpy(irq_affinity, saved_affinity, NR_IRQS * sizeof(unsigned =
long));=0A=
+	for (i =3D 0; i < NR_IRQS; i++) {=0A=
+		if (irq_desc[i].handler =3D=3D NULL)=0A=
+			continue;=0A=
+		if (irq_desc[i].handler->set_affinity !=3D NULL)=0A=
+			irq_desc[i].handler->set_affinity(i, saved_affinity[i]);=0A=
+	}=0A=
+}=0A=
+=0A=
+#else /* !CONFIG_SMP */=0A=
+#define save_other_cpu_states()=0A=
+#endif /* !CONFIG_SMP */=0A=
+=0A=
+/*=0A=
+ * Name: __dump_silence_system()=0A=
+ * Func: Do an architecture-specific silencing of the system.=0A=
+ *     - Change irq affinities=0A=
+ *     - Wait for other cpus to come out of irq handling=0A=
+ *     - Send CALL_FUNCTION_VECTOR ipi to other cpus to put them to =
spin=0A=
+ */=0A=
+unsigned int=0A=
+__dump_silence_system(unsigned int stage)=0A=
+{=0A=
+#ifdef CONFIG_SMP=0A=
+	if (stage) {	/* Do this after interrupts are enabled */=0A=
+		/* read the comments above ... */=0A=
+		__dump_set_irq_affinity();=0A=
+		synchronize_irq();=0A=
+		smp_call_function(__dump_spin, NULL, 0, 0);=0A=
+	}=0A=
+#endif=0A=
+=0A=
+	/* return */=0A=
+	return (0);=0A=
+}=0A=
+=0A=
+/*=0A=
+ * Name: __dump_resume_system()=0A=
+ * Func: Resume the system state in an architecture-specific way.=0A=
+ */=0A=
+unsigned int=0A=
+__dump_resume_system(unsigned int stage)=0A=
+{=0A=
+#ifdef CONFIG_SMP=0A=
+	/* put the irq affinity tables back */=0A=
+	__dump_reset_irq_affinity();=0A=
+#endif=0A=
+=0A=
+	/* return */=0A=
+	return (0);=0A=
+}=0A=
+=0A=
+/*=0A=
+ * Name: __dump_configure_header()=0A=
+ * Func: Configure the dump header with all proper values.=0A=
+ */=0A=
+int=0A=
+__dump_configure_header(struct pt_regs *regs)=0A=
+{=0A=
+	int cpu =3D smp_processor_id();=0A=
+=0A=
+	dump_header_asm.dha_smp_num_cpus =3D smp_num_cpus;=0A=
+	dump_header_asm.dha_dumping_cpu =3D cpu;=0A=
+=0A=
+	save_this_cpu_state(cpu, regs, current);=0A=
+=0A=
+	save_other_cpu_states();=0A=
+=0A=
+	return (1);=0A=
+}=0A=
+=0A=
+/*=0A=
+ * Name: __dump_init()=0A=
+ * Func: Initialize the dumping routine process.  This is in case=0A=
+ *       it's necessary in the future.=0A=
+ */=0A=
+void=0A=
+__dump_init(uint64_t local_memory_start)=0A=
+{=0A=
+	/* return */=0A=
+	return;=0A=
+}=0A=
+=0A=
+/*=0A=
+ * Name: __dump_open()=0A=
+ * Func: Open the dump device (architecture specific).  This is in=0A=
+ *       case it's necessary in the future.=0A=
+ */=0A=
+void=0A=
+__dump_open(void)=0A=
+{=0A=
+	alloc_dha_stack();=0A=
+#ifdef CONFIG_SMP	=0A=
+	dump_trace_ptr =3D show_cpu_state;=0A=
+#endif=0A=
+	/* return */=0A=
+	return;=0A=
+}=0A=
+=0A=
+/*=0A=
+ * Name: __dump_cleanup()=0A=
+ * Func: Free any architecture specific data structures. This is =
called=0A=
+ *       when the dump module is being removed.=0A=
+ */=0A=
+void=0A=
+__dump_cleanup(void)=0A=
+{=0A=
+	free_dha_stack();=0A=
+#ifdef CONFIG_SMP=0A=
+	dump_trace_ptr =3D NULL;=0A=
+#endif=0A=
+	/* return */=0A=
+	return;=0A=
+}=0A=
+=0A=
diff -Naur linux-2.4.21_lkcd/drivers/dump/Makefile =
lkcd_linux_x86_64/drivers/dump/Makefile=0A=
--- linux-2.4.21_lkcd/drivers/dump/Makefile	2004-06-04 =
10:54:44.000000000 +0530=0A=
+++ lkcd_linux_x86_64/drivers/dump/Makefile	2004-07-01 =
20:49:02.000000000 +0530=0A=
@@ -22,6 +22,10 @@=0A=
 	dump-objs		+=3D dump_i386.o=0A=
 endif=0A=
 =0A=
+ifeq ($(ARCH),x86_64)=0A=
+	dump-objs		+=3D dump_x86_64.o=0A=
+endif=0A=
+=0A=
 ifeq ($(ARCH),alpha)=0A=
 	dump-objs		+=3D dump_alpha.o=0A=
 endif=0A=
diff -Naur linux-2.4.21_lkcd/include/asm-x86_64/dump.h =
lkcd_linux_x86_64/include/asm-x86_64/dump.h=0A=
--- linux-2.4.21_lkcd/include/asm-x86_64/dump.h	1970-01-01 =
05:30:00.000000000 +0530=0A=
+++ lkcd_linux_x86_64/include/asm-x86_64/dump.h	2004-07-02 =
21:01:28.000000000 +0530=0A=
@@ -0,0 +1,98 @@=0A=
+/*=0A=
+ * Kernel header file for Linux crash dumps.=0A=
+ *=0A=
+ * Created by: Matt Robinson ([email protected])=0A=
+ * =0A=
+ * modified for x86_64 by: Sanjay Kumar =
([email protected])=0A=
+ *=0A=
+ * Copyright 1999 Silicon Graphics, Inc. All rights reserved.=0A=
+ *=0A=
+ * This code is released under version 2 of the GNU GPL.=0A=
+ */=0A=
+=0A=
+/* This header file holds the architecture specific crash dump header =
*/=0A=
+#ifndef _ASM_DUMP_H=0A=
+#define _ASM_DUMP_H=0A=
+=0A=
+/* necessary header files */=0A=
+#include <asm/ptrace.h>                          /* for pt_regs        =
     */=0A=
+#include <linux/threads.h>=0A=
+=0A=
+/* definitions */=0A=
+#define DUMP_ASM_MAGIC_NUMBER     0xdeaddeadULL  /* magic number       =
     */=0A=
+#define DUMP_ASM_VERSION_NUMBER   0x3            /* version number     =
     */=0A=
+=0A=
+/* max number of cpus */=0A=
+#define DUMP_MAX_NUM_CPUS 32=0A=
+=0A=
+/*=0A=
+ * Structure: dump_header_asm_t=0A=
+ *  Function: This is the header for architecture-specific stuff.  =
It=0A=
+ *            follows right after the dump header.=0A=
+ */=0A=
+typedef struct _dump_header_asm_s {=0A=
+=0A=
+        /* the dump magic number -- unique to verify dump is valid =
*/=0A=
+        uint64_t             dha_magic_number;=0A=
+=0A=
+        /* the version number of this dump */=0A=
+        uint32_t             dha_version;=0A=
+=0A=
+        /* the size of this header (in case we can't read it) */=0A=
+        uint32_t             dha_header_size;=0A=
+=0A=
+	/* the esp for i386 systems */=0A=
+	uint32_t             dha_esp;=0A=
+=0A=
+	/* the eip for i386 systems */=0A=
+	uint32_t             dha_eip;=0A=
+=0A=
+	/* the dump registers */=0A=
+	struct pt_regs       dha_regs;=0A=
+=0A=
+	/* smp specific */=0A=
+	uint32_t	     dha_smp_num_cpus;=0A=
+	uint32_t	     dha_dumping_cpu;	=0A=
+	struct pt_regs	     dha_smp_regs[DUMP_MAX_NUM_CPUS];=0A=
+	uint64_t	     dha_smp_current_task[DUMP_MAX_NUM_CPUS];=0A=
+	uint64_t	     dha_stack[DUMP_MAX_NUM_CPUS];=0A=
+} __attribute__((packed)) dump_header_asm_t;=0A=
+=0A=
+#ifdef __KERNEL__=0A=
+static inline void get_current_regs(struct pt_regs *regs)=0A=
+{=0A=
+	asm("movq %%r15, %0": "=3Dr" (regs->r15));=0A=
+	asm("movq %%r14, %0": "=3Dr" (regs->r14));=0A=
+	asm("movq %%r13, %0": "=3Dr" (regs->r13));=0A=
+	asm("movq %%r12, %0": "=3Dr" (regs->r12));=0A=
+	asm("movq %%rbp, %0": "=3Dr" (regs->rbp));=0A=
+	asm("movq %%rbx, %0": "=3Dr" (regs->rbx));=0A=
+	asm("movq %%r11, %0": "=3Dr" (regs->r11));=0A=
+	asm("movq %%r10, %0": "=3Dr" (regs->r10));=0A=
+	asm("movq %%r9, %0": "=3Dr" (regs->r9));=0A=
+	asm("movq %%r8, %0": "=3Dr" (regs->r8));=0A=
+	asm("movq %%rax, %0": "=3Dr" (regs->rax));=0A=
+	asm("movq %%rcx, %0": "=3Dr" (regs->rcx));=0A=
+	asm("movq %%rdx, %0": "=3Dr" (regs->rdx));=0A=
+	asm("movq %%rsi, %0": "=3Dr" (regs->rsi));=0A=
+	asm("movq %%rdi, %0": "=3Dr" (regs->rdi));=0A=
+	asm("movl %%cs, %0": "=3Dm" (regs->cs));=0A=
+	asm("movq %%rsp, %0": "=3Dr" (regs->rsp));=0A=
+	asm("movl %%ss, %0": "=3Dm" (regs->ss));=0A=
+	asm("pushf; pop %0" :"=3Dm"(regs->eflags));=0A=
+	regs->rip =3D (unsigned long)current_text_addr();=0A=
+}=0A=
+=0A=
+extern volatile int dump_in_progress;=0A=
+extern unsigned long irq_affinity[];=0A=
+extern dump_header_asm_t dump_header_asm;=0A=
+=0A=
+#ifdef CONFIG_SMP=0A=
+extern int (*dump_ipi_function_ptr)(struct pt_regs *);=0A=
+extern void dump_send_ipi(void);=0A=
+#else=0A=
+#define dump_send_ipi()=0A=
+#endif=0A=
+#endif /* __KERNEL__ */=0A=
+=0A=
+#endif /* _ASM_DUMP_H */=0A=
diff -Naur linux-2.4.21_lkcd/include/asm-x86_64/hw_irq.h =
lkcd_linux_x86_64/include/asm-x86_64/hw_irq.h=0A=
--- linux-2.4.21_lkcd/include/asm-x86_64/hw_irq.h	2003-06-13 =
20:21:38.000000000 +0530=0A=
+++ lkcd_linux_x86_64/include/asm-x86_64/hw_irq.h	2004-07-01 =
20:50:45.000000000 +0530=0A=
@@ -52,6 +52,9 @@=0A=
 #define RESCHEDULE_VECTOR	0xfc=0A=
 /* 0xfa free */=0A=
 #define CALL_FUNCTION_VECTOR	0xfb=0A=
+#if defined(CONFIG_DUMP) || defined(CONFIG_DUMP_MODULE)=0A=
+#define DUMP_VECTOR     0xfa=0A=
+#endif=0A=
 =0A=
 /*=0A=
  * Local APIC timer IRQ vector is on a different priority level,=0A=
diff -Naur linux-2.4.21_lkcd/Makefile lkcd_linux_x86_64/Makefile=0A=
--- linux-2.4.21_lkcd/Makefile	2004-06-04 10:54:45.000000000 +0530=0A=
+++ lkcd_linux_x86_64/Makefile	2004-07-01 21:32:06.000000000 +0530=0A=
@@ -190,6 +190,7 @@=0A=
 DRIVERS-$(CONFIG_BLUEZ) +=3D drivers/bluetooth/bluetooth.o=0A=
 DRIVERS-$(CONFIG_HOTPLUG_PCI) +=3D drivers/hotplug/vmlinux-obj.o=0A=
 DRIVERS-$(CONFIG_ISDN_BOOL) +=3D drivers/isdn/vmlinux-obj.o=0A=
+DRIVERS-$(CONFIG_DUMP) +=3D drivers/dump/dump.o=0A=
 =0A=
 DRIVERS :=3D $(DRIVERS-y)=0A=
 =0A=

------_=_NextPart_000_01C47E96.DEE9E562--


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285