From nobody Mon Feb 9 06:48:23 2026 Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (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 2C06022D7A5 for ; Fri, 2 Jan 2026 14:53:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767365626; cv=none; b=lpIEfP1rb5AepDPdKGQzkA61Xm5E0PNZufjFY6uYsVP11ZNORRizxPMa7aPLgGmRZKXoTUBxEbnznOMBcX42PKJ7IMNBbSlTA/JiQ0Nb5vNWaqdDYLfY/JgYXJQ5+pVMFSvUvBBLWIvvp0bzAMj8t2GbB4cbeOkKzN1IU4cy5Ns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767365626; c=relaxed/simple; bh=wkabXvOflaMtjicTrJd388Qj/w3vpwAMxUhL5Eu01do=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uEzXFIQ/8pD5luTujCKEjh75eIX81gyyJst9jgGVZRVLmDuAXSAu+pf68Eu9RrrHPQy4HqmUMuQFl+tJpzlnsO2u0W4wxmyilrH9LhiwOdTJPC1bUryO9eufukGo5H+GkK2bCQhyjHQHSR/fYj5wz2V86M5UkBd7FLPi3ajlIok= 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.160.43 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-oa1-f43.google.com with SMTP id 586e51a60fabf-3e89d226c3aso9523415fac.2 for ; Fri, 02 Jan 2026 06:53:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767365624; x=1767970424; h=cc:to:in-reply-to:references: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=yBZj2F93B0VknEVYf7xGk1WgByUhBAGZQZsBhmv5asg=; b=Ga6u3kCEGeU/KwXQeIm8BZzw96dG2HC0n5cz6Xl7+J/BZYmSMZtheO2QNDVD0Ayw0X HPai+gBYuuyB5aESKY95PzWk8TvZtstx8y2wVRk3339fmYWWMs9uXEmpXFdRHrYc5BJq oEGddgGpLHd6AWekoTm2N/skqHyN32+dQsdwC8bVYm2Q/LnMElwxXGmDNnCD4LZQ4r3p 0ZZRCOBK/B2Nz6QVYwmXjU2fpiPwZ/dBn/K1e22YAYuWwFT12yuBfUsYQ4YWCmUcN4/h eo7MVXXbM6XE8VgCAibC6GzGOjy4KK7dmqyKgDj9YqfHEPEFOeI5UKe5Yi2jTwypjSL9 3c7w== X-Gm-Message-State: AOJu0YxzXbchUTUIMYtZEMY9rBO76uc2WJzeF9ACkKryy8jjD+E+mz89 uJM2FMMo/eYPEkwKhNXDkC+2vKX6m96PjJGYxWRjJzgBwkL1mzq8pvUv X-Gm-Gg: AY/fxX4lzznnmTCo6hA4tmd6WaDZoPKu2oWcGwti4zHXjI1/vXmBXaq1n7FaS4JlCvr RtWqhpcHQZKza016+9DMT3VxPyQpaQPBxmgOIY1FNmQQKuYc50kaHWme+PcRPaYYY+2hMWaMfSD 1hroKTcqiZwqiqSNiF21nr3atTrF1pB/mX6k+G0RfAVGR3HPSI/xH7FqAu3emyqFs30qnkOr1We z0La/tYCYi6JH9EdbNgsEI5ripehCF13RI4gr6VPJPkxSZg4QlYjUkbSWpcwE653rKkYA8ksK2J QkiygNQMEHJ052nSGv/iqUqLU3nwktWqD7sup+vbFmRn+nz3NI9N1A1fVG9RL56XRuwj9MEyMHG YFfm/UWGFpwTAHx13zoKTHTGtdvd6iOwskuOCrZQUM4XS3fPLqg/Ijd9/Ygeq7HNOWgWSE8uerE Drtin0O5dHrFHiAA== X-Google-Smtp-Source: AGHT+IFOaVirBFIVBZXp+VZPeHS4wt8YP6E5VjPc88CEkvgr+k+wnwNlOhaQTCbgaVjjYSCBS7oZqQ== X-Received: by 2002:a05:6871:3607:b0:3f5:4172:17 with SMTP id 586e51a60fabf-3fda5481b05mr24323475fac.56.1767365623867; Fri, 02 Jan 2026 06:53:43 -0800 (PST) Received: from localhost ([2a03:2880:10ff:50::]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-3fdaac145bcsm23292303fac.22.2026.01.02.06.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jan 2026 06:53:43 -0800 (PST) From: Breno Leitao Date: Fri, 02 Jan 2026 06:53:23 -0800 Subject: [PATCH v2 1/2] kexec: history: track previous kernel version 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: <20260102-kho-v2-1-1747b1a3a1d6@debian.org> References: <20260102-kho-v2-0-1747b1a3a1d6@debian.org> In-Reply-To: <20260102-kho-v2-0-1747b1a3a1d6@debian.org> 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, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.15-dev-47773 X-Developer-Signature: v=1; a=openpgp-sha256; l=3988; i=leitao@debian.org; h=from:subject:message-id; bh=wkabXvOflaMtjicTrJd388Qj/w3vpwAMxUhL5Eu01do=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBpV9v1U6zJLO/ry+WPczyFJZR1wa6NiK54DUKmT /oKNSxUEUWJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaVfb9QAKCRA1o5Of/Hh3 bRJyD/4sYGh1GsPWiH6s8aw30fI88MqDBiSHTaYzpuOZCJMhkh1im4Uqn0+m95TXj5JEClEJV8d gIardAHHIJ8vnaLCm2ex+aTkT3SWIUoHp74QgDp0VtP6QHqbsp+RK+cCyNokL89rWx2/RsJfwzp n1Hoc5m1P4F8MJjksTjNdceX2C1zrJ8iLlzjnlUiTDQKZQng+7nJz2LhzeoXFLU9PqW0kJ5Vhtp epab9wfi+G4uEFf4GCU2h5xLiBBenVW/woOk6XXfMSi8QchtXwx/6qQ3LBKNZX0xHEQkOO9GUrl WkYdO3KVJ1x6joMJcins4nEPiantJViFgi4EW22q8TcuMTAQZZZCDdlJI2fBTm3+g1XboDOjZSh 8bA2PBGH2BnpccZffEraNywxbyK3hROLRsxrKvcJw+vDHnLRk7pU24j/tVPwUEw/v+ca+qC4gMO xOQjHJc7sv6QO1+ug+/gys3oM8FU6KpKiV2yHoxrLgv1FEx1wT5VTbCX4lA6ncA20QFfwDYFgdf b7yptHQN0RsyLF6WC/YxU0snOsIO95kx/E54y6SRO8lJuLp15Vh8pvD+ni/uRYUSYRX3/I5W179 JM9EXTiuctOk+dk78FPHuCWSXV5kV0wA0tmuHpnz7xgj/09oQNH7pZJ9bJC59NEi7/Wihbbx8lA 5iKY0CP3fzn2maw== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Add CONFIG_KEXEC_HISTORY to store and display the kernel version from the previous kexec boot. When enabled, the current kernel's release string is saved to the "previous-release" property in the KHO device tree before kexec. On the next boot, if this property exists, the previous kernel version is retrieved and printed during early boot. This helps diagnose bugs that only manifest when kexecing from specific kernel versions, making it easier to correlate crashes with the kernel that initiated the kexec. Disabled by default to avoid overhead for users who don't need this information. Signed-off-by: Breno Leitao --- kernel/Kconfig.kexec | 13 +++++++++++++ kernel/liveupdate/kexec_handover.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/kernel/Kconfig.kexec b/kernel/Kconfig.kexec index 15632358bcf7..b770c68a3800 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_HISTORY + bool "Track kexec kernel history" + 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..06d99627bb3c 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_HISTORY + 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_HISTORY + 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_HISTORY +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) { @@ -1527,6 +1555,7 @@ void __init kho_populate(phys_addr_t fdt_phys, u64 fd= t_len, kho_in.scratch_phys =3D scratch_phys; kho_scratch_cnt =3D scratch_cnt; pr_info("found kexec handover data.\n"); + kho_print_previous_kernel(fdt); =20 out: if (fdt) --=20 2.47.3