* [PATCH] Fix in free initrd when overlapped with crashkernel region
@ 2006-02-07 3:50 Haren Myneni
2006-02-07 8:47 ` Paul Mackerras
0 siblings, 1 reply; 3+ messages in thread
From: Haren Myneni @ 2006-02-07 3:50 UTC (permalink / raw)
To: linux-kernel, Fastboot mailing list, linuxppc64-dev; +Cc: hpa, Milton Miller
[-- Attachment #1: Type: text/plain, Size: 948 bytes --]
It is possible that the reserved crashkernel region can be overlapped
with initrd since the bootloader sets the initrd location. When the
initrd region is freed, the second kernel memory will not be contiguous.
The Kexec_load can cause an oops since there is no contiguous memory to
write the second kernel or this memory could be used in the first kernel
itself and may not be part of the dump. For example, on powerpc, the
initrd is located at 36MB and the crashkernel starts at 32MB. The
kexec_load caused panic since writing into non-allocated memory (after
36MB). We could see the similar issue even on other archs.
One possibility is to move the initrd outside of crashkernel region.
But, the initrd region will be freed anyway before the system is up.
This patch fixes this issue and frees only regions that are not part of
crashkernel memory in case overlaps.
Thanks
Haren
Signed-off-by: Haren Myneni <haren@us.ibm.com>
[-- Attachment #2: kdump-initrd-overlap-fix.patch --]
[-- Type: text/x-patch, Size: 1723 bytes --]
diff -Naurp 2616-rc2.orig/include/linux/kexec.h 2616-rc2/include/linux/kexec.h
--- 2616-rc2.orig/include/linux/kexec.h 2006-02-06 19:08:01.000000000 -0800
+++ 2616-rc2/include/linux/kexec.h 2006-02-06 19:06:37.000000000 -0800
@@ -6,6 +6,7 @@
#include <linux/list.h>
#include <linux/linkage.h>
#include <linux/compat.h>
+#include <linux/ioport.h>
#include <asm/kexec.h>
/* Verify architecture specific macros are defined */
diff -Naurp 2616-rc2.orig/init/initramfs.c 2616-rc2/init/initramfs.c
--- 2616-rc2.orig/init/initramfs.c 2006-02-06 19:04:42.000000000 -0800
+++ 2616-rc2/init/initramfs.c 2006-02-06 19:04:59.000000000 -0800
@@ -466,10 +466,32 @@ static char * __init unpack_to_rootfs(ch
extern char __initramfs_start[], __initramfs_end[];
#ifdef CONFIG_BLK_DEV_INITRD
#include <linux/initrd.h>
+#include <linux/kexec.h>
static void __init free_initrd(void)
{
- free_initrd_mem(initrd_start, initrd_end);
+#ifdef CONFIG_KEXEC
+ unsigned long crashk_start = (unsigned long)__va(crashk_res.start);
+ unsigned long crashk_end = (unsigned long)__va(crashk_res.end);
+
+ /*
+ * If the initrd region is overlapped with crashkernel reserved region,
+ * free only memory that is not part of crashkernel region.
+ */
+ if (initrd_start < crashk_end && initrd_end > crashk_start) {
+ /*
+ * Initialize initrd memory region since the kexec boot does
+ * not do.
+ */
+ memset((void *)initrd_start, 0, initrd_end - initrd_start);
+ if (initrd_start < crashk_start)
+ free_initrd_mem(initrd_start, crashk_start);
+ if (initrd_end > crashk_end)
+ free_initrd_mem(crashk_end, initrd_end);
+ } else
+#endif
+ free_initrd_mem(initrd_start, initrd_end);
+
initrd_start = 0;
initrd_end = 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix in free initrd when overlapped with crashkernel region
2006-02-07 3:50 [PATCH] Fix in free initrd when overlapped with crashkernel region Haren Myneni
@ 2006-02-07 8:47 ` Paul Mackerras
2006-02-07 23:01 ` Haren Myneni
0 siblings, 1 reply; 3+ messages in thread
From: Paul Mackerras @ 2006-02-07 8:47 UTC (permalink / raw)
To: Haren Myneni
Cc: linux-kernel, Fastboot mailing list, linuxppc64-dev, Milton Miller, hpa
Haren Myneni writes:
> --- 2616-rc2.orig/include/linux/kexec.h 2006-02-06 19:08:01.000000000 -0800
> +++ 2616-rc2/include/linux/kexec.h 2006-02-06 19:06:37.000000000 -0800
> @@ -6,6 +6,7 @@
> #include <linux/list.h>
> #include <linux/linkage.h>
> #include <linux/compat.h>
> +#include <linux/ioport.h>
> #include <asm/kexec.h>
What's this hunk for?
Paul.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix in free initrd when overlapped with crashkernel region
2006-02-07 8:47 ` Paul Mackerras
@ 2006-02-07 23:01 ` Haren Myneni
0 siblings, 0 replies; 3+ messages in thread
From: Haren Myneni @ 2006-02-07 23:01 UTC (permalink / raw)
To: Paul Mackerras
Cc: linux-kernel, Fastboot mailing list, linuxppc64-dev, Milton Miller, hpa
Paul Mackerras wrote:
>Haren Myneni writes:
>
>
>
>>--- 2616-rc2.orig/include/linux/kexec.h 2006-02-06 19:08:01.000000000 -0800
>>+++ 2616-rc2/include/linux/kexec.h 2006-02-06 19:06:37.000000000 -0800
>>@@ -6,6 +6,7 @@
>> #include <linux/list.h>
>> #include <linux/linkage.h>
>> #include <linux/compat.h>
>>+#include <linux/ioport.h>
>> #include <asm/kexec.h>
>>
>>
>
>What's this hunk for?
>
>Paul.
>
>
crashk_res is an extern declaration in kexec.h. Declared as "struct
resource" which is defined in linux/ioport.h.
For other places wherever this variable is used, ioport.h got included
through some other header file. Whereas for initramfs.c, either we need
to include ioport.h explicitly or include in kexec.h. Chosen the later
one. Probably, some comment would be better to make it clear.
Paul, do you prefer to repost the patch with the comment?
Thanks
Haren
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at http://www.tux.org/lkml/
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-02-07 23:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-07 3:50 [PATCH] Fix in free initrd when overlapped with crashkernel region Haren Myneni
2006-02-07 8:47 ` Paul Mackerras
2006-02-07 23:01 ` Haren Myneni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).