Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6537905ybl; Mon, 23 Dec 2019 07:29:01 -0800 (PST) X-Google-Smtp-Source: APXvYqz+f04Rtq/1/F73m7fCNTG9FmB6SW6pghk7SdHjtUSvjHA9Mrv3sYo1iuZWOQeHKUyKM8lq X-Received: by 2002:a9d:6e03:: with SMTP id e3mr17538666otr.46.1577114941896; Mon, 23 Dec 2019 07:29:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577114941; cv=none; d=google.com; s=arc-20160816; b=Pqsu0rFCvBN1qF/Fzk2k4wcqkveHOl4bTN1JU8Hr9Lu9y79bOMEGTATq+7zpjjtFZk ARbMKckMpc8IaZ8nQI/FN8hYpLKJMxoOYJg/aBnOiiDxpQ41GK3nj69An4KGgu0JKq7S LUbyTKpcJhIQjWzPZ6xQqIZYAI9T/INloLbD4AbXqc7bF4Yko9Rpxy1fah5dhFQ6sexm Obn8Bw8WqevugbbJ3rOabr8n3LBXBauNm5JCWFFb8f1OS86I4ULAbA9t7P1jU2RQMohf TUdWJFi2DD32tEaRkzhoo+xjZi6yiocAVXVaiefbbZQSkB6QsYVt5KZ4mZJm08S5v9Ak K0TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=znU3txEUFRkQu0sc2SSwapS/lF1xJYSTYTwArSPrIoE=; b=W4k9kO1wjmHn+LvhW/+inyWHqRpE5I0GG9Bt9rkmBGjB3Re2r8nYd1JgSgnvt8F9g0 EwxKh7Hn5x67KVIId5jQKWOjP9ThZMHaPSRWqI7rlrL4GtYiaMzWVJnJEQFko3e2w9yP fl3uWmVFfjPc/lj3skXHHGpGE8r3uynEr3EHFxRQmJgCmzrhLL9+e+8H9egSftWNlWJP SHWf0JsJ9kjZ0+SnRn1QW9HnW4agq2s9ELAeKtD83U2+M4fg7+sLPraUoRt0HCbDutLm LSwb/ikLOl5E9oJxCuEw34lJWSc4aI/D7lBaIY3ETXbrntNdB5xNIMKV37d3IkIx0/Pc crcQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l26si9901365oti.152.2019.12.23.07.28.50; Mon, 23 Dec 2019 07:29:01 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726994AbfLWP1a (ORCPT + 99 others); Mon, 23 Dec 2019 10:27:30 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:57908 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726828AbfLWP13 (ORCPT ); Mon, 23 Dec 2019 10:27:29 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E941AE2CA5765FA2C7DE; Mon, 23 Dec 2019 23:27:24 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Mon, 23 Dec 2019 23:27:16 +0800 From: Chen Zhou To: , , , , , , CC: , , , , , , Subject: [PATCH v7 2/4] arm64: kdump: reserve crashkenel above 4G for crash dump kernel Date: Mon, 23 Dec 2019 23:23:47 +0800 Message-ID: <20191223152349.180172-3-chenzhou10@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191223152349.180172-1-chenzhou10@huawei.com> References: <20191223152349.180172-1-chenzhou10@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Crashkernel=X tries to reserve memory for the crash dump kernel under 4G. If crashkernel=X,low is specified simultaneously, reserve spcified size low memory for crash kdump kernel devices firstly and then reserve memory above 4G. Signed-off-by: Chen Zhou --- arch/arm64/kernel/setup.c | 8 +++++++- arch/arm64/mm/init.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 56f6645..04d1c87 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -238,7 +238,13 @@ static void __init request_standard_resources(void) kernel_data.end <= res->end) request_resource(res, &kernel_data); #ifdef CONFIG_KEXEC_CORE - /* Userspace will find "Crash kernel" region in /proc/iomem. */ + /* + * Userspace will find "Crash kernel" region in /proc/iomem. + * Note: the low region is renamed as Crash kernel (low). + */ + if (crashk_low_res.end && crashk_low_res.start >= res->start && + crashk_low_res.end <= res->end) + request_resource(res, &crashk_low_res); if (crashk_res.end && crashk_res.start >= res->start && crashk_res.end <= res->end) request_resource(res, &crashk_res); diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index b65dffd..0d7afd5 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -80,6 +80,7 @@ static void __init reserve_crashkernel(void) { unsigned long long crash_base, crash_size; int ret; + phys_addr_t crash_max = arm64_dma32_phys_limit; ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), &crash_size, &crash_base); @@ -87,12 +88,38 @@ static void __init reserve_crashkernel(void) if (ret || !crash_size) return; + ret = reserve_crashkernel_low(); + if (!ret && crashk_low_res.end) { + /* + * If crashkernel=X,low specified, there may be two regions, + * we need to make some changes as follows: + * + * 1. rename the low region as "Crash kernel (low)" + * In order to distinct from the high region and make no effect + * to the use of existing kexec-tools, rename the low region as + * "Crash kernel (low)". + * + * 2. change the upper bound for crash memory + * Set MEMBLOCK_ALLOC_ACCESSIBLE upper bound for crash memory. + * + * 3. mark the low region as "nomap" + * The low region is intended to be used for crash dump kernel + * devices, just mark the low region as "nomap" simply. + */ + const char *rename = "Crash kernel (low)"; + + crashk_low_res.name = rename; + crash_max = MEMBLOCK_ALLOC_ACCESSIBLE; + memblock_mark_nomap(crashk_low_res.start, + resource_size(&crashk_low_res)); + } + crash_size = PAGE_ALIGN(crash_size); if (crash_base == 0) { /* Current arm64 boot protocol requires 2MB alignment */ - crash_base = memblock_find_in_range(0, arm64_dma32_phys_limit, - crash_size, SZ_2M); + crash_base = memblock_find_in_range(0, crash_max, crash_size, + SZ_2M); if (crash_base == 0) { pr_warn("cannot allocate crashkernel (size:0x%llx)\n", crash_size); -- 2.7.4