Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796145746; b=ZD2MDxIIRl8ArvG2myrDMVDyhbFyE4gBVK8RLKUqIuhZmIqtB9q9voXOvS3b32nMS0KX TEwNnK+5LXFKUwAPcGqHtadwQ2vNrLqfSZ5fUvMFyIi6jFK52E8gW6Y8M7fgtpKmWmuxm R0SWImIl9rFl2rsIwy8najaL6PRZk5vLYdck6aAyDNEjebbICmVC3b45JKv6ibcGif2Co EibIHy3lxfrj0AzS5+fhHIcBjx2vEksIFyWcpvchRx6+b5imi52aGjxfA1GFNTjUam+zZ NrxSrtPfvBBkQp2CrCVo5kb1SaleA/qWw9HCXhecTnms/FDlWLCWMtgzbtAueLXpRBw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796145746; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=4A4WBnV/oVOQ1cyapXTp7DmUqhMQW65PICBwYtc5VBs=; b=Hxc+zvhrRrYXjqszUL6hTMvRu8uyjRjoZ0chjmOKAUc3g/73sSARe7QpITKk6BOaGDIu mYrFpPtGoX8jzhcooZln0MA1VBreDmK4yPG7xKGod1ju62etsTWG4OWAe4lZ4FJU23Tmf DNqdzBdjg53Gxzj/eTXK2jv8l09iU3wr3mfioKEPNBHmBz+pPbLrXR9lDElzRuM/umHTg 09Y0V2Fua7TZcb92aLOmLcBZComVMU6tL4kl8Yy80fZohYv3Cv45HM2tlI3pYkvpKgTVv qJ8Fvy73qoMnHo4T5Cdsz1T8zQTP8xmA3swUUZgBHYo7gt61+85UE6pi5LaAB0HtKFw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--suseendranb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=BGT3eHSc; arc=none smtp.remote-ip=209.85.210.200 Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) (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 92011606A33E for ; Tue, 1 Dec 2026 17:22:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 92011606A33E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--suseendranb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=BGT3eHSc Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-8bfe396acb4so7796910b3a.1 for ; Tue, 01 Dec 2026 09:22:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796145743; x=1796750543; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=4A4WBnV/oVOQ1cyapXTp7DmUqhMQW65PICBwYtc5VBs=; b=BGT3eHScv4re25l08ESCePXXtbfI/WzwFdjH6qEx95Hk8hqMQcNOU77Ln0Wg0J2kGs n5XtRPq214LIz2UEmFfqGyiy960kbUwTQPVWAUYODWUVMlKFkhpaUj7EPeVXX+o+Vc7w 5MibaUmdJIFKcA2Q7UBYc09CvZTCWG5SBhz2zjRlEIZl0g2WzO+vPMfmHWtbejc6CZwK kyupnFW5+SxMd8p+WLgU649M0V9Mqm+F/u0uAxiuU9kZmelq2LlGokxtnu8ZVMe0usu3 yl7tsy/m3XzXm0MqV2720AUF48lK5tv4CuvQgG/ug2I54xzszhiuihep4dg1IGPZb2/s G52A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796145743; x=1796750543; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4A4WBnV/oVOQ1cyapXTp7DmUqhMQW65PICBwYtc5VBs=; b=qheS5Jc8WsWS4e/52otYLOmZ9Wbw9j1xPGvt5fD8/Wrw2CzQYR5YGxB5Lgs7Std8GW jwyMTSsC/wCyQWtOhGZ3s1FCzBbQ52r7OdyvfFrol7zaOhyhdcn6mVa/3xi4tDiY7Nef y+KMT5V2i+YJ0SWYwW6Um03ARBM5yaKm1/n5An5mdjHcTHj4dfk/zCSGurT0nRs9nGU+ daPPb9OM+hjF7cc4z25IlrKgBlqGp67QavUGcjfJvqur7s1BDMGt8/iad+bA3KlmKlJh uPjZKQ3Q3hZgvng8gxjhLoWmLTXQWCkbYmZMURmWPzBK7VyP1lKrPJ5lVv46fs57peyN XS7w== X-Forwarded-Encrypted: i=1; AL+hErH8rLps2VJ/HNti6NOEEbuGMneHELhSZvq755Dgm16bbFcb3lSI1rAz2BBtrDJu36z52AxnI4gTcQhvLuk=@vger.kernel.org X-Gm-Message-State: APuU4Z8t6ZTFg1kduUkxTdg/9Kp2K0Tn0zc1VpyucDbChQvRLrZT8Xp1 GxjN28j9ylAzdbZZqk/V6W25rKuVRiL5OHwleo9fYI73OybxxzQK8zr+cwWUDj1BUjZcdiS07PK 5RWPcvkz6aT/ovx+U33SyISxljw== X-Received: from pfev3-n2.prod.google.com ([2002:a05:6a00:c203:20b0:8b5:c1f1:e4a2]) (user=suseendranb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6300:6bd2:20b0:40d:f5c0:8533 with SMTP id adf61e73a8af0-40df5c08656mr7643561637.68.1796145742469; Tue, 01 Dec 2026 09:22:22 -0800 (PST) Date: Tue, 1 Dec 2026 17:21:59 +0000 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 X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261201172159.2671514-1-suseendranb@google.com> Subject: [PATCH] x86/crash: Include Elf64_Ehdr and RAM ranges in elfcorehdr size From: Suseendran Bhaskaran To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "H . Peter Anvin" , Andrew Morton , Baoquan He , Mike Rapoport , Eric DeVolder , Sourabh Jain , Jinjie Ruan , Ionut Nechita , Greg Thelen , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Suseendran Bhaskaran Content-Type: text/plain; charset="UTF-8" arch_crash_get_elfcorehdr_size() computes the size exported via /sys/kernel/kexec/crash_elfcorehdr_size for kexec_load() with crash hotplug support. Unlike crash_load_segments(), it omits both sizeof(Elf64_Ehdr) and the existing System RAM ranges when CONFIG_MEMORY_HOTPLUG is disabled. With --hotplug, kexec-tools overrides the elfcorehdr segment memsz with this sysfs value and truncates bufsz if bufsz > memsz, so the loaded elfcorehdr can be silently truncated on CONFIG_MEMORY_HOTPLUG=n systems, and subsequent hotplug updates fail. For example, on a default CONFIG_NR_CPUS=64 kernel with CONFIG_MEMORY_HOTPLUG=n, 64 possible CPUs, and 10 System RAM ranges, crash_elfcorehdr_size reports 3696 bytes (memsz 4096) and CPU offline fails with: crash hp: update elfcorehdr elfsz 8192 > memsz 4096 Add arch_get_system_nr_ranges() when !IS_ENABLED(CONFIG_MEMORY_HOTPLUG) and include sizeof(Elf64_Ehdr) so arch_crash_get_elfcorehdr_size() matches crash_load_segments(). Tested with kexec-tools 2.0.32 in QEMU under the configuration above: crash_elfcorehdr_size reports 4488 bytes (memsz 8192) and CPU offline updates elfcorehdr cleanly. Gemini assisted with code analysis and the QEMU reproducer. All changes and test results were reviewed by the author. Fixes: a72bbec70da2 ("crash: hotplug support for kexec_load()") Signed-off-by: Suseendran Bhaskaran --- arch/x86/kernel/crash.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index e6f23933a6df2..49bc4bc5ebc0b 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -433,7 +433,10 @@ unsigned int arch_crash_get_elfcorehdr_size(void) sz = 2 + CONFIG_NR_CPUS; if (IS_ENABLED(CONFIG_MEMORY_HOTPLUG)) sz += CONFIG_CRASH_MAX_MEMORY_RANGES; + else + sz += arch_get_system_nr_ranges(); sz *= sizeof(Elf64_Phdr); + sz += sizeof(Elf64_Ehdr); return sz; } base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244 -- 2.56.1.911.g883d8bcb20-goog