From nobody Sun Feb 8 06:56:17 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 From nobody Sun Feb 8 06:56:17 2026 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (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 9495223313E for ; Fri, 2 Jan 2026 14:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767365628; cv=none; b=cc8wq8/Y4WWTdyA4lVRBV+mxFOL27xGGkRezxuBD/A1ESwsX4rMX4Db53E+EKApswXF8drD5wn8WQErpZMuy0yo/7o2FqDqNpjk7VFca6/iCdF5z/Bg3TssrzJ6Aa/elEsV4fucXeOnKDPAMg7oNjQm6DDI9wyJwBitAHhlmJEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767365628; c=relaxed/simple; bh=1J/J5ij0+LfyJIZQr+aeQQR9ouWDsomWRVfj1KaYkEk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SGYWTLrG5+8gUs9GgGf8+u8U2dDoKN+aQ84NWfUfirEXTBknLXj7OtToyj1y6TW0a6H4D/fZ6zr7WPGhB5pI5W6QOkklee3gVn7+bhkzm8xZATgaQbaFJFN8oRG9ik/75GNCH2/42HAT335/QxkqjiLeujEfImLEu3Tn+GlcKyw= 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.167.171 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-oi1-f171.google.com with SMTP id 5614622812f47-45392215f74so4225742b6e.3 for ; Fri, 02 Jan 2026 06:53:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767365625; x=1767970425; 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=4jFm0T13XSPTZvu12KUE1F2bt+65MnaHKDG0zzV+nX8=; b=C73LLXyhkWrtJ5hcqPQdpryfwBzUXDxfeoJJk+joZuGHxG/O14Ikw1vNF64Q/+nIRj q54L/rzEoyfu0xg6utxU0HZB+8zZgzBV9TDT9TOF0OlW+ZxSsHV8EH6d6kHbBeHdMrsz zq0uTbi9ZmP1E3awuGMx4b5u++zmAdKNWrmX5PBGmpvUkDltcSf6wqZeu9UYsKGIQcPa hlbsDTbjUPVWtXRILwhaDd10pAvEWLOVY8lHm0uqK/DYFskJWjjlrWjzO/HVQcLPMEGK UhjPeNcyRxHhcPa0SMAgX+iaCpoWByPyudxqrE1TDPjp97KA9nqtRwNHzLjBXWQUs+ni XJQg== X-Gm-Message-State: AOJu0YwnB78tT4XaSpQbT5QmbND78FLgq3yTzQBwnhiakIAEHqyVq0wq JL8VEzU56ed4pN/8O1UWPrlFPaF9OgmMRmDVdO3NLp513CLpZUqWjdlH X-Gm-Gg: AY/fxX5B7swaVSdhyJWg1hbAJGDW8LT+RpjkTN7cGSVDE+O4afsa+Z8DFq8O/VAsLGd nKuGtuzuTn6MFLqTIn5PZ9o0o9JQ1A77ta52BXIkcYGx1M+EPkXJKfjabvMNtixwSuyspU08mmq U08ewY1DDU2Wz3EqIJkfuCedhi5PkuR4ilJh+oO3hanbzuuDzen0DOauXcAQDa3FTULqK6VWeYI px1AJLkBqGU3XxRYVXAlYzk8ZxpJL6XpeeywnoXOZVH++2lK5bZ0oPu6F5vVDYTyZBxwJJses14 TYpiCb9jvU9apGp5rFEjs1Ebwt6eLfAnPKnJ+PYYLY6CH1F33yn9TPowhScMPAG3Q8zRiaZIOJd PrYfJwgHftTToRQL8ZJQytw9v2v0+8ZUrxSKePSa064rYOaZ1k0Dfb8psOX7X69xYNkf1Zg+z1R rzrMpr2O4ZkN4yWQ== X-Google-Smtp-Source: AGHT+IGmJX/gWScL9DW7qlBrngJY3793niWXqd+psddu0novXBDKwZolnXT6vOxbAgd6Px9WJeU2HA== X-Received: by 2002:a05:6808:1247:b0:450:b3a:539e with SMTP id 5614622812f47-457b1f09e02mr17787125b6e.28.1767365625515; Fri, 02 Jan 2026 06:53:45 -0800 (PST) Received: from localhost ([2a03:2880:10ff:53::]) by smtp.gmail.com with ESMTPSA id 5614622812f47-457b3cc0928sm19854424b6e.10.2026.01.02.06.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jan 2026 06:53:45 -0800 (PST) From: Breno Leitao Date: Fri, 02 Jan 2026 06:53:24 -0800 Subject: [PATCH v2 2/2] kexec: history: track kexec boot counter 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-2-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=3495; i=leitao@debian.org; h=from:subject:message-id; bh=1J/J5ij0+LfyJIZQr+aeQQR9ouWDsomWRVfj1KaYkEk=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBpV9v1LR8K2jVcyo0Xngo00G/NBInYvKssHASJN f9h88ed14OJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaVfb9QAKCRA1o5Of/Hh3 bUQtD/0brf946ihzUuvEQ6ksdzQPT41UQBAtTG3YPKf+kVRegfC4XfpErJI7CFo0Kwa6aI99E64 QeEd8RMWgVejsfvhMBPHudOp3prj7N6bM9a23ZykDNrIOlo5wTuBKLu/lfFTdOsfC72nVYRdmMM fqm2+ze34QevvPttBHCnFk4vAm0SaZ/szA8A83eg0FCPqVpUl+Ap5e3iCdzH4SWElMiP8+KAUnD ByzlQDuSUkVgwEFzeMrQ7qqzOiGJj2ckyLkgOLrHQSEVUiG36OXaUVbRINc0pc9wpAkLth+JSZC T4F0eU3f9WbrDTK/2xbI4XhvKiNelMCLSrQfS6SjA+ETWtiOYfDv9uIGhrx8lEBnYHKu70E7PQr 4DcCoxOCBmYGv/Ig4U77BW/lR5iieC28cSQST8GNaI1v1lELkHGEHZsQHOm2nQ+h+7hs8JYW5tI DsjmCSqVe+Ckfp3ZzQ7nfgSKb7quOJ+zrvrlFpwoEVsKns3QWmZES6NYw2pyAVTTiPvpTLn+UGP YqG6RQTd0oZinBTrFfcGALM7M4W8wmnBWi1a0DZXYYO6nskdklOAUVBT9knmR1QOZ0qVmpCuLat HS/3LWKSyvzIjC6id9lKy8HKxhfEj9+Br2oWjqXim0XVLEN560iWsilfAyty3cw8KvrBZG9pOu1 MJl+dUxNnXe2YAQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Track and display the number of kexec boots since the last cold reboot when CONFIG_KEXEC_HISTORY is enabled. This extends the previous kernel release tracking feature by adding a counter that increments with each kexec boot. The counter provides visibility into the kexec chain depth, which is useful for understanding boot history in production environments. Add a new property, "kexec-count" in KHO FDT alongside the existing "previous-release" property. The counter is: - Initialized to 0 when kho_in is instantiated. - Incremented by 1 on each subsequent kexec. - Printed alongside the previous kernel release version. The counter is stored as a 32-bit unsigned integer in FDT format and is only active when CONFIG_KEXEC_HISTORY is enabled. Signed-off-by: Breno Leitao Suggested-by: Pasha Tatashin --- kernel/liveupdate/kexec_handover.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_h= andover.c index 06d99627bb3c..fe5a2c5c4c86 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -38,6 +38,7 @@ #define PROP_PRESERVED_MEMORY_MAP "preserved-memory-map" #define PROP_SUB_FDT "fdt" #define PROP_PREVIOUS_RELEASE "previous-release" +#define PROP_KEXEC_COUNT "kexec-count" =20 #define KHO_PAGE_MAGIC 0x4b484f50U /* ASCII for 'KHOP' */ =20 @@ -1257,6 +1258,7 @@ struct kho_in { phys_addr_t scratch_phys; #ifdef CONFIG_KEXEC_HISTORY char previous_release[__NEW_UTS_LEN + 1]; + u32 kexec_count; #endif struct kho_debugfs dbg; }; @@ -1330,6 +1332,9 @@ static __init int kho_out_fdt_setup(void) void *root =3D kho_out.fdt; u64 empty_mem_map =3D 0; int err; +#ifdef CONFIG_KEXEC_HISTORY + u32 kexec_count; +#endif =20 err =3D fdt_create(root, PAGE_SIZE); err |=3D fdt_finish_reservemap(root); @@ -1340,6 +1345,10 @@ static __init int kho_out_fdt_setup(void) #ifdef CONFIG_KEXEC_HISTORY err |=3D fdt_property_string(root, PROP_PREVIOUS_RELEASE, init_uts_ns.name.release); + /* kho_in.kexec_count is set to 0 on cold boot */ + kexec_count =3D cpu_to_fdt32(kho_in.kexec_count + 1); + err |=3D fdt_property(root, PROP_KEXEC_COUNT, &kexec_count, + sizeof(kexec_count)); #endif err |=3D fdt_end_node(root); err |=3D fdt_finish(root); @@ -1468,6 +1477,7 @@ void __init kho_memory_init(void) static void __init kho_print_previous_kernel(const void *fdt) { const char *prev_release; + const u32 *count_ptr; int len; =20 prev_release =3D fdt_getprop(fdt, 0, PROP_PREVIOUS_RELEASE, &len); @@ -1476,8 +1486,19 @@ static void __init kho_print_previous_kernel(const v= oid *fdt) =20 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); + + /* Read the kexec count from the previous kernel */ + count_ptr =3D fdt_getprop(fdt, 0, PROP_KEXEC_COUNT, &len); + if (WARN_ON_ONCE(!count_ptr || len <=3D 0)) + /* + * PROP_KEXEC_COUNT should exist if PROP_PREVIOUS_RELEASE + * exists. + */ + return; + kho_in.kexec_count =3D fdt32_to_cpu(*count_ptr); + + pr_info("This kernel was kexec'ed from kernel release: %s (kexec count: %= u)\n", + kho_in.previous_release, kho_in.kexec_count); } #else static void __init kho_print_previous_kernel(const void *fdt) { } --=20 2.47.3