From nobody Tue Feb 10 08:26:38 2026 Received: from mail-yx1-f48.google.com (mail-yx1-f48.google.com [74.125.224.48]) (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 D1A6F2E5B1D for ; Fri, 14 Nov 2025 19:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763146823; cv=none; b=RTdj0LPeH2V2Ye8YAWW+54hJ4oyv2kB4ppOQ1mNBkLPq14FErGtk/wZ+FThEHrx2UKavcdNcAJynHAZyMea+dNObvsMKmASKomLp2dJS+CRjz+Is0R6tnK9oszUKZBsIptZHvHRPA/1TJg9nCnWVmn7B0PDZmf8tD+qVGJ4/wvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763146823; c=relaxed/simple; bh=nSAwfY2J0FrlXoH20NASZ16MFoernp4Ig+8UIlCo4YU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b5NKY4BT6CwMyVjVT9obRmJ1Ro7j+mvhf/h4fLFMZyYsUkadzm0K9pJGEHoCw/pI0obyXZlIevPlrNoxiDrzaYQR2jM8XetjI6UVG9lnGvOh/sX2XoqzjxDC2AcuEkFkI7bTt8NNcutgSP0Uw7PeHzmBPNkob4qSE88IgARcTpM= 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=EyBWSQ+V; arc=none smtp.client-ip=74.125.224.48 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="EyBWSQ+V" Received: by mail-yx1-f48.google.com with SMTP id 956f58d0204a3-640f2c9ccbdso2066601d50.1 for ; Fri, 14 Nov 2025 11:00:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1763146817; x=1763751617; 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=kUeee70aoCoEDH7tpogbMA7MC1e04DJkCX99vV5Wq8c=; b=EyBWSQ+V2RP9Eku/TOEfQmBs9555+M92t1IHme9nBXHafYOxivC6eDATfWZ0zaMNHP BhYBwU4K7NcmyHxmyKKSViYAB1DbecbGAhERBI/4WWPsd/51Lp8FJrHsID2BmpTZ+FWx 1WJU4fZK9La3FML7bxkUGEVDI0M6U9Nz3ByoPHt0SPCxSd9riLWhNAfQW0uUCZvt7nbO B3sV75Y0lcXAF1Jxzpro7bcSzamQBkHg11FVfrvceFLyOz1lHzwYhjM+vwHJ/nWyXmJA 8vmiVafnJTf3o/1VWbtPpd/IgFgMo8WCwA32yz4aePdEydkM/8qCgxdb8O6hjPSbcIh9 d+vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763146817; x=1763751617; 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=kUeee70aoCoEDH7tpogbMA7MC1e04DJkCX99vV5Wq8c=; b=Tyuyetdj287i2sCfotGU3JZuq3Dwi804Tl6CI3M1f67C61HKww1++LO8AW9QcTNGzu K+4FQZ2h3hGjypJOP9oHuidWhOjfALYS//YOZNpK/sBO3KpB4Vjgsc2NjRHoDmSKhEKD Bx2K39vHqro/Pkuaq1wdGsKxdKpgHta3aO19YOxKqaoLTsGIjWd0E/EUdylQWCSs/pkW 7oDlYw1eM9MmP1t4Tap3uXCZuwBMFBQ53Qi32wyLY8deoJZqfER6EOjOJeraFyg3tnWA uykW3DfvXlXygozQ1BDqMNVjPHrfOUN4yinrrNnYt/3ECDNT2GmYG0/umGJ0gVOBsjsl YAMw== X-Forwarded-Encrypted: i=1; AJvYcCWiIG0EnWz62+I9QfPRTnDcNU/K/y6RjL/gl7S/pUoQeG7z9hUdREN/mRdA4dpy9UWi5cVWqh8VdWOU7a8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7OCJmxer8sNNTlMjVNuig1nPVCVO8KNxOhdjpATMaSQjNdrof S8GkeoXhLUaSULYEe0uiLD1YRhtNSW3jQ+c7IgAN6bUSe0LKbhlY2F0Th67cYqQjPAE= X-Gm-Gg: ASbGncu+0BlQuwbY5UYbUfZMBMJTfaTkraqbDN+rzWV1H5i+IhMsdbtHXGkY2MMOQ47 cr1zk8d2cq1wIcKVEvrWIiP+Zh0V+FV4d4e27zE/8bjfhjH+uDWVa1a2QWL/wnzilTPiYIDigV3 JSF0+Xlf88jFktyYiy5ZD0rq5BvtvGnun1GR5iAAsmaUDit9eJXACa5C3S/UDl0mlYkSK2a40Cd SPSTXg22qZuVwtKKSRQRide7gqQbWxvgBLHzmxQPYWkrN+247OYtxI1SaIl0lTJdfzdSFcuYLN3 8xFEPvNg2UqeEgKDKltDGD7CztOwYoFwXbN60TdJ0wNTf1SPgYadLyw9jYSMq1bWewzB4qTfYzP /o0rVJR3fns3rWMjiCfTNx+wxfLe1H1Dpqeu83iNwpiEtTEmtT7LVJlOAqcE4pvfXwv/CrE86De 4aRlBMSK5cWHc2JGwuM/2J5NjRkK4CJpVW4iuAoKb5MqeLO+wCM/4FgdRb6lNojIJ1ESC7z5GvS ocegJI= X-Google-Smtp-Source: AGHT+IEDAZBpiF1oFEsVLGFJo+UdrqqTZLyy4yADm49I+si1ealVeGbZmEoKhxOu20FcmsBgPYr9rw== X-Received: by 2002:a53:b10f:0:b0:63f:9c11:cfed with SMTP id 956f58d0204a3-641e76402b0mr2553029d50.32.1763146816706; Fri, 14 Nov 2025 11:00:16 -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 956f58d0204a3-6410e8f4f2esm2014058d50.0.2025.11.14.11.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Nov 2025 11:00:16 -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 v2 09/13] kho: Remove abort functionality and support state refresh Date: Fri, 14 Nov 2025 13:59:58 -0500 Message-ID: <20251114190002.3311679-10-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.52.0.rc1.455.g30608eb744-goog In-Reply-To: <20251114190002.3311679-1-pasha.tatashin@soleen.com> References: <20251114190002.3311679-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: Mike Rapoport (Microsoft) 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 63800f63551f..624fd648d21f 100644 --- a/kernel/liveupdate/kexec_handover.c +++ b/kernel/liveupdate/kexec_handover.c @@ -1232,21 +1232,6 @@ void kho_restore_free(void *mem) } EXPORT_SYMBOL_GPL(kho_restore_free); =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; @@ -1297,8 +1282,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