From: Horms Date: Tue, 12 Dec 2006 08:49:03 +0000 Subject: [PATCH] [IA64] CONFIG_KEXEC and CONFIG_CRASH_DUMP Message-Id: <20061212084901.GK18377@verge.net.au> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-ia64@vger.kernel.org On Tue, Dec 12, 2006 at 03:54:51PM +0900, Horms wrote: > On Mon, Dec 11, 2006 at 03:58:18PM -0800, Luck, Tony wrote: > > The kexec/crash_dump patches for ia64 have gone into Linus' > > tree ... but there are some loose ends to tidy up. One of them > > is what is supposed to happen if I configure CONFIG_KEXEC=y with > > CONFIG_CRASH_DUMP=n or CONFIG_KEXEC=n with CONFIG_CRASH_DUMP=y. > > > > The current result is build errors unless both are 'n' or both > > are 'y'. Looking at Documentation/kdump/kdump.txt it looks like > > the original intent was that CONFIG_KEXEC=y be used for the normal > > kernel that you run all the time, and CONFIG_CRASH_DUMP=y be used > > for the kernel that you transfer to when bad stuff has happened to > > actually dump memory. > > > > But on ia64 I don't think that we need such a distinction. We don't > > need to link the crashdump kernel at a special address, so it can > > be the same binary as our normal kernel. > > > > I did take a quick look at untangling KEXEC/CRASH_DUMP ... but > > there seem to be a few places where the ia64 port assumes that > > both are either set or not set. > > > > Perhaps the path of least resistance would be to just fix > > arch/ia64/Kconfig to only offer a single "kexec + crashdump" > > option that sets both CONFIG options? Or are there other > > benefits/reasons to keep separate options? > > I doubt that there is a benifit other than consistency with > other architectures. I'll cook up a patch to merge them as > you suggest, as appart from anything else, it should > avoid missusing them in future. 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 Index: linux-2.6/arch/ia64/kernel/Makefile =================================--- linux-2.6.orig/arch/ia64/kernel/Makefile 2006-12-12 17:40:52.000000000 +0900 +++ linux-2.6/arch/ia64/kernel/Makefile 2006-12-12 17:40:54.000000000 +0900 @@ -29,6 +29,7 @@ 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 obj-$(CONFIG_PCI_MSI) += msi_ia64.o Index: linux-2.6/arch/ia64/kernel/crash.c =================================--- linux-2.6.orig/arch/ia64/kernel/crash.c 2006-12-12 17:40:51.000000000 +0900 +++ linux-2.6/arch/ia64/kernel/crash.c 2006-12-12 17:40:54.000000000 +0900 @@ -19,29 +19,11 @@ #include #include -#include 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< + * Original code moved from kernel/crash.c + * Original code comment copied from the i386 version of this file + */ + +#include +#include + +#include + +/** + * 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<