android_kernel_motorola_sm6375/arch
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Myrrh Periwinkle 05718ff746 x86/e820: Fix handling of subpage regions when calculating nosave ranges in e820__register_nosave_regions()
commit f2f29da9f0d4367f6ff35e0d9d021257bb53e273 upstream.

While debugging kexec/hibernation hangs and crashes, it turned out that
the current implementation of e820__register_nosave_regions() suffers from
multiple serious issues:

 - The end of last region is tracked by PFN, causing it to find holes
   that aren't there if two consecutive subpage regions are present

 - The nosave PFN ranges derived from holes are rounded out (instead of
   rounded in) which makes it inconsistent with how explicitly reserved
   regions are handled

Fix this by:

 - Treating reserved regions as if they were holes, to ensure consistent
   handling (rounding out nosave PFN ranges is more correct as the
   kernel does not use partial pages)

 - Tracking the end of the last RAM region by address instead of pages
   to detect holes more precisely

These bugs appear to have been introduced about ~18 years ago with the very
first version of e820_mark_nosave_regions(), and its flawed assumptions were
carried forward uninterrupted through various waves of rewrites and renames.

[ mingo: Added Git archeology details, for kicks and giggles. ]

Fixes: e8eff5ac29 ("[PATCH] Make swsusp avoid memory holes and reserved memory regions on x86_64")
Reported-by: Roberto Ricci <io@r-ricci.it>
Tested-by: Roberto Ricci <io@r-ricci.it>
Signed-off-by: Myrrh Periwinkle <myrrhperiwinkle@qtmlabs.xyz>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Woodhouse <dwmw@amazon.co.uk>
Cc: Len Brown <len.brown@intel.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20250406-fix-e820-nosave-v3-1-f3787bc1ee1d@qtmlabs.xyz
Closes: https://lore.kernel.org/all/Z4WFjBVHpndct7br@desktop0a/
Signed-off-by: Myrrh Periwinkle <myrrhperiwinkle@qtmlabs.xyz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-05-02 07:39:17 +02:00
..
alpha alpha: replace hardcoded stack offsets with autogenerated ones 2025-03-13 12:43:18 +01:00
arc ARC: build: Try to guess GCC variant of cross compiler 2025-01-09 13:23:36 +01:00
arm ARM: Remove address checking for MMUless devices 2025-04-10 14:29:39 +02:00
arm64 arm64: dts: mediatek: mt8173: Fix disp-pwm compatible string 2025-05-02 07:39:16 +02:00
c6x
csky
h8300
hexagon hexagon: Fix unbalanced spinlock in die() 2025-03-13 12:43:01 +01:00
ia64
m68k m68k: vga: Fix I/O defines 2025-03-13 12:43:06 +01:00
microblaze microblaze: don't treat zero reserved memory regions as error 2024-11-08 16:20:25 +01:00
mips MIPS: ftrace: Declare ftrace_get_parent_ra_addr() as static 2025-03-13 12:43:11 +01:00
nds32
nios2
openrisc
parisc parisc: Fix 64-bit userspace syscall path 2024-11-08 16:20:40 +01:00
powerpc spufs: fix a leak in spufs_create_context() 2025-04-10 14:29:42 +02:00
riscv riscv: Remove unused GENERATING_ASM_OFFSETS 2024-11-08 16:20:54 +01:00
s390 KVM: s390: vsie: fix some corner-cases when grabbing vsie pages 2025-03-13 12:43:07 +01:00
sh sh: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK 2024-12-14 19:44:37 +01:00
sparc sparc/mm: disable preemption in lazy mmu mode 2025-05-02 07:39:16 +02:00
um um: Always dump trace for specified task in show_stack 2024-12-14 19:44:40 +01:00
unicore32
x86 x86/e820: Fix handling of subpage regions when calculating nosave ranges in e820__register_nosave_regions() 2025-05-02 07:39:17 +02:00
xtensa
.gitignore
Kconfig