From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71BFD48F856; Mon, 12 Oct 2026 14:43:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791816212; cv=none; b=JYEOw2SjWFZ4SoaAzro6g8erM++6gzUwx8JUM6ai6JyO3Hxf9PU5q8cRzBMxYKmOa9EdQUsE4hBVfOaogFmIqJ7YHTReXIF7iDU6DEWc412gPZ9petv1l7Hal9QQu3vbxzg0ohkOFA00Itcq1fxUtPVelycd63L0ErUzrbjlKDs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791816212; c=relaxed/simple; bh=vja9f80kKdriS8q5Ufpwmpcgz5B4qE3CigKeA1xzsB8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=nUbeITcJ6o3Yh6IbCsY5muxm/H8ADP/5eeaoz96luPqblpoZgxGjy8+mzmSgXhLqCzl2eoAECcVneSGJUXjyt9t+nsy2tOvFEdPVuDVzh4jmlI9MZTedfgvlh1z/lmwEsD1HtJ2UqLDYPREY09A3JwHrvxblq8GFD3zfd+EcHow= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IM1g2mg+; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IM1g2mg+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F02D1F0089B; Mon, 12 Oct 2026 14:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791816211; bh=kQsn0vmJ9Enc8KpOevs5GF67ZaQJBMeRFwUmu6G9Q+U=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=IM1g2mg+0ZjCqewi5D/5jQ6yvlDnaIY7CfHe3fekAL1P7K2B1Pdazo6RlILpbXA/m OKWqYFRZbakcWW8wvl/IGx3jKOfhx6gG9grJCMyYTTPOO54lwG11SzZLFmYUzoHepz Bifnke+sfu3+fO6tag2ROronuIV/kBdId1F4OR+RJKfkp1MNdS/0oTCG5yW7dFPBz3 8Pf5fLzzyjx313sPM1FT9MsaEQoe6yqsWVffDnKvbjyTeb1r8C7W54xPayKybSWynm Go1/udLGAdEhxwHvF3Aq2Z7HlKWiDk2AsjEAtagV7WI5uVTJoAmPH0KF7nRtxv5YPs FLSSDzFuIMwJQ== From: Pratyush Yadav To: sashiko-bot@kernel.org Cc: "Sourabh Jain" , sashiko-reviews@lists.linux.dev, "Hari Bathini" , kexec@lists.infradead.org, "Pratyush Yadav" , "Michael Ellerman" , linux-kernel@vger.kernel.org, "Alexander Graf" , linuxppc-dev@lists.ozlabs.org, "Madhavan Srinivasan" , "Mahesh Salgaonkar" , "Shivang Upadhyay" , "Andrew Morton" , "Baoquan He" , "Ritesh Harjani (IBM)" , "Shrikanth Hegde" , "Aditya Gupta" , "Mike Rapoport" , "Christophe Leroy (CS GROUP)" , "Pasha Tatashin" , "Nicholas Piggin" Subject: Re: [PATCH v1 2/2] powerpc: add support for Kexec HandOver (KHO) In-Reply-To: <20260928084310.10CDB1F00893@smtp.kernel.org> (sashiko-bot@kernel.org's message of "Mon, 28 Sep 2026 08:43:09 +0000") References: <20260928083226.107807-1-sourabhjain@linux.ibm.com> <20260928083226.107807-3-sourabhjain@linux.ibm.com> <20260928084310.10CDB1F00893@smtp.kernel.org> Date: Mon, 12 Oct 2026 16:43:26 +0200 Message-ID: <2vxzbj8zj7xt.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Mon, Sep 28 2026, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > - [High] boot: late KHO initialization allows memblock to clobber preserved memory > -- > > commit 2f581dec390379323e7a0b4e4badb03487eea55f > Author: Sourabh Jain > > powerpc: add support for Kexec HandOver (KHO) > > Add architecture bits to enable CONFIG_KEXEC_HANDOVER on powerpc. This > patch checks for KHO information in the device tree before unflattening it, > allowing a kernel booted via KHO kexec to recover the FDT and scratch region. > It also moves early_init_dt_check_kho() to be called from setup_arch(). > >> diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c >> index 4afaba19b5867..53c2f1897bfe1 100644 >> --- a/arch/powerpc/kernel/setup-common.c >> +++ b/arch/powerpc/kernel/setup-common.c >> @@ -923,6 +923,8 @@ void __init setup_arch(char **cmdline_p) >> /* Set a half-reasonable default so udelay does something sensible */ >> loops_per_jiffy = 500000000 / HZ; >> >> + early_init_dt_check_kho(); >> + >> /* Unflatten the device-tree passed by prom_init or kexec */ >> unflatten_device_tree(); > > [Severity: High] > Does calling early_init_dt_check_kho() in setup_arch() happen too late to > protect against early memblock allocations clobbering preserved KHO memory? > > The Kexec HandOver (KHO) mechanism uses a scratch memory region to strictly > confine early boot memory allocations in the successor kernel. This prevents > them from overwriting memory pages preserved by the previous kernel, and is > enforced when kho_populate() invokes memblock_set_kho_scratch_only(). > > However, setup_arch() is invoked from start_kernel() long after early_setup() > completes. During early_setup(), substantial dynamic memblock allocations occur > before KHO scratch memory confinement is enforced. > > For example, move_device_tree() allocates memory for the FDT: > > arch/powerpc/kernel/prom.c:move_device_tree() { > ... > p = memblock_alloc_raw(size, PAGE_SIZE); > ... > } > > This is called via early_init_devtree() from early_setup(): > > arch/powerpc/kernel/setup_64.c:early_setup() { > ... > early_init_devtree(__va(dt_ptr)); > > allocate_paca_ptrs(); > allocate_paca(boot_cpuid); > ... > early_init_mmu(); > ... > } > > Because KHO scratch-only mode has not yet been enforced during these early > allocations, could they use standard memblock policies and overwrite preserved > KHO memory state, corrupting the handover? Sashiko seems to have a point. early_init_devtree() (called from early_setup()) already does a lot of initialization that x86's setup_arch() does, including making memblock allocations, allowing resize, etc. So perhaps you need to move this early_init_dt_check_kho() call to early_setup()? -- Regards, Pratyush Yadav