Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5938738imu; Sun, 20 Jan 2019 23:53:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN4iRyzeSBaIcex1taDNmY/6s6Rau7zpP8VFSksEsbAya/WxJHMvVvDQlwmpY8i+lheqnu4k X-Received: by 2002:a63:df50:: with SMTP id h16mr27474742pgj.421.1548057226815; Sun, 20 Jan 2019 23:53:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548057226; cv=none; d=google.com; s=arc-20160816; b=w55U0UX+M5CQXCS+q3AKFla0rapcfDRCfnGig2rixraGGawGmhcIctwY43bW8wcYbj Set2eQ9BDS5IWt4+cdT0iXhn4XwVGq4RWgTzn48BjHW8yUOafj6nrDFvd32aKdreyF9Y iHgD7WZi6nL3+p9JKyf5tHvbrrevEOHbRPCg1nijpR9afFMiuzLfaFx4LZYJtVqspLHL h7w0xDaamYMCt5aUwfmbV7VBMjn/CQIZxUPLoTYjEAHnP/HB3XZmao8aoTI66tL6r7RD 4iBdzpyEQXPWz2vkKpYr5I3JfeRZTih9mxNpX8o11Po/UgEfYstssPkkIWDPclliXSR6 1DIQ== 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=VwtpKFkarJQTrnp91bAROukJhzGrFDojqjTq9xzyvLM=; b=QXD+kL4aP5hqndG/WzKVPNKVQy9EXAIrH8M25ciDrzqdmNWg0ccPrLTui9omjcpXK/ CkFBe6Hmat6UsUzDOBPMWnmuzH9hhR+FnRzvYq0UHlWldZVG9AP56rRU0h8ouWA8fGAr dGkVafxWNn+o/+TtrjxMcXk/6l8E8QOE6q+ySsIchA2hdY+qVfIlMH7thwDO+2iL4jcO Bb5X4kZDJJ5pjyipHBUwlA/gbpwSC6RHZQVuMs0w05N63QzdujxYuFu9I/qmH8XmqnJi pghuGHJ/zZBjFbrCmC/ezQXIOTPoLCocvFpgVcxSL6Mx3zhO7TqepS4CH4hrPyGOBZwM 7J7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="QUifWiu/"; 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 e2si11198545pgs.94.2019.01.20.23.53.31; Sun, 20 Jan 2019 23:53:46 -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="QUifWiu/"; 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 S1728832AbfAUHvw (ORCPT + 99 others); Mon, 21 Jan 2019 02:51:52 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34404 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727634AbfAUHvw (ORCPT ); Mon, 21 Jan 2019 02:51:52 -0500 Received: by mail-pf1-f196.google.com with SMTP id h3so9758315pfg.1 for ; Sun, 20 Jan 2019 23:51:51 -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=VwtpKFkarJQTrnp91bAROukJhzGrFDojqjTq9xzyvLM=; b=QUifWiu/dxnIP6lpjGUy3QpJG0R+7KqDRevW7A9+I0xyIC0m0J5rhjA2YDs+iy3nHz TsfjOzNxqmnMXrWyakTOqaMRetpwYFlfV1EUBhQRN4ErmLGwjlW5xQU0guk7Z7ml+ErP ntvRjMF+eC/DuPjBygVuLGCATuTSZcAL7tFNBhIdzyE6CuF6EbkskaHEaGuFRKtXUelh ujGOYF9mcfJDyIEK0nKVqNv+DNz3ErJzdTbhMfn7j2E4Ner4ygiSzw8TpxjsLsO6Ur9+ jb+keQXX+gQurfaA7WcPgwlluG3CxDNywcDuZoYyjEnSvVjRm877C9h1X8cQsisTBKSq HzuQ== 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=VwtpKFkarJQTrnp91bAROukJhzGrFDojqjTq9xzyvLM=; b=NiRHw9S6PMSG8cGBVy6mm+2KmOMzHV9anCySANb0e6pucBTPT66lG1STx8pkT3c2t0 Z1nupasrADg1C6mWtxMohhTbUhiCSPd+jbS8K1gANhQT9nlne4Ixq2pLDsZXvFz7r1Tw +6lqYu40RfBAgifxwFnyyShjtwW0FFA8z5EQydPLmKp9Lu5MGmSqfRSH0JfoI2jH9fVI eQxBDf504TvrU8ktEpUry7FnMEobiAIXv0vGtBOPTWNv4SHdwjc4bs/gCo/XglmBjX1h R53qyMZ8AZ9cQkTTbDkJiRkHcw2QuWDHA671An7htY94w5blDJsTt2dd8VqzpASuwPgc D6AA== X-Gm-Message-State: AJcUukdL41EffZHDxNcYecukoKFWsk+Dr0JHigGMgZRIo1J5IJnP3qDD rG1mks3NWgSlAOZzYiHtztI8DtECcw== X-Received: by 2002:a62:11c7:: with SMTP id 68mr28350595pfr.21.1548047790887; Sun, 20 Jan 2019 21:16:30 -0800 (PST) Received: from mylaptop.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id k24sm16755208pfj.13.2019.01.20.21.16.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Jan 2019 21:16:30 -0800 (PST) From: Pingfan Liu To: kexec@lists.infradead.org Cc: Pingfan Liu , Dave Young , Baoquan He , Andrew Morton , Mike Rapoport , yinghai@kernel.org, vgoyal@redhat.com, Randy Dunlap , Borislav Petkov , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCHv7] x86/kdump: bugfix, make the behavior of crashkernel=X consistent with kaslr Date: Mon, 21 Jan 2019 13:16:08 +0800 Message-Id: <1548047768-7656-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 crashkernel=384M reservation failed on a high end server with KASLR enabled. In that case there is enough free memory under 896M but crashkernel reservation still fails intermittently. The situation is crashkernel reservation code only finds free region under 896 MB with 128M aligned in case no ',high' being used. And KASLR could break the first 896M into several parts randomly thus the failure happens. User has no way to predict and make sure crashkernel=xM working unless he/she use 'crashkernel=xM,high'. Since 'crashkernel=xM' is the most common use case this issue is a serious bug. And we can't answer questions raised from customer: 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 Cc: Borislav Petkov Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org --- v6 -> v7: commit log improvement 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