Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4507314imu; Tue, 15 Jan 2019 00:57:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN5T6gaHNxnzYrrvfXdRWnZpoVGL7fOjy5xPu6AigcHQMClu5r7N96x4x1KRewBdmEFuXTjQ X-Received: by 2002:a62:32c4:: with SMTP id y187mr2946924pfy.195.1547542642519; Tue, 15 Jan 2019 00:57:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547542642; cv=none; d=google.com; s=arc-20160816; b=IRPm/s1vg6QQMJzJsKNiO8wnTCC/CKacLPYqsjeIKjguJXqmSw86BpfTVOn0ZcrjLB tuJZWZKBvH+Pz41c9vPsTJ9N6aCjMz/MUMRDnimDVF7Fi4ahLdY+WOzOhYI9SVh+QvE8 BWg06qSYvGIYgkvEV1VX39Zbg4RZzsPSWo3oXd7iYtdmAVfmxcbNFWTcbB68TFYzhV5p +7aCJv6Xt+2+hYwexq22xDYInSeoOTo2+oxvVU8nV/yi3Rrfvk3olGGCQwN+jrkbr+sQ ICdE5ux38sc6gq0/ue+p8UlUW75Zxgh6UEv0q4vI9QaPwMPovij2KdkPYjB9I2s6Q/uH QSbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=KORwXFzpEltZpxmTPyMtmgz43m066XMlEdPBJpiM3/0=; b=zoFpPEkcJWW52XgqsLV46lSvRNN68W5cPN1vBaDsbR5NuNBqbOmDkj1Xf5pg2h111q C1FairBca+HBcXy0UOlBx+ncvpjXyZbaxbdTdqFTR+ze0rKf67yXkkb7Ai9u2zQO9B7g ebMOfJOszPqODagVxVby/AriM7J/znWd7mri0OCEYnNSPQv02YhHbVvLgP09nrtMjVag IY8Kp5HF6mgnN09kWiY4KeQ0q+1ydrJNSuepnpn9JvOSDCe1R8aTQRanvnN4SO508waY IEGwi0QGo1JDfKUUiucrQD+wj/19M10Wbwv4A0+6oUFRWngEmx4nEuZGFmoddcQHjfbo bC3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FsIgvhIM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t75si2610979pfi.193.2019.01.15.00.57.07; Tue, 15 Jan 2019 00:57:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FsIgvhIM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727746AbfAOIH0 (ORCPT + 99 others); Tue, 15 Jan 2019 03:07:26 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:34293 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbfAOIH0 (ORCPT ); Tue, 15 Jan 2019 03:07:26 -0500 Received: by mail-pg1-f196.google.com with SMTP id j10so915390pga.1 for ; Tue, 15 Jan 2019 00:07:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=KORwXFzpEltZpxmTPyMtmgz43m066XMlEdPBJpiM3/0=; b=FsIgvhIMImg15PtrbP8s4JebSMkj9LPglBtaib1EdTcWEvzL8cnD40evdiIiFUe2kM q2pQf4YH0sUKXWGHGpQQ9IsqAxfApzKQlMn4PRssXlnmz8Y/7YdkB1O9sa7ytRb1Kw9J n1HTfZre3NC8mU9eQkVQlbedyR1rVTS8SxQIGHUvIqUwE60BP+LWrp3DJ2weVpUfBYtF 3sLvh8LGeChn9NSKwiRJi7ayLP652ZDuyf+r7JCGWaSbk3xOGEu3i519blZyYRb28Ic+ WawfxPOM0eWHSc52OOpGczoZxPMbvGLgr+shyx/LrdiAc4pVHJVbSxqEch/ZjhyYAZsC j4Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=KORwXFzpEltZpxmTPyMtmgz43m066XMlEdPBJpiM3/0=; b=WFLpG+C4tCKMjwOqRvVVlEl88a5HBhZPjycIHLJIZK86jaTZ2nRpkUZBQhYjXZ8hVS HaH/MXRRJ6JIzVXrU4eZFbL+eu3xy9yZP8KbSkdE6xP57re7TEodvgN2y7BYlSAnnIr6 YpY2S9EYoAkw200JcnZawvnjmSfJKRDy+maiUF+LnFxZMvarIcuTiN8buSeVlLozOq9c aJi5RMe5Dipm79TWIQp6S6oFKGcc1HcdfAQxd8U0hX/gygMBGePGeg01XOvXaLrFJAmu UntCyxU37SBsIDMITa6sCsCr1G3dkMxtDXot7Lsq37+jzTC9PwGtRU3Hi0Y5Jtwd7Rqd 9o2g== X-Gm-Message-State: AJcUukdyqUTYs/MECnjbUn7D94gOD0Uk2cJM/x5ycUXK0BX0EbEFr2Xq 2T4Xjw2z2FzRtZ7A1+b4Jw== X-Received: by 2002:a62:5dd1:: with SMTP id n78mr2707653pfj.58.1547539645593; Tue, 15 Jan 2019 00:07:25 -0800 (PST) Received: from mylaptop.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id n186sm2971538pfn.137.2019.01.15.00.07.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jan 2019 00:07:24 -0800 (PST) From: Pingfan Liu To: kexec@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Pingfan Liu , Dave Young , Baoquan He , Andrew Morton , Mike Rapoport , yinghai@kernel.org, vgoyal@redhat.com, Randy Dunlap Subject: [PATCHv7] x86/kdump: bugfix, make the behavior of crashkernel=X consistent with kaslr Date: Tue, 15 Jan 2019 16:07:03 +0800 Message-Id: <1547539623-18201-1-git-send-email-kernelfans@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org People reported a bug on a high end server with many pcie devices, where kernel bootup with crashkernel=384M, and kaslr is enabled. Even though we still see much memory under 896 MB, the finding still failed intermittently. Because currently we can only find region under 896 MB, if without ',high' specified. Then KASLR breaks 896 MB into several parts randomly, and crashkernel reservation need be aligned to 128 MB, that's why failure is found. It raises confusion to the end user that sometimes crashkernel=X works while sometimes fails. If want to make it succeed, customer can change kernel option to "crashkernel=384M,high". Just this give "crashkernel=xx@yy" a very limited space to behave even though its grammar looks more generic. And we can't answer questions raised from customer that confidently: 1) why it doesn't succeed to reserve 896 MB; 2) what's wrong with memory region under 4G; 3) why I have to add ',high', I only require 384 MB, not 3840 MB. This patch tries to get memory region from 896 MB firstly, then [896MB,4G], finally above 4G. Dave Young sent the original post, and I just re-post it with commit log improvement as his requirement. http://lists.infradead.org/pipermail/kexec/2017-October/019571.html There was an old discussion below (previously posted by Chao Wang): https://lkml.org/lkml/2013/10/15/601 Signed-off-by: Pingfan Liu Cc: Dave Young Cc: Baoquan He Cc: Andrew Morton Cc: Mike Rapoport Cc: yinghai@kernel.org, Cc: vgoyal@redhat.com Cc: Randy Dunlap --- v6 -> v7: fix spelling mistake pointed out by Randy arch/x86/kernel/setup.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 3d872a5..fa62c81 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -551,6 +551,22 @@ static void __init reserve_crashkernel(void) high ? CRASH_ADDR_HIGH_MAX : CRASH_ADDR_LOW_MAX, crash_size, CRASH_ALIGN); +#ifdef CONFIG_X86_64 + /* + * crashkernel=X reserve below 896M fails? Try below 4G + */ + if (!high && !crash_base) + crash_base = memblock_find_in_range(CRASH_ALIGN, + (1ULL << 32), + crash_size, CRASH_ALIGN); + /* + * crashkernel=X reserve below 4G fails? Try MAXMEM + */ + if (!high && !crash_base) + crash_base = memblock_find_in_range(CRASH_ALIGN, + CRASH_ADDR_HIGH_MAX, + crash_size, CRASH_ALIGN); +#endif if (!crash_base) { pr_info("crashkernel reservation failed - No suitable area found.\n"); return; -- 2.7.4