From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.133 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796530510; b=DM/9wwPrm+STYqyg/iRc1OcOzkRq1q3uG8RKJzdbQMO81Qdm3lvCLcY/8haJGi7pFSkG IsK7z+K/LgyKyiB4qo1TVbOARY2BAf6mgDmwCQUxKboD5f5bAm5Kku5g301UwWeXDG3Ra ehRUADrbe2kqm7haidA2ng0ephNGW1LmWjY7rOf6YQITljF4ILc8/QCGi5OD0ogvNPlSo sjg3m7qPy9quKsdz4eDi9yWJltOQ28YANBtX09brtX+oysnE01Nmo5Xg7yUa42E+Dbmkp yFv6VjnNx6YokWoEOvVwJvvnu6akGq2v7k9VbTQL8RjOe0LnwQpca2LtR/TQPpuqSQA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796530510; 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:From:Subject:To:Cc:MIME-Version:Content-Type: Content-Disposition:User-Agent; bh=kf9dCXMxddXTU7yDL7LKSKkP0rTMaUQG/G2iCXZhJ2M=; b=VDTBUYlJVoT5XbcNRutBF2wGK1ZrhULPTqLrPK8CRfESnfRPDqRBPOoRON5KFvLwk8cs FqL7U5SktUH/HR7tnZujOQKTzwrHJOaxEl8hXAYobMA5V8laOAhU/yNPGicvsMcb7wjvD aLiuLeq8zMuN1n2PugGV6Te0hhwA3g9kJBU2gfnlQiDutYFJIxSO+wDQhiPGBXus6uuKo JJOoeLnIHhzRUCWWzaXyb0as3rGynan0IgC4gDZGOEYylhi2dWA7JPvB/8O/4k8WN87zc CQhMBnplk7vayPCGsMzODmgJJ+j11HT25Q5XrAC03QuHnvBGGNxCJVRL3e2qy1NYPXg== 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=FGZ6EPMw; arc=none smtp.remote-ip=74.125.224.133 Received: from mail-yx2-f5.google.com (mail-yx2-f5.google.com [74.125.224.133]) (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 67D7A606A31F for ; Sun, 6 Dec 2026 04:15:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 67D7A606A31F 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, unprotected) header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=FGZ6EPMw Received: by mail-yx2-f5.google.com with SMTP id 00721157ae682-8b50788d48eso5429347b3.0 for ; Sat, 05 Dec 2026 20:15:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1796530509; x=1797135309; darn=vger.kernel.org; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:message-id:date:from:to:cc:subject:date:message-id :reply-to:content-type; bh=kf9dCXMxddXTU7yDL7LKSKkP0rTMaUQG/G2iCXZhJ2M=; b=FGZ6EPMwEuSaIpFlZ4DkZjf0beMq1b3/R3eGcmlrZ4e20oatIRvRDU8VMsgGvRADHo 7z3wGGNN8JDX/HGIovNc5JKA0noVrgJGdEdjlvAt8BlyvqW9NEPafEinbtalz/OWReed wLTiHeb40Zd/rZBQ7ZzCyIZqFkFx19OboI1vs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796530509; x=1797135309; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:message-id:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=kf9dCXMxddXTU7yDL7LKSKkP0rTMaUQG/G2iCXZhJ2M=; b=bjdK1Q8X38OHRB4Tu2Ojxmsq5XE2jvXNBNW4b+dA11Vcsjrju7Du3AEx3b17o7wHXe YL1p73Hw7bKudp0qQ37BCvvWJYME31d0T/1cR2XWq9hbqj1GkDWYlxwYIFUfeLiO6u2M KIyTqThIY0t5Su10GL8huFuREZDAW6iWW0Q8iQichRfDf5lYeyz+rfK0Jo1+u2p3+gr+ F+0x3pbHSBKVixyHC2m7C2aSDYPkip13EPx/+4Ec0eLX96TuVA1i/ZXJHF0oPeM6ap/p otOTsZTwL21WbcGdMSpxJSJWPh8UCVvIEUNCHnGNBpxR1BZZtZm6l6f6JGZlTc7AKPTo XjkA== X-Forwarded-Encrypted: i=1; AL+hErGCtylQ/U3DQVE9a2tO+YBI3cZwUtUvdrpkNIsmGeBBmflfjtWhhK2m4rPLloLopobwxO7E1vomMRh5TuU=@vger.kernel.org X-Gm-Message-State: AB4q+uHAV3i4NiqI1klu+gT6dwZ01Zu82nwd5QEIVFacPo4exrh8z+ql faKPQjfrTsJDalbBpSLo7+R/J90OXf7j1GBAQisJ1eJVEDk3pIJziqjrfJbF/bSCcOE= X-Gm-Gg: AZFdTZdopbvk3j7QsQhF8tqM8d/XkjQNNGZGirVjJQL4POyPEFsW6PZueYZL1fAV16/ LMvY3ycFJmWCdCDtHohtOVN0RM6RuH874rFUMiWL0P9ZIrg6M63MLWxT33aM7+G+E9xNAYa+yDs 9FbjOeToUVavF5iwAS0X/qDgX5zim1sez1HgrQyhT/G5T6QNvcjadS8V2Ui3GxvCbqwggPWeri9 7+iphg8RCicYyZUfA+DJHCJVqMF6hrwyKJxG5TRR0sMVNtNtRsn3yAI+wXr5O+x2Up2WvLEToov t9IRnHEDrgyP9+1Sa1X+JXsjYbecaPmzc6nwukXRtZODW+D9yG/2dBgeLy/wGEWCcXLwdrjFZ69 dZIVnYZQ9dwPn8f1PPoGnujiO3j1R2ChfgRjtWxAGqjVJP/AQgSDb3URQsSQmRCrRiaQzI1bY+A 9PULWovJgot5wfu5Q+3LTLvWoiz7BxYuDr2rOxeREjOuLcUrS0KfRN8pRMfP9bnhv8gClzhM6fr ob9Qwd8airSjBFCWVS3PZ1DzGkjTSL9xxCmBk4AMgcEafTJD4RJS5h2iTp1ayj2VsvHikZcL6IR PVcvvlU/Mzi/idWo1zmTWvTmyjriGsiRY/8MgJa9hmZ0/X3jdau5xBE9aMgTbODwYlL2jJSyQ1e oQy7AvJigR/1QOC1fCI3WztZyfb3fu52ladAUpJzSkrtd0YS6y5cDQUvOGfybeXyRKjw2kNetHY gAVs9fYKrVWUnLZPJG/ydEc5Lh5riO29x7UINXQkuNwoAiziVOSZyL0BsQb80kjQZD1DHjagRVp 3XLHEvjglB1BUn1ltYw6Co= X-Received: by 2002:a05:690c:3343:b0:8b4:d882:4a14 with SMTP id 00721157ae682-8b659db2b13mr26859787b3.5.1796530509318; Sat, 05 Dec 2026 20:15:09 -0800 (PST) Received: from [172.18.0.2] (c-73-207-185-9.hsd1.ga.comcast.net. [73.207.185.9]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b6604050d7sm28739717b3.5.2026.12.05.20.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 20:15:07 -0800 (PST) Date: Sat, 05 Dec 2026 20:15:05 -0800 Message-ID: From: Chris Down Subject: [PATCH v3 0/3] kho: handle failures to reserve preserved memory To: rppt@kernel.org, tatashin@kernel.org, pratyush@kernel.org Cc: pasha.tatashin@soleen.com, graf@amazon.com, kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, 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) When a kernel boots with a handover, kho_preserved_memory_reserve() reserves each range of preserved memory in memblock, but it ignores failures. If one happens, memory that a KHO user still expects to restore can be released to the page allocator. This needs memblock to fail to grow its reserved array, so it's unlikely. But if it does happen, the result is bad enough to be worth handling. Patch 3 makes the walk stop on such a failure, so that kho_mem_retrieve() drops the handover and the boot carries on without it. For that to be safe, reserve_mem_kho_revive() now reserves its own region, and patches 1 and 2 make KHO keep treating the bootmem areas as inherited after a failed handover. >From a quick check I did with one of the reservations forced to fail, the kernel logs the failure and boots without the handover. The reserve_mem region stays reserved, and a later KHO kexec out of that kernel works. This is based on the next branch of the liveupdate tree, as it needs the CMA accounting from liveupdate-7.5 as well as 0e88c65680e2 ("kho: don't release incoming bootmem areas when kho_init() fails") from mainline, and only next has both. v3: - Check kho_in.bootmem_phys for the CMA accounting and in kho_init()'s error path as well, in a new patch 1 - Keep kho_in.bootmem_phys and kho_bootmem set when kho_memory_init_early() fails, and don't reserve new bootmem areas in that case (Pratyush) - Retitle what was patch 1 and is now patch 2, as it's no longer only about kho_init() - Reword the comments in kho_init() and reserve_mem_kho_revive() (Pratyush) - Say in patch 3 what it takes for the reservation to fail (Mike) - Show in patch 3 that the kernel still boots after a failed reservation, with a way to trigger one v2: - Drop the handover and carry on instead of panicking, with reserve_mem_kho_revive() reserving its own region (Mike) - Stop kho_init() from releasing inherited bootmem areas after a failed retrieval, as a separate patch (Mike) v2: https://lore.kernel.org/r/cover.1796126791.git.chris@chrisdown.name v1: https://lore.kernel.org/r/avQUquBK6cO6tUUI@chrisdown.name Chris Down (3): kho: don't use is_kho_boot() to check for inherited bootmem kho: leave inherited bootmem alone if the handover fails kho: drop the handover if preserved memory can't be reserved kernel/liveupdate/kho_core.c | 61 ++++++++++++++++++++++-------------- mm/memblock.c | 11 +++++++ 2 files changed, 49 insertions(+), 23 deletions(-) base-commit: 13278f869c76f01ab1a6f6c694f718d9f487bd68 -- 2.56.1