From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 11A1637F8C3 for ; Thu, 13 Aug 2026 16:05:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786637146; cv=none; b=tm2wSK7p9DG74zUld+hX4zSGIiroRC88eUWgtgybsors5jMP8OLXLNRTPRKAbADuHW1Rbo7UinnaYi3crQ+NhAXh90rL1nyjJVIrx/Lr+n4Vsd+/nNVwADUITmQ+FMpGRbUOR0h9+eA5xkir5t8ZCvNn1kDD5/NeSzv4WQli7bY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786637146; c=relaxed/simple; bh=GdOVLavtixtz+bwc773F7iXmbQhbVm7TNS88fVv9av4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R67ufjahjwC5gIERufxGcEIkadeV5Ey+Jo/a4KmPRQhhsTXD8KFYaF7z/qfqD4zeCSlwK7ZKX0BNXXxiyPBF7L6QBGV5kUcrK5Fx8f4uwHyc1yEWVQCrDxKThJ7E/Nf/ytHqNMPNR1PDGIPeKcuvtfaUd160+/NV2n1gn+1XKzM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=NvzpgAY1; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="NvzpgAY1" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 539FC1576; Thu, 13 Aug 2026 09:05:40 -0700 (PDT) Received: from arm.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 815B43F66F; Thu, 13 Aug 2026 09:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1786637144; bh=GdOVLavtixtz+bwc773F7iXmbQhbVm7TNS88fVv9av4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NvzpgAY1Qf9f/5pkj2ip0dskQnm1FKdRNqgDA2KzDQwfoIxhbdoZ2807TR5WYZ1IT 9ms3QyyBXSoensTxvyvQMH8eGt5xKglWWxw74Ab4YnC9jgNv2p1XDtMn/4aFB0Wfeg gLO3nGrAGuMfrvC9hd/oTCG3w5V710ykuOrhfJUA= Date: Thu, 13 Aug 2026 17:05:37 +0100 From: Catalin Marinas To: Jinjie Ruan Cc: will@kernel.org, akpm@linux-foundation.org, baoquan.he@linux.dev, rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org, thuth@redhat.com, mark.rutland@arm.com, jic23@kernel.org, james.morse@arm.com, ardb@kernel.org, leitao@debian.org, yeoreum.yun@arm.com, sourabhjain@linux.ibm.com, robh@kernel.org, kees@kernel.org, coxu@redhat.com, makb@juniper.net, piliu@redhat.com, graf@amazon.com, ebiggers@kernel.org, jbouron@amazon.com, bgwin@google.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org Subject: Re: [PATCH v2 5/5] arm64: crash: Add crash hotplug support Message-ID: References: <20260729031235.2840255-1-ruanjinjie@huawei.com> <20260729031235.2840255-6-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260729031235.2840255-6-ruanjinjie@huawei.com> Hi Jinjie, On Wed, Jul 29, 2026 at 11:12:35AM +0800, Jinjie Ruan wrote: > +/** > + * update_crash_elfcorehdr() - Recreate the elfcorehdr and replace it with old > + * elfcorehdr in the kexec segment array. > + * @image: the active struct kimage > + */ > +static void update_crash_elfcorehdr(struct kimage *image) > +{ > + void *elfbuf = NULL, *old_elfcorehdr; > + unsigned long mem, memsz; > + unsigned long elfsz = 0; > + > + /* > + * Create the new elfcorehdr reflecting the changes to CPU and/or > + * memory resources. > + */ > + if (crash_prepare_headers(true, &elfbuf, &elfsz, NULL)) { > + pr_err("unable to create new elfcorehdr"); > + goto out; > + } > + > + /* > + * Obtain address and size of the elfcorehdr segment, and > + * check it against the new elfcorehdr buffer. > + */ > + mem = image->segment[image->elfcorehdr_index].mem; > + memsz = image->segment[image->elfcorehdr_index].memsz; > + if (elfsz > memsz) { > + pr_err("update elfcorehdr elfsz %lu > memsz %lu", > + elfsz, memsz); > + goto out; > + } > + > + /* > + * Copy new elfcorehdr over the old elfcorehdr at destination. > + */ > + old_elfcorehdr = phys_to_virt(mem); > + > + /* > + * Temporarily invalidate the crash image while the > + * elfcorehdr is updated. > + */ > + xchg(&kexec_crash_image, NULL); > + memcpy(old_elfcorehdr, elfbuf, elfsz); > + dcache_clean_inval_poc((unsigned long)old_elfcorehdr, > + (unsigned long)(old_elfcorehdr + elfsz)); > + xchg(&kexec_crash_image, image); > + pr_debug("updated elfcorehdr\n"); > + > +out: > + vfree(elfbuf); > +} > + > +/** > + * arch_crash_handle_hotplug_event() - Handle hotplug elfcorehdr changes > + * @image: a pointer to kexec_crash_image > + * @arg: struct memory_notify handler for memory hotplug case and > + * NULL for CPU hotplug case. > + * > + * Update the kdump image based on the type of hotplug event: > + * - CPU add and remove: No action is needed. > + * - Memory add/remove: Update the elfcorehdr to reflect the current memory layout. > + * > + * Prepare the new elfcorehdr and replace the existing elfcorehdr. > + */ > +void arch_crash_handle_hotplug_event(struct kimage *image, void *arg) > +{ > + if (image->hp_action == KEXEC_CRASH_HP_ADD_CPU || > + image->hp_action == KEXEC_CRASH_HP_REMOVE_CPU) > + return; > + > + update_crash_elfcorehdr(image); > +} Looking at powerpc, they pass the arg down to update_crash_elfcorehdr() to handle the memory hot-unplug case. It looks like the notifier is called before the memblock_remove(), so the update above will still count the memory being removed. There are a few Sashiko comments as well, though some might be about existing issues (it would be nice to have them fixed ;)). -- Catalin