All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk
Cc: marc.zyngier@arm.com, bhsharma@redhat.com,
	linux-efi@vger.kernel.org, will.deacon@arm.com,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH v2 2/6] ARM: mm: permit memblock resizing right after mapping the linear region
Date: Wed,  7 Nov 2018 15:16:07 +0100	[thread overview]
Message-ID: <20181107141611.12076-3-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20181107141611.12076-1-ard.biesheuvel@linaro.org>

The memblock arrays can be resized dynamically if needed, but this is
only done after memblock_allow_resize() is called, since it is up to
the architecture to decide at which point doing so is possible (i.e.,
when all the memory that memblock describes is actually mapped)

ARM grants this permission in bootmem_init(), but in order for the EFI
persistent memory reservation code (which may create memblock
reservations that trigger such a dynamic resize) to be able to be called
before shutting down early fixmap (upon which the EFI code depends due
to its use of early_memremap()), we need to do this earlier.

So let's move the call to memblock_allow_resize() to right after the
point where low memory is mapped and declared as the memory limit for
memblock allocation.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 arch/arm/mm/init.c | 1 -
 arch/arm/mm/mmu.c  | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 32e4845af2b6..797fad2b16ee 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -304,7 +304,6 @@ void __init bootmem_init(void)
 {
 	unsigned long min, max_low, max_high;
 
-	memblock_allow_resize();
 	max_low = max_high = 0;
 
 	find_limits(&min, &max_low, &max_high);
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index f5cc1ccfea3d..f6bf6686559d 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1626,6 +1626,7 @@ void __init paging_init(const struct machine_desc *mdesc)
 	prepare_page_table();
 	map_lowmem();
 	memblock_set_current_limit(arm_lowmem_limit);
+	memblock_allow_resize();
 	dma_contiguous_remap();
 	early_fixmap_shutdown();
 	devicemaps_init(mdesc);
-- 
2.19.1

WARNING: multiple messages have this Message-ID (diff)
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/6] ARM: mm: permit memblock resizing right after mapping the linear region
Date: Wed,  7 Nov 2018 15:16:07 +0100	[thread overview]
Message-ID: <20181107141611.12076-3-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20181107141611.12076-1-ard.biesheuvel@linaro.org>

The memblock arrays can be resized dynamically if needed, but this is
only done after memblock_allow_resize() is called, since it is up to
the architecture to decide at which point doing so is possible (i.e.,
when all the memory that memblock describes is actually mapped)

ARM grants this permission in bootmem_init(), but in order for the EFI
persistent memory reservation code (which may create memblock
reservations that trigger such a dynamic resize) to be able to be called
before shutting down early fixmap (upon which the EFI code depends due
to its use of early_memremap()), we need to do this earlier.

So let's move the call to memblock_allow_resize() to right after the
point where low memory is mapped and declared as the memory limit for
memblock allocation.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 arch/arm/mm/init.c | 1 -
 arch/arm/mm/mmu.c  | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 32e4845af2b6..797fad2b16ee 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -304,7 +304,6 @@ void __init bootmem_init(void)
 {
 	unsigned long min, max_low, max_high;
 
-	memblock_allow_resize();
 	max_low = max_high = 0;
 
 	find_limits(&min, &max_low, &max_high);
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index f5cc1ccfea3d..f6bf6686559d 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1626,6 +1626,7 @@ void __init paging_init(const struct machine_desc *mdesc)
 	prepare_page_table();
 	map_lowmem();
 	memblock_set_current_limit(arm_lowmem_limit);
+	memblock_allow_resize();
 	dma_contiguous_remap();
 	early_fixmap_shutdown();
 	devicemaps_init(mdesc);
-- 
2.19.1

  parent reply	other threads:[~2018-11-07 14:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-07 14:16 [PATCH v2 0/6] arm/efi: fix memblock reallocation crash due to persistent reservations Ard Biesheuvel
2018-11-07 14:16 ` Ard Biesheuvel
2018-11-07 14:16 ` [PATCH v2 1/6] arm64: memblock: don't permit memblock resizing until linear mapping is up Ard Biesheuvel
2018-11-07 14:16   ` Ard Biesheuvel
2018-11-08 17:53   ` Catalin Marinas
2018-11-08 17:53     ` Catalin Marinas
2018-11-07 14:16 ` Ard Biesheuvel [this message]
2018-11-07 14:16   ` [PATCH v2 2/6] ARM: mm: permit memblock resizing right after mapping the linear region Ard Biesheuvel
2018-11-07 14:16 ` [PATCH v2 3/6] ARM: mm: permit early_memremap() to be used in paging_init() Ard Biesheuvel
2018-11-07 14:16   ` Ard Biesheuvel
2018-11-07 14:16 ` [PATCH v2 4/6] efi/arm: defer persistent reservations until after paging_init() Ard Biesheuvel
2018-11-07 14:16   ` Ard Biesheuvel
2018-11-07 14:16 ` [PATCH v2 5/6] efi: permit multiple entries in persistent memreserve data structure Ard Biesheuvel
2018-11-07 14:16   ` Ard Biesheuvel
2018-11-07 14:16 ` [PATCH v2 6/6] efi: reduce the amount of memblock reservations for persistent allocations Ard Biesheuvel
2018-11-07 14:16   ` Ard Biesheuvel
2018-11-08 19:13 ` [PATCH v2 0/6] arm/efi: fix memblock reallocation crash due to persistent reservations Bhupesh Sharma
2018-11-08 19:13   ` Bhupesh Sharma
2018-11-08 19:14   ` Bhupesh Sharma
2018-11-08 19:14     ` Bhupesh Sharma
2018-11-08 19:14   ` Ard Biesheuvel
2018-11-08 19:14     ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181107141611.12076-3-ard.biesheuvel@linaro.org \
    --to=ard.biesheuvel@linaro.org \
    --cc=bhsharma@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=marc.zyngier@arm.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.