The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 0/3] crash: Restore 1M crashkernel offsets on x86 and report misaligned ones
@ 2026-12-04 20:59 Chris Down
  2026-12-04 20:59 ` [PATCH 1/3] x86/crash: Reserve crashkernel=size@offset at 1M-aligned offsets again Chris Down
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chris Down @ 2026-12-04 20:59 UTC (permalink / raw)
  To: Andrew Morton, Baoquan He, Mike Rapoport
  Cc: Jonathan Corbet, Shuah Khan, Randy Dunlap, Pasha Tatashin,
	Pratyush Yadav, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, linux-doc, kexec, linux-kernel,
	kernel-team

Since v6.7, crashkernel=size@offset on x86 only reserves anything when
offset is a multiple of 16M, and the kernel just says that the memory is
in use otherwise. Before that, any 1M-aligned offset worked. The result
is that unfortunately, some existing crashkernel configs stopped working.
Of course, they are in the minority, since usually most sensible people
would set it to powers of two above 16M... but anyway.

Patch 1 fixes that by asking for 1M alignment again for an explicit
offset on x86. This is the one that probably should go to stable, given
this is a somewhat unintended behaviour change.

Patch 2 reports misalignment, since previously we just write that it
failed, with no docs or message to really help the user understand why.
The new message gives the alignment the offset has to meet, instead of
claiming that the memory is in use.

Patch 3 documents the alignment. kdump.rst currently says that a
misaligned offset only wastes the memory below the alignment point, but
on x86, arm64, riscv and loongarch nothing is reserved at all.

Patches 2 and 3 build on patch 1, but don't need to go to stable.

Chris Down (3):
  x86/crash: Reserve crashkernel=size@offset at 1M-aligned offsets again
  crash: Don't report a misaligned crashkernel offset as memory in use
  Documentation: kdump: Mention that the crashkernel offset must be
    aligned

 Documentation/admin-guide/kdump/kdump.rst       | 15 ++++++++++-----
 Documentation/admin-guide/kernel-parameters.txt |  4 +++-
 arch/x86/include/asm/crash_reserve.h            |  2 ++
 include/linux/crash_reserve.h                   |  3 +++
 kernel/crash_reserve.c                          |  9 ++++++++-
 5 files changed, 26 insertions(+), 7 deletions(-)


base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106
-- 
2.56.1


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

* [PATCH 1/3] x86/crash: Reserve crashkernel=size@offset at 1M-aligned offsets again
  2026-12-04 20:59 [PATCH 0/3] crash: Restore 1M crashkernel offsets on x86 and report misaligned ones Chris Down
@ 2026-12-04 20:59 ` Chris Down
  2026-12-04 20:59 ` [PATCH 2/3] crash: Don't report a misaligned crashkernel offset as memory in use Chris Down
  2026-12-04 20:59 ` [PATCH 3/3] Documentation: kdump: Mention that the crashkernel offset must be aligned Chris Down
  2 siblings, 0 replies; 4+ messages in thread
From: Chris Down @ 2026-12-04 20:59 UTC (permalink / raw)
  To: Andrew Morton, Baoquan He, Mike Rapoport
  Cc: Jonathan Corbet, Shuah Khan, Randy Dunlap, Pasha Tatashin,
	Pratyush Yadav, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, linux-doc, kexec, linux-kernel,
	kernel-team

Since x86 moved to the generic crashkernel reservation code in v6.7,
crashkernel=size@offset fails for any offset that isn't a multiple of
16M. For example, on a 4G x86-64 guest booted with nokaslr, where we
easily have over 1G of free memory:

    crashkernel=256M@1000M
    crashkernel reservation failed - memory is in use.

    crashkernel=256M@1024M
    crashkernel reserved: 0x0000000040000000 - 0x0000000050000000 (256 MB)

As you can see, the messaging we give to users here is a bit janky too,
that's fixed in the next patch.

The bug likely went unnoticed since the usual offsets are multiples of
16M, but nevertheless this means that a command line that worked up to
v6.6 may have silently stopped working.

For context, I ran into this in practice when testing kexec/KHO code,
and was rather bemused by the error given (which is also improved in the
following two patches).

To fix this, let's add CRASH_FIXED_BASE_ALIGN. This is the alignment
reserve_crashkernel_generic() asks for when the user gives an offset,
and it defaults to CRASH_ALIGN, so other architectures are unaffected.
x86 sets it to 1M, which restores the pre-v6.7 behaviour.

Fixes: 9c08a2a139fe ("x86: kdump: use generic interface to simplify crashkernel reservation code")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Down <chris@chrisdown.name>
---
 arch/x86/include/asm/crash_reserve.h | 2 ++
 include/linux/crash_reserve.h        | 3 +++
 kernel/crash_reserve.c               | 4 +++-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/crash_reserve.h b/arch/x86/include/asm/crash_reserve.h
index 047f638a766d..b5dafc771325 100644
--- a/arch/x86/include/asm/crash_reserve.h
+++ b/arch/x86/include/asm/crash_reserve.h
@@ -5,6 +5,8 @@
 /* 16M alignment for crash kernel regions */
 #define CRASH_ALIGN             SZ_16M
 
+#define CRASH_FIXED_BASE_ALIGN  SZ_1M
+
 /*
  * Keep the crash kernel below this limit.
  *
diff --git a/include/linux/crash_reserve.h b/include/linux/crash_reserve.h
index 30864d90d7f5..5c8cce363147 100644
--- a/include/linux/crash_reserve.h
+++ b/include/linux/crash_reserve.h
@@ -46,6 +46,9 @@ static inline bool arch_add_crash_res_to_iomem(void)
 #ifndef CRASH_ALIGN
 #define CRASH_ALIGN			SZ_2M
 #endif
+#ifndef CRASH_FIXED_BASE_ALIGN
+#define CRASH_FIXED_BASE_ALIGN		CRASH_ALIGN
+#endif
 #ifndef CRASH_ADDR_LOW_MAX
 #define CRASH_ADDR_LOW_MAX		SZ_4G
 #endif
diff --git a/kernel/crash_reserve.c b/kernel/crash_reserve.c
index eee37a11380c..d3364242e3a9 100644
--- a/kernel/crash_reserve.c
+++ b/kernel/crash_reserve.c
@@ -393,11 +393,13 @@ void __init reserve_crashkernel_generic(unsigned long long crash_size,
 					bool high)
 {
 	unsigned long long search_end = CRASH_ADDR_LOW_MAX, search_base = 0;
+	unsigned long long align = CRASH_ALIGN;
 	bool fixed_base = false;
 
 	/* User specifies base address explicitly. */
 	if (crash_base) {
 		fixed_base = true;
+		align = CRASH_FIXED_BASE_ALIGN;
 		search_base = crash_base;
 		search_end = crash_base + crash_size;
 	} else if (high) {
@@ -406,7 +408,7 @@ void __init reserve_crashkernel_generic(unsigned long long crash_size,
 	}
 
 retry:
-	crash_base = memblock_phys_alloc_range(crash_size, CRASH_ALIGN,
+	crash_base = memblock_phys_alloc_range(crash_size, align,
 					       search_base, search_end);
 	if (!crash_base) {
 		/*
-- 
2.56.1


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

* [PATCH 2/3] crash: Don't report a misaligned crashkernel offset as memory in use
  2026-12-04 20:59 [PATCH 0/3] crash: Restore 1M crashkernel offsets on x86 and report misaligned ones Chris Down
  2026-12-04 20:59 ` [PATCH 1/3] x86/crash: Reserve crashkernel=size@offset at 1M-aligned offsets again Chris Down
@ 2026-12-04 20:59 ` Chris Down
  2026-12-04 20:59 ` [PATCH 3/3] Documentation: kdump: Mention that the crashkernel offset must be aligned Chris Down
  2 siblings, 0 replies; 4+ messages in thread
From: Chris Down @ 2026-12-04 20:59 UTC (permalink / raw)
  To: Andrew Morton, Baoquan He, Mike Rapoport
  Cc: Jonathan Corbet, Shuah Khan, Randy Dunlap, Pasha Tatashin,
	Pratyush Yadav, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, linux-doc, kexec, linux-kernel,
	kernel-team

When the offset in crashkernel=size@offset isn't aligned the way the
architecture requires, reserve_crashkernel_generic() can't reserve
anything. Rather unhelpfully, it then prints the following:

    crashkernel reservation failed - memory is in use.

But that is codswallop, the problem is that it's not aligned, not that
the memory is in use.

To fix this, let's check the offset's alignment before trying to
reserve anything, and tell the user what it must be aligned to. With
this applied, crashkernel=256M@1000500K on x86 gives:

    crashkernel reservation failed - offset 0x3d10d000 is not aligned to 0x100000.

Signed-off-by: Chris Down <chris@chrisdown.name>
---
 kernel/crash_reserve.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/crash_reserve.c b/kernel/crash_reserve.c
index d3364242e3a9..817cfe6b7d93 100644
--- a/kernel/crash_reserve.c
+++ b/kernel/crash_reserve.c
@@ -400,6 +400,11 @@ void __init reserve_crashkernel_generic(unsigned long long crash_size,
 	if (crash_base) {
 		fixed_base = true;
 		align = CRASH_FIXED_BASE_ALIGN;
+		if (!IS_ALIGNED(crash_base, align)) {
+			pr_warn("crashkernel reservation failed - offset 0x%llx is not aligned to 0x%llx.\n",
+				crash_base, align);
+			return;
+		}
 		search_base = crash_base;
 		search_end = crash_base + crash_size;
 	} else if (high) {
-- 
2.56.1


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

* [PATCH 3/3] Documentation: kdump: Mention that the crashkernel offset must be aligned
  2026-12-04 20:59 [PATCH 0/3] crash: Restore 1M crashkernel offsets on x86 and report misaligned ones Chris Down
  2026-12-04 20:59 ` [PATCH 1/3] x86/crash: Reserve crashkernel=size@offset at 1M-aligned offsets again Chris Down
  2026-12-04 20:59 ` [PATCH 2/3] crash: Don't report a misaligned crashkernel offset as memory in use Chris Down
@ 2026-12-04 20:59 ` Chris Down
  2 siblings, 0 replies; 4+ messages in thread
From: Chris Down @ 2026-12-04 20:59 UTC (permalink / raw)
  To: Andrew Morton, Baoquan He, Mike Rapoport
  Cc: Jonathan Corbet, Shuah Khan, Randy Dunlap, Pasha Tatashin,
	Pratyush Yadav, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, linux-doc, kexec, linux-kernel,
	kernel-team

kdump.rst says that if the start address in crashkernel=size@offset
isn't aligned to the architecture's alignment, the space below the
alignment point is wasted. That's true for s390, which rounds the start
address up. But x86, arm64, riscv and loongarch pass the offset
unchanged to reserve_crashkernel_generic(), which actually has different
behaviour. It, instead, simply reserves nothing at all, which is quite
different from what the docs say.

So, let's document the rules here to avoid confusion and kdumpless
chagrin.

Signed-off-by: Chris Down <chris@chrisdown.name>
---
 Documentation/admin-guide/kdump/kdump.rst       | 15 ++++++++++-----
 Documentation/admin-guide/kernel-parameters.txt |  4 +++-
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/Documentation/admin-guide/kdump/kdump.rst b/Documentation/admin-guide/kdump/kdump.rst
index 7587caadbae1..7638881282aa 100644
--- a/Documentation/admin-guide/kdump/kdump.rst
+++ b/Documentation/admin-guide/kdump/kdump.rst
@@ -264,10 +264,14 @@ crashkernel syntax
 
          crashkernel=256M
 
-   If the start address is specified, note that the start address of the
-   kernel will be aligned to a value (which is Arch dependent), so if the
-   start address is not then any space below the alignment point will be
-   wasted.
+   If the start address is specified, it has to be aligned to a value which
+   is arch dependent. For example, it is 1MiB on x86, and 2MiB on arm64,
+   loongarch, and 64-bit riscv. If it is not aligned properly, nothing will
+   be reserved.
+
+   However, note well that on some architectures like s390, unaligned start
+   addresses are rounded up instead, and so any space below the alignment
+   point is simply wasted.
 
 2) range1:size1[,range2:size2,...][@offset]
 
@@ -341,7 +345,8 @@ Boot into System Kernel
 
    On x86 and x86_64, use "crashkernel=Y[@X]". Most of the time, the
    start address 'X' is not necessary, kernel will search a suitable
-   area. Unless an explicit start address is expected.
+   area. Unless an explicit start address is expected. Note that X, if
+   explicitly specified, must be aligned to 1MiB (0x100000).
 
    On ppc64, use "crashkernel=128M@32M".
 
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index dce9b8f3ae98..8a41b45b1e47 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1061,7 +1061,9 @@ Kernel parameters
 			upon panic. This parameter reserves the physical
 			memory region [offset, offset + size] for that kernel
 			image. If '@offset' is omitted, then a suitable offset
-			is selected automatically.
+			is selected automatically. Some architectures require
+			offset to be aligned, and will fail to reserve anything
+			if the alignment is not cromulent.
 			[KNL, X86-64, ARM64, RISCV, LoongArch] Select a region
 			under 4G first, and fall back to reserve region above
 			4G when '@offset' hasn't been specified.
-- 
2.56.1


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

end of thread, other threads:[~2026-12-04 20:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 20:59 [PATCH 0/3] crash: Restore 1M crashkernel offsets on x86 and report misaligned ones Chris Down
2026-12-04 20:59 ` [PATCH 1/3] x86/crash: Reserve crashkernel=size@offset at 1M-aligned offsets again Chris Down
2026-12-04 20:59 ` [PATCH 2/3] crash: Don't report a misaligned crashkernel offset as memory in use Chris Down
2026-12-04 20:59 ` [PATCH 3/3] Documentation: kdump: Mention that the crashkernel offset must be aligned Chris Down

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