From nobody Fri Oct 3 00:04:13 2025 Received: from forwardcorp1a.mail.yandex.net (forwardcorp1a.mail.yandex.net [178.154.239.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 207EA2AD0C; Tue, 9 Sep 2025 20:15:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.154.239.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757448940; cv=none; b=UeWFavAS8DthztEZkRs+nd7qVy+br+kx6jWBhwlWAvN8S88artcS6xsbLOQtmkgmxnRvw8ojE1oWNNyC+iE5cmiAsywTBi6BWNQIPsEDoeWaOrfc/bgU3Ok1IKzXCCZQOUGG27o6WL6G+qUs4p2YUiFVQN0szRHeGliX+DxHWRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757448940; c=relaxed/simple; bh=epzB1q1ey7mcrlZUHSpH2WU1v4WMKeXwXIlTlN92sAg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rw/AehRm2FM+Ect1apdXVM41fuGIoP9MLqg76KBm8Xf1ZFFfCvz+x7pLTuE0qMcZwUrhe5cKqHLQKCCZxquCK4BQ3yoj+fAvHwdLnYXvU0PcIedb1GfGAkQUDGmax8GuKga2VsNz1Nbex/ru9o1uZVsZA5KHLiWYzq04GQBBNNA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex-team.com; spf=pass smtp.mailfrom=yandex-team.com; dkim=pass (1024-bit key) header.d=yandex-team.com header.i=@yandex-team.com header.b=neGSZgoq; arc=none smtp.client-ip=178.154.239.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex-team.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex-team.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex-team.com header.i=@yandex-team.com header.b="neGSZgoq" Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 03AC6C0178; Tue, 09 Sep 2025 23:15:29 +0300 (MSK) Received: from localhost.localdomain (172.31.115.73-vpn.dhcp.yndx.net [172.31.115.73]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id IFQqlX5GteA0-l4Vy856v; Tue, 09 Sep 2025 23:15:28 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.com; s=default; t=1757448928; bh=BrTg0k8lCV2HUq6REznRngkexlNL5x/b5e/pmlQ15ZI=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=neGSZgoqXYXwpLcgher3hOxnbUXCh+LnfyKfxD6OWkli/tXddCyRc7h06ZF74m86Z KOW7OV80CpU3W0NMV/XxwboV0qA0Cd5wpuLTqhRluGsQJYAxSqi2Imnkg+R/1mMtyN lhAVl+kpBSt43LU/t9BrjK5i3nl0JtZpUGJwqX/w= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.com From: Andrey Ryabinin To: linux-kernel@vger.kernel.org Cc: Alexander Graf , Mike Rapoport , James Gowans , Andrew Morton , linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Baoquan He , kexec@lists.infradead.org, Pratyush Yadav , Jason Gunthorpe , Pasha Tatashin , David Rientjes , Pratyush Yadav , Changyuan Lyu , Jonathan Corbet , linux-doc@vger.kernel.org, Andrey Ryabinin , Chris Li , Ashish.Kalra@amd.com, William Tu , David Matlack , Andrey Ryabinin Subject: [PATCH v3 1/7] kho: move fdt setup in separate helper. Date: Tue, 9 Sep 2025 22:14:36 +0200 Message-ID: <20250909201446.13138-2-arbn@yandex-team.com> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250909201446.13138-1-arbn@yandex-team.com> References: <20250909201446.13138-1-arbn@yandex-team.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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_h= andover.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) } } =20 -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 =3D NULL; - struct kho_scratch *scratch =3D NULL; int err =3D 0; - unsigned int scratch_cnt =3D scratch_len / sizeof(*kho_scratch); =20 /* Validate the input FDT */ fdt =3D early_memremap(fdt_phys, fdt_len); @@ -1107,6 +1104,26 @@ void __init kho_populate(phys_addr_t fdt_phys, u64 f= dt_len, goto out; } =20 +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 =3D NULL; + int err =3D 0; + unsigned int scratch_cnt =3D scratch_len / sizeof(*kho_scratch); + + + err =3D kho_fdt_init(fdt_phys, fdt_len); + if (err) + goto out; + scratch =3D early_memremap(scratch_phys, scratch_len); if (!scratch) { pr_warn("setup: failed to memremap scratch (phys=3D0x%llx, len=3D%lld)\n= ", @@ -1151,8 +1168,6 @@ void __init kho_populate(phys_addr_t fdt_phys, u64 fd= t_len, pr_info("found kexec handover data. Will skip init for some devices\n"); =20 out: - if (fdt) - early_memunmap(fdt, fdt_len); if (scratch) early_memunmap(scratch, scratch_len); if (err) --=20 2.49.1