From nobody Sat Oct 4 06:37:14 2025 Received: from pdx-out-009.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-009.esa.us-west-2.outbound.mail-perimeter.amazon.com [35.155.198.111]) (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 282AC21B9DA; Tue, 19 Aug 2025 23:24:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.155.198.111 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755645892; cv=none; b=UsHtlA7cUU8szflsSoOIwUE4TWSYzhtqoKmH0nsxMPYNUNOdCpysfxDpGDZT42t//6Hjup6I42wWJwvz7wFdott17kMHibtKMeacBjr1jHRk7iF5cPCs2AeLewp2gt+yBJaGpXRz0OJrO4ddX2jW9kGoqexoA9luxMwrMWCsThc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755645892; c=relaxed/simple; bh=7tVscKwHqLj9p6JD4sEM9kG1z7+dyGh6VMgNIUWfBOk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s1dirpFbKuidec+R9FtvGCQ9uCh18EeYZnCNcrmMPBcf4idk2pt39jddIThPSuHZHX7cwdSmc/4QNWqxd0bSqXIUFVU6PBuTR17B66iz8kVW9mzrESFZnmimxKCWRbfc+zurdLDr5E0mgvVdFc35jaMIGNZsqgyloVoKE+GNFhk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de; spf=pass smtp.mailfrom=amazon.de; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b=D7PbGt0H; arc=none smtp.client-ip=35.155.198.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b="D7PbGt0H" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1755645891; x=1787181891; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tF++dyX6f56vFwu3NGpYE/r8N67nbsIdg66sRFyfopY=; b=D7PbGt0HtxHakCjAVtiKLt5wjmTCDuAXa4f7uotA0Ra8U4D5DJ/xCuAp pgw/rTrksS963rBSe+4Yf223LSLHTuFR0eotJt7H9+lL0ZHyks3vRIpWw 3LMTU9ejAf51R/NTcqkIIurgC0lcOpDAPoKyi60E0nCIZElUogxnRboan hQGw8sjhNC2gAm0Sxpzq7veDLa8pIMyeDDsmbSKGo8lmpxqlYtt2H8m2m VDfQdCwNIUfjNVG/V3JiCjW1zW425bJw4YG/P8Xtr6EGn40IbG5+bXyGS Z1AIdjixh9C72tfIqfjIliurepxnZv8XCD+dS6PpCtQW+g8am00/+Awp5 g==; X-CSE-ConnectionGUID: HB4nEjqHQxipsnhSvM8fbw== X-CSE-MsgGUID: 8RszvGG1R/2We4GiosIQLg== X-IronPort-AV: E=Sophos;i="6.17,302,1747699200"; d="scan'208";a="1284831" Received: from ip-10-5-9-48.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.9.48]) by internal-pdx-out-009.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2025 23:24:48 +0000 Received: from EX19MTAUWA001.ant.amazon.com [10.0.21.151:36246] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.29.152:2525] with esmtp (Farcaster) id 54c19edc-accf-4bc3-a6cd-bccc3df96575; Tue, 19 Aug 2025 23:24:48 +0000 (UTC) X-Farcaster-Flow-ID: 54c19edc-accf-4bc3-a6cd-bccc3df96575 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWA001.ant.amazon.com (10.250.64.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.17; Tue, 19 Aug 2025 23:24:48 +0000 Received: from dev-dsk-epetron-1c-1d4d9719.eu-west-1.amazon.com (10.253.109.105) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.17; Tue, 19 Aug 2025 23:24:46 +0000 From: Evangelos Petrongonas To: Ard Biesheuvel , Mike Rapoport CC: Evangelos Petrongonas , Alexander Graf , Changyuan Lyu , Andrew Morton , Baoquan He , , , , , Subject: [PATCH v2 1/2] kexec: introduce is_kho_boot() Date: Tue, 19 Aug 2025 23:22:45 +0000 Message-ID: <7043f4da31390c58bb7721a3774c30998997df44.1755643201.git.epetron@amazon.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D038UWC003.ant.amazon.com (10.13.139.209) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" During early initialisation, after a kexec, other components, like EFI need to know if a KHO enabled kexec is performed. The `kho_is_enabled` function is not enough as in the early stages, it only reflects whether the cmdline has KHO enabled, not if an actual KHO FDT exists. Extend the KHO API with `is_kho_boot()` to provide a way for components to check if a KHO enabled kexec is performed. Signed-off-by: Evangelos Petrongonas Reviewed-by: Mike Rapoport (Microsoft) --- include/linux/kexec_handover.h | 6 ++++++ kernel/kexec_handover.c | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/kexec_handover.h b/include/linux/kexec_handover.h index 348844cffb13..559d13a3bc44 100644 --- a/include/linux/kexec_handover.h +++ b/include/linux/kexec_handover.h @@ -40,6 +40,7 @@ struct kho_serialization; =20 #ifdef CONFIG_KEXEC_HANDOVER bool kho_is_enabled(void); +bool is_kho_boot(void); =20 int kho_preserve_folio(struct folio *folio); int kho_preserve_phys(phys_addr_t phys, size_t size); @@ -60,6 +61,11 @@ static inline bool kho_is_enabled(void) return false; } =20 +static inline bool is_kho_boot(void) +{ + return false; +} + static inline int kho_preserve_folio(struct folio *folio) { return -EOPNOTSUPP; diff --git a/kernel/kexec_handover.c b/kernel/kexec_handover.c index 69b953551677..a1a4e76e0ff1 100644 --- a/kernel/kexec_handover.c +++ b/kernel/kexec_handover.c @@ -925,6 +925,26 @@ static const void *kho_get_fdt(void) return kho_in.fdt_phys ? phys_to_virt(kho_in.fdt_phys) : NULL; } =20 +/** + * is_kho_boot - check if current kernel was booted via KHO-enabled + * kexec + * + * This function checks if the current kernel was loaded through a kexec + * operation with KHO enabled, by verifying both that KHO is enabled via + * cmdline AND that a valid KHO FDT was passed. + * + * Note: This function returns reliable results only after + * kho_populate() has been called during early boot. Before that, + * it may return false even if KHO data is present. + * + * Return: true if booted via KHO-enabled kexec, false otherwise + */ +bool is_kho_boot(void) +{ + return !!kho_get_fdt() && kho_enable; +} +EXPORT_SYMBOL_GPL(is_kho_boot); + /** * kho_retrieve_subtree - retrieve a preserved sub FDT by its name. * @name: the name of the sub FDT passed to kho_add_subtree(). --=20 2.47.3 Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13 10243 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597