All of lore.kernel.org
 help / color / mirror / Atom feed
* + efi-support-booting-with-kexec-handover-kho.patch added to mm-hotfixes-unstable branch
@ 2025-08-21 21:30 Andrew Morton
  2025-08-26 12:55 ` Ard Biesheuvel
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2025-08-21 21:30 UTC (permalink / raw)
  To: mm-commits, rppt, graf, changyuanl, bhe, ardb, epetron, akpm


The patch titled
     Subject: efi: support booting with kexec handover (KHO)
has been added to the -mm mm-hotfixes-unstable branch.  Its filename is
     efi-support-booting-with-kexec-handover-kho.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/efi-support-booting-with-kexec-handover-kho.patch

This patch will later appear in the mm-hotfixes-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Evangelos Petrongonas <epetron@amazon.de>
Subject: efi: support booting with kexec handover (KHO)
Date: Thu, 21 Aug 2025 17:59:00 +0000

When KHO (Kexec HandOver) is enabled, it sets up scratch memory regions
early during device tree scanning.  After kexec, the new kernel
exclusively uses this region for memory allocations during boot up to the
initialization of the page allocator

However, when booting with EFI, EFI's reserve_regions() uses
memblock_remove(0, PHYS_ADDR_MAX) to clear all memory regions before
rebuilding them from EFI data.  This destroys KHO scratch regions and
their flags, thus causing a kernel panic, as there are no scratch memory
regions.

Instead of wholesale removal, iterate through memory regions and only
remove non-KHO ones.  This preserves KHO scratch regions, which are good
known memory, while still allowing EFI to rebuild its memory map.

Link: https://lkml.kernel.org/r/b34da9fd50c89644cd4204136cfa6f5533445c56.1755721529.git.epetron@amazon.de
Signed-off-by: Evangelos Petrongonas <epetron@amazon.de>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Alexander Graf <graf@amazon.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Baoquan He <bhe@redhat.com>
Cc: Changyuan Lyu <changyuanl@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/firmware/efi/efi-init.c |   29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

--- a/drivers/firmware/efi/efi-init.c~efi-support-booting-with-kexec-handover-kho
+++ a/drivers/firmware/efi/efi-init.c
@@ -12,6 +12,7 @@
 #include <linux/efi.h>
 #include <linux/fwnode.h>
 #include <linux/init.h>
+#include <linux/kexec_handover.h>
 #include <linux/memblock.h>
 #include <linux/mm_types.h>
 #include <linux/of.h>
@@ -164,12 +165,32 @@ static __init void reserve_regions(void)
 		pr_info("Processing EFI memory map:\n");
 
 	/*
-	 * Discard memblocks discovered so far: if there are any at this
-	 * point, they originate from memory nodes in the DT, and UEFI
-	 * uses its own memory map instead.
+	 * Discard memblocks discovered so far except for KHO scratch
+	 * regions. Most memblocks at this point originate from memory nodes
+	 * in the DT and UEFI uses its own memory map instead. However, if
+	 * KHO is enabled, scratch regions, which are good known memory
+	 * must be preserved.
 	 */
 	memblock_dump_all();
-	memblock_remove(0, PHYS_ADDR_MAX);
+
+	if (is_kho_boot()) {
+		struct memblock_region *r;
+
+		/* Remove all non-KHO regions */
+		for_each_mem_region(r) {
+			if (!memblock_is_kho_scratch(r)) {
+				memblock_remove(r->base, r->size);
+				r--;
+			}
+		}
+	} else {
+		/*
+		 * KHO is disabled. Discard memblocks discovered so far:
+		 * if there are any at this point, they originate from memory
+		 * nodes in the DT, and UEFI uses its own memory map instead.
+		 */
+		memblock_remove(0, PHYS_ADDR_MAX);
+	}
 
 	for_each_efi_memory_desc(md) {
 		paddr = md->phys_addr;
_

Patches currently in -mm which might be from epetron@amazon.de are

kexec-introduce-is_kho_boot.patch
efi-support-booting-with-kexec-handover-kho.patch


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

* Re: + efi-support-booting-with-kexec-handover-kho.patch added to mm-hotfixes-unstable branch
  2025-08-21 21:30 + efi-support-booting-with-kexec-handover-kho.patch added to mm-hotfixes-unstable branch Andrew Morton
@ 2025-08-26 12:55 ` Ard Biesheuvel
  2025-08-26 23:31   ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Ard Biesheuvel @ 2025-08-26 12:55 UTC (permalink / raw)
  To: Andrew Morton; +Cc: mm-commits, rppt, graf, changyuanl, bhe, epetron

On Thu, 21 Aug 2025 at 23:30, Andrew Morton <akpm@linux-foundation.org> wrote:
>
>
> The patch titled
>      Subject: efi: support booting with kexec handover (KHO)
> has been added to the -mm mm-hotfixes-unstable branch.  Its filename is
>      efi-support-booting-with-kexec-handover-kho.patch
>

Please drop this patch. Once we agree on the right approach, I will
take this via the EFI tree. Thanks.

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

* Re: + efi-support-booting-with-kexec-handover-kho.patch added to mm-hotfixes-unstable branch
  2025-08-26 12:55 ` Ard Biesheuvel
@ 2025-08-26 23:31   ` Andrew Morton
  2025-08-27  2:38     ` Ard Biesheuvel
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2025-08-26 23:31 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: mm-commits, rppt, graf, changyuanl, bhe, epetron

On Tue, 26 Aug 2025 14:55:59 +0200 Ard Biesheuvel <ardb@kernel.org> wrote:

> On Thu, 21 Aug 2025 at 23:30, Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> >
> > The patch titled
> >      Subject: efi: support booting with kexec handover (KHO)
> > has been added to the -mm mm-hotfixes-unstable branch.  Its filename is
> >      efi-support-booting-with-kexec-handover-kho.patch
> >
> 
> Please drop this patch. Once we agree on the right approach, I will
> take this via the EFI tree. Thanks.

This was part of a two-patch series.  You're saying we should split
that series apart?  That this patch has no interaction with [1/2]?

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

* Re: + efi-support-booting-with-kexec-handover-kho.patch added to mm-hotfixes-unstable branch
  2025-08-26 23:31   ` Andrew Morton
@ 2025-08-27  2:38     ` Ard Biesheuvel
  2025-08-27  3:42       ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Ard Biesheuvel @ 2025-08-27  2:38 UTC (permalink / raw)
  To: Andrew Morton; +Cc: mm-commits, rppt, graf, changyuanl, bhe, epetron

On Wed, 27 Aug 2025 at 01:31, Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Tue, 26 Aug 2025 14:55:59 +0200 Ard Biesheuvel <ardb@kernel.org> wrote:
>
> > On Thu, 21 Aug 2025 at 23:30, Andrew Morton <akpm@linux-foundation.org> wrote:
> > >
> > >
> > > The patch titled
> > >      Subject: efi: support booting with kexec handover (KHO)
> > > has been added to the -mm mm-hotfixes-unstable branch.  Its filename is
> > >      efi-support-booting-with-kexec-handover-kho.patch
> > >
> >
> > Please drop this patch. Once we agree on the right approach, I will
> > take this via the EFI tree. Thanks.
>
> This was part of a two-patch series.  You're saying we should split
> that series apart?  That this patch has no interaction with [1/2]?

Please drop both if you think that is more appropriate.

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

* Re: + efi-support-booting-with-kexec-handover-kho.patch added to mm-hotfixes-unstable branch
  2025-08-27  2:38     ` Ard Biesheuvel
@ 2025-08-27  3:42       ` Andrew Morton
  2025-08-27  3:58         ` Ard Biesheuvel
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2025-08-27  3:42 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: mm-commits, rppt, graf, changyuanl, bhe, epetron

On Wed, 27 Aug 2025 04:38:38 +0200 Ard Biesheuvel <ardb@kernel.org> wrote:

> On Wed, 27 Aug 2025 at 01:31, Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > On Tue, 26 Aug 2025 14:55:59 +0200 Ard Biesheuvel <ardb@kernel.org> wrote:
> >
> > > On Thu, 21 Aug 2025 at 23:30, Andrew Morton <akpm@linux-foundation.org> wrote:
> > > >
> > > >
> > > > The patch titled
> > > >      Subject: efi: support booting with kexec handover (KHO)
> > > > has been added to the -mm mm-hotfixes-unstable branch.  Its filename is
> > > >      efi-support-booting-with-kexec-handover-kho.patch
> > > >
> > >
> > > Please drop this patch. Once we agree on the right approach, I will
> > > take this via the EFI tree. Thanks.
> >
> > This was part of a two-patch series.  You're saying we should split
> > that series apart?  That this patch has no interaction with [1/2]?
> 
> Please drop both if you think that is more appropriate.

Why, what happens then?  Will the kexec patch be merged via the efi tree?



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

* Re: + efi-support-booting-with-kexec-handover-kho.patch added to mm-hotfixes-unstable branch
  2025-08-27  3:42       ` Andrew Morton
@ 2025-08-27  3:58         ` Ard Biesheuvel
  0 siblings, 0 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2025-08-27  3:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: mm-commits, rppt, graf, changyuanl, bhe, epetron

On Wed, 27 Aug 2025 at 05:42, Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Wed, 27 Aug 2025 04:38:38 +0200 Ard Biesheuvel <ardb@kernel.org> wrote:
>
> > On Wed, 27 Aug 2025 at 01:31, Andrew Morton <akpm@linux-foundation.org> wrote:
> > >
> > > On Tue, 26 Aug 2025 14:55:59 +0200 Ard Biesheuvel <ardb@kernel.org> wrote:
> > >
> > > > On Thu, 21 Aug 2025 at 23:30, Andrew Morton <akpm@linux-foundation.org> wrote:
> > > > >
> > > > >
> > > > > The patch titled
> > > > >      Subject: efi: support booting with kexec handover (KHO)
> > > > > has been added to the -mm mm-hotfixes-unstable branch.  Its filename is
> > > > >      efi-support-booting-with-kexec-handover-kho.patch
> > > > >
> > > >
> > > > Please drop this patch. Once we agree on the right approach, I will
> > > > take this via the EFI tree. Thanks.
> > >
> > > This was part of a two-patch series.  You're saying we should split
> > > that series apart?  That this patch has no interaction with [1/2]?
> >
> > Please drop both if you think that is more appropriate.
>
> Why, what happens then?  Will the kexec patch be merged via the efi tree?
>

Who knows. But queuing it up now is premature.

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

end of thread, other threads:[~2025-08-27  3:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-21 21:30 + efi-support-booting-with-kexec-handover-kho.patch added to mm-hotfixes-unstable branch Andrew Morton
2025-08-26 12:55 ` Ard Biesheuvel
2025-08-26 23:31   ` Andrew Morton
2025-08-27  2:38     ` Ard Biesheuvel
2025-08-27  3:42       ` Andrew Morton
2025-08-27  3:58         ` Ard Biesheuvel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.