linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] ARM: re-enable EFI persistent memory reservations
@ 2018-12-10 16:29 Ard Biesheuvel
  2018-12-10 16:29 ` [PATCH 1/4] ARM: mm: permit memblock resizing right after mapping the linear region Ard Biesheuvel
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2018-12-10 16:29 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Marc Zyngier, linux-efi, Russell King, Ard Biesheuvel

The EFI persistent memory reservations introduced during the v4.20
merge window had some teething issue, and we ended up disabling it
temporarily for 32-bit ARM due to the fact that the needed changes
were not as straightforward as on arm64.

So this series fixes the issues, and re-enables the feature for
32-bit ARM.

Cc: Russell King <linux@armlinux.org.uk>
Cc: Marc Zyngier <marc.zyngier@arm.com>

Ard Biesheuvel (4):
  ARM: mm: permit memblock resizing right after mapping the linear
    region
  ARM: mm: permit early_memremap() to be used in paging_init()
  efi/arm: apply persistent memory reservations during paging_init()
  efi/arm: re-enable the memreserve table for 32-bit ARM

 arch/arm/kernel/setup.c                 | 2 --
 arch/arm/mm/init.c                      | 1 -
 arch/arm/mm/mmu.c                       | 5 +++++
 drivers/firmware/efi/libstub/arm-stub.c | 3 ---
 4 files changed, 5 insertions(+), 6 deletions(-)

-- 
2.19.2

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

* [PATCH 1/4] ARM: mm: permit memblock resizing right after mapping the linear region
  2018-12-10 16:29 [PATCH 0/4] ARM: re-enable EFI persistent memory reservations Ard Biesheuvel
@ 2018-12-10 16:29 ` Ard Biesheuvel
  2018-12-10 16:29 ` [PATCH 2/4] ARM: mm: permit early_memremap() to be used in paging_init() Ard Biesheuvel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2018-12-10 16:29 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Marc Zyngier, linux-efi, Russell King, Ard Biesheuvel

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

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

* [PATCH 2/4] ARM: mm: permit early_memremap() to be used in paging_init()
  2018-12-10 16:29 [PATCH 0/4] ARM: re-enable EFI persistent memory reservations Ard Biesheuvel
  2018-12-10 16:29 ` [PATCH 1/4] ARM: mm: permit memblock resizing right after mapping the linear region Ard Biesheuvel
@ 2018-12-10 16:29 ` Ard Biesheuvel
  2018-12-10 16:29 ` [PATCH 3/4] efi/arm: apply persistent memory reservations during paging_init() Ard Biesheuvel
  2018-12-10 16:29 ` [PATCH 4/4] efi/arm: re-enable the memreserve table for 32-bit ARM Ard Biesheuvel
  3 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2018-12-10 16:29 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Marc Zyngier, linux-efi, Russell King, Ard Biesheuvel

early_memremap() and early_ioremap() rely on early fixmap support,
which shares its virtual address space with kmap(), and so it is
taken down in paging_init().

In order to permit the EFI persistent memory reservation code to
use early_memremap() when called from paging_init(), move the call
to early_ioremap_reset() into paging_init(), right before the call
to early_fixmap_shutdown(), creating a window where we can add the
call to efi_apply_persistent_mem_reservations() in a subsequent patch.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 arch/arm/kernel/setup.c | 2 --
 arch/arm/mm/mmu.c       | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 375b13f7e780..7e2a936a5ed0 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -1124,8 +1124,6 @@ void __init setup_arch(char **cmdline_p)
 	/* Memory may have been removed so recalculate the bounds. */
 	adjust_lowmem_bounds();
 
-	early_ioremap_reset();
-
 	paging_init(mdesc);
 	request_standard_resources(mdesc);
 
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index f6bf6686559d..078f82f89fe5 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -22,6 +22,7 @@
 #include <asm/cputype.h>
 #include <asm/sections.h>
 #include <asm/cachetype.h>
+#include <asm/early_ioremap.h>
 #include <asm/fixmap.h>
 #include <asm/sections.h>
 #include <asm/setup.h>
@@ -1628,6 +1629,7 @@ void __init paging_init(const struct machine_desc *mdesc)
 	memblock_set_current_limit(arm_lowmem_limit);
 	memblock_allow_resize();
 	dma_contiguous_remap();
+	early_ioremap_reset();
 	early_fixmap_shutdown();
 	devicemaps_init(mdesc);
 	kmap_init();
-- 
2.19.2

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

* [PATCH 3/4] efi/arm: apply persistent memory reservations during paging_init()
  2018-12-10 16:29 [PATCH 0/4] ARM: re-enable EFI persistent memory reservations Ard Biesheuvel
  2018-12-10 16:29 ` [PATCH 1/4] ARM: mm: permit memblock resizing right after mapping the linear region Ard Biesheuvel
  2018-12-10 16:29 ` [PATCH 2/4] ARM: mm: permit early_memremap() to be used in paging_init() Ard Biesheuvel
@ 2018-12-10 16:29 ` Ard Biesheuvel
  2018-12-10 16:29 ` [PATCH 4/4] efi/arm: re-enable the memreserve table for 32-bit ARM Ard Biesheuvel
  3 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2018-12-10 16:29 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Marc Zyngier, linux-efi, Russell King, Ard Biesheuvel

The new memory EFI reservation feature we introduced to allow memory
reservations to persist across kexec may trigger an unbounded number
of calls to memblock_reserve(). The memblock subsystem can deal with
this fine, but not before memblock resizing is enabled, which we can
only do after paging_init(), when the memory we reallocate the array
into is actually mapped.

So  on ARM, call the broken out efi_apply_persistent_mem_reservations()
after memblock resizing has been enabled but before the early memremap
support that we rely on has been taken down.

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

diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 078f82f89fe5..8ecffb8c0c0b 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -9,6 +9,7 @@
  */
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/efi.h>
 #include <linux/errno.h>
 #include <linux/init.h>
 #include <linux/mman.h>
@@ -1629,6 +1630,7 @@ void __init paging_init(const struct machine_desc *mdesc)
 	memblock_set_current_limit(arm_lowmem_limit);
 	memblock_allow_resize();
 	dma_contiguous_remap();
+	efi_apply_persistent_mem_reservations();
 	early_ioremap_reset();
 	early_fixmap_shutdown();
 	devicemaps_init(mdesc);
-- 
2.19.2

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

* [PATCH 4/4] efi/arm: re-enable the memreserve table for 32-bit ARM
  2018-12-10 16:29 [PATCH 0/4] ARM: re-enable EFI persistent memory reservations Ard Biesheuvel
                   ` (2 preceding siblings ...)
  2018-12-10 16:29 ` [PATCH 3/4] efi/arm: apply persistent memory reservations during paging_init() Ard Biesheuvel
@ 2018-12-10 16:29 ` Ard Biesheuvel
  3 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2018-12-10 16:29 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: Marc Zyngier, linux-efi, Russell King, Ard Biesheuvel

Now that we have readded the call to efi_apply_persistent_mem_reservations
in the 32-bit ARM boot path in a place where potentially creating
many memblock reservations is permissible, re-enable the MEMRESERVE
table in the 32-bit ARM EFI stub. This brings ARM back in line with
arm64 in terms of support for efi_mem_reserve_persistent().

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/firmware/efi/libstub/arm-stub.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index 3d36142cf812..30ac0c975f8a 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -75,9 +75,6 @@ void install_memreserve_table(efi_system_table_t *sys_table_arg)
 	efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID;
 	efi_status_t status;
 
-	if (IS_ENABLED(CONFIG_ARM))
-		return;
-
 	status = efi_call_early(allocate_pool, EFI_LOADER_DATA, sizeof(*rsv),
 				(void **)&rsv);
 	if (status != EFI_SUCCESS) {
-- 
2.19.2

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

end of thread, other threads:[~2018-12-10 16:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-10 16:29 [PATCH 0/4] ARM: re-enable EFI persistent memory reservations Ard Biesheuvel
2018-12-10 16:29 ` [PATCH 1/4] ARM: mm: permit memblock resizing right after mapping the linear region Ard Biesheuvel
2018-12-10 16:29 ` [PATCH 2/4] ARM: mm: permit early_memremap() to be used in paging_init() Ard Biesheuvel
2018-12-10 16:29 ` [PATCH 3/4] efi/arm: apply persistent memory reservations during paging_init() Ard Biesheuvel
2018-12-10 16:29 ` [PATCH 4/4] efi/arm: re-enable the memreserve table for 32-bit ARM Ard Biesheuvel

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