From: Andrey Ryabinin <arbn@yandex-team.com>
To: linux-kernel@vger.kernel.org
Cc: Alexander Graf <graf@amazon.com>, Mike Rapoport <rppt@kernel.org>,
James Gowans <jgowans@amazon.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Baoquan He <bhe@redhat.com>,
kexec@lists.infradead.org, Pratyush Yadav <ptyadav@amazon.de>,
Jason Gunthorpe <jgg@nvidia.com>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
David Rientjes <rientjes@google.com>,
Pratyush Yadav <pratyush@kernel.org>,
Changyuan Lyu <changyuanl@google.com>,
Jonathan Corbet <corbet@lwn.net>,
linux-doc@vger.kernel.org,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
Chris Li <chrisl@kernel.org>,
Ashish.Kalra@amd.com, William Tu <witu@nvidia.com>,
David Matlack <dmatlack@google.com>,
Andrey Ryabinin <arbn@yandex-team.com>
Subject: [PATCH v3 1/7] kho: move fdt setup in separate helper.
Date: Tue, 9 Sep 2025 22:14:36 +0200 [thread overview]
Message-ID: <20250909201446.13138-2-arbn@yandex-team.com> (raw)
In-Reply-To: <20250909201446.13138-1-arbn@yandex-team.com>
Move FDT initialization logic from kho_populate() into a new
helper function kho_fdt_init(). The helper takes care of mapping,
validating, and unmapping the FDT.
This prepares for using KSTATE in KHO instead of FDT.
Signed-off-by: Andrey Ryabinin <arbn@yandex-team.com>
---
kernel/liveupdate/kexec_handover.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
index 364a69a2fa1b..e5a436893f5b 100644
--- a/kernel/liveupdate/kexec_handover.c
+++ b/kernel/liveupdate/kexec_handover.c
@@ -1077,13 +1077,10 @@ void __init kho_memory_init(void)
}
}
-void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len,
- phys_addr_t scratch_phys, u64 scratch_len)
+static int __init kho_fdt_init(phys_addr_t fdt_phys, u64 fdt_len)
{
void *fdt = NULL;
- struct kho_scratch *scratch = NULL;
int err = 0;
- unsigned int scratch_cnt = scratch_len / sizeof(*kho_scratch);
/* Validate the input FDT */
fdt = early_memremap(fdt_phys, fdt_len);
@@ -1107,6 +1104,26 @@ void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len,
goto out;
}
+out:
+ if (fdt)
+ early_memunmap(fdt, fdt_len);
+
+ return err;
+}
+
+void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len,
+ phys_addr_t scratch_phys, u64 scratch_len)
+{
+
+ struct kho_scratch *scratch = NULL;
+ int err = 0;
+ unsigned int scratch_cnt = scratch_len / sizeof(*kho_scratch);
+
+
+ err = kho_fdt_init(fdt_phys, fdt_len);
+ if (err)
+ goto out;
+
scratch = early_memremap(scratch_phys, scratch_len);
if (!scratch) {
pr_warn("setup: failed to memremap scratch (phys=0x%llx, len=%lld)\n",
@@ -1151,8 +1168,6 @@ void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len,
pr_info("found kexec handover data. Will skip init for some devices\n");
out:
- if (fdt)
- early_memunmap(fdt, fdt_len);
if (scratch)
early_memunmap(scratch, scratch_len);
if (err)
--
2.49.1
next prev parent reply other threads:[~2025-09-09 20:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-09 20:14 [PATCH v3 0/7] KSTATE: [de]serialization framework for KHO Andrey Ryabinin
2025-09-09 20:14 ` Andrey Ryabinin [this message]
2025-09-09 20:14 ` [PATCH v3 2/7] kho: move scratch memory in separate helper Andrey Ryabinin
2025-09-09 20:14 ` [PATCH v3 3/7] kstate: Add KSTATE - [de]serialization framework for KHO Andrey Ryabinin
2025-09-09 20:14 ` [PATCH v3 4/7] kho: replace KHO FDT with kstate metadata Andrey Ryabinin
2025-09-10 16:50 ` Rob Herring
2025-09-11 16:54 ` Andrey Ryabinin
2025-09-09 20:14 ` [PATCH v3 5/7] kstate, test: add test module for testing kstate subsystem Andrey Ryabinin
2025-09-10 0:33 ` Randy Dunlap
2025-09-11 17:00 ` Andrey Ryabinin
2025-09-09 20:14 ` [PATCH v3 6/7] mm/memblock: Use KSTATE instead of kho to preserve preserved_mem_table Andrey Ryabinin
2025-09-15 11:47 ` Jason Gunthorpe
2025-09-18 19:00 ` Andrey Ryabinin
2025-09-18 23:14 ` Jason Gunthorpe
2025-09-09 20:14 ` [PATCH v3 7/7] Documentation, kstate: Add KSTATE documentation Andrey Ryabinin
2025-09-10 0:53 ` Bagas Sanjaya
2025-09-11 17:07 ` Andrey Ryabinin
2025-09-10 1:00 ` Randy Dunlap
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250909201446.13138-2-arbn@yandex-team.com \
--to=arbn@yandex-team.com \
--cc=Ashish.Kalra@amd.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=bp@alien8.de \
--cc=changyuanl@google.com \
--cc=chrisl@kernel.org \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=dmatlack@google.com \
--cc=graf@amazon.com \
--cc=hpa@zytor.com \
--cc=jgg@nvidia.com \
--cc=jgowans@amazon.com \
--cc=kexec@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@redhat.com \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=ptyadav@amazon.de \
--cc=rientjes@google.com \
--cc=rppt@kernel.org \
--cc=ryabinin.a.a@gmail.com \
--cc=tglx@linutronix.de \
--cc=witu@nvidia.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox