linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC GIT PULL] EFI fixes, memblock quirk
@ 2019-02-17 10:59 Ingo Molnar
  2019-02-17 17:24 ` Linus Torvalds
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2019-02-17 10:59 UTC (permalink / raw)
  To: Linus Torvalds, Andrew Morton
  Cc: linux-kernel, Ard Biesheuvel, Thomas Gleixner, Borislav Petkov,
	Peter Zijlstra, Benjamin Herrenschmidt, Tejun Heo, Yinghai Lu,
	Mike Rapoport, Tang Chen, Alexander Kuleshov

Linus,

Please pull the latest efi-urgent-for-linus git tree from:

   git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git efi-urgent-for-linus

   # HEAD: 582a32e708823e5957fd73ccd78dc4a9e49d21ea efi/arm: Revert "Defer persistent reservations until after paging_init()"

This tree reverts a GICv3 commit (which was broken) and fixes it in 
another way, by adding a memblock build-time entries quirk for ARM64.

I marked it RFC: please have a second look at the mm/memblock.c change, 
which adds a INIT_MEMBLOCK_RESERVED_REGIONS detour that ARM64 takes for 
these systems.

Perhaps we should upgrade the build time sizing of all platforms to 
INIT_MEMBLOCK_REGIONS+NR_CPUS+1 and thus centrally give an extra 
allocation entry per CPU configured?

Or is there some cleaner solution?

 Thanks,

	Ingo

------------------>
Ard Biesheuvel (2):
      arm64, mm, efi: Account for GICv3 LPI tables in static memblock reserve table
      efi/arm: Revert "Defer persistent reservations until after paging_init()"


 arch/arm64/include/asm/memory.h         | 11 +++++++++++
 arch/arm64/kernel/setup.c               |  1 -
 drivers/firmware/efi/efi.c              |  4 ----
 drivers/firmware/efi/libstub/arm-stub.c |  3 ---
 include/linux/efi.h                     |  7 -------
 include/linux/memblock.h                |  3 ---
 mm/memblock.c                           | 11 +++++++++--
 7 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index e1ec947e7c0c..0c656850eeea 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -332,6 +332,17 @@ static inline void *phys_to_virt(phys_addr_t x)
 #define virt_addr_valid(kaddr)		\
 	(_virt_addr_is_linear(kaddr) && _virt_addr_valid(kaddr))
 
+/*
+ * Given that the GIC architecture permits ITS implementations that can only be
+ * configured with a LPI table address once, GICv3 systems with many CPUs may
+ * end up reserving a lot of different regions after a kexec for their LPI
+ * tables (one per CPU), as we are forced to reuse the same memory after kexec
+ * (and thus reserve it persistently with EFI beforehand)
+ */
+#if defined(CONFIG_EFI) && defined(CONFIG_ARM_GIC_V3_ITS)
+# define INIT_MEMBLOCK_RESERVED_REGIONS	(INIT_MEMBLOCK_REGIONS + NR_CPUS + 1)
+#endif
+
 #include <asm-generic/memory_model.h>
 
 #endif
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 4b0e1231625c..d09ec76f08cf 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -313,7 +313,6 @@ void __init setup_arch(char **cmdline_p)
 	arm64_memblock_init();
 
 	paging_init();
-	efi_apply_persistent_mem_reservations();
 
 	acpi_table_upgrade();
 
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 4c46ff6f2242..55b77c576c42 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -592,11 +592,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz,
 
 		early_memunmap(tbl, sizeof(*tbl));
 	}
-	return 0;
-}
 
-int __init efi_apply_persistent_mem_reservations(void)
-{
 	if (efi.mem_reserve != EFI_INVALID_TABLE_ADDR) {
 		unsigned long prsv = efi.mem_reserve;
 
diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index eee42d5e25ee..c037c6c5d0b7 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) {
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 45ff763fba76..28604a8d0aa9 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -1198,8 +1198,6 @@ static inline bool efi_enabled(int feature)
 extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);
 
 extern bool efi_is_table_address(unsigned long phys_addr);
-
-extern int efi_apply_persistent_mem_reservations(void);
 #else
 static inline bool efi_enabled(int feature)
 {
@@ -1218,11 +1216,6 @@ static inline bool efi_is_table_address(unsigned long phys_addr)
 {
 	return false;
 }
-
-static inline int efi_apply_persistent_mem_reservations(void)
-{
-	return 0;
-}
 #endif
 
 extern int efi_status_to_err(efi_status_t status);
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 64c41cf45590..859b55b66db2 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -29,9 +29,6 @@ extern unsigned long max_pfn;
  */
 extern unsigned long long max_possible_pfn;
 
-#define INIT_MEMBLOCK_REGIONS	128
-#define INIT_PHYSMEM_REGIONS	4
-
 /**
  * enum memblock_flags - definition of memory region attributes
  * @MEMBLOCK_NONE: no special request
diff --git a/mm/memblock.c b/mm/memblock.c
index 022d4cbb3618..ea31045ba704 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -26,6 +26,13 @@
 
 #include "internal.h"
 
+#define INIT_MEMBLOCK_REGIONS			128
+#define INIT_PHYSMEM_REGIONS			4
+
+#ifndef INIT_MEMBLOCK_RESERVED_REGIONS
+# define INIT_MEMBLOCK_RESERVED_REGIONS		INIT_MEMBLOCK_REGIONS
+#endif
+
 /**
  * DOC: memblock overview
  *
@@ -92,7 +99,7 @@ unsigned long max_pfn;
 unsigned long long max_possible_pfn;
 
 static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;
-static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;
+static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_RESERVED_REGIONS] __initdata_memblock;
 #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP
 static struct memblock_region memblock_physmem_init_regions[INIT_PHYSMEM_REGIONS] __initdata_memblock;
 #endif
@@ -105,7 +112,7 @@ struct memblock memblock __initdata_memblock = {
 
 	.reserved.regions	= memblock_reserved_init_regions,
 	.reserved.cnt		= 1,	/* empty dummy entry */
-	.reserved.max		= INIT_MEMBLOCK_REGIONS,
+	.reserved.max		= INIT_MEMBLOCK_RESERVED_REGIONS,
 	.reserved.name		= "reserved",
 
 #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP

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

* Re: [RFC GIT PULL] EFI fixes, memblock quirk
  2019-02-17 10:59 [RFC GIT PULL] EFI fixes, memblock quirk Ingo Molnar
@ 2019-02-17 17:24 ` Linus Torvalds
  2019-02-19 15:16   ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Linus Torvalds @ 2019-02-17 17:24 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Andrew Morton, Linux List Kernel Mailing, Ard Biesheuvel,
	Thomas Gleixner, Borislav Petkov, Peter Zijlstra,
	Benjamin Herrenschmidt, Tejun Heo, Yinghai Lu, Mike Rapoport,
	Tang Chen, Alexander Kuleshov

On Sun, Feb 17, 2019 at 2:59 AM Ingo Molnar <mingo@kernel.org> wrote:
>
> I marked it RFC: please have a second look at the mm/memblock.c change,
> which adds a INIT_MEMBLOCK_RESERVED_REGIONS detour that ARM64 takes for
> these systems.

It's not pretty, but it looks minimal for now. Pulled.

> Perhaps we should upgrade the build time sizing of all platforms to
> INIT_MEMBLOCK_REGIONS+NR_CPUS+1 and thus centrally give an extra
> allocation entry per CPU configured?
>
> Or is there some cleaner solution?

Is there some reason other platforms might want that kind of thing?
If not, then the current hack seems sufficient.

                    Linus

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

* Re: [RFC GIT PULL] EFI fixes, memblock quirk
  2019-02-17 17:24 ` Linus Torvalds
@ 2019-02-19 15:16   ` Ingo Molnar
  2019-02-19 15:29     ` Ard Biesheuvel
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2019-02-19 15:16 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Andrew Morton, Linux List Kernel Mailing, Ard Biesheuvel,
	Thomas Gleixner, Borislav Petkov, Peter Zijlstra,
	Benjamin Herrenschmidt, Tejun Heo, Yinghai Lu, Mike Rapoport,
	Tang Chen, Alexander Kuleshov


* Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Sun, Feb 17, 2019 at 2:59 AM Ingo Molnar <mingo@kernel.org> wrote:
> >
> > I marked it RFC: please have a second look at the mm/memblock.c change,
> > which adds a INIT_MEMBLOCK_RESERVED_REGIONS detour that ARM64 takes for
> > these systems.
> 
> It's not pretty, but it looks minimal for now. Pulled.

Thanks!

> > Perhaps we should upgrade the build time sizing of all platforms to
> > INIT_MEMBLOCK_REGIONS+NR_CPUS+1 and thus centrally give an extra
> > allocation entry per CPU configured?
> >
> > Or is there some cleaner solution?
> 
> Is there some reason other platforms might want that kind of thing?

Not that I'm aware of.

> If not, then the current hack seems sufficient.

Ok!

Thanks,

	Ingo

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

* Re: [RFC GIT PULL] EFI fixes, memblock quirk
  2019-02-19 15:16   ` Ingo Molnar
@ 2019-02-19 15:29     ` Ard Biesheuvel
  0 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2019-02-19 15:29 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Linus Torvalds, Andrew Morton, Linux List Kernel Mailing,
	Thomas Gleixner, Borislav Petkov, Peter Zijlstra,
	Benjamin Herrenschmidt, Tejun Heo, Yinghai Lu, Mike Rapoport,
	Tang Chen, Alexander Kuleshov

On Tue, 19 Feb 2019 at 16:16, Ingo Molnar <mingo@kernel.org> wrote:
>
>
> * Linus Torvalds <torvalds@linux-foundation.org> wrote:
>
> > On Sun, Feb 17, 2019 at 2:59 AM Ingo Molnar <mingo@kernel.org> wrote:
> > >
> > > I marked it RFC: please have a second look at the mm/memblock.c change,
> > > which adds a INIT_MEMBLOCK_RESERVED_REGIONS detour that ARM64 takes for
> > > these systems.
> >
> > It's not pretty, but it looks minimal for now. Pulled.
>
> Thanks!
>
> > > Perhaps we should upgrade the build time sizing of all platforms to
> > > INIT_MEMBLOCK_REGIONS+NR_CPUS+1 and thus centrally give an extra
> > > allocation entry per CPU configured?
> > >
> > > Or is there some cleaner solution?
> >
> > Is there some reason other platforms might want that kind of thing?
>
> Not that I'm aware of.
>

Nor me.

> > If not, then the current hack seems sufficient.
>
> Ok!
>

Thanks. It's a bit of a hack indeed, but every other option I explored
was a lot nastier. We might be able to tweak the LPI table allocation
logic so that they are adjacent, taking up only a single slot in the
reservation table, but that will have to wait for v5.2

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

end of thread, other threads:[~2019-02-19 15:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-17 10:59 [RFC GIT PULL] EFI fixes, memblock quirk Ingo Molnar
2019-02-17 17:24 ` Linus Torvalds
2019-02-19 15:16   ` Ingo Molnar
2019-02-19 15:29     ` 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).