Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* kexec-tools and multiboot breakage
@ 2014-01-15  3:25 Peter Chubb
  2014-01-15  3:48 ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Chubb @ 2014-01-15  3:25 UTC (permalink / raw)
  To: horms; +Cc: kexec

Hi Simon,
   When you get a moment, please check out
   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=735360

Quick summary:
  If your kernel is configured to protect the first few pages of
  physical memory, then low memory doesn't start at location 0 --- so
  when scanning the memory ranges from /proc/iomem, the code in
  kexec/arch/i386/kexec-multiboot-x86.c never fills in mem_lower.

  I think it's safe to assume that if a memory segment starts at 64k or
  lower, it can be extended to location 0 because of the kernel
  protection on a PC99-style architecture.

Peter C
--
Dr Peter Chubb				        peter.chubb AT nicta.com.au
http://www.ssrg.nicta.com.au          Software Systems Research Group/NICTA

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

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

* Re: kexec-tools and multiboot breakage
  2014-01-15  3:25 kexec-tools and multiboot breakage Peter Chubb
@ 2014-01-15  3:48 ` Simon Horman
  2014-01-15 21:39   ` [PATCH] Fix value of mbi->mem_lower for multiboot-x86 Peter Chubb
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Horman @ 2014-01-15  3:48 UTC (permalink / raw)
  To: Peter Chubb; +Cc: kexec

On Wed, Jan 15, 2014 at 01:25:49PM +1000, Peter Chubb wrote:
> Hi Simon,
>    When you get a moment, please check out
>    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=735360
> 
> Quick summary:
>   If your kernel is configured to protect the first few pages of
>   physical memory, then low memory doesn't start at location 0 --- so
>   when scanning the memory ranges from /proc/iomem, the code in
>   kexec/arch/i386/kexec-multiboot-x86.c never fills in mem_lower.
> 
>   I think it's safe to assume that if a memory segment starts at 64k or
>   lower, it can be extended to location 0 because of the kernel
>   protection on a PC99-style architecture.

Hi Peter,

that approach seems reasonable to me. Could you formally post
the patch to the kexec list with me CCed? I would like a Signed-off-by
line. Thanks.

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

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

* [PATCH] Fix value of mbi->mem_lower for multiboot-x86
  2014-01-15  3:48 ` Simon Horman
@ 2014-01-15 21:39   ` Peter Chubb
  2014-01-16  0:22     ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Chubb @ 2014-01-15 21:39 UTC (permalink / raw)
  To: kexec; +Cc: Simon Horman, Peter Chubb


In the multiboot header, there is a field, `mem_lower' that is meant to
contain the size of memory starting at zero and ending below 640k.
If your kernel is compiled with CONFIG_X86_RESERVE_LOW non zero
(the usual case), then a hole is inserted into kernel's physical
memory map at zero, so the test to find the size of this region in
kexec/arch/i386/kexec-multiboot-x86.c never succeeds, so the value is
always zero.

On a PC99 architecture, there is always memory at physycal address zero;
assume that a region that starts below 64k actually starts at zero,
and use it for the mem_lower variable.

Signed-off-by: Peter Chubb <peter.chubb@nicta.com.au>

---
 kexec/arch/i386/kexec-multiboot-x86.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Index: kexec-tools-2.0.4/kexec/arch/i386/kexec-multiboot-x86.c
===================================================================
--- kexec-tools-2.0.4.orig/kexec/arch/i386/kexec-multiboot-x86.c	2013-03-14 18:45:16.000000000 +1000
+++ kexec-tools-2.0.4/kexec/arch/i386/kexec-multiboot-x86.c	2014-01-15 10:21:02.138172304 +1000
@@ -261,10 +261,18 @@ int multiboot_x86_load(int argc, char **
 		mmap[i].length_high    = length >> 32;
 		if (range[i].type == RANGE_RAM) {
 			mmap[i].Type = 1; /* RAM */
-			/* Is this the "low" memory? */
-			if ((range[i].start == 0)
-			    && (range[i].end > mem_lower))
+			/*
+                         * Is this the "low" memory?  Can't just test
+                         * against zero, because Linux protects (and
+                         * hides) the first few pages of physical
+                         * memory.
+                         */
+
+			if ((range[i].start <= 64*1024)
+			    && (range[i].end > mem_lower)) {
+                                range[i].start = 0;
 				mem_lower = range[i].end;
+                        }
 			/* Is this the "high" memory? */
 			if ((range[i].start <= 0x100000)
 			    && (range[i].end > mem_upper + 0x100000))

--
Dr Peter Chubb				        peter.chubb AT nicta.com.au
http://www.ssrg.nicta.com.au          Software Systems Research Group/NICTA

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

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

* Re: [PATCH] Fix value of mbi->mem_lower for multiboot-x86
  2014-01-15 21:39   ` [PATCH] Fix value of mbi->mem_lower for multiboot-x86 Peter Chubb
@ 2014-01-16  0:22     ` Simon Horman
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2014-01-16  0:22 UTC (permalink / raw)
  To: Peter Chubb; +Cc: kexec

On Thu, Jan 16, 2014 at 08:39:06AM +1100, Peter Chubb wrote:
> 
> In the multiboot header, there is a field, `mem_lower' that is meant to
> contain the size of memory starting at zero and ending below 640k.
> If your kernel is compiled with CONFIG_X86_RESERVE_LOW non zero
> (the usual case), then a hole is inserted into kernel's physical
> memory map at zero, so the test to find the size of this region in
> kexec/arch/i386/kexec-multiboot-x86.c never succeeds, so the value is
> always zero.
> 
> On a PC99 architecture, there is always memory at physycal address zero;
> assume that a region that starts below 64k actually starts at zero,
> and use it for the mem_lower variable.
> 
> Signed-off-by: Peter Chubb <peter.chubb@nicta.com.au>

Thanks Peter, I have applied this.

> 
> ---
>  kexec/arch/i386/kexec-multiboot-x86.c |   14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> Index: kexec-tools-2.0.4/kexec/arch/i386/kexec-multiboot-x86.c
> ===================================================================
> --- kexec-tools-2.0.4.orig/kexec/arch/i386/kexec-multiboot-x86.c	2013-03-14 18:45:16.000000000 +1000
> +++ kexec-tools-2.0.4/kexec/arch/i386/kexec-multiboot-x86.c	2014-01-15 10:21:02.138172304 +1000
> @@ -261,10 +261,18 @@ int multiboot_x86_load(int argc, char **
>  		mmap[i].length_high    = length >> 32;
>  		if (range[i].type == RANGE_RAM) {
>  			mmap[i].Type = 1; /* RAM */
> -			/* Is this the "low" memory? */
> -			if ((range[i].start == 0)
> -			    && (range[i].end > mem_lower))
> +			/*
> +                         * Is this the "low" memory?  Can't just test
> +                         * against zero, because Linux protects (and
> +                         * hides) the first few pages of physical
> +                         * memory.
> +                         */
> +
> +			if ((range[i].start <= 64*1024)
> +			    && (range[i].end > mem_lower)) {
> +                                range[i].start = 0;
>  				mem_lower = range[i].end;
> +                        }
>  			/* Is this the "high" memory? */
>  			if ((range[i].start <= 0x100000)
>  			    && (range[i].end > mem_upper + 0x100000))
> 
> --
> Dr Peter Chubb				        peter.chubb AT nicta.com.au
> http://www.ssrg.nicta.com.au          Software Systems Research Group/NICTA
> 

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

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

end of thread, other threads:[~2014-01-16  0:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-15  3:25 kexec-tools and multiboot breakage Peter Chubb
2014-01-15  3:48 ` Simon Horman
2014-01-15 21:39   ` [PATCH] Fix value of mbi->mem_lower for multiboot-x86 Peter Chubb
2014-01-16  0:22     ` Simon Horman

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