From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=113.46.200.224 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796002164; b=0cgvIIEyw963kcg5jyBEtG+KZSfniQO9w8+1MUJe9bhuboSxlBFXdbE8W4XezxCct5Bk avlaP8ObvjHAmHW0ZJnOPhxweJ7dHQAXEIVgdg3kykYaaFw1z3eUuEtN+qgWesaQqgowH h/vznZ9BOiJYFYcq17DdSbmy0K9ibRIX3fL7viob2+ZImdhIiGcxIgGAlvwxdlcJOj1cz pr80ofPB7UML46KaBwEe/YSb1/FOUjOH79Ias6COmDK5ujVaeHw6UrS86DHiSuWIsyFnq utFDemNCwQ6IYSzfHACo8L5OonrSQOuKK/Y9wAZ9e75GRBlI4Tuz5/2cWRVwk0+1qhw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796002164; h=DMARC-Filter:dkim-signature:Received:Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:CC:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding:X-Originating-IP: X-ClientProxiedBy; bh=FwmiWbRLbSVVt6TPt3uoiYhyKpSUuNv4oYvm7HwgKYk=; b=Stu1taEjiZa9zMa4epSmFtvbasHcq0mVTiiJdlCpR985Mdv408jg1piAV2wb/cQzij2f 5SrUAaGleDpFtg4vEQ5SH5Ci9ZyitTVgF6mWwLByF0cP50upODn38o01DbPZWaTxinqEk xrW/HB/iKsVDTqWChGhtVdDRxILwb/ZmCVX8Zp/ZZnF41eFcE6KQ+Ehll+XkWtEDkTbvl A5mVB7yhsZIOWxN0ylVytmZ9cuPW+bqOqkK5jtIxDXwOqd0dexNijq7VjsoD8S/u2lWf/ a/ZcZvk3hKX/AtgKjwY/Pb8mtUpmzE0mr++ThHG5jZ8aYHsgIQtSukbnVF2AwV69erA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=4iEMP0HQ; arc=none smtp.remote-ip=113.46.200.224 Received: from canpmsgout09.his.huawei.com (canpmsgout09.his.huawei.com [113.46.200.224]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BBDA606A31C for ; Mon, 30 Nov 2026 01:29:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7BBDA606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=4iEMP0HQ dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=FwmiWbRLbSVVt6TPt3uoiYhyKpSUuNv4oYvm7HwgKYk=; b=4iEMP0HQk32pnn3lemNUr05YyM8ec2Rg2usVW5EbyWREyplJ43DSFsSXUCQDDMcDJMG/coo1V KJ2We61PY1jEBdvWZaSGCx3WdeMgrrw0Xldpm7mNrcYD/dxLjYKK/Vg+5ldequUFAwsh94wmQAb 83laYcjOz1g4mtIkvCjJ3+U= Received: from mail.maildlp.com (unknown [172.19.163.127]) by canpmsgout09.his.huawei.com (SkyGuard) with ESMTPS id 4jd5yP73kTz1cyQk; Mon, 30 Nov 2026 09:28:45 +0800 (CST) Received: from kwepemk200008.china.huawei.com (unknown [7.202.194.74]) by mail.maildlp.com (Postfix) with ESMTPS id 1379440561; Mon, 30 Nov 2026 09:29:13 +0800 (CST) Received: from [10.67.110.68] (10.67.110.68) by kwepemk200008.china.huawei.com (7.202.194.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Mon, 30 Nov 2026 09:29:12 +0800 Message-ID: Date: Mon, 30 Nov 2026 09:29:11 +0800 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] kexec: use phys_addr_t in generic crash_free_reserved_phys_range() To: Jingyi Sun <1045704958@qq.com>, 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 , , , References: From: Jinjie Ruan In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemk200008.china.huawei.com (7.202.194.74) 在 2026/11/29 18:28, Jingyi Sun 写道: > 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 Right, arm32 with LPAE will select PHYS_ADDR_T_64BIT, resource_size_t will be u64. 169 #ifdef CONFIG_PHYS_ADDR_T_64BIT 170 typedef u64 phys_addr_t; 171 #else 172 typedef u32 phys_addr_t; 173 #endif ..... 180 typedef phys_addr_t resource_size_t; 680 config ARM_LPAE 681 >-------bool "Support for the Large Physical Address Extension" 682 >-------depends on MMU && CPU_32v7 && !CPU_32v6 && !CPU_32v5 && \ 683 >------->-------!CPU_32v4 && !CPU_32v3 684 >-------select PHYS_ADDR_T_64BIT > /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. LGTM Reviewed-by: Jinjie Ruan > > 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