From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796193133; b=Z7e3OahvBbSm3OeiYGfngo1i47qEfsnI/TiepGIuWOmFKGzngD6ftKooIolON2xb+FHb QSSLoMuHIJn9GkUtJeYORMbLaGNbygBWggHbgQourAu4fEP8zHw1AfEbjHocHnEB0XED+ kQCn83Wr8xNbjCNGqc6Mgkaep61CWjorxdPiDKGy2XQnERK9h7mrpsffucxV5pzj7+SfA 6/vJYL1ac1kdpM0UoooFkfIZoXlKM+2braOz3cqKNps74CqNeQyyO+vwt3TW/P2tlWX/Z GdXeVqvwuc5Ip+BSMlVYQv59xP02+sOqPtQa1uVsaTem0T6+sLOqGMwASAc/Fn237Zg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796193133; 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=SimF+GAhTqrH3hiQA1b3EwLbwofgMd+AYHgPtSGiX/s=; b=dJGGuAvnLsxhewpd3f2gMRYxuykLS9c3n5OkMYzleENlLE046jua2E0ptkla0Ypxj4nW D6lD24dT2HMXvOx4Mv2PeAUeyndbW05X+pjrah+xohWuh0NBzja4ZRsIX4fCCXE2/1QzM lqmOa4Y0O5EZXTUq0KErjHDbRQb54IPRv+HaFC2tvJ05Qp79nt+cqVAlPiMxmk4GmGaHi AF/IWg0iWxpTUidpsCx6pwoStq8iUCzZmbXDCcXhOkO65gErx28fJEPFPyN53x+oYMY7T vUGBr3nN6VWOceWvSXfxpcXArX0O7UmyjwHI63I4BiWsC0brctfFMuVGv5Hx7zisiQw== 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="YJ/tckDo"; arc=none smtp.remote-ip=209.85.128.179 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 2CC3F606A329 for ; Wed, 2 Dec 2026 06:32:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2CC3F606A329 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=YJ/tckDo Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-8b360828905so119437427b3.2 for ; Tue, 01 Dec 2026 22:32:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1796193132; x=1796797932; 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=SimF+GAhTqrH3hiQA1b3EwLbwofgMd+AYHgPtSGiX/s=; b=YJ/tckDoO5GOhP6irDLVRQUojOfyI1KCVvdufwrjdezvTb1HWkax0ep+j+GqGQ9f84 4+EG7tkB0dHaMywBYACP0RhZjaA9DJsEfqBeqSQJv+3eGkU9j0tqX1Sgp1NaB9QnDI7y j7szaMULRy+O0CprrT7TCsf5S2VrPXOyq72PA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796193132; x=1796797932; 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=SimF+GAhTqrH3hiQA1b3EwLbwofgMd+AYHgPtSGiX/s=; b=tzURcp2JWi8FGysSu4NCDykFDNxWPf6WdiS6T0yoq84C7Tt1I7FbXkoOYQBKEhKy+P +3webD+SNNVhU7EFNSkELoXk5whDv0Pc2nuK8kFFAg3pqOrZHb8pQjrGttChWEyAdyIx cF8MHov7vTDks3RIP2J+Akz7ZyaO9aaYYNBIgoSQaEW8heMgy6iUC5eTzCJ0q7fdTDd6 NBI9ac6Ly3eoV54HVEmWL++6rhx2zHnA8jrXO7qtI1BCF02XN7sIRz/n4R73YoI7lrUg BVUYc7r6a/XQP3ygb8TC+KKtDiOgbQb36pMiR6FAG5fqDbIu4Mb6fjqTURa29v6gK/Eo GDIw== X-Forwarded-Encrypted: i=1; AL+hErE0KMCxtf+X1Of1qZ8ZDZ7WnYsWrDhL61xc6VlENOKIDCpRvu9/F4SeIHvOLrKqo5weCt8uvjqnexr6EPY=@vger.kernel.org X-Gm-Message-State: APuU4Z8R3DmiTOW+wGqUPbUqea22oKcCN4arVHqPNwnVUgW8lobsEVmR b7CJjBdR5llIWbDKCW0fepnSxMRUtpPuRlT37bPdWqQmMiHAk+wFsIqwBSLxc3vL9Xk= X-Gm-Gg: AZFdTZczBivoMIlyEFNgo4GzsPKFXGYTmiQpQhzjpd+WrqCO3yf7jDMWyxEXb0TlQ0x S2OB0cqh7SFPSN6hkE8570pGFxrzzGK5qhOF161d6/H04UKXGCauU2fG2W7aYx8JQl9KhbIPFdF qLwKaxOY9gJN3GOhyVdi4E2zI8HLd4YdnrvYycDVtnKWZEoM6VCgEr5Pvo6yBkgPNijYjLm6fKw kVY0jCiBjK8FCPnDw51RmXqUrevSqcvAozIIMj1MMnBZwpG5R7JdkBsZ/K4osm3T+5ApXjBDZCU s/1TDgK0Q1NrseV86KdqvXKtIAXfIUWb+Z01IDM0A2JPSmPdW951zvqSyn4X/bCbL8ydYr3tcFl B8943zOGtiGuAHczQuLUfxHyaXSZiqjho9qHE2lUADelyAcxZVegWgk5upKRAcvpgt/Gkkd37m0 PHXG4VK/CRPjZZXaWKUFQdPerxSTDxeij94UABdqGursuG6TvLRO+ZyUp/OsYo+YbdZNGp0sa0I PYCLLECMeiNtA0xJcLPuEcRNz6syF0hatV6XXjinbIGXr5CoWsV8n/COfCR6YdEfL0xdze7Kq/L jpUkCrEOjvZqWt9dzmLfkK/j8LH2J0Sqr1jETjeHROrFZRn/TYHsd47FNKMvezQ0AY/QSAKIsOt chkK5RnLLs7DXGa+FSDlNW4Y3+gh2dpe0IK0ONckRsosQYLJ/et1b9n3Y1+ghP4Q0CyevR5pywq XXmrKuLXGYs8mqd424xmkP8BITtNoMpnogOE2GUIae+d82+40zjOTQn7FiRO6PhGbjY93+UMcow zHsYCKYou1u4GuNHd4Nvd4= X-Received: by 2002:a05:690c:6f91:b0:8b3:4db3:ac8f with SMTP id 00721157ae682-8b52031bb93mr137617327b3.11.1796193131830; Tue, 01 Dec 2026 22:32:11 -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-8b52028d160sm155712227b3.10.2026.12.01.22.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 22:32:11 -0800 (PST) Date: Tue, 01 Dec 2026 22:32:09 -0800 Message-ID: In-Reply-To: References: From: Chris Down Subject: [PATCH v2 1/2] kho: skip bootmem setup in kho_init() if bootmem was inherited To: rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org Cc: graf@amazon.com, kexec@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com 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) On a cold boot, kho_reserve_bootmem() reserves the bootmem areas in memblock, and kho_init() later releases them to the page allocator as CMA. A kernel that was handed its bootmem areas by the previous kernel boots out of them instead. kho_init() must leave them alone. kho_init() tells the two cases apart by whether there is a handover FDT. That doesn't work if kho_mem_retrieve() fails. It clears kho_in.fdt_phys so that KHO users don't treat the boot as a KHO boot, but the bootmem areas are still the inherited ones. kho_init() would then run init_cma_reserved_pageblock() over memory that is in use. Nothing makes kho_mem_retrieve() fail at the moment, but the next patch does. Test kho_in.bootmem_phys instead, which is what kho_memory_init() uses to choose between retrieving the handover and reserving new bootmem areas. Signed-off-by: Chris Down --- kernel/liveupdate/kho_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/liveupdate/kho_core.c b/kernel/liveupdate/kho_core.c index 15fb892a4412..43ecef317cfd 100644 --- a/kernel/liveupdate/kho_core.c +++ b/kernel/liveupdate/kho_core.c @@ -1928,10 +1928,16 @@ static __init int kho_init(void) if (err) goto err_free_fdt; - if (fdt) { + if (fdt) kho_in_debugfs_init(&kho_in.dbg, fdt); + + /* + * We've booted from the inherited bootmem. That means this kernel is + * already using it. As such, leave it alone even if the handover is + * dropped later. + */ + if (kho_in.bootmem_phys) return 0; - } for (int i = 0; i < kho_bootmem_cnt; i++) { unsigned long base_pfn = PHYS_PFN(kho_bootmem[i].addr); -- 2.56.1