From nobody Tue Dec 16 17:50:19 2025 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 DBC5D1396 for ; Mon, 22 Jul 2024 03:52:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721620333; cv=none; b=uRH92JgVMhsH+oLzd85n2GT6TuRbvkiSgRuOzWoqlaYjwlnHPH4hD7NMPiepHjaBYyWskJ/LI8wCIdQsKglLFf3SqZrRZoTInC4qqFAgKYZCmAXunZTxXCR6WVPqtvxhQadpyF071a1f7V0e4sIR5M9YvKkvsyjFioUhFllvjTU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721620333; c=relaxed/simple; bh=pUz3zsNSoTxp0DNINxVoUjmyY0qseumNHFhL23K9Nys=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A1lVpET0QRN5bO692cU9/YgX6uZQNV5KVGu3CKklUTL/so1lFbF0J9gKJQ7fwAABeiwrJTZohtt/5WopN2C4KtrVpAWXuC0pgaOst+YwmdwKfHHFH2trPcFS0/c3jb2UzD8Um4vb3jnFszMclFVyvDNFglJ5CBGvmviNfr0yi9E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 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 Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WS5nT6nVKzxSQm; Mon, 22 Jul 2024 11:47:09 +0800 (CST) Received: from kwepemi100008.china.huawei.com (unknown [7.221.188.57]) by mail.maildlp.com (Postfix) with ESMTPS id 1B0721800A1; Mon, 22 Jul 2024 11:52:08 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi100008.china.huawei.com (7.221.188.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 22 Jul 2024 11:52:07 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v4 1/3] x86/kexec: Fix crash memory reserve exceed system memory bug Date: Mon, 22 Jul 2024 11:56:59 +0800 Message-ID: <20240722035701.696874-2-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240722035701.696874-1-ruanjinjie@huawei.com> References: <20240722035701.696874-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi100008.china.huawei.com (7.221.188.57) Content-Type: text/plain; charset="utf-8" On x86_32 Qemu machine with 1GB memory, the cmdline "crashkernel=3D4G" is ok as below: crashkernel reserved: 0x0000000020000000 - 0x0000000120000000 (4096 MB) The cause is that the crash_size is parsed and printed with "unsigned long long" data type which is 8 bytes but allocated used with "phys_addr_t" which is 4 bytes in memblock_phys_alloc_range(). Fix it by checking if the crash_size is greater than system RAM size and warn out as parse_crashkernel_mem() do it if so as Baoquan suggested. After this patch, it fails and there is no above confusing reserve success info. Signed-off-by: Jinjie Ruan Suggested-by: Baoquan He --- v4: - Update the warn info to align with parse_crashkernel_mem(). - Update the commit message. v3: - Handle the check in arch_reserve_crashkernel() Baoquan suggested. - Split x86_32 and arm32. - Add Suggested-by. - Drop the wrong fix tag. v2: - Also fix for x86_32. - Update the fix method. - Peel off the other two patches. - Update the commit message. --- arch/x86/kernel/setup.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 5d34cad9b7b1..77b937dbd98c 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -482,6 +482,11 @@ static void __init arch_reserve_crashkernel(void) if (ret) return; =20 + if (crash_size >=3D memblock_phys_mem_size()) { + pr_warn("Crashkernel: invalid size."); + return; + } + if (xen_pv_domain()) { pr_info("Ignoring crashkernel for a Xen PV domain\n"); return; --=20 2.34.1 From nobody Tue Dec 16 17:50:19 2025 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 6108310979 for ; Mon, 22 Jul 2024 03:52:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721620333; cv=none; b=sqKCr5lLJBGbG+IOfvnmZ2EwV/VVyawdgKcc1oV3drodMxFEQr5LKZFsSE5EMFIaLEo4j/EbeaD9/te0Ru2a8Kn612G9SDjmN1AH8aFiG3sKq0q//umADIlmVVCELx/tXgJ4BuIbisra2c7nvGpU8gKs8BFCic0OGJBhlwnC/+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721620333; c=relaxed/simple; bh=sr6QXu0aogv3BiDGigv5pkL4kHTAC+h15lyetZR7/ko=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TCrHpU4qlw8vZulzDGUx7p/QKJNbXSFQRG8OQWKefctHQuqRcKzcuoR/Sg/AKNXrQbaD4qg9UddHWHnSiT5kGGsOPf/dJx+l1Uv4PiiG/OaUHZQ+l7oZiROvO9hBytkBm1ldmPu7bc0/V1HeAw2oco5Gs6ZhhwDowCi9oJ2WwoQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 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 Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WS5pS4cxPz20krZ; Mon, 22 Jul 2024 11:48:00 +0800 (CST) Received: from kwepemi100008.china.huawei.com (unknown [7.221.188.57]) by mail.maildlp.com (Postfix) with ESMTPS id DD5BE1A016C; Mon, 22 Jul 2024 11:52:08 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi100008.china.huawei.com (7.221.188.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 22 Jul 2024 11:52:07 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v4 2/3] ARM: Fix crash memory reserve exceed system memory bug Date: Mon, 22 Jul 2024 11:57:00 +0800 Message-ID: <20240722035701.696874-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240722035701.696874-1-ruanjinjie@huawei.com> References: <20240722035701.696874-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi100008.china.huawei.com (7.221.188.57) Content-Type: text/plain; charset="utf-8" Similar with x86_32, on Qemu vexpress-a9 with 1GB memory, the crash kernel "crashkernel=3D4G" is ok as below: Reserving 4096MB of memory at 2432MB for crashkernel (System RAM: 1024MB) The cause is that the crash_size is parsed and printed with "unsigned long long" data type which is 8 bytes but allocated used with "phys_addr_t" which is 4 bytes in memblock_phys_alloc_range(). Fix it by checking if the crash_size is greater than system RAM size and warn out as parse_crashkernel_mem() do it if so as Baoquan suggested. After this patch, it fails and there is no above confusing reserve success info. Signed-off-by: Jinjie Ruan Suggested-by: Baoquan He Reviewed-by: Russell King (Oracle) --- v4: - Update the warn info to align with parse_crashkernel_mem(). - Rebased on the "ARM: Use generic interface to simplify crashkernel reservation" patch. - Update the commit message. v3: - Handle the check in reserve_crashkernel() Baoquan suggested. - Split x86_32 and arm32. - Add Suggested-by. - Drop the wrong fix tag. v2: - Also fix for x86_32. - Update the fix method. - Peel off the other two patches. - Update the commit message. --- arch/arm/kernel/setup.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index fc0ada003f6d..aea320dcac41 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -1005,6 +1005,11 @@ static void __init arch_reserve_crashkernel(void) if (ret || !crash_size) return; =20 + if (crash_size >=3D total_mem) { + pr_warn("Crashkernel: invalid size."); + return; + } + reserve_crashkernel_generic(boot_command_line, crash_size, crash_base, lo= w_size, high); =20 if (arm_has_idmap_alias()) { --=20 2.34.1 From nobody Tue Dec 16 17:50:19 2025 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 2FD9812B8B for ; Mon, 22 Jul 2024 03:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721620334; cv=none; b=G0isXPQ1GHXo+8PRmxbQVQh7GbrMAdBcECWI+krAbg2YZouFV1fbALK62htVtsV1djD78YmXdNA6yqwUc+uRniaX3qFS5XLSo/yQy6Fq877iV12lb29MHcvyt/wlnZ9oMo3fNw5QD+NQA3zlzZncKrR8V5c79qBe49+1uk571dk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721620334; c=relaxed/simple; bh=IWFco5zE7qmDL7q2Y1gm33E8h63HaHGW7p+keXeovuU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tsMz92caVQI9KxdvuKaFZl8at03s19aZXVp0iUxQBZuZK8fY4QyEaW+/Dx17pPlWZVE47xIj3w2JtAZqe3xT63lsXVFzQNW9noUMX0/kQzw7kUBT25KtOEWR+YhSJZFPIENb380L/uRdUP7rR4ysYmpNc57UdQf//MDx6pOkjR0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 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 Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WS5pB6SQcz2ClNw; Mon, 22 Jul 2024 11:47:46 +0800 (CST) Received: from kwepemi100008.china.huawei.com (unknown [7.221.188.57]) by mail.maildlp.com (Postfix) with ESMTPS id B63621A0188; Mon, 22 Jul 2024 11:52:09 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi100008.china.huawei.com (7.221.188.57) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 22 Jul 2024 11:52:08 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v4 3/3] riscv: kdump: Fix crash memory reserve exceed system memory bug Date: Mon, 22 Jul 2024 11:57:01 +0800 Message-ID: <20240722035701.696874-4-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240722035701.696874-1-ruanjinjie@huawei.com> References: <20240722035701.696874-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi100008.china.huawei.com (7.221.188.57) Content-Type: text/plain; charset="utf-8" Similar with x86_32, on Riscv32 Qemu "virt" machine with 1GB memory, the crash kernel "crashkernel=3D4G" is ok as below: crashkernel reserved: 0x00000000bf400000 - 0x00000001bf400000 (4096 MB) The cause is that the crash_size is parsed and printed with "unsigned long long" data type which is 8 bytes but allocated used with "phys_addr_t" which is 4 bytes in memblock_phys_alloc_range(). Fix it by checking if the crash_size is greater than system RAM size and warn out as parse_crashkernel_mem() do it if so. After this patch, it fails and there is no above confusing reserve success info. Signed-off-by: Jinjie Ruan --- arch/riscv/mm/init.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index bfa2dea95354..5d66a4937fcd 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -1381,6 +1381,11 @@ static void __init arch_reserve_crashkernel(void) if (ret) return; =20 + if (crash_size >=3D memblock_phys_mem_size()) { + pr_warn("Crashkernel: invalid size."); + return; + } + reserve_crashkernel_generic(cmdline, crash_size, crash_base, low_size, high); } --=20 2.34.1