WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [patch 05/16] CONFIG_KEXEC/CONFIG_CRASH_DUMP permutatio

To: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [patch 05/16] CONFIG_KEXEC/CONFIG_CRASH_DUMP permutations
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Wed, 12 Sep 2007 17:28:39 +0900
Delivery-date: Wed, 12 Sep 2007 01:44:29 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20070912082834.175658477@xxxxxxxxxxxx>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: quilt/0.46-1
[IA64] CONFIG_KEXEC/CONFIG_CRASH_DUMP permutations

Actually, on reflection I think that there is a good case for
keeping the options separate. I am thinking particularly of people
who want a very small crashdump kernel and thus don't want to compile
in kexec.

The patch below should fix things up so that all valid combinations of
KEXEC, CRASH_DUMP and VMCORE compile cleanly - VMCORE depends on
CRASH_DUMP which is why I said valid combinations. In a nutshell
it just untangles unrelated code and switches around a few defines.

Please note that it creats a new file, arch/ia64/kernel/crash_dump.c
This is in keeping with the i386 implementation.

Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>
Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>

 arch/ia64/kernel/Makefile     |    1
 arch/ia64/kernel/crash.c      |   22 ------------------
 arch/ia64/kernel/crash_dump.c |   48 +++++++++++++++++++++++++++++++++++++++++
 arch/ia64/kernel/mca.c        |    2 -
 arch/ia64/kernel/setup.c      |   15 ++++++++++++
 arch/ia64/kernel/smp.c        |    4 +--
 arch/ia64/mm/contig.c         |    6 +++++
 7 files changed, 73 insertions(+), 25 deletions(-)
---
>From Linux upstream

Index: linux-2.6.18-xen.hg/arch/ia64/kernel/mca.c
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/kernel/mca.c     2007-07-09 
14:53:09.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/kernel/mca.c  2007-07-09 14:59:39.000000000 
+0900
@@ -1068,7 +1068,7 @@ ia64_mca_handler(struct pt_regs *regs, s
                ia64_sal_clear_state_info(SAL_INFO_TYPE_MCA);
                sos->os_status = IA64_MCA_CORRECTED;
        } else {
-#ifdef CONFIG_CRASH_DUMP
+#ifdef CONFIG_KEXEC
                atomic_set(&kdump_in_progress, 1);
                monarch_cpu = -1;
 #endif
Index: linux-2.6.18-xen.hg/arch/ia64/kernel/smp.c
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/kernel/smp.c     2007-07-09 
14:53:09.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/kernel/smp.c  2007-07-09 14:59:39.000000000 
+0900
@@ -157,7 +157,7 @@ handle_IPI (int irq, void *dev_id, struc
                              case IPI_CPU_STOP:
                                stop_this_cpu();
                                break;
-#ifdef CONFIG_CRASH_DUMP
+#ifdef CONFIG_KEXEC
                              case IPI_KDUMP_CPU_STOP:
                                unw_init_running(kdump_cpu_freeze, NULL);
                                break;
@@ -219,7 +219,7 @@ send_IPI_self (int op)
        send_IPI_single(smp_processor_id(), op);
 }
 
-#ifdef CONFIG_CRASH_DUMP
+#ifdef CONFIG_KEXEC
 void
 kdump_smp_send_stop()
 {
Index: linux-2.6.18-xen.hg/arch/ia64/mm/contig.c
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/mm/contig.c      2007-07-09 
14:53:09.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/mm/contig.c   2007-07-09 14:59:39.000000000 
+0900
@@ -174,6 +174,12 @@ find_memory (void)
        reserve_bootmem(bootmap_start, bootmap_size);
 
        find_initrd();
+
+#ifdef CONFIG_CRASH_DUMP
+       /* If we are doing a crash dump, we still need to know the real mem
+        * size before original memory map is * reset. */
+       saved_max_pfn = max_pfn;
+#endif
 }
 
 #ifdef CONFIG_SMP
Index: linux-2.6.18-xen.hg/arch/ia64/kernel/Makefile
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/kernel/Makefile  2007-07-09 
15:00:04.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/kernel/Makefile       2007-07-09 
15:00:34.000000000 +0900
@@ -29,6 +29,7 @@ obj-$(CONFIG_CPU_FREQ)                += cpufreq/
 obj-$(CONFIG_IA64_MCA_RECOVERY)        += mca_recovery.o
 obj-$(CONFIG_KPROBES)          += kprobes.o jprobes.o
 obj-$(CONFIG_KEXEC)            += machine_kexec.o relocate_kernel.o crash.o
+obj-$(CONFIG_CRASH_DUMP)       += crash_dump.o
 obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR)  += uncached.o
 obj-$(CONFIG_AUDIT)            += audit.o
 mca_recovery-y                 += mca_drv.o mca_drv_asm.o
Index: linux-2.6.18-xen.hg/arch/ia64/kernel/crash.c
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/kernel/crash.c   2007-07-09 
15:00:04.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/kernel/crash.c        2007-07-09 
15:00:34.000000000 +0900
@@ -19,29 +19,11 @@
 
 #include <asm/kdebug.h>
 #include <asm/mca.h>
-#include <asm/uaccess.h>
 
 int kdump_status[NR_CPUS];
 atomic_t kdump_cpu_freezed;
 atomic_t kdump_in_progress;
 int kdump_on_init = 1;
-ssize_t
-copy_oldmem_page(unsigned long pfn, char *buf,
-               size_t csize, unsigned long offset, int userbuf)
-{
-       void  *vaddr;
-
-       if (!csize)
-               return 0;
-       vaddr = __va(pfn<<PAGE_SHIFT);
-       if (userbuf) {
-               if (copy_to_user(buf, (vaddr + offset), csize)) {
-                       return -EFAULT;
-               }
-       } else
-               memcpy(buf, (vaddr + offset), csize);
-       return csize;
-}
 
 static inline Elf64_Word
 *append_elf_note(Elf64_Word *buf, char *name, unsigned type, void *data,
@@ -224,14 +206,10 @@ static ctl_table sys_table[] = {
 static int
 machine_crash_setup(void)
 {
-       char *from = strstr(saved_command_line, "elfcorehdr=");
        static struct notifier_block kdump_init_notifier_nb = {
                .notifier_call = kdump_init_notifier,
        };
        int ret;
-       if (from)
-               elfcorehdr_addr = memparse(from+11, &from);
-       saved_max_pfn = (unsigned long)-1;
        if((ret = register_die_notifier(&kdump_init_notifier_nb)) != 0)
                return ret;
 #ifdef CONFIG_SYSCTL
Index: linux-2.6.18-xen.hg/arch/ia64/kernel/crash_dump.c
===================================================================
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.18-xen.hg/arch/ia64/kernel/crash_dump.c   2007-07-09 
15:00:34.000000000 +0900
@@ -0,0 +1,48 @@
+/*
+ *     kernel/crash_dump.c - Memory preserving reboot related code.
+ *
+ *     Created by: Simon Horman <horms@xxxxxxxxxxxx>
+ *     Original code moved from kernel/crash.c
+ *     Original code comment copied from the i386 version of this file
+ */
+
+#include <linux/errno.h>
+#include <linux/types.h>
+
+#include <linux/uaccess.h>
+
+/**
+ * copy_oldmem_page - copy one page from "oldmem"
+ * @pfn: page frame number to be copied
+ * @buf: target memory address for the copy; this can be in kernel address
+ *     space or user address space (see @userbuf)
+ * @csize: number of bytes to copy
+ * @offset: offset in bytes into the page (based on pfn) to begin the copy
+ * @userbuf: if set, @buf is in user address space, use copy_to_user(),
+ *     otherwise @buf is in kernel address space, use memcpy().
+ *
+ * Copy a page from "oldmem". For this page, there is no pte mapped
+ * in the current kernel. We stitch up a pte, similar to kmap_atomic.
+ *
+ * Calling copy_to_user() in atomic context is not desirable. Hence first
+ * copying the data to a pre-allocated kernel page and then copying to user
+ * space in non-atomic context.
+ */
+ssize_t
+copy_oldmem_page(unsigned long pfn, char *buf,
+               size_t csize, unsigned long offset, int userbuf)
+{
+       void  *vaddr;
+
+       if (!csize)
+               return 0;
+       vaddr = __va(pfn<<PAGE_SHIFT);
+       if (userbuf) {
+               if (copy_to_user(buf, (vaddr + offset), csize)) {
+                       return -EFAULT;
+               }
+       } else
+               memcpy(buf, (vaddr + offset), csize);
+       return csize;
+}
+
Index: linux-2.6.18-xen.hg/arch/ia64/kernel/setup.c
===================================================================
--- linux-2.6.18-xen.hg.orig/arch/ia64/kernel/setup.c   2007-07-09 
15:00:04.000000000 +0900
+++ linux-2.6.18-xen.hg/arch/ia64/kernel/setup.c        2007-07-09 
15:00:34.000000000 +0900
@@ -484,6 +484,21 @@ static __init int setup_nomca(char *s)
 }
 early_param("nomca", setup_nomca);
 
+#ifdef CONFIG_PROC_VMCORE
+/* elfcorehdr= specifies the location of elf core header
+ * stored by the crashed kernel.
+ */
+static int __init parse_elfcorehdr(char *arg)
+{
+       if (!arg)
+               return -EINVAL;
+
+        elfcorehdr_addr = memparse(arg, &arg);
+       return 0;
+}
+early_param("elfcorehdr", parse_elfcorehdr);
+#endif /* CONFIG_PROC_VMCORE */
+
 void __init
 setup_arch (char **cmdline_p)
 {

-- 

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/


_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel

<Prev in Thread] Current Thread [Next in Thread>