From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795890461; b=rxORUXvu3x5TJvPgdrr0Kee/fL/VuyytyxmPAaSGELUdhOi3AAIc0fnyKf/vDIO7R/qt 6sTnWk9y01J0lTJi1aJOr+ThvQXZ6FJ8GblvtaHNJeJpmwdOpfTuKOT7BesVPJKd8Orpm I1jzGutOLhD6LxRhdausQBSVAhN9OkqzyTZQC9/LJ7gP6UAK8icQ+68Yc5EDyIIYYcq6V jtRD5YaDGKCOxbx1a9llFjDmfEHwh9A7XP/hYFuOGBCRprGGIDWM6d+i80LTzipBMDNtS BRhF8MUGbivyE843WsyBFEotY5TSKdeud+ybY+aMToG1vzidEQcCPHSAgrsLC+POagw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795890461; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:Message-ID:In-Reply-To:References:From:Subject:To:Cc: MIME-Version:Content-Type:Content-Disposition:User-Agent; bh=qS7gE9joH/zv7OfYv0paV200SasrbkYDioRK8oKXElY=; b=JOQ1m6r2Oz7JGoHPIpa3tg8jQKh95uDgpf7J3Yt+Z8RbUDlWNnICH6jUF6sFmmbLKd8a F9NoIRTKVyMScLscT3oSYdw1akogO2wyM3bBf3PG9P9cFrsoFQiJPA6zz5CaFQPU7t7+l P4BVxNPY2AvDpoMa/YPoqSDyd6KMfD7hAu79BGFH2Pe1YPB4sShriqB2cJL1G+Ur2xw6G CelGDndIklMN0CB0I4XfrAMNSnwTIjLDvrYlsJc400QQQ0cw7kzGpRsaLWhkaJhk5BpzG yHBpDPJ83K9NooByPU5LBuX6m5RYIs2pqgV9iLxy9Y/V98glJO/j2ER1CIZLwBJHMEA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chrisdown.name; spf=pass smtp.mailfrom=chrisdown.name; dkim=pass header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b="V90Gn/HM"; arc=none smtp.remote-ip=209.85.128.172 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 754D5606A6A3 for ; Sat, 28 Nov 2026 18:27:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 754D5606A6A3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=V90Gn/HM Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-8b502b9b702so104418027b3.3 for ; Sat, 28 Nov 2026 10:27:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1795890460; x=1796495260; darn=vger.kernel.org; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:references:in-reply-to:message-id:date:from:to:cc :subject:date:message-id:reply-to:content-type; bh=qS7gE9joH/zv7OfYv0paV200SasrbkYDioRK8oKXElY=; b=V90Gn/HMBu1GxBhOIsShPLfCklEXpuemLG6IF5Mg9GMDRagrupvZXFFQ3AIDscFrj0 ExOFvNAe//fCkCcM+XmdqMPTyGGGOBAcjmpfe/1Gr2U2HB2NCH/nU50yJmN722LAPFGa BsDBkjOh2Isp/iKrGPhAvysS8b+IBJnFzuWho= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795890460; x=1796495260; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:references:in-reply-to:message-id:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=qS7gE9joH/zv7OfYv0paV200SasrbkYDioRK8oKXElY=; b=oj7dnS9+4newL3Ii/Fc0Scp+YZyU8k1iSEAq3ZgfWgQxrQ+CO6RL/F+PSUSQvacfg7 8RD5LvPzRR3VZqte5e1J0ZKkvwVR44tkwZAG/xCHUdBFh9o1pYf+3Bya8AUSE/r46Vy6 ZeFyJnd/luf5hscx8F6Pg6+eRSEUxNl7O5Zd1oGTYOJdMuEb7KhoDHbKNTSjdocSmYv/ HrNZnfd6F27W9NIyKZQsu6CY97lwD2zzXPJWEZZSZ4/xerKGdvgpkkSmAlHsm4LYal2s /oWsYGJbPG8mbipNxk8AdmFxvapSWOvtLwbOpOa0Hcx4KNqMIIPb06RZVk1WppcbKGFh 5vJQ== X-Forwarded-Encrypted: i=1; AL+hErEuJWf2RAHBclq1OLDO3HHRS/5aOzd9I3R/ndGxstK9jpiRlrd2AFiIcCOg3HmRNZcRKiFzl8hizdEPWqU=@vger.kernel.org X-Gm-Message-State: APuU4Z93DVfwdkqlxBJwQLVzOFueYEGq9iXJ7IzjTnhisHsWP2KqXrYY PQjmOlVRAph21ZgFOd8NNg5kgIHhliu61IR4mLtwzlRKBwPozybXnAQ9XgILiK5MLX4= X-Gm-Gg: AZFdTZdij11EC9G7NvslJl1mzIo8A3vl+B2jk6pUjgkPg16UOKkNZL/6InPyH+u7rTF 8/UQ8Sr0YSr1uulPx1lLP2MxWLcdhJDLIWOsaJvuqUPtcReT2OJXhlysuIHv3PO/Vixw9fasE0J TZgPCtsvCSnw71Tl6LwDuPyseRQyEUKCMWXYi8XPBscGe/WAA1TtzgL/JL9XF2JIqbDXxtWyvWh HQ2Gnozue+Bo4/038ClTT3X+RVnc7IDCqhYhrgW4v+eO8vcGiM1JBMWn4Lt4+nTXdpuSI9B4UBA lhauESmIXalBeWaXry26uh207X4zn3XPRx3nReDi1mU4AMfDuzlwa+mKD/T+qHChYje906yxley lZ3MpOSCpeLyUK3MJI6n+vE+ObefX5i04cPumtsrZr9y5ge3y0pke0j+u1z/R7mky35i+aZpwnd BCf11MZxohx6kOux6ttP3XB2amUzubIb3oDA7skQZEuS2BuPl2kwBe+Vfb0v7G0tlWdN2XgYvmT ygjhUDcdBGFalV1TYMJACzMAq3YUVtJKD/R36SHNh26ERR3Qh2R8CjKkrmCRGozuItsaUSW9AmB fm3jV39Q7+aluThIEKILz80hXfXpnOcbjDC3H0xG/boaBef5TOXuOCpoG5g7X3PN4AGG1lZ1YTE Ogfz1zX+FeYTxpvpyUrN05FCKTtKHhymdVXq5JpS0zo6hLYsCiEs6NUg4E+nr6kpA+tYrt3rOro ybW8xdtCGJwuyV2vP75eSQ6FAMzWOvyFUmzcLbfz8vsWCwRr+wX5QmRw1yN6k2Zy4ZQeuBXNT4A 7gDCSK+pbVigLwEavE/VUs= X-Received: by 2002:a05:690c:b14:b0:8b4:cb03:c8bd with SMTP id 00721157ae682-8b52051dca4mr104628727b3.68.1795890460589; Sat, 28 Nov 2026 10:27:40 -0800 (PST) Received: from [172.20.0.3] (c-73-207-185-9.hsd1.ga.comcast.net. [73.207.185.9]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b5202fb0a2sm106224897b3.27.2026.11.28.10.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 10:27:40 -0800 (PST) Date: Sat, 28 Nov 2026 10:27:38 -0800 Message-ID: <3131fae711e7e2350689ebf4dbf5cb8209625cf5.1795857773.git.chris@chrisdown.name> In-Reply-To: References: From: Chris Down Subject: [PATCH v2 4/7] kho: Expose rejected handovers that look like cold boots To: Pasha Tatashin , Mike Rapoport , Pratyush Yadav Cc: Alexander Graf , Baoquan He , Jonathan Corbet , Shuah Khan , kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-team@meta.com, Breno Leitao , sashiko-bot@kernel.org X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/2.4.3 (cc9e3943) (2026-10-09) At Meta, our rollout needs to stop if the new kernel rejects the KHO handover. For example, if it doesn't recognise the handover FDT's compatible string, it can boot normally with all the preserved state lost. LUO's incoming/state reads "none", as on a cold boot. We log "disabling KHO revival", but our fleet collector reads procfs and sysfs and can't rely on kernel logs from every host. Let's add /sys/kernel/kho/incoming/state so the collector can tell a rejected handover from an ordinary boot. "revived" means the kernel accepted the handover and completed the preserved memory map walk. LUO reports the outcome of restoring sessions separately. KHO has no sysfs directory yet, so this adds /sys/kernel/kho in its own file, kho_sysfs.c. It is set up separately from kho_init(), because kho_init() returns early when KHO is disabled, and a rejected handover still needs to be reported then. Signed-off-by: Chris Down --- .../ABI/testing/sysfs-class-misc-liveupdate | 3 ++ Documentation/ABI/testing/sysfs-kernel-kho | 11 ++++ Documentation/admin-guide/mm/kho.rst | 8 +++ MAINTAINERS | 2 + kernel/liveupdate/Makefile | 2 +- kernel/liveupdate/kexec_handover.c | 9 ++++ kernel/liveupdate/kexec_handover_internal.h | 8 +++ kernel/liveupdate/kho_sysfs.c | 54 +++++++++++++++++++ 8 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-kernel-kho create mode 100644 kernel/liveupdate/kho_sysfs.c diff --git a/Documentation/ABI/testing/sysfs-class-misc-liveupdate b/Documentation/ABI/testing/sysfs-class-misc-liveupdate index 25e3b49d7aeb..8c3814ee3d37 100644 --- a/Documentation/ABI/testing/sysfs-class-misc-liveupdate +++ b/Documentation/ABI/testing/sysfs-class-misc-liveupdate @@ -19,6 +19,9 @@ Description: read only "deserialized" The sessions can be retrieved. "failed" Deserialization failed. Opening /dev/liveupdate returns -EIO. + + See /sys/kernel/kho/incoming/state for the status of + the underlying KHO handover. Users: system monitoring What: /sys/class/misc/liveupdate/incoming/sessions diff --git a/Documentation/ABI/testing/sysfs-kernel-kho b/Documentation/ABI/testing/sysfs-kernel-kho new file mode 100644 index 000000000000..21488e35d1f3 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-kernel-kho @@ -0,0 +1,11 @@ +What: /sys/kernel/kho/incoming/state +Date: Nov 2026 +Contact: kexec@lists.infradead.org +Description: read only + Status of the incoming KHO handover: + + "none" No handover was passed to this kernel. + "revived" The kernel accepted the handover and completed + the walk of its preserved memory map. + "failed" The kernel rejected the handover. +Users: system monitoring diff --git a/Documentation/admin-guide/mm/kho.rst b/Documentation/admin-guide/mm/kho.rst index 4281da6be5fa..8810813a5d0a 100644 --- a/Documentation/admin-guide/mm/kho.rst +++ b/Documentation/admin-guide/mm/kho.rst @@ -81,6 +81,14 @@ At scale, correlating crashes to the previous kernel version enables faster root cause analysis when issues only occur in specific kernel transition scenarios. +sysfs Interfaces +================ + +``/sys/kernel/kho/incoming/state`` + Status of the incoming KHO handover. + +See Documentation/ABI/testing/sysfs-kernel-kho for the sysfs ABI. + debugfs Interfaces ================== diff --git a/MAINTAINERS b/MAINTAINERS index 5c74e7dfcdc0..baf39fcc0e87 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14779,6 +14779,7 @@ L: kexec@lists.infradead.org L: linux-mm@kvack.org S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux.git +F: Documentation/ABI/testing/sysfs-kernel-kho F: Documentation/admin-guide/mm/kho.rst F: Documentation/core-api/kho/* F: include/asm-generic/kexec_handover.h @@ -14786,6 +14787,7 @@ F: include/linux/kexec_handover.h F: include/linux/kho/ F: include/linux/kho_block.h F: kernel/liveupdate/kexec_handover* +F: kernel/liveupdate/kho_sysfs.c F: lib/test_kho.c F: tools/testing/selftests/kho/ diff --git a/kernel/liveupdate/Makefile b/kernel/liveupdate/Makefile index d9f469462556..6de82ffe8d40 100644 --- a/kernel/liveupdate/Makefile +++ b/kernel/liveupdate/Makefile @@ -7,7 +7,7 @@ luo-y := \ luo_flb.o \ luo_session.o -obj-$(CONFIG_KEXEC_HANDOVER) += kexec_handover.o +obj-$(CONFIG_KEXEC_HANDOVER) += kexec_handover.o kho_sysfs.o obj-$(CONFIG_KEXEC_HANDOVER_DEBUGFS) += kexec_handover_debugfs.o obj-$(CONFIG_LIVEUPDATE) += luo.o diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c index 233c126f6352..aff96aa401f8 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -102,6 +102,7 @@ struct kho_in { phys_addr_t bootmem_phys; char previous_release[__NEW_UTS_LEN + 1]; u32 kexec_count; + enum kho_incoming_state state; struct kho_debugfs dbg; struct kho_radix_tree radix_tree; }; @@ -1744,6 +1745,7 @@ err: */ kho_in.fdt_phys = 0; kho_in.radix_tree.root = NULL; + kho_in.state = KHO_INCOMING_FAILED; } static __init int kho_out_fdt_setup(void) @@ -1770,6 +1772,11 @@ static __init int kho_out_fdt_setup(void) return err; } +enum kho_incoming_state kho_in_state(void) +{ + return kho_in.state; +} + static void __init kho_in_kexec_metadata(void) { struct kho_kexec_metadata *metadata; @@ -1981,6 +1988,7 @@ err: */ kho_in.fdt_phys = 0; kho_in.bootmem_phys = 0; + kho_in.state = KHO_INCOMING_FAILED; } void __init kho_memory_init(void) @@ -2079,6 +2087,7 @@ unmap_bootmem: unmap_fdt: early_memunmap(fdt, fdt_len); report: + kho_in.state = populated ? KHO_INCOMING_REVIVED : KHO_INCOMING_FAILED; if (!populated) pr_warn("disabling KHO revival\n"); } diff --git a/kernel/liveupdate/kexec_handover_internal.h b/kernel/liveupdate/kexec_handover_internal.h index e9685e1ef6d7..b559f5d43116 100644 --- a/kernel/liveupdate/kexec_handover_internal.h +++ b/kernel/liveupdate/kexec_handover_internal.h @@ -22,6 +22,14 @@ struct kho_debugfs {}; extern struct kho_bootmem *kho_bootmem; extern unsigned int kho_bootmem_cnt; +enum kho_incoming_state { + KHO_INCOMING_NONE, + KHO_INCOMING_REVIVED, + KHO_INCOMING_FAILED, +}; + +enum kho_incoming_state kho_in_state(void); + #ifdef CONFIG_KEXEC_HANDOVER_DEBUGFS int kho_debugfs_init(void); void kho_in_debugfs_init(struct kho_debugfs *dbg, const void *fdt); diff --git a/kernel/liveupdate/kho_sysfs.c b/kernel/liveupdate/kho_sysfs.c new file mode 100644 index 000000000000..eb2e4ce72f20 --- /dev/null +++ b/kernel/liveupdate/kho_sysfs.c @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * kho_sysfs.c - kexec handover sysfs interfaces + */ + +#include +#include +#include +#include "kexec_handover_internal.h" + +static const char * const kho_incoming_state_names[] = { + [KHO_INCOMING_NONE] = "none", + [KHO_INCOMING_REVIVED] = "revived", + [KHO_INCOMING_FAILED] = "failed", +}; + +static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + return sysfs_emit(buf, "%s\n", kho_incoming_state_names[kho_in_state()]); +} +static struct kobj_attribute state_attr = __ATTR_RO(state); + +static struct attribute *incoming_attrs[] = { + &state_attr.attr, + NULL +}; + +static const struct attribute_group incoming_group = { + .name = "incoming", + .attrs = incoming_attrs, +}; + +/* + * Set up separately from kho_init(), because kho_init() returns early + * when KHO is disabled, and a rejected handover still needs to be + * reported then. + */ +static int __init kho_sysfs_init(void) +{ + struct kobject *kho_kobj; + int err; + + kho_kobj = kobject_create_and_add("kho", kernel_kobj); + if (!kho_kobj) + return -ENOMEM; + + err = sysfs_create_group(kho_kobj, &incoming_group); + if (err) + kobject_put(kho_kobj); + + return err; +} +late_initcall(kho_sysfs_init); -- 2.56.1