mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] arm64/mm: prevent panic on -ENOMEM in arch_add_memory()
@ 2025-10-13  8:02 Linu Cherian
  2025-10-13  8:02 ` [PATCH v2 1/2] arm64/mm: Allow __create_pgd_mapping() to propagate pgtable_alloc() errors Linu Cherian
  2025-10-13  8:02 ` [PATCH v2 2/2] arm64/mm: Rename try_pgd_pgtable_alloc_init_mm Linu Cherian
  0 siblings, 2 replies; 8+ messages in thread
From: Linu Cherian @ 2025-10-13  8:02 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Andrew Morton, Ryan Roberts,
	linux-arm-kernel, linux-kernel
  Cc: Anshuman Khandual, Kevin Brodsky, Zhenhua Huang, Dev Jain,
	Lorenzo Stoakes, Yang Shi, Linu Cherian

arch_add_memory() acts as a means to hotplug memory into a system. It
invokes __create_pgd_mapping() which further unwinds to call
pgtable_alloc(). Initially, this path was only invoked during early boot
and therefore it made sense to BUG_ON() in case pgtable_alloc() failed.
Now however, we risk running into a kernel crash if we try to hotplug
memory into a system that is already extremely tight on available
memory. This is undesirable and hence __create_pgd_mapping() and it's
helpers are reworked to be able to propagate the error from
pgtable_alloc() allowing the system to fail gracefully.

Keeping in mind that it is still essential to BUG_ON()/panic if
pgtable_alloc() encounters failure at the time of boot, a wrapper is
created around __create_pgd_mapping() which is designed to panic() if
it encounters a non-zero return value. This wrapper is then invoked from
the init functions instead of __create_pgd_mapping(), thereby keeping the
original functionality intact.

This theoretical bug was identified by Ryan Roberts<ryan.roberts@arm.com>
as a part of code review of the following series[1].

[1] https://lore.kernel.org/linux-arm-kernel/20250304222018.615808-4-yang@os.amperecomputing.com/


Changelog

v2:
* With cleanup merged as part of, "arm64: mm: Move KPTI helpers to mmu.c"
  changes in patch 2(v1) got much simplified and squashed to patch 1 itself.
* Patch 2 now does a trivial renaming for better readability 
* Make use of INVALID_PHYS_ADDR for error checks instead of 0.  
* Do early function return where we do not have any
  common cleanup in return path
* Remove redundant variable initialization
* Changed BUG_ON to panic
* Renamed ___create_pgd_mapping to early_create_pgd_mapping  

This series is now rebased to linux-6.18-rc1.

I will be taking the stewardship for this patch series, as Chaitanya
has left Arm.

Thanks,
Linu Cherian.

Chaitanya S Prakash (1):
  arm64/mm: Allow __create_pgd_mapping() to propagate pgtable_alloc()
    errors

Linu Cherian (1):
  arm64/mm: Rename try_pgd_pgtable_alloc_init_mm

 arch/arm64/mm/mmu.c | 208 ++++++++++++++++++++++++++++----------------
 1 file changed, 132 insertions(+), 76 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2025-10-15  4:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-13  8:02 [PATCH v2 0/2] arm64/mm: prevent panic on -ENOMEM in arch_add_memory() Linu Cherian
2025-10-13  8:02 ` [PATCH v2 1/2] arm64/mm: Allow __create_pgd_mapping() to propagate pgtable_alloc() errors Linu Cherian
2025-10-13  9:26   ` Ryan Roberts
2025-10-15  4:21     ` Linu Cherian
2025-10-14  9:29   ` Kevin Brodsky
2025-10-15  4:22     ` Linu Cherian
2025-10-13  8:02 ` [PATCH v2 2/2] arm64/mm: Rename try_pgd_pgtable_alloc_init_mm Linu Cherian
2025-10-13  9:30   ` Ryan Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®