public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Getting biarch support
@ 2010-03-11  8:16 Eric W. Biederman
  2010-03-11  8:20 ` [PATCH 1/3] Refix concat_cmdline Eric W. Biederman
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Eric W. Biederman @ 2010-03-11  8:16 UTC (permalink / raw)
  To: Simon Horman; +Cc: Kexec Mailing List


It looks like no one ever tested taking a crashdump
from a 64bit kernel with a 32bit userspace on x86,
and we have a reuse-cmdline regression fixes follow.

Eric


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] Refix concat_cmdline
  2010-03-11  8:16 [PATCH 0/3] Getting biarch support Eric W. Biederman
@ 2010-03-11  8:20 ` Eric W. Biederman
  2010-03-11  8:20 ` [PATCH 0/3] Getting biarch support Simon Horman
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Eric W. Biederman @ 2010-03-11  8:20 UTC (permalink / raw)
  To: Simon Horman; +Cc: Kexec Mailing List


When removing the potential leak the logic was flipped which
mean we never reached the case for handling when both parameters
were set.

Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
---
 kexec/kexec.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index d282ade..43d0189 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -1007,9 +1007,9 @@ char *concat_cmdline(const char *base, const char *append)
 	char *cmdline;
 	if (!base && !append)
 		return NULL;
-	if (append)
+	if (append && !base)
 		return xstrdup(append);
-	if (base)
+	if (base && !append)
 		return xstrdup(base);
 	cmdline = xmalloc(strlen(base) + 1 + strlen(append) + 1);
 	strcpy(cmdline, base);
-- 
1.6.6.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] Getting biarch support
  2010-03-11  8:16 [PATCH 0/3] Getting biarch support Eric W. Biederman
  2010-03-11  8:20 ` [PATCH 1/3] Refix concat_cmdline Eric W. Biederman
@ 2010-03-11  8:20 ` Simon Horman
  2010-03-11  8:21 ` [PATCH 2/3] kexec: Figure out our native architecture before load Eric W. Biederman
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Simon Horman @ 2010-03-11  8:20 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: Kexec Mailing List

On Thu, Mar 11, 2010 at 12:16:58AM -0800, Eric W. Biederman wrote:
> 
> It looks like no one ever tested taking a crashdump
> from a 64bit kernel with a 32bit userspace on x86,
> and we have a reuse-cmdline regression fixes follow.

I seem to recall testing that, but it was many moons ago :-)


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/3] kexec: Figure out our native architecture before load
  2010-03-11  8:16 [PATCH 0/3] Getting biarch support Eric W. Biederman
  2010-03-11  8:20 ` [PATCH 1/3] Refix concat_cmdline Eric W. Biederman
  2010-03-11  8:20 ` [PATCH 0/3] Getting biarch support Simon Horman
@ 2010-03-11  8:21 ` Eric W. Biederman
  2010-03-11  8:22 ` [PATCH 3/3] x86: Fix biarch crashdump setup Eric W. Biederman
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Eric W. Biederman @ 2010-03-11  8:21 UTC (permalink / raw)
  To: Simon Horman; +Cc: Kexec Mailing List


This moves the computing of our native archtecture earlier so
that load can use it, as arch/i386/crashdump-x86.c has been
trying to.

Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
---
 kexec/kexec.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/kexec/kexec.c b/kexec/kexec.c
index 43d0189..16a0ec9 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -695,17 +695,19 @@ static int my_load(const char *type, int fileind, int argc, char **argv,
 			}
 		}
 	}
+	/* Figure out our native architecture before load */
+	native_arch = physical_arch();
+	if (native_arch < 0) {
+		return -1;
+	}
+	info.kexec_flags |= native_arch;
+
 	if (file_type[i].load(argc, argv, kernel_buf,
 			      kernel_size, &info) < 0) {
 		fprintf(stderr, "Cannot load %s\n", kernel);
 		return -1;
 	}
 	/* If we are not in native mode setup an appropriate trampoline */
-	native_arch = physical_arch();
-	if (native_arch < 0) {
-		return -1;
-	}
-	info.kexec_flags |= native_arch;
 	if (arch_compat_trampoline(&info) < 0) {
 		return -1;
 	}
-- 
1.6.6.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] x86: Fix biarch crashdump setup.
  2010-03-11  8:16 [PATCH 0/3] Getting biarch support Eric W. Biederman
                   ` (2 preceding siblings ...)
  2010-03-11  8:21 ` [PATCH 2/3] kexec: Figure out our native architecture before load Eric W. Biederman
@ 2010-03-11  8:22 ` Eric W. Biederman
  2010-03-11  8:22 ` [PATCH 0/3] Getting biarch support Bernhard Walle
  2010-03-11  8:48 ` Simon Horman
  5 siblings, 0 replies; 8+ messages in thread
From: Eric W. Biederman @ 2010-03-11  8:22 UTC (permalink / raw)
  To: Simon Horman; +Cc: Kexec Mailing List


Generate the correct crashdump header for x86_64 kernels
when a 32bit kernel is used.

Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
---
 kexec/arch/i386/crashdump-x86.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index 804dadd..9d37442 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -509,7 +509,7 @@ static struct crash_elf_info elf_info32 =
 static enum coretype get_core_type(struct kexec_info *info,
 				   struct memory_range *range, int ranges)
 {
-	if (info->kexec_flags & KEXEC_ARCH_X86_64)
+	if ((info->kexec_flags & KEXEC_ARCH_MASK) == KEXEC_ARCH_X86_64)
 		return CORE_TYPE_ELF64;
 	else {
 		/* fall back to default */
@@ -534,6 +534,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 	unsigned long sz, elfcorehdr;
 	int nr_ranges, align = 1024;
 	struct memory_range *mem_range, *memmap_p;
+	unsigned machine;
 
 	if (get_crash_memory_ranges(&mem_range, &nr_ranges,
 				    info->kexec_flags) < 0)
@@ -548,6 +549,12 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 			get_core_type(info, mem_range, nr_ranges);
 	}
 
+        /* Get the elf architecture of the running kernel */
+	machine = EM_386;
+	if ((info->kexec_flags & KEXEC_ARCH_MASK) == KEXEC_ARCH_X86_64) {
+		machine = EM_X86_64;
+	}
+
 	/* Memory regions which panic kernel can safely use to boot into */
 	sz = (sizeof(struct memory_range) * (KEXEC_MAX_SEGMENTS + 1));
 	memmap_p = xmalloc(sz);
@@ -571,6 +578,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 
 	/* Create elf header segment and store crash image data. */
 	if (arch_options.core_header_type == CORE_TYPE_ELF64) {
+		elf_info64.machine = machine;
 		if (crash_create_elf64_headers(info, &elf_info64,
 					       crash_memory_range, nr_ranges,
 					       &tmp, &sz,
@@ -578,6 +586,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
 			return -1;
 	}
 	else {
+		elf_info32.machine = machine;
 		if (crash_create_elf32_headers(info, &elf_info32,
 					       crash_memory_range, nr_ranges,
 					       &tmp, &sz,
-- 
1.6.6.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] Getting biarch support
  2010-03-11  8:16 [PATCH 0/3] Getting biarch support Eric W. Biederman
                   ` (3 preceding siblings ...)
  2010-03-11  8:22 ` [PATCH 3/3] x86: Fix biarch crashdump setup Eric W. Biederman
@ 2010-03-11  8:22 ` Bernhard Walle
  2010-03-11  8:35   ` Eric W. Biederman
  2010-03-11  8:48 ` Simon Horman
  5 siblings, 1 reply; 8+ messages in thread
From: Bernhard Walle @ 2010-03-11  8:22 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: Simon Horman, Kexec Mailing List


Zitat von "Eric W. Biederman" <ebiederm@xmission.com>:

>
> It looks like no one ever tested taking a crashdump
> from a 64bit kernel with a 32bit userspace on x86,
> and we have a reuse-cmdline regression fixes follow.

I didn't even know that it is supposed to work...


Regards,
Bernhard




_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] Getting biarch support
  2010-03-11  8:22 ` [PATCH 0/3] Getting biarch support Bernhard Walle
@ 2010-03-11  8:35   ` Eric W. Biederman
  0 siblings, 0 replies; 8+ messages in thread
From: Eric W. Biederman @ 2010-03-11  8:35 UTC (permalink / raw)
  To: Bernhard Walle; +Cc: Simon Horman, Kexec Mailing List

Bernhard Walle <bernhard@bwalle.de> writes:

> Zitat von "Eric W. Biederman" <ebiederm@xmission.com>:
>
>>
>> It looks like no one ever tested taking a crashdump
>> from a 64bit kernel with a 32bit userspace on x86,
>> and we have a reuse-cmdline regression fixes follow.
>
> I didn't even know that it is supposed to work...

The x86 biarch tends to be an after thought.  But we
have to do the hard work for all of the architectures
where the optimal configuration is 32bit userspace with
a 64bit kernel.  So we might as well have it work on
x86 so we can test the code without need an exotic
architecture.

In my case it was purely code size savings on an embedded
setup that got me using, and thus fixing it.

Eric

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/3] Getting biarch support
  2010-03-11  8:16 [PATCH 0/3] Getting biarch support Eric W. Biederman
                   ` (4 preceding siblings ...)
  2010-03-11  8:22 ` [PATCH 0/3] Getting biarch support Bernhard Walle
@ 2010-03-11  8:48 ` Simon Horman
  5 siblings, 0 replies; 8+ messages in thread
From: Simon Horman @ 2010-03-11  8:48 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: Kexec Mailing List

On Thu, Mar 11, 2010 at 12:16:58AM -0800, Eric W. Biederman wrote:
> 
> It looks like no one ever tested taking a crashdump
> from a 64bit kernel with a 32bit userspace on x86,
> and we have a reuse-cmdline regression fixes follow.

Thanks, these patches all look good to me. I have applied and pushed them.


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-03-11  8:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-11  8:16 [PATCH 0/3] Getting biarch support Eric W. Biederman
2010-03-11  8:20 ` [PATCH 1/3] Refix concat_cmdline Eric W. Biederman
2010-03-11  8:20 ` [PATCH 0/3] Getting biarch support Simon Horman
2010-03-11  8:21 ` [PATCH 2/3] kexec: Figure out our native architecture before load Eric W. Biederman
2010-03-11  8:22 ` [PATCH 3/3] x86: Fix biarch crashdump setup Eric W. Biederman
2010-03-11  8:22 ` [PATCH 0/3] Getting biarch support Bernhard Walle
2010-03-11  8:35   ` Eric W. Biederman
2010-03-11  8:48 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox