Patchwork MIPS: OCTEON: Don't clobber bootloader data structures.

login
register
mail settings
Submitter David Daney
Date June 12, 2013, 6:28 p.m.
Message ID <1371061713-29028-1-git-send-email-ddaney.cavm@gmail.com>
Download mbox | patch
Permalink /patch/5449/
State Accepted
Delegated to: Ralf Baechle
Headers show

Comments

David Daney - June 12, 2013, 6:28 p.m.
From: David Daney <david.daney@cavium.com>

Commit abe77f90dc (MIPS: Octeon: Add kexec and kdump support) added a
bootmem region for the kernel image itself.  The problem is that this
is rounded up to a 0x100000 boundary, which is memory that may not be
owned by the kernel.  Depending on the kernel's configuration based
size, this 'extra' memory may contain data passed from the bootloader
to the kernel itself, which if clobbered makes the kernel crash in
various ways.

The fix: Quit rounding the size up, so that we only use memory
assigned to the kernel.

Can be applied to v3.8 and later.

Signed-off-by: David Daney <david.daney@cavium.com>
Cc: <stable@vger.kernel.org>
---

This should probably go into 3.10

 arch/mips/cavium-octeon/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
root - June 13, 2013, 2:35 p.m.
On Wed, Jun 12, 2013 at 11:28:33AM -0700, David Daney wrote:

> Commit abe77f90dc (MIPS: Octeon: Add kexec and kdump support) added a
> bootmem region for the kernel image itself.  The problem is that this
> is rounded up to a 0x100000 boundary, which is memory that may not be
> owned by the kernel.  Depending on the kernel's configuration based
> size, this 'extra' memory may contain data passed from the bootloader
> to the kernel itself, which if clobbered makes the kernel crash in
> various ways.
> 
> The fix: Quit rounding the size up, so that we only use memory
> assigned to the kernel.
> 
> Can be applied to v3.8 and later.

Thanks, applied.  Will send to Linus with the next pull request.

  Ralf

Patch

diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
index 01b1b3f..1e1e18c 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -996,7 +996,7 @@  void __init plat_mem_setup(void)
 	cvmx_bootmem_unlock();
 	/* Add the memory region for the kernel. */
 	kernel_start = (unsigned long) _text;
-	kernel_size = ALIGN(_end - _text, 0x100000);
+	kernel_size = _end - _text;
 
 	/* Adjust for physical offset. */
 	kernel_start &= ~0xffffffff80000000ULL;