From nobody Mon Feb 9 13:35:58 2026 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (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 EBB862D8DB5 for ; Thu, 8 Jan 2026 16:41:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767890485; cv=none; b=FBzYZIpo6KDu6H94X2BBqepQUb05+oTwD49SVHNEgIJUkJZUSSxYwYZSqyDpkI3InsNli9937ku4q45espVfKk4Ddr1tUuv/kW+rErr69CDmNQJFYh808KQxiNHVX0bdHzrHF9PM8l/hnSDbI10xGf7EcI2BFWz/mMPqryo95Mk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767890485; c=relaxed/simple; bh=EGjW1NDVm9NCUZnt/TocKG3VnYx6DZQuPLEer3uoR8g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZA9OkVtWfiQP6OFzTK644CcHODlCXMpFW5OMRLclAhoTzGsBTXJi6q88yoF+5G8QH6N5z3sftC22+QE7UDzBT+cBqxgwtLZNWjRsN4UO5QQdCbqMEukEOOlkVqWJFfT+A5Cuf+zZ7nZc0Hw3z1d6p9HP3rOWBgy8Mhi78GQaYBY= 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.172 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-f172.google.com with SMTP id 5614622812f47-45a84c6746cso147478b6e.1 for ; Thu, 08 Jan 2026 08:41:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767890483; x=1768495283; 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=iZ8umbGJ/p+Drr1QM9elVdtntyBO93C2g1yduoenlV8=; b=lGAPKSo5cdZzpv0CavsRePyxvdCo4EHTxUctWTp7bvyPJu03A1iVU28D8vx6dfPa8G ZPJGAIqD6+Ub7R+B6Qc4398tBp32hOCf2w9aRVr21jtcUuxPbMYGFj4U/YQ9zbPAK3sE Uz/v/Hm7zmcDEZ+3uw7ba3Ar08+2doX/jjLUpneFodM8Q7TxzU0+tceATheNt14RTWaw ivNqiCsj2ookWLRu8sW1XTlLI0Mfe0b456uXb3YP0lzWXEtBg3ZWagMKyTHdGjY83YLw BjqClt1L0IECOVQ3NYxIKm0puVRwJjnYsXqqngy4mSlb4NF5TE1swVdZaVcfOAOnGMKo xWZg== X-Gm-Message-State: AOJu0Ywc6tjKHuBo+6h2Nsbf5FepVmYu4dros9xLtJsyzXwmISIs2zIj M5o09QxFWW3nVUwZRdNrhDtzgvV3QlkMq8lE0OLhdSKJ0b7AFuLggciE X-Gm-Gg: AY/fxX4zkVHTOHY0lWPmKpLfoILzgr8aKVwgmB0lc9Vv379yQHw6rU4bG2/o0PL0x9D 2Uf/RGnKJc+5ZrDG20PXqGqCbTLMqt8ALhono3yKy59a6WHNOPLvHTTN9GorrZKlNPP1jbxPznA YppCm84UbSrvHCOMC6UkL7YjdgxWEdLsorux3bwgzn+4zfjAP6N7e2uRE2yqPeo0Lvkj8+FEiKk 3ZQe222GwfRtAujNcJX4XjBQj8F3kpO29iF9aCX9HWJyERAm+KFDaOKTduM/vhKS52sikpRk3fH ubmaDYCZB7U9hRSE+ARWkmE0NM/3mVR+4e3U0Zqrwye8SBetI1OBTkpRwaUZewFhZGf7I0SjB3+ eitTQAXmSdM73feXw2yFDXmmQmMoiiy3nGnnf05Jc0knkHfYgx6ZLYCzheoRnhRW768wyceRgZo Y/mg== X-Google-Smtp-Source: AGHT+IHCIuadUBoGbDl8lPNAk2Neo0/wiZHMcJrJn3lIxd7Vxi/rrb+Y2bIjsKx5NXNgYjuC3j6EEw== X-Received: by 2002:a05:6830:1cc2:b0:7c5:3045:6c6f with SMTP id 46e09a7af769-7ce50a28c93mr3497087a34.20.1767890482801; Thu, 08 Jan 2026 08:41:22 -0800 (PST) Received: from localhost ([2a03:2880:10ff:43::]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7ce478af8besm5595632a34.14.2026.01.08.08.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 08:41:22 -0800 (PST) From: Breno Leitao Date: Thu, 08 Jan 2026 08:40:59 -0800 Subject: [PATCH v3 2/2] kho: 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: <20260108-kho-v3-2-b1d6b7a89342@debian.org> References: <20260108-kho-v3-0-b1d6b7a89342@debian.org> In-Reply-To: <20260108-kho-v3-0-b1d6b7a89342@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=3603; i=leitao@debian.org; h=from:subject:message-id; bh=EGjW1NDVm9NCUZnt/TocKG3VnYx6DZQuPLEer3uoR8g=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBpX94vFhyv1+q5nq7d3U4aG09l2a2v9OVLjM38M Alw0viiRZ2JAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaV/eLwAKCRA1o5Of/Hh3 bYQwD/9eHb6ErCrxXzsTuDNHlKgULxd03DOyrKRfmQu7kTOUtZlqSCyZ4P2EeLCfbluUpJnnESG UAVFWIxNs7YXzhUNd7cWqmoZH+mBLVOby7T8HD+MeG+8z6VuUQXpE9mQVEsS0N5g0L6+FWWFgAd VqezYtxXpJeV32vXCpcmBEcZpUE3od+8MAIK1LqWcUbsCKLy/0kXXemulGMzLks31aLqX86ni/i X+9lZpg99/gVXF8Jz3lqX+hNi9TIRsXWGaU281XTD1tF3BgTcXXCyHE8m15DjbelamQimU3chBg DMteI6JOK4sjOWjTLtutUHeHuUwcuuUpiTc2Zk+pvF6X4ij24/VQcoCVl9QLiHL4EjTlbYaXGMK eh6yLVMjs32YEVhnOxY850v6dWpXovo5PFQUd3ECljjlvTmrD6aLrQh1g92CX7sPIoJYTOEIl8x 81RtpCzW+Gky6ezAfpzbZfnGAJrQi2XvgB6Y7xvZEiDsGTKtnNKeHZ4uZDf2xt0EBZmbk8aP4Rd IQ/tPzLyEsBSAJTjlPDAIaeEFRFmBwoI1s/vu1zCB0DiRnm6/tnremV8GX/ewBSbiyaDWX2+8zH AzQ0hXXhX98UteCdW/+vC7v/59qftT+spmlGWRF8WqkY9v/ZZwZ3kMESQjBGioYQXj3Q3+SR7BB FQswweva+CDz0Zg== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D Track and display the number of kexec boots since the last cold reboot. This extends the previous kernel release tracking 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 on cold boot (when kho_in is first 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. This is different than counter for LUO, given KHO can be used independently from LUO. Also WARN() if KHO_PROP_PREVIOUS_RELEASE doesn't exist, because it must exist if KHO_PROP_PREVIOUS_RELEASE exists. Signed-off-by: Breno Leitao Suggested-by: Pasha Tatashin --- include/linux/kho/abi/kexec_handover.h | 3 +++ kernel/liveupdate/kexec_handover.c | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/linux/kho/abi/kexec_handover.h b/include/linux/kho/abi= /kexec_handover.h index f4f31e8f575b..9c4fc4c6a212 100644 --- a/include/linux/kho/abi/kexec_handover.h +++ b/include/linux/kho/abi/kexec_handover.h @@ -87,6 +87,9 @@ /* The FDT property to track previous kernel (kexec caller) */ #define KHO_PROP_PREVIOUS_RELEASE "previous-release" =20 +/* The FDT property to track number of kexec counts so far */ +#define KHO_PROP_KEXEC_COUNT "kexec-count" + /** * DOC: Kexec Handover ABI for vmalloc Preservation * diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_h= andover.c index b2d57868d22f..34cfc98076b8 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -1248,6 +1248,7 @@ struct kho_in { phys_addr_t scratch_phys; phys_addr_t mem_map_phys; char previous_release[__NEW_UTS_LEN + 1]; + u32 kexec_count; struct kho_debugfs dbg; }; =20 @@ -1319,6 +1320,7 @@ static __init int kho_out_fdt_setup(void) { void *root =3D kho_out.fdt; u64 empty_mem_map =3D 0; + u32 kexec_count; int err; =20 err =3D fdt_create(root, PAGE_SIZE); @@ -1329,6 +1331,10 @@ static __init int kho_out_fdt_setup(void) sizeof(empty_mem_map)); err |=3D fdt_property_string(root, KHO_PROP_PREVIOUS_RELEASE, init_uts_ns.name.release); + /* kho_in.kexec_count is set to 0 on cold boot */ + kexec_count =3D kho_in.kexec_count + 1; + err |=3D fdt_property(root, KHO_PROP_KEXEC_COUNT, &kexec_count, + sizeof(kexec_count)); err |=3D fdt_end_node(root); err |=3D fdt_finish(root); =20 @@ -1443,15 +1449,23 @@ void __init kho_memory_init(void) static int __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, KHO_PROP_PREVIOUS_RELEASE, &len); if (!prev_release || len <=3D 0) return -ENOENT; =20 + /* Read the kexec count from the previous kernel */ + count_ptr =3D fdt_getprop(fdt, 0, KHO_PROP_KEXEC_COUNT, &len); + if (WARN_ON(!count_ptr || len !=3D sizeof(u32))) + return -ENOENT; + kho_in.kexec_count =3D *count_ptr; + strscpy(kho_in.previous_release, prev_release, sizeof(kho_in.previous_release)); - pr_info("exec from: %s\n", kho_in.previous_release); + pr_info("exec from: %s (count %u)\n", kho_in.previous_release, + kho_in.kexec_count); =20 return 0; } --=20 2.47.3