Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

arm64, mm, efi: Account for GICv3 LPI tables in static memblock reserve table

In the irqchip and EFI code, we have what basically amounts to a quirk
to work around a peculiarity in the GICv3 architecture, which permits
the system memory address of LPI tables to be programmable only once
after a CPU reset. This means kexec kernels must use the same memory
as the first kernel, and thus ensure that this memory has not been
given out for other purposes by the time the ITS init code runs, which
is not very early for secondary CPUs.

On systems with many CPUs, these reservations could overflow the
memblock reservation table, and this was addressed in commit:

eff896288872 ("efi/arm: Defer persistent reservations until after paging_init()")

However, this turns out to have made things worse, since the allocation
of page tables and heap space for the resized memblock reservation table
itself may overwrite the regions we are attempting to reserve, which may
cause all kinds of corruption, also considering that the ITS will still
be poking bits into that memory in response to incoming MSIs.

So instead, let's grow the static memblock reservation table on such
systems so it can accommodate these reservations at an earlier time.
This will permit us to revert the above commit in a subsequent patch.

[ mingo: Minor cleanups. ]

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20190215123333.21209-2-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Ard Biesheuvel and committed by
Ingo Molnar
8a5b403d 5ded5871

+20 -5
+11
arch/arm64/include/asm/memory.h
··· 332 332 #define virt_addr_valid(kaddr) \ 333 333 (_virt_addr_is_linear(kaddr) && _virt_addr_valid(kaddr)) 334 334 335 + /* 336 + * Given that the GIC architecture permits ITS implementations that can only be 337 + * configured with a LPI table address once, GICv3 systems with many CPUs may 338 + * end up reserving a lot of different regions after a kexec for their LPI 339 + * tables (one per CPU), as we are forced to reuse the same memory after kexec 340 + * (and thus reserve it persistently with EFI beforehand) 341 + */ 342 + #if defined(CONFIG_EFI) && defined(CONFIG_ARM_GIC_V3_ITS) 343 + # define INIT_MEMBLOCK_RESERVED_REGIONS (INIT_MEMBLOCK_REGIONS + NR_CPUS + 1) 344 + #endif 345 + 335 346 #include <asm-generic/memory_model.h> 336 347 337 348 #endif
-3
include/linux/memblock.h
··· 29 29 */ 30 30 extern unsigned long long max_possible_pfn; 31 31 32 - #define INIT_MEMBLOCK_REGIONS 128 33 - #define INIT_PHYSMEM_REGIONS 4 34 - 35 32 /** 36 33 * enum memblock_flags - definition of memory region attributes 37 34 * @MEMBLOCK_NONE: no special request
+9 -2
mm/memblock.c
··· 26 26 27 27 #include "internal.h" 28 28 29 + #define INIT_MEMBLOCK_REGIONS 128 30 + #define INIT_PHYSMEM_REGIONS 4 31 + 32 + #ifndef INIT_MEMBLOCK_RESERVED_REGIONS 33 + # define INIT_MEMBLOCK_RESERVED_REGIONS INIT_MEMBLOCK_REGIONS 34 + #endif 35 + 29 36 /** 30 37 * DOC: memblock overview 31 38 * ··· 99 92 unsigned long long max_possible_pfn; 100 93 101 94 static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; 102 - static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock; 95 + static struct memblock_region memblock_reserved_init_regions[INIT_MEMBLOCK_RESERVED_REGIONS] __initdata_memblock; 103 96 #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP 104 97 static struct memblock_region memblock_physmem_init_regions[INIT_PHYSMEM_REGIONS] __initdata_memblock; 105 98 #endif ··· 112 105 113 106 .reserved.regions = memblock_reserved_init_regions, 114 107 .reserved.cnt = 1, /* empty dummy entry */ 115 - .reserved.max = INIT_MEMBLOCK_REGIONS, 108 + .reserved.max = INIT_MEMBLOCK_RESERVED_REGIONS, 116 109 .reserved.name = "reserved", 117 110 118 111 #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP