From patchwork Mon Oct 19 23:38:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 55267 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 5D2FE22F11 for ; Mon, 19 Oct 2015 23:45:53 +0000 (UTC) Received: by lbbor1 with SMTP id or1sf557414lbb.2 for ; Mon, 19 Oct 2015 16:45:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:in-reply-to:references :from:patch-date:subject:to:date:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=MX5xTCYK8WTc/11q0e03jhELYSQQBXedu8WtuY3M+TI=; b=CBDAB9f0VK8LfvjCpJu9eBtzxj/XDpVebV5R6G4+M4KyTgGLKcunJkln8Sg/4wMwJr xUpSLiD0kNy9v90jbgAZIUAs5Q+29cgtbtu61My//PQUjYjdxjGJh5fIXLEb2TgVaaU3 Flj5+VHWxP3b1NGmQTHgQ7Uh9ysDvdYTJvxQaZM0r3iWslEt8BHzY6CVQxIpcprSizmE CTREKnmjI/tUy53Ug6vu/Qd7ttgr0Lb1Opd3QERrqc4p/tBCJxxPKb51WFLfbDavCfae hpvvl5UEVJfS93wxeR8Bu7b2EAN5Hrb059Kj2pVIk2QxiMRiC/QG2cBqkwph47bbfPZV pptQ== X-Gm-Message-State: ALoCoQnIxX0m5dFSGJDMEdhJXuDSPz+QeWBUTneRqKAjZns8WAw8WA2qOO/RIpdPKmwwdHzwdfPW X-Received: by 10.112.55.69 with SMTP id q5mr21065lbp.24.1445298352251; Mon, 19 Oct 2015 16:45:52 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.21.42 with SMTP id l42ls3807lfi.96.gmail; Mon, 19 Oct 2015 16:45:51 -0700 (PDT) X-Received: by 10.25.142.203 with SMTP id q194mr29048lfd.83.1445298351979; Mon, 19 Oct 2015 16:45:51 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id oi8si129839lbb.152.2015.10.19.16.45.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2015 16:45:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbwb3 with SMTP id wb3so981846lbb.1 for ; Mon, 19 Oct 2015 16:45:51 -0700 (PDT) X-Received: by 10.25.86.213 with SMTP id k204mr41498lfb.36.1445298351538; Mon, 19 Oct 2015 16:45:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1757990lbq; Mon, 19 Oct 2015 16:45:50 -0700 (PDT) X-Received: by 10.66.227.101 with SMTP id rz5mr119017pac.123.1445298350524; Mon, 19 Oct 2015 16:45:50 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [198.137.202.9]) by mx.google.com with ESMTPS id sn2si308765pac.146.2015.10.19.16.45.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2015 16:45:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 198.137.202.9 as permitted sender) client-ip=198.137.202.9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoK3l-0008Kf-Vn; Mon, 19 Oct 2015 23:41:46 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZoK15-0002ks-VT; Mon, 19 Oct 2015 23:39:00 +0000 Received: from geoff by merlin.infradead.org with local (Exim 4.85 #2 (Red Hat Linux)) id 1ZoK10-0000wm-73; Mon, 19 Oct 2015 23:38:54 +0000 Message-Id: <2a2dedbeafd39f862f1704a9cc7f57612223ffe5.1445297709.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Wed, 19 Aug 2015 12:07:21 +0900 Subject: [PATCH 11/16] arm64: kdump: reserve memory for crash dump kernel To: Catalin Marinas , Will Deacon Date: Mon, 19 Oct 2015 23:38:54 +0000 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Cc: Mark Rutland , AKASHI@infradead.org, marc.zyngier@arm.com, kexec@lists.infradead.org, Takahiro , linux-arm-kernel@lists.infradead.org, christoffer.dall@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: geoff@infradead.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: AKASHI Takahiro On primary kernel, the memory region used by crash dump kernel must be specified by "crashkernel=" boot parameter. reserve_crashkernel() will allocate and reserve the region for later use. User space tools will be able to find the region marked as "Crash kernel" in /proc/iomem. Signed-off-by: AKASHI Takahiro --- arch/arm64/kernel/setup.c | 7 +++++- arch/arm64/mm/init.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 2322479..9d085ac 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -337,6 +336,12 @@ static void __init request_standard_resources(void) kernel_data.end <= res->end) request_resource(res, &kernel_data); } + +#ifdef CONFIG_KEXEC + /* User space tools will find "Crash kernel" region in /proc/iomem. */ + if (crashk_res.end) + insert_resource(&iomem_resource, &crashk_res); +#endif } #ifdef CONFIG_BLK_DEV_INITRD diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index f5c0680..f33f201 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -66,6 +67,55 @@ static int __init early_initrd(char *p) early_param("initrd", early_initrd); #endif +#ifdef CONFIG_KEXEC +/* + * reserve_crashkernel() - reserves memory for crash kernel + * + * This function reserves memory area given in "crashkernel=" kernel command + * line parameter. The memory reserved is used by dump capture kernel when + * primary kernel is crashing. + */ +static void __init reserve_crashkernel(void) +{ + unsigned long long crash_size = 0, crash_base = 0; + int ret; + + ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), + &crash_size, &crash_base); + if (ret) + return; + + if (crash_base == 0) { + crash_base = memblock_alloc(crash_size, 1 << 21); + if (crash_base == 0) { + pr_warn("Unable to allocate crashkernel (size:%llx)\n", + crash_size); + return; + } + } else { + /* User specifies base address explicitly. */ + if (!memblock_is_region_memory(crash_base, crash_size) || + memblock_is_region_reserved(crash_base, crash_size)) { + pr_warn("crashkernel has wrong address or size\n"); + return; + } + + if (crash_base & ((1 << 21) - 1)) { + pr_warn("crashkernel base address is not 2MB aligned\n"); + return; + } + + memblock_reserve(crash_base, crash_size); + } + + pr_info("Reserving %lldMB of memory at %lldMB for crashkernel\n", + crash_size >> 20, crash_base >> 20); + + crashk_res.start = crash_base; + crashk_res.end = crash_base + crash_size - 1; +} +#endif /* CONFIG_KEXEC */ + /* * Return the maximum physical address for ZONE_DMA (DMA_BIT_MASK(32)). It * currently assumes that for memory starting above 4G, 32-bit devices will @@ -170,6 +220,10 @@ void __init arm64_memblock_init(void) memblock_reserve(__virt_to_phys(initrd_start), initrd_end - initrd_start); #endif +#ifdef CONFIG_KEXEC + reserve_crashkernel(); +#endif + early_init_fdt_scan_reserved_mem(); /* 4GB maximum for 32-bit only capable devices */