From nobody Tue Feb 10 00:57:53 2026 Received: from mail-yx1-f52.google.com (mail-yx1-f52.google.com [74.125.224.52]) (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 7A35833436D for ; Fri, 14 Nov 2025 15:54:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763135654; cv=none; b=OkIg1mVE8BhmxUhpR+vniVPZniDEvbBXgXzFhvWaZRX9MxFgg4/PjHcSyQWqBRupzU7hFcGwBaBInFrUp+qDv7/kyFhm3yOfdMZmhqkL00G1UXB3oxkBNYKDBklkH9S9bp1JhurfnnG6bk7Duc9RQfX/TqBp8woqG1XgXf1sMzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763135654; c=relaxed/simple; bh=cq7IzzF8tpHIaPBKDmpjd17BayBAy0OBGUhdhDTAtSs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OCP0yNEcp20eajX7xicXgPfBv4BiaoW+KSZ8eNfnIhneCylQUOFMp8OnbTaAYyBK6hCe7k4tSJfcaEtlXp08qNFkcTWbjeHXCfNovJfCakXY5oKLlku6rvNxJSzIRaZbLgMro5ztuhq1ZML8hlKRlail0DPa5wlGmUpu3vO7e2Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b=OypAr+lg; arc=none smtp.client-ip=74.125.224.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="OypAr+lg" Received: by mail-yx1-f52.google.com with SMTP id 956f58d0204a3-63fca769163so2009497d50.2 for ; Fri, 14 Nov 2025 07:54:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1763135651; x=1763740451; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=oAQesQhs6e+PTptufLvrkGE1DQZP/NgJYpEOzUVqdGc=; b=OypAr+lgCs5epDXrH/AagqJFxEiWk6QELxX19O+QslzeFQR+xQWDjfHROs8WRhAzYZ WpY5IwvA/77Bz/Rv73RyGGN64v217peFx/w6iqL+O3F8kbqBat+Zv9YG6dSjbt3hecy4 Vlh+tQMmznw4ZEccPnMS+MS+eqdsa6rMiuTi7ZUfPY5FlxDkvaNyi3n1Fg8CQNaUWijE a/SLhGRnEFJjoWuay0EUDEoXPaN3WVZlDiONYAgKP8WJMnz+VsqPXuF0CMNjjboXi1HO nljejLEKMoRHUKmWyVx1Ze3TW7ZvbOZ58WdB4rVKaliKp2ikKfXB6HAHv3LNGybtxWP7 PziQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763135651; x=1763740451; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=oAQesQhs6e+PTptufLvrkGE1DQZP/NgJYpEOzUVqdGc=; b=Feyi63Ap3ARs7nkGpwForScpjFxdnv+hn7oovdzeVBnzcLyE3AJciu/wJnKFzB5Vcg jyu3Lh08CyABCc+/FhyPgr4StSE/I/y98pGY5lVikfPN37iLmnbl6rXEw9Z/SsSsee9b ryq9TbiWDZMYaEIVR6yqlIeHKGYp/ZfJ6PcPMkW5ZrfWIG76roLl2dytGbWvjtN7K1YJ QGEq4YX0ePk35/abXbcCuQcxUssGrqWw939NQAJLv9jsrQK7OI8WdWixw1TdapPsQ9EY 1iQaBs11hmvq3PsYnfjkezbLQPJ+wuLg9Ybt1rE2/A4RZIWXaksmwmpgjdpMW2ebh7oG yQtw== X-Forwarded-Encrypted: i=1; AJvYcCU3C6nSQ1Rqz315RLZcrQODrZzH0F1l5mmu3PPtCyeDnB1kfkYi8xS0PJW4HO1+LMe417krB5JnEtNGD30=@vger.kernel.org X-Gm-Message-State: AOJu0YzP2JfhTbFLwbg0R9qyPSTAoISu58cBXAOsuupmylpo/G3MiBaU HBmVuYIZlRO6hfdkq4/5S6RR6CExYPDMKzTMWWjOHJA6lATjSJTXJ7b3ULJbeqJkPq8= X-Gm-Gg: ASbGncu79plWkyGiqq+CSroXTUthsbVZU1OqMckAD/4c7lRi9nMy20o1sTpH52i8xPM TgysC4PtkvxN6nM9lbiAA17B4RtrXgrcTM18nrUSlhGarX0ubKp8Tkmi8ki4l3JIqz96rWPXoNe EcL9d2YTPRMOhF7xfBjdKbNEloNtT0doxZY/n9A+SQW6kCCzkIAnZNLd1Mmfe2cI/35mOgjAvpm qRp4sRtyRKKggQXIWjAGVxazYUFroSPjb7w+2pU41p9VDE8jLTuy9AxzX62lqN8KZdIvuEt85MX Pzizs+bkU4AjUVkSKSn7zs0DRw1swAFXf9au0PMoZ6yYZQOPFkoNrDx0xGkWX3RdYQobREcQoEv OsbRTWDmTOPQgkO83Kw8RjSBdI75maLjE2ki57UFRfnyTFGuMBvUNMvW+5EaZR2b1kZfmoIrmA7 pRMFuzccLoxMCFLDEgaFbGw+0rCbedEvoQi/FW/uOBo9kknVCx5WKxZpSOfK+MF8aUVYkSdWLLs a7p5/Y= X-Google-Smtp-Source: AGHT+IGlvukkElqwWxXv7Gpk1y3f7JDTm4WbhlGwLIf1Tn2iiPc/ZeTFQ6+QGmg6hTPSZZWz9TZhAg== X-Received: by 2002:a53:d013:0:b0:63f:b952:dfef with SMTP id 956f58d0204a3-641e7280bb1mr3380829d50.0.1763135650981; Fri, 14 Nov 2025 07:54:10 -0800 (PST) Received: from soleen.c.googlers.com.com (182.221.85.34.bc.googleusercontent.com. [34.85.221.182]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78822125317sm16468577b3.37.2025.11.14.07.54.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Nov 2025 07:54:10 -0800 (PST) From: Pasha Tatashin To: akpm@linux-foundation.org, bhe@redhat.com, pasha.tatashin@soleen.com, rppt@kernel.org, jasonmiu@google.com, arnd@arndb.de, coxu@redhat.com, dave@vasilevsky.ca, ebiggers@google.com, graf@amazon.com, kees@kernel.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org Subject: [PATCH v1 08/13] kho: Remove abort functionality and support state refresh Date: Fri, 14 Nov 2025 10:53:53 -0500 Message-ID: <20251114155358.2884014-9-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.52.0.rc1.455.g30608eb744-goog In-Reply-To: <20251114155358.2884014-1-pasha.tatashin@soleen.com> References: <20251114155358.2884014-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Previously, KHO required a dedicated kho_abort() function to clean up state before kho_finalize() could be called again. This was necessary to handle complex unwind paths when using notifiers. With the shift to direct memory preservation, the explicit abort step is no longer strictly necessary. Remove kho_abort() and refactor kho_finalize() to handle re-entry. If kho_finalize() is called while KHO is already finalized, it will now automatically clean up the previous memory map and state before generating a new one. This allows the KHO state to be updated/refreshed simply by triggering finalize again. Update debugfs to return -EINVAL if userspace attempts to write 0 to the finalize attribute, as explicit abort is no longer supported. Suggested-by: Mike Rapoport (Microsoft) Signed-off-by: Pasha Tatashin Reviewed-by: Pratyush Yadav --- kernel/liveupdate/kexec_handover.c | 21 ++++----------------- kernel/liveupdate/kexec_handover_debugfs.c | 2 +- kernel/liveupdate/kexec_handover_internal.h | 1 - 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_h= andover.c index f1c3dd1ef680..8ab77cb85ca9 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -1145,21 +1145,6 @@ void *kho_restore_vmalloc(const struct kho_vmalloc *= preservation) } EXPORT_SYMBOL_GPL(kho_restore_vmalloc); =20 -int kho_abort(void) -{ - if (!kho_enable) - return -EOPNOTSUPP; - - guard(mutex)(&kho_out.lock); - if (!kho_out.finalized) - return -ENOENT; - - kho_update_memory_map(NULL); - kho_out.finalized =3D false; - - return 0; -} - static int __kho_finalize(void) { void *root =3D kho_out.fdt; @@ -1210,8 +1195,10 @@ int kho_finalize(void) return -EOPNOTSUPP; =20 guard(mutex)(&kho_out.lock); - if (kho_out.finalized) - return -EEXIST; + if (kho_out.finalized) { + kho_update_memory_map(NULL); + kho_out.finalized =3D false; + } =20 ret =3D __kho_finalize(); if (ret) diff --git a/kernel/liveupdate/kexec_handover_debugfs.c b/kernel/liveupdate= /kexec_handover_debugfs.c index ac739d25094d..2abbf62ba942 100644 --- a/kernel/liveupdate/kexec_handover_debugfs.c +++ b/kernel/liveupdate/kexec_handover_debugfs.c @@ -87,7 +87,7 @@ static int kho_out_finalize_set(void *data, u64 val) if (val) return kho_finalize(); else - return kho_abort(); + return -EINVAL; } =20 DEFINE_DEBUGFS_ATTRIBUTE(kho_out_finalize_fops, kho_out_finalize_get, diff --git a/kernel/liveupdate/kexec_handover_internal.h b/kernel/liveupdat= e/kexec_handover_internal.h index 52ed73659fe6..0202c85ad14f 100644 --- a/kernel/liveupdate/kexec_handover_internal.h +++ b/kernel/liveupdate/kexec_handover_internal.h @@ -24,7 +24,6 @@ extern unsigned int kho_scratch_cnt; =20 bool kho_finalized(void); int kho_finalize(void); -int kho_abort(void); =20 #ifdef CONFIG_KEXEC_HANDOVER_DEBUGFS int kho_debugfs_init(void); --=20 2.52.0.rc1.455.g30608eb744-goog