From nobody Sun Feb 8 06:56:13 2026 Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26DE11DF987 for ; Tue, 30 Dec 2025 14:13:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767104022; cv=none; b=pZsrla7+z8XLX9ysU5EN/FLxWmrWzDhn0F6PpJlujPFmpoY1quoplnKIMBN+5425uH5BuNrZXElCRJIIMYcfUG9ocXVRyf46KpDfbU6kWOmXdLCvw0f6WRR+RUmkONafzfz1S03FYPu2L/IgFfqU4yIWdEzugr/FdzLyOQLVFb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767104022; c=relaxed/simple; bh=gK8KJEjlEAfBqObb/slM/LZJZuItTQI6xDseBucP/Xg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=MnbNhjOcE6a4yq8jnOom1sWdvYXZNtXDxnHczcefIiXFGB4I4pQkqRYzikK4INBWb/1C8xrxCSa409zI4XveEdwJQPiPc1b5W8wiehIHJyeAKHyul5+2tZspwJrCXOrWtBUnF9Ll1oYpIZMA1eOW6M6XWDu9sBiJ8uk8Zr+A2LY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.161.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-65d1f0a9f54so1127905eaf.1 for ; Tue, 30 Dec 2025 06:13:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767104020; x=1767708820; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mLK1D9aqGISPxdXLsfOEkDLEGBqoig1fU8f2AHbKcKI=; b=FnLBSdsLZemTIa3eYS7tF1KpGlqSHBa5Xdg5dNKUPFP+qvBqtQFBSDQIV2/+A6xZHS dHIVj8svZHcAdaMr6IZ7c1BijihrMWe70VLD+0pLevGdkJBy19OKOtIwBs1m54Nt4an/ 1dRK7/LGClJklO1GFL01PcN9tnwJvnqx+dlzLYiCwGbJusegKiy7hCRW7R1d08VehnF2 HMI3GlRMVpnFX47HgQkDHvekVHer5GXqBj/kiSzO4HhSRi2Gsa0wXnDi28AsD/VpQUdv v2bdYkxFwHu00G44kqIG4MD/re0Pm9HwQ8zDH5IpEWNWGpmr+Ec70ioEx4xoSMKv+eTH XwiQ== X-Gm-Message-State: AOJu0YyHESa0cmJr7zyM7Ex37LIFH+UFwC74uBsondcxvr17Yz1NnAi1 lY6dxRKtKlhdoNMTBvLOufHs04TXTB0Uj/KzAX3FqADd6y9xzNzpxChR X-Gm-Gg: AY/fxX6uVE5w6LbxvSsYeiD8jSDs79++pKCB6i45GTQyFMdaLllIqjrACMmyBk0fTUT dAQIyy0WPVUOep+bsgU7M2gUovy0gvuNcdBKPRQyvW87y598v1EtJ700Nj5JxF8QKr1epBQ1bnc yN8PtykeMhkUyWsdcm1Bi2n7fDtANm15pnXJA87dIyI79I7exSVAwi3Q6blQDzW6F3SxaIeX5AI d4hiBfGYSPj2HGBC4iJ5hUsNLFSTvMffJB2qL6EhCPXxTtkbWatB/d3TEdK0DXHCw5DS4jLCIH2 Q4KsVYeHYHzQm3+KzhSZuhG2prDbMep/ccX1eZD2yxrVG8pcA9XwWZxoUkT8btAFjYi9Nz6PrTm 9X7VTx8tUVIuFgJJKwZ1aakyTMeT3XkAVK+wjfDb1kSYC0L0iRAwhhMy2lV3qXNdXmsernvMdoz ocdAmI61xul//ouA== X-Google-Smtp-Source: AGHT+IGv4hgA4RK+/hAqnWuIzxUEbkxk7UI7cZze7GMuRgrBPu7eHE9ZgTQA0cPeHSPZAv5YDbYeLg== X-Received: by 2002:a05:6820:267:b0:65c:fc36:4a6d with SMTP id 006d021491bc7-65d0ea4be60mr10400519eaf.28.1767104020021; Tue, 30 Dec 2025 06:13:40 -0800 (PST) Received: from localhost ([2a03:2880:10ff:4a::]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-65d0f4b7c42sm19071790eaf.6.2025.12.30.06.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Dec 2025 06:13:39 -0800 (PST) From: Breno Leitao Date: Tue, 30 Dec 2025 06:13:23 -0800 Subject: [PATCH RFC] kexec: add option to print previous kernel release after kexec Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251230-kho-v1-1-4d795a24da9e@debian.org> X-B4-Tracking: v=1; b=H4sIAAPeU2kC/6tWKk4tykwtVrJSqFYqSi3LLM7Mz1OyUjDUUVBKz kjMS0/VzUxRslJQMjIwMjU0MjbQzc7I1zU3NzBPtUg0Sk0zTFXSUVAqKEpNy6wAmxKtFOTmrBQ LESwuTcpKTS4B6VeqrQUALnl+n2wAAAA= X-Change-ID: 20251230-kho-7707e8a2ef1e To: Alexander Graf , Mike Rapoport , Pasha Tatashin , Pratyush Yadav Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, usamaarif642@gmail.com, rmikey@meta.com, clm@fb.com, riel@surriel.com, kernel-team@meta.com, Breno Leitao X-Mailer: b4 0.15-dev-47773 X-Developer-Signature: v=1; a=openpgp-sha256; l=5289; i=leitao@debian.org; h=from:subject:message-id; bh=gK8KJEjlEAfBqObb/slM/LZJZuItTQI6xDseBucP/Xg=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBpU94SxD28tleBbvF+TLi4wjE43Uo4k3nzDqek3 Fv/zPpwjAGJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaVPeEgAKCRA1o5Of/Hh3 ba4YD/wI9BraF2/4xSe6rqirbLk4zVpwJGQ2RcsjWPrxVDHiKcj3e0uyeGj5kdNnx+FFsXA3pqa SUnhvSCMrm7vR3FqxrTyeb77jRLtWRSxQiohSjMyu8pqQAGCGL4Wv9dztVb5y/IcWcBtR0J1o+m pt1uzfl4le4JR0LZRllCDBexg+A57AByhm5wXOCT+xxHoMMCzBxWkBBDvM9fy42pgQwdaYsJzTh 20B/OVWtDJ/QQrTfBBPIE9DF9Q+ipIsaAhR99jDObV3L9h/rGnqFb05IIqCdoivDdA0V0smIi6c 7xfpCZSIRAboZdxhscYDxScngYQhSt0kaN2Oeo8/fXJRFo+homluJE2VUrFbC4tayop3th9C9fq aIT9fWMUHse6s9HTsBJuaXuhrgc1m7Cyo1TaHWlOaX/cYjzi8I4yxNNAlSu4zMqwqcIimljF3io DYXtHfaEskHUMd3G5nlxiyRDR1AiOV2434HQIrTf/bfaK7TEKTvaBlt+voftPyhQENAkurkrRiB /Vg7vzd72AUkGAwssxxjSqQOLoTs+1DCUlqQ5lYQIPlR3u++sKPlVAzwLbZAEzacQ/jZAPG4KcL Q2f691EiEYQmosm42BofSABJctYq8o18hGfdgvBGa7JLsV/cwdmNdxyRZgcwmej9VCxdkHOD2GF yH5pXsXX4QlW+Bw== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Introduce a new Kconfig option, CONFIG_KEXEC_SHOW_PREVIOUS_RELEASE, which enables the storage and display of the previous kernel's release version across kexec boots when using Kexec Handover (KHO). Motivation =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Kernel bugs that depend on the version of the previously running kernel are not uncommon, especially in scenarios where a buggy kernel kexecs into a new one and the issue only manifests in the subsequent kernel. Recent examples include: * eb2266312507 ("x86/boot: Fix page table access in 5-level to 4-level pag= ing transition") * 77d48d39e991 ("efistub/tpm: Use ACPI reclaim memory for event log to avo= id corruption") * 64b45dd46e15 ("x86/efi: skip memattr table on kexec boot") As kexec-based reboots become more widespread among Linux users, these issues are becoming increasingly prominent. When such crashes occur, correlating them to the previous kernel version is challenging, especially at scale, where the problem may only appear in specific cases and it is hard to correlate. With the introduction of Kexec Handover (KHO), we now have a reliable mechanism to pass information between kernels. This presents an opportunity to address the problem by carrying the previous kernel's release version to the next kernel and printing it at boot time. Implementation Details =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The feature is controlled by a new Kconfig option, CONFIG_KEXEC_SHOW_PREVIOUS_RELEASE. When enabled, the previous kernel's release version is stored and printed during boot after a kexec. The option is disabled by default to avoid unnecessary overhead for users who do not require this information. Signed-off-by: Breno Leitao --- kernel/Kconfig.kexec | 13 +++++++++++++ kernel/liveupdate/kexec_handover.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec index 15632358bcf7..9f2a669e13aa 100644 --- a/kernel/Kconfig.kexec +++ b/kernel/Kconfig.kexec @@ -94,6 +94,19 @@ config KEXEC_JUMP Jump between original kernel and kexeced kernel and invoke code in physical address mode via KEXEC =20 +config KEXEC_SHOW_PREVIOUS_RELEASE + bool "Print previous kernel version on kexec boot" + depends on KEXEC_HANDOVER + help + When enabled, the kernel will store its release version in the + KHO FDT before kexec, and the newly booted kernel will read and + print this information during early boot. + + This is useful for debugging and auditing to know which kernel + version performed the kexec that booted the current kernel. + + If unsure, say N. + config CRASH_DUMP bool "kernel crash dumps" default ARCH_DEFAULT_CRASH_DUMP diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_h= andover.c index 73da00aeaa99..9e90c8445864 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -21,6 +21,7 @@ #include #include #include +#include =20 #include =20 @@ -36,6 +37,7 @@ #define KHO_FDT_COMPATIBLE "kho-v1" #define PROP_PRESERVED_MEMORY_MAP "preserved-memory-map" #define PROP_SUB_FDT "fdt" +#define PROP_PREVIOUS_RELEASE "previous-release" =20 #define KHO_PAGE_MAGIC 0x4b484f50U /* ASCII for 'KHOP' */ =20 @@ -1253,6 +1255,9 @@ bool kho_finalized(void) struct kho_in { phys_addr_t fdt_phys; phys_addr_t scratch_phys; +#ifdef CONFIG_KEXEC_SHOW_PREVIOUS_RELEASE + char previous_release[__NEW_UTS_LEN + 1]; +#endif struct kho_debugfs dbg; }; =20 @@ -1332,6 +1337,10 @@ static __init int kho_out_fdt_setup(void) err |=3D fdt_property_string(root, "compatible", KHO_FDT_COMPATIBLE); err |=3D fdt_property(root, PROP_PRESERVED_MEMORY_MAP, &empty_mem_map, sizeof(empty_mem_map)); +#ifdef CONFIG_KEXEC_SHOW_PREVIOUS_RELEASE + err |=3D fdt_property_string(root, PROP_PREVIOUS_RELEASE, + init_uts_ns.name.release); +#endif err |=3D fdt_end_node(root); err |=3D fdt_finish(root); =20 @@ -1455,6 +1464,25 @@ void __init kho_memory_init(void) } } =20 +#ifdef CONFIG_KEXEC_SHOW_PREVIOUS_RELEASE +static void __init kho_print_previous_kernel(const void *fdt) +{ + const char *prev_release; + int len; + + prev_release =3D fdt_getprop(fdt, 0, PROP_PREVIOUS_RELEASE, &len); + if (!prev_release || len <=3D 0) + return; + + strscpy(kho_in.previous_release, prev_release, + sizeof(kho_in.previous_release)); + pr_info("This kernel was kexec'ed from kernel release: %s\n", + kho_in.previous_release); +} +#else +static void __init kho_print_previous_kernel(const void *fdt) { } +#endif + void __init kho_populate(phys_addr_t fdt_phys, u64 fdt_len, phys_addr_t scratch_phys, u64 scratch_len) { @@ -1526,6 +1554,8 @@ void __init kho_populate(phys_addr_t fdt_phys, u64 fd= t_len, kho_in.fdt_phys =3D fdt_phys; kho_in.scratch_phys =3D scratch_phys; kho_scratch_cnt =3D scratch_cnt; + + kho_print_previous_kernel(fdt); pr_info("found kexec handover data.\n"); =20 out: --- base-commit: 7620f9ccfabbdaf07620381264d8b8d91412542f change-id: 20251230-kho-7707e8a2ef1e Best regards, -- =20 Breno Leitao