From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=162.62.57.137 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795948101; b=0NYONZrNzZNPLKng5l1YQuWQSqVH96gJokn4EZBYjrPsWstGKGV1L4ENbxM9JlaWChCO OejFOtGk0X/OEtFlwDvqQlcGYpRBwDDGm9jRla7wDStgnZXwULm8YCCYtxpjgXGNIsqBZ rXGqdcQd1vIOrOyaU6OERBNcA0w1d89yhJAuB7yuvU2JE2rUs2/GNBqe0tkwojl0q7KGT h+mGS2k1sRqtyhcOK5fFg/6mh87A9gefFfiOBtrQvyiKdLMY1HPwu5KYvymASh7CrSLrw zN1qhNzXhUSK/9mDmUQDt74Y4TsY+fErd3/A5QCkEYW9O80togApIWd5cYwi8Q9pO/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795948101; h=DMARC-Filter:DKIM-Signature:Received:X-QQ-mid:Message-ID: X-QQ-XMAILINFO:X-QQ-XMRINFO:From:To:Cc:Subject:Date:X-OQ-MSGID: X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=Xif1E2tzjlyYaprEc3Nf1Dj7JjFAVYRymgjZ6E3/vZ0=; b=CTrNyyFDvXeCXnVU3tP3xTVnXcsvW7NOl6kHsbEmhuWsbWVgvbAfB2S6VudjN03+hc5y NO9t0nC9nUsbVVfsptyLuYw1e54gt10INQH/fFpS+XfmyXCQSrZz1KcWCWHevJVSVlpne So1pTD1arPs7rqD3YjMMfK3pmeqm6pDHG7Vb0UFdHN56RkKKLEWB+KXyjpO16XN2gSfHV /vD2srQ4FDhW5qLuT8id3GWtoa6rpe4ii/YwCMmNGKlMJOLvyMD9SebLu/xz50yvpSTOo UPI3zVZwQjvjkA1vijpEJ2BcIwZjuj7EydUfu+enKUrIynmsHeq/zF7kpRodNCtYlIw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=qq.com; spf=pass smtp.mailfrom=qq.com; dkim=pass header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=sM08Vbhy; arc=none smtp.remote-ip=162.62.57.137 Received: from out162-62-57-137.mail.qq.com (out162-62-57-137.mail.qq.com [162.62.57.137]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC95D606A31C for ; Sun, 29 Nov 2026 10:28:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DC95D606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qq.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=sM08Vbhy DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1795948096; bh=Xif1E2tzjlyYaprEc3Nf1Dj7JjFAVYRymgjZ6E3/vZ0=; h=From:To:Cc:Subject:Date; b=sM08VbhyARhfJHb/Drl//VYVfF/le5AwwgO799rBXv4Qup0ufEnIxF+nvUtMwqYCK jOA/wG+ap/iAE5ippwGNtOKJO5YyK0oK7SaFOafeYUREfZbagMZvhdq9Aq6xnznDp/ MEtjsA3ReoAvRSGUCCzZDhxwF9UkLFhdFOfSHb68= Received: from DESKTOP-6LNKCJL.localdomain ([111.199.66.152]) by newxmesmtplogicsvrszb43-0.qq.com (NewEsmtp) with SMTP id 70904CAF; Sun, 29 Nov 2026 18:28:09 +0800 X-QQ-mid: xmsmtpt1795948089t2jjqacfy Message-ID: X-QQ-XMAILINFO: NDD+ZwUaH+mroTYk0AaQ8q69yA0RtUp7aoJZFIYEjYYwdUXcFX/wpcuVZcvg6Y j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jg 719jcMg5LyKjIZ9mJpfr1qA8pQAw0UQFzZp/hdCMsgtvXJYrY= X-QQ-XMRINFO: M/715EihBoGS47X28/vv4NpnfpeBLnr4Qg== From: Jingyi Sun <1045704958@qq.com> To: Andrew Morton , Baoquan He , Mike Rapoport Cc: Pasha Tatashin , Pratyush Yadav , Shradha Gupta , Thomas Huth , Sourabh Jain , Pingfan Liu , Benjamin Herrenschmidt , Anton Blanchard , Russell King , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] kexec: use phys_addr_t in generic crash_free_reserved_phys_range() Date: Sun, 29 Nov 2026 18:28:09 +0800 X-OQ-MSGID: <20261129102809.1022-1-1045704958@qq.com> X-Mailer: git-send-email 2.43.0 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-Transfer-Encoding: 8bit The generic crash_free_reserved_phys_range() in takes the range as unsigned long, but its only caller, __crash_shrink_memory(), passes resource_size_t values from crashk_res / crashk_low_res. arm64, powerpc and s390 provide their own crash_free_reserved_phys_range(); all other architectures use the generic one. On 32-bit architectures with a 64-bit phys_addr_t among them (e.g. ARM with LPAE), a crash kernel region above 4GiB is then truncated to its low 32 bits when /sys/kernel/kexec_crash_size is shrunk: free_reserved_page() is called on unrelated low-memory pages, while the pages that were actually released from the reservation stay reserved forever. This was observed on QEMU (virt, cortex-a15, ARM_LPAE, 6G) with "mem=1G@0x40000000 mem=512M@0x140000000 crashkernel=64M@0x150000000": after "echo 0 > /sys/kernel/kexec_crash_size" the HighMem zone's managed page count stayed unchanged, while the low-memory zone grew by 16384 pages (64MiB), i.e. the pages at 0x50000000-0x53ffffff were "freed" instead of 0x150000000-0x153ffffff. Use phys_addr_t for the range and the loop variable, and PHYS_PFN() to derive the PFN. Fixes: c0bb9e45f3a7 ("kdump: Allow shrinking of kdump region to be overridden") Signed-off-by: Jingyi Sun <1045704958@qq.com> --- Changes in v2: - Say which architectures provide their own helper (Mike Rapoport) - Drop the unrelated x86_64 remark (Mike Rapoport) - No code changes v1: https://lore.kernel.org/all/tencent_0EE98A1C2110785434DE9692533FF737DD07@qq.com/ include/linux/kexec.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index bac11e940e74..e21dcc316bf9 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -484,12 +484,12 @@ static inline phys_addr_t boot_phys_to_phys(unsigned long boot_phys) #endif #ifndef crash_free_reserved_phys_range -static inline void crash_free_reserved_phys_range(unsigned long begin, unsigned long end) +static inline void crash_free_reserved_phys_range(phys_addr_t begin, phys_addr_t end) { - unsigned long addr; + phys_addr_t addr; for (addr = begin; addr < end; addr += PAGE_SIZE) - free_reserved_page(boot_pfn_to_page(addr >> PAGE_SHIFT)); + free_reserved_page(boot_pfn_to_page(PHYS_PFN(addr))); } #endif base-commit: 7cd8495c0f16275c4f9abe1cef09a7b5fcd6d046 -- 2.43.0