linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V4 0/3] mm: Add generic copy from early unmapped RAM
@ 2015-08-17 17:01 Mark Salter
  2015-08-17 17:01 ` [PATCH V4 1/3] mm: add utility for early copy from unmapped ram Mark Salter
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Mark Salter @ 2015-08-17 17:01 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, x86
  Cc: Andrew Morton, Arnd Bergmann, Ard Biesheuvel, Mark Rutland,
	linux-kernel, linux-arm-kernel, linux-mm, linux-arch,
	Mark Salter

When booting an arm64 kernel w/initrd using UEFI/grub, use of mem= will likely
cut off part or all of the initrd. This leaves it outside the kernel linear
map which leads to failure when unpacking. The x86 code has a similar need to
relocate an initrd outside of mapped memory in some cases.

The current x86 code uses early_memremap() to copy the original initrd from
unmapped to mapped RAM. This patchset creates a generic copy_from_early_mem()
utility based on that x86 code and has arm64 and x86 share it in their
respective initrd relocation code.

Changes from V3:

  * Fixed arm64 build error with !CONFIG_BLK_DEV_INITRD case

  * Fixed nonsensical comment in arm64 relocate_initrd()

Changes from V2:

  * Fixed sparse warning in copy_from_early_mem()

  * Removed unneeded MAX_MAP_CHUNK from x86 setup.c

  * Moved #ifdef outside arm64 relocate_initrd() definition.
  
Changes from V1:

  * Change cover letter subject to highlight the added generic code

  * Add patch for x86 to use common copy_from_early_mem()


Mark Salter (3):
  mm: add utility for early copy from unmapped ram
  arm64: support initrd outside kernel linear map
  x86: use generic early mem copy

 arch/arm64/kernel/setup.c           | 62 +++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/setup.c             | 22 +------------
 include/asm-generic/early_ioremap.h |  6 ++++
 mm/early_ioremap.c                  | 22 +++++++++++++
 4 files changed, 91 insertions(+), 21 deletions(-)

-- 
2.4.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH V4 1/3] mm: add utility for early copy from unmapped ram
  2015-08-17 17:01 [PATCH V4 0/3] mm: Add generic copy from early unmapped RAM Mark Salter
@ 2015-08-17 17:01 ` Mark Salter
  2015-08-17 17:01 ` [PATCH V4 2/3] arm64: support initrd outside kernel linear map Mark Salter
  2015-08-17 17:01 ` [PATCH V4 3/3] x86: use generic early mem copy Mark Salter
  2 siblings, 0 replies; 11+ messages in thread
From: Mark Salter @ 2015-08-17 17:01 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, x86
  Cc: Andrew Morton, Arnd Bergmann, Ard Biesheuvel, Mark Rutland,
	linux-kernel, linux-arm-kernel, linux-mm, linux-arch,
	Mark Salter

In some early boot circumstances, it may be necessary to copy
from RAM outside the kernel linear mapping to mapped RAM. The
need to relocate an initrd is one example in the x86 code. This
patch creates a helper function based on current x86 code.

Signed-off-by: Mark Salter <msalter@redhat.com>
---
 include/asm-generic/early_ioremap.h |  6 ++++++
 mm/early_ioremap.c                  | 22 ++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/include/asm-generic/early_ioremap.h b/include/asm-generic/early_ioremap.h
index a5de55c..e539f27 100644
--- a/include/asm-generic/early_ioremap.h
+++ b/include/asm-generic/early_ioremap.h
@@ -33,6 +33,12 @@ extern void early_ioremap_setup(void);
  */
 extern void early_ioremap_reset(void);
 
+/*
+ * Early copy from unmapped memory to kernel mapped memory.
+ */
+extern void copy_from_early_mem(void *dest, phys_addr_t src,
+				unsigned long size);
+
 #else
 static inline void early_ioremap_init(void) { }
 static inline void early_ioremap_setup(void) { }
diff --git a/mm/early_ioremap.c b/mm/early_ioremap.c
index e10ccd2..a0baeb4 100644
--- a/mm/early_ioremap.c
+++ b/mm/early_ioremap.c
@@ -217,6 +217,28 @@ early_memremap(resource_size_t phys_addr, unsigned long size)
 	return (__force void *)__early_ioremap(phys_addr, size,
 					       FIXMAP_PAGE_NORMAL);
 }
+
+#define MAX_MAP_CHUNK	(NR_FIX_BTMAPS << PAGE_SHIFT)
+
+void __init copy_from_early_mem(void *dest, phys_addr_t src, unsigned long size)
+{
+	unsigned long slop, clen;
+	char *p;
+
+	while (size) {
+		slop = src & ~PAGE_MASK;
+		clen = size;
+		if (clen > MAX_MAP_CHUNK - slop)
+			clen = MAX_MAP_CHUNK - slop;
+		p = early_memremap(src & PAGE_MASK, clen + slop);
+		memcpy(dest, p + slop, clen);
+		early_memunmap(p, clen + slop);
+		dest += clen;
+		src += clen;
+		size -= clen;
+	}
+}
+
 #else /* CONFIG_MMU */
 
 void __init __iomem *
-- 
2.4.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH V4 2/3] arm64: support initrd outside kernel linear map
  2015-08-17 17:01 [PATCH V4 0/3] mm: Add generic copy from early unmapped RAM Mark Salter
  2015-08-17 17:01 ` [PATCH V4 1/3] mm: add utility for early copy from unmapped ram Mark Salter
@ 2015-08-17 17:01 ` Mark Salter
  2015-08-18  8:56   ` Will Deacon
  2015-09-08 11:31   ` Mark Rutland
  2015-08-17 17:01 ` [PATCH V4 3/3] x86: use generic early mem copy Mark Salter
  2 siblings, 2 replies; 11+ messages in thread
From: Mark Salter @ 2015-08-17 17:01 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, x86
  Cc: Andrew Morton, Arnd Bergmann, Ard Biesheuvel, Mark Rutland,
	linux-kernel, linux-arm-kernel, linux-mm, linux-arch,
	Mark Salter

The use of mem= could leave part or all of the initrd outside of
the kernel linear map. This will lead to an error when unpacking
the initrd and a probable failure to boot. This patch catches that
situation and relocates the initrd to be fully within the linear
map.

Signed-off-by: Mark Salter <msalter@redhat.com>
---
 arch/arm64/kernel/setup.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index f3067d4..40a894e 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -359,6 +359,67 @@ static void __init request_standard_resources(void)
 	}
 }
 
+#ifdef CONFIG_BLK_DEV_INITRD
+/*
+ * Relocate initrd if it is not completely within the linear mapping.
+ * This would be the case if mem= cuts out all or part of it.
+ */
+static void __init relocate_initrd(void)
+{
+	phys_addr_t orig_start = __virt_to_phys(initrd_start);
+	phys_addr_t orig_end = __virt_to_phys(initrd_end);
+	phys_addr_t ram_end = memblock_end_of_DRAM();
+	phys_addr_t new_start;
+	unsigned long size, to_free = 0;
+	void *dest;
+
+	if (orig_end <= ram_end)
+		return;
+
+	/*
+	 * Any of the original initrd which overlaps the linear map should
+	 * be freed after relocating.
+	 */
+	if (orig_start < ram_end)
+		to_free = ram_end - orig_start;
+
+	size = orig_end - orig_start;
+
+	/* initrd needs to be relocated completely inside linear mapping */
+	new_start = memblock_find_in_range(0, PFN_PHYS(max_pfn),
+					   size, PAGE_SIZE);
+	if (!new_start)
+		panic("Cannot relocate initrd of size %ld\n", size);
+	memblock_reserve(new_start, size);
+
+	initrd_start = __phys_to_virt(new_start);
+	initrd_end   = initrd_start + size;
+
+	pr_info("Moving initrd from [%llx-%llx] to [%llx-%llx]\n",
+		orig_start, orig_start + size - 1,
+		new_start, new_start + size - 1);
+
+	dest = (void *)initrd_start;
+
+	if (to_free) {
+		memcpy(dest, (void *)__phys_to_virt(orig_start), to_free);
+		dest += to_free;
+	}
+
+	copy_from_early_mem(dest, orig_start + to_free, size - to_free);
+
+	if (to_free) {
+		pr_info("Freeing original RAMDISK from [%llx-%llx]\n",
+			orig_start, orig_start + to_free - 1);
+		memblock_free(orig_start, to_free);
+	}
+}
+#else
+static inline void __init relocate_initrd(void)
+{
+}
+#endif
+
 u64 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID };
 
 void __init setup_arch(char **cmdline_p)
@@ -392,6 +453,7 @@ void __init setup_arch(char **cmdline_p)
 	acpi_boot_table_init();
 
 	paging_init();
+	relocate_initrd();
 	request_standard_resources();
 
 	early_ioremap_reset();
-- 
2.4.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH V4 3/3] x86: use generic early mem copy
  2015-08-17 17:01 [PATCH V4 0/3] mm: Add generic copy from early unmapped RAM Mark Salter
  2015-08-17 17:01 ` [PATCH V4 1/3] mm: add utility for early copy from unmapped ram Mark Salter
  2015-08-17 17:01 ` [PATCH V4 2/3] arm64: support initrd outside kernel linear map Mark Salter
@ 2015-08-17 17:01 ` Mark Salter
  2 siblings, 0 replies; 11+ messages in thread
From: Mark Salter @ 2015-08-17 17:01 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, x86
  Cc: Andrew Morton, Arnd Bergmann, Ard Biesheuvel, Mark Rutland,
	linux-kernel, linux-arm-kernel, linux-mm, linux-arch,
	Mark Salter

The early_ioremap library now has a generic copy_from_early_mem()
function. Use the generic copy function for x86 relocate_initrd().

Signed-off-by: Mark Salter <msalter@redhat.com>
---
 arch/x86/kernel/setup.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 80f874b..21fa9a3 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -317,15 +317,12 @@ static u64 __init get_ramdisk_size(void)
 	return ramdisk_size;
 }
 
-#define MAX_MAP_CHUNK	(NR_FIX_BTMAPS << PAGE_SHIFT)
 static void __init relocate_initrd(void)
 {
 	/* Assume only end is not page aligned */
 	u64 ramdisk_image = get_ramdisk_image();
 	u64 ramdisk_size  = get_ramdisk_size();
 	u64 area_size     = PAGE_ALIGN(ramdisk_size);
-	unsigned long slop, clen, mapaddr;
-	char *p, *q;
 
 	/* We need to move the initrd down into directly mapped mem */
 	relocated_ramdisk = memblock_find_in_range(0, PFN_PHYS(max_pfn_mapped),
@@ -343,25 +340,8 @@ static void __init relocate_initrd(void)
 	printk(KERN_INFO "Allocated new RAMDISK: [mem %#010llx-%#010llx]\n",
 	       relocated_ramdisk, relocated_ramdisk + ramdisk_size - 1);
 
-	q = (char *)initrd_start;
-
-	/* Copy the initrd */
-	while (ramdisk_size) {
-		slop = ramdisk_image & ~PAGE_MASK;
-		clen = ramdisk_size;
-		if (clen > MAX_MAP_CHUNK-slop)
-			clen = MAX_MAP_CHUNK-slop;
-		mapaddr = ramdisk_image & PAGE_MASK;
-		p = early_memremap(mapaddr, clen+slop);
-		memcpy(q, p+slop, clen);
-		early_memunmap(p, clen+slop);
-		q += clen;
-		ramdisk_image += clen;
-		ramdisk_size  -= clen;
-	}
+	copy_from_early_mem((void *)initrd_start, ramdisk_image, ramdisk_size);
 
-	ramdisk_image = get_ramdisk_image();
-	ramdisk_size  = get_ramdisk_size();
 	printk(KERN_INFO "Move RAMDISK from [mem %#010llx-%#010llx] to"
 		" [mem %#010llx-%#010llx]\n",
 		ramdisk_image, ramdisk_image + ramdisk_size - 1,
-- 
2.4.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V4 2/3] arm64: support initrd outside kernel linear map
  2015-08-17 17:01 ` [PATCH V4 2/3] arm64: support initrd outside kernel linear map Mark Salter
@ 2015-08-18  8:56   ` Will Deacon
  2015-09-08 11:31   ` Mark Rutland
  1 sibling, 0 replies; 11+ messages in thread
From: Will Deacon @ 2015-08-18  8:56 UTC (permalink / raw)
  To: Mark Salter
  Cc: Catalin Marinas, x86, Andrew Morton, Arnd Bergmann,
	Ard Biesheuvel, Mark Rutland, linux-kernel, linux-arm-kernel,
	linux-mm, linux-arch

On Mon, Aug 17, 2015 at 06:01:06PM +0100, Mark Salter wrote:
> The use of mem= could leave part or all of the initrd outside of
> the kernel linear map. This will lead to an error when unpacking
> the initrd and a probable failure to boot. This patch catches that
> situation and relocates the initrd to be fully within the linear
> map.
> 
> Signed-off-by: Mark Salter <msalter@redhat.com>
> ---
>  arch/arm64/kernel/setup.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 62 insertions(+)

Looks good to me:

  Acked-by: Will Deacon <will.deacon@arm.com>

This series should replace the version that Andrew has currently got in
linux-next.

Will

> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index f3067d4..40a894e 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -359,6 +359,67 @@ static void __init request_standard_resources(void)
>  	}
>  }
>  
> +#ifdef CONFIG_BLK_DEV_INITRD
> +/*
> + * Relocate initrd if it is not completely within the linear mapping.
> + * This would be the case if mem= cuts out all or part of it.
> + */
> +static void __init relocate_initrd(void)
> +{
> +	phys_addr_t orig_start = __virt_to_phys(initrd_start);
> +	phys_addr_t orig_end = __virt_to_phys(initrd_end);
> +	phys_addr_t ram_end = memblock_end_of_DRAM();
> +	phys_addr_t new_start;
> +	unsigned long size, to_free = 0;
> +	void *dest;
> +
> +	if (orig_end <= ram_end)
> +		return;
> +
> +	/*
> +	 * Any of the original initrd which overlaps the linear map should
> +	 * be freed after relocating.
> +	 */
> +	if (orig_start < ram_end)
> +		to_free = ram_end - orig_start;
> +
> +	size = orig_end - orig_start;
> +
> +	/* initrd needs to be relocated completely inside linear mapping */
> +	new_start = memblock_find_in_range(0, PFN_PHYS(max_pfn),
> +					   size, PAGE_SIZE);
> +	if (!new_start)
> +		panic("Cannot relocate initrd of size %ld\n", size);
> +	memblock_reserve(new_start, size);
> +
> +	initrd_start = __phys_to_virt(new_start);
> +	initrd_end   = initrd_start + size;
> +
> +	pr_info("Moving initrd from [%llx-%llx] to [%llx-%llx]\n",
> +		orig_start, orig_start + size - 1,
> +		new_start, new_start + size - 1);
> +
> +	dest = (void *)initrd_start;
> +
> +	if (to_free) {
> +		memcpy(dest, (void *)__phys_to_virt(orig_start), to_free);
> +		dest += to_free;
> +	}
> +
> +	copy_from_early_mem(dest, orig_start + to_free, size - to_free);
> +
> +	if (to_free) {
> +		pr_info("Freeing original RAMDISK from [%llx-%llx]\n",
> +			orig_start, orig_start + to_free - 1);
> +		memblock_free(orig_start, to_free);
> +	}
> +}
> +#else
> +static inline void __init relocate_initrd(void)
> +{
> +}
> +#endif
> +
>  u64 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID };
>  
>  void __init setup_arch(char **cmdline_p)
> @@ -392,6 +453,7 @@ void __init setup_arch(char **cmdline_p)
>  	acpi_boot_table_init();
>  
>  	paging_init();
> +	relocate_initrd();
>  	request_standard_resources();
>  
>  	early_ioremap_reset();
> -- 
> 2.4.3
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V4 2/3] arm64: support initrd outside kernel linear map
  2015-08-17 17:01 ` [PATCH V4 2/3] arm64: support initrd outside kernel linear map Mark Salter
  2015-08-18  8:56   ` Will Deacon
@ 2015-09-08 11:31   ` Mark Rutland
  2015-10-06 17:11     ` Mark Rutland
  1 sibling, 1 reply; 11+ messages in thread
From: Mark Rutland @ 2015-09-08 11:31 UTC (permalink / raw)
  To: Mark Salter
  Cc: Catalin Marinas, Will Deacon, x86, Andrew Morton, Arnd Bergmann,
	Ard Biesheuvel, linux-kernel, linux-arm-kernel, linux-mm,
	linux-arch

Hi Mark,

On Mon, Aug 17, 2015 at 06:01:06PM +0100, Mark Salter wrote:
> The use of mem= could leave part or all of the initrd outside of
> the kernel linear map. This will lead to an error when unpacking
> the initrd and a probable failure to boot. This patch catches that
> situation and relocates the initrd to be fully within the linear
> map.

With next-20150908, this patch results in a confusing message at boot when not
using an initrd:

Moving initrd from [4080000000-407fffffff] to [9fff49000-9fff48fff]

I think that can be solved by folding in the diff below.

Thanks,
Mark.

diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 6bab21f..2322479 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -364,6 +364,8 @@ static void __init relocate_initrd(void)
                to_free = ram_end - orig_start;
 
        size = orig_end - orig_start;
+       if (!size)
+               return;
 
        /* initrd needs to be relocated completely inside linear mapping */
        new_start = memblock_find_in_range(0, PFN_PHYS(max_pfn),

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V4 2/3] arm64: support initrd outside kernel linear map
  2015-09-08 11:31   ` Mark Rutland
@ 2015-10-06 17:11     ` Mark Rutland
  2015-10-06 17:16       ` Mark Salter
  0 siblings, 1 reply; 11+ messages in thread
From: Mark Rutland @ 2015-10-06 17:11 UTC (permalink / raw)
  To: msalter
  Cc: linux-arch, Arnd Bergmann, Ard Biesheuvel, Catalin Marinas, x86,
	Will Deacon, linux-kernel, linux-mm, Andrew Morton,
	linux-arm-kernel

On Tue, Sep 08, 2015 at 12:31:13PM +0100, Mark Rutland wrote:
> Hi Mark,
> 
> On Mon, Aug 17, 2015 at 06:01:06PM +0100, Mark Salter wrote:
> > The use of mem= could leave part or all of the initrd outside of
> > the kernel linear map. This will lead to an error when unpacking
> > the initrd and a probable failure to boot. This patch catches that
> > situation and relocates the initrd to be fully within the linear
> > map.
> 
> With next-20150908, this patch results in a confusing message at boot when not
> using an initrd:
> 
> Moving initrd from [4080000000-407fffffff] to [9fff49000-9fff48fff]
> 
> I think that can be solved by folding in the diff below.

Mark, it looks like this fell by the wayside.

Do you have any objection to this? I'll promote this to it's own patch
if not.

Mark.

> 
> Thanks,
> Mark.
> 
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index 6bab21f..2322479 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -364,6 +364,8 @@ static void __init relocate_initrd(void)
>                 to_free = ram_end - orig_start;
>  
>         size = orig_end - orig_start;
> +       if (!size)
> +               return;
>  
>         /* initrd needs to be relocated completely inside linear mapping */
>         new_start = memblock_find_in_range(0, PFN_PHYS(max_pfn),
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V4 2/3] arm64: support initrd outside kernel linear map
  2015-10-06 17:11     ` Mark Rutland
@ 2015-10-06 17:16       ` Mark Salter
  2015-10-08  8:49         ` Christoffer Dall
  0 siblings, 1 reply; 11+ messages in thread
From: Mark Salter @ 2015-10-06 17:16 UTC (permalink / raw)
  To: Mark Rutland
  Cc: linux-arch, Arnd Bergmann, Ard Biesheuvel, Catalin Marinas, x86,
	Will Deacon, linux-kernel, linux-mm, Andrew Morton,
	linux-arm-kernel

On Tue, 2015-10-06 at 18:11 +0100, Mark Rutland wrote:
> On Tue, Sep 08, 2015 at 12:31:13PM +0100, Mark Rutland wrote:
> > Hi Mark,
> > 
> > On Mon, Aug 17, 2015 at 06:01:06PM +0100, Mark Salter wrote:
> > > The use of mem= could leave part or all of the initrd outside of
> > > the kernel linear map. This will lead to an error when unpacking
> > > the initrd and a probable failure to boot. This patch catches that
> > > situation and relocates the initrd to be fully within the linear
> > > map.
> > 
> > With next-20150908, this patch results in a confusing message at boot when not
> > using an initrd:
> > 
> > Moving initrd from [4080000000-407fffffff] to [9fff49000-9fff48fff]
> > 
> > I think that can be solved by folding in the diff below.
> 
> Mark, it looks like this fell by the wayside.
> 
> Do you have any objection to this? I'll promote this to it's own patch
> if not.
> 
> Mark.
> 
> > 
> > Thanks,
> > Mark.
> > 
> > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> > index 6bab21f..2322479 100644
> > --- a/arch/arm64/kernel/setup.c
> > +++ b/arch/arm64/kernel/setup.c
> > @@ -364,6 +364,8 @@ static void __init relocate_initrd(void)
> >                 to_free = ram_end - orig_start;
> >  
> >         size = orig_end - orig_start;
> > +       if (!size)
> > +               return;
> >  
> >         /* initrd needs to be relocated completely inside linear mapping */
> >         new_start = memblock_find_in_range(0, PFN_PHYS(max_pfn),

Sorry, no. That looks perfectly good to me.


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V4 2/3] arm64: support initrd outside kernel linear map
  2015-10-06 17:16       ` Mark Salter
@ 2015-10-08  8:49         ` Christoffer Dall
  2015-10-08  9:18           ` yalin wang
  0 siblings, 1 reply; 11+ messages in thread
From: Christoffer Dall @ 2015-10-08  8:49 UTC (permalink / raw)
  To: Mark Salter
  Cc: Mark Rutland, linux-arch, Arnd Bergmann, Ard Biesheuvel,
	Catalin Marinas, x86, Will Deacon, linux-kernel, linux-mm,
	Andrew Morton, linux-arm-kernel

On Tue, Oct 06, 2015 at 01:16:52PM -0400, Mark Salter wrote:
> On Tue, 2015-10-06 at 18:11 +0100, Mark Rutland wrote:
> > On Tue, Sep 08, 2015 at 12:31:13PM +0100, Mark Rutland wrote:
> > > Hi Mark,
> > > 
> > > On Mon, Aug 17, 2015 at 06:01:06PM +0100, Mark Salter wrote:
> > > > The use of mem= could leave part or all of the initrd outside of
> > > > the kernel linear map. This will lead to an error when unpacking
> > > > the initrd and a probable failure to boot. This patch catches that
> > > > situation and relocates the initrd to be fully within the linear
> > > > map.
> > > 
> > > With next-20150908, this patch results in a confusing message at boot when not
> > > using an initrd:
> > > 
> > > Moving initrd from [4080000000-407fffffff] to [9fff49000-9fff48fff]
> > > 
> > > I think that can be solved by folding in the diff below.
> > 
> > Mark, it looks like this fell by the wayside.
> > 
> > Do you have any objection to this? I'll promote this to it's own patch
> > if not.
> > 
> > Mark.
> > 
> > > 
> > > Thanks,
> > > Mark.
> > > 
> > > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> > > index 6bab21f..2322479 100644
> > > --- a/arch/arm64/kernel/setup.c
> > > +++ b/arch/arm64/kernel/setup.c
> > > @@ -364,6 +364,8 @@ static void __init relocate_initrd(void)
> > >                 to_free = ram_end - orig_start;
> > >  
> > >         size = orig_end - orig_start;
> > > +       if (!size)
> > > +               return;
> > >  
> > >         /* initrd needs to be relocated completely inside linear mapping */
> > >         new_start = memblock_find_in_range(0, PFN_PHYS(max_pfn),
> 
> Sorry, no. That looks perfectly good to me.
> 
FYI: I applied these patches to 4.0 (only a trivial conflict on the x86
side) and this fixed an issue for me booting systems with mem=X,
reducing the amount of physical memory available on a system, which
would otherwise cause the system to just silently halt during boot.

Note that this seems to fix even more than it promises, because one of
those systems does not use an initrd, but I'm thinking maybe this fixes
issues with the DT as well?

In any case, I think this may be a good candidate for cc'ing to stable?

Thanks,
-Christoffer

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V4 2/3] arm64: support initrd outside kernel linear map
  2015-10-08  8:49         ` Christoffer Dall
@ 2015-10-08  9:18           ` yalin wang
  2015-10-08  9:40             ` Russell King - ARM Linux
  0 siblings, 1 reply; 11+ messages in thread
From: yalin wang @ 2015-10-08  9:18 UTC (permalink / raw)
  To: Christoffer Dall
  Cc: Mark Salter, Mark Rutland, linux-arch, Arnd Bergmann,
	Ard Biesheuvel, Catalin Marinas, x86, Will Deacon, linux-kernel,
	linux-mm, Andrew Morton, linux-arm-kernel


> On Oct 8, 2015, at 16:49, Christoffer Dall <christoffer.dall@linaro.org> wrote:
> 
> On Tue, Oct 06, 2015 at 01:16:52PM -0400, Mark Salter wrote:
>> On Tue, 2015-10-06 at 18:11 +0100, Mark Rutland wrote:
>>> On Tue, Sep 08, 2015 at 12:31:13PM +0100, Mark Rutland wrote:
>>>> Hi Mark,
>>>> 
>>>> On Mon, Aug 17, 2015 at 06:01:06PM +0100, Mark Salter wrote:
>>>>> The use of mem= could leave part or all of the initrd outside of
>>>>> the kernel linear map. This will lead to an error when unpacking
>>>>> the initrd and a probable failure to boot. This patch catches that
>>>>> situation and relocates the initrd to be fully within the linear
>>>>> map.
>>>> 
>>>> With next-20150908, this patch results in a confusing message at boot when not
>>>> using an initrd:
>>>> 
>>>> Moving initrd from [4080000000-407fffffff] to [9fff49000-9fff48fff]
>>>> 
>>>> I think that can be solved by folding in the diff below.
>>> 
>>> Mark, it looks like this fell by the wayside.
>>> 
>>> Do you have any objection to this? I'll promote this to it's own patch
>>> if not.
>>> 
>>> Mark.
>>> 
>>>> 
>>>> Thanks,
>>>> Mark.
>>>> 
>>>> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
>>>> index 6bab21f..2322479 100644
>>>> --- a/arch/arm64/kernel/setup.c
>>>> +++ b/arch/arm64/kernel/setup.c
>>>> @@ -364,6 +364,8 @@ static void __init relocate_initrd(void)
>>>>                to_free = ram_end - orig_start;
>>>> 
>>>>        size = orig_end - orig_start;
>>>> +       if (!size)
>>>> +               return;
>>>> 
>>>>        /* initrd needs to be relocated completely inside linear mapping */
>>>>        new_start = memblock_find_in_range(0, PFN_PHYS(max_pfn),
>> 
>> Sorry, no. That looks perfectly good to me.
>> 
is it also possible to implement it on ARM platforms?
ARM64 platform don’t have HIGH_MEM zone .
but ARM platform have .
i remember boot loader must put init rd  into low memory region,
so if some boot loader put init rd into HIGH men zone
we can also relocate it to low men region ?
then boot loader don’t need care about this ,
and since vmalloc= boot option will change HIGH mem region size,
if we can relocate init rd , boot loader don’t need care about init rd load address,
when change vmalloc= boot options .


Thanks









--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH V4 2/3] arm64: support initrd outside kernel linear map
  2015-10-08  9:18           ` yalin wang
@ 2015-10-08  9:40             ` Russell King - ARM Linux
  0 siblings, 0 replies; 11+ messages in thread
From: Russell King - ARM Linux @ 2015-10-08  9:40 UTC (permalink / raw)
  To: yalin wang
  Cc: Christoffer Dall, Mark Rutland, linux-arch, Arnd Bergmann,
	Ard Biesheuvel, Catalin Marinas, x86, Will Deacon, linux-kernel,
	linux-mm, Mark Salter, Andrew Morton, linux-arm-kernel

On Thu, Oct 08, 2015 at 05:18:14PM +0800, yalin wang wrote:
> is it also possible to implement it on ARM platforms?
> ARM64 platform dona??t have HIGH_MEM zone .
> but ARM platform have .
> i remember boot loader must put init rd  into low memory region,
> so if some boot loader put init rd into HIGH men zone
> we can also relocate it to low men region ?
> then boot loader dona??t need care about this ,
> and since vmalloc= boot option will change HIGH mem region size,
> if we can relocate init rd , boot loader dona??t need care about init rd load address,
> when change vmalloc= boot options .

I'd be more inclined to say yes if the kernel wasn't buggering around
passing virtual addresses (initrd_start) of the initrd image around,
but instead used a physical address.  initrd_start must be a lowmem
address.

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2015-10-08  9:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-17 17:01 [PATCH V4 0/3] mm: Add generic copy from early unmapped RAM Mark Salter
2015-08-17 17:01 ` [PATCH V4 1/3] mm: add utility for early copy from unmapped ram Mark Salter
2015-08-17 17:01 ` [PATCH V4 2/3] arm64: support initrd outside kernel linear map Mark Salter
2015-08-18  8:56   ` Will Deacon
2015-09-08 11:31   ` Mark Rutland
2015-10-06 17:11     ` Mark Rutland
2015-10-06 17:16       ` Mark Salter
2015-10-08  8:49         ` Christoffer Dall
2015-10-08  9:18           ` yalin wang
2015-10-08  9:40             ` Russell King - ARM Linux
2015-08-17 17:01 ` [PATCH V4 3/3] x86: use generic early mem copy Mark Salter

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).