From patchwork Tue Jan 24 08:49:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 92286 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1612335qgi; Tue, 24 Jan 2017 00:50:11 -0800 (PST) X-Received: by 10.200.36.43 with SMTP id c40mr29572485qtc.161.1485247811353; Tue, 24 Jan 2017 00:50:11 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id q16si12679207qke.113.2017.01.24.00.50.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:50:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cVwno-0007zw-IF; Tue, 24 Jan 2017 08:50:08 +0000 Received: from mail-pf0-f169.google.com ([209.85.192.169]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVwnP-0006ex-AW for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2017 08:49:45 +0000 Received: by mail-pf0-f169.google.com with SMTP id 189so48830940pfu.3 for ; Tue, 24 Jan 2017 00:49:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WJ6dV6fY/62XXFfkPc35D1L7WkDGpy3g7SIEXbK20fs=; b=ciAW0mCKGaYfoSV/63oeMU+hoC8+LL1ub8VZprHZIdPYrqKTAALgdMaQppCty7Ordd dBHfIFYAlq1T9aMiFkahPhbsaIk/TQNpf06596rvfIQYD0ZbnQYzLrKZ8YZkBRC0U9jl V+kmUdIPIR5wrI9IDnKHXvaJjFjHVaJZB5DbM= 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:in-reply-to :references; bh=WJ6dV6fY/62XXFfkPc35D1L7WkDGpy3g7SIEXbK20fs=; b=HUx3XKmOSGQzR++1KQTYQGym0bIfq+sVwokX3zUnXTQgoNgJBYDyB3LKkx+aem9uT3 C/f/vCVv1BGMTwB5zjDaJHP7EddgGhFYSnPlL1qOvLare+s8ptP/zdM2+eXgPGQs6BPH ub6gidhcpua84st8rh5JG58PIzvAnw+PByQNYrHVr+ZFpzH58Y949I7a2YxyVAKRJt6K tEjX3/4ZltNkQGYbvTPlv8hSTvoMzIApK+hBG0u47wmaBFOOKtbEjBeO2RAgw6ahuSEx zA1JABxGIVEFvnnfB5wuV9pDA1sjI2DvUru2W3vFFZGdeOIRiZOQMInstMVqXvY3srAQ PiUQ== X-Gm-Message-State: AIkVDXJTODFsrIK4ZDqV46ITwA/9lZVV6yed3q5iJ38TBeLPhRkc4MFdoD/UTsIDIk/NZi8e X-Received: by 10.84.128.66 with SMTP id 60mr50414528pla.34.1485247700808; Tue, 24 Jan 2017 00:48:20 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id f3sm42717108pfd.10.2017.01.24.00.48.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:48:20 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, akpm@linux-foundation.org Subject: [PATCH v30 01/11] memblock: add memblock_cap_memory_range() Date: Tue, 24 Jan 2017 17:49:07 +0900 Message-Id: <20170124084907.3838-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124084638.3770-1-takahiro.akashi@linaro.org> References: <20170124084638.3770-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170124_004943_434902_81365959 X-CRM114-Status: GOOD ( 15.24 ) X-Spam-Score: -3.9 (---) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-3.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.192.169 listed in list.dnswl.org] -1.2 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.169 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, AKASHI Takahiro , geoff@infradead.org, kexec@lists.infradead.org, linux-mm@kvack.org, james.morse@arm.com, bauerman@linux.vnet.ibm.com, dyoung@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Add memblock_cap_memory_range() which will remove all the memblock regions except the memory range specified in the arguments. In addition, rework is done on memblock_mem_limit_remove_map() to re-implement it using memblock_cap_memory_range(). This function, like memblock_mem_limit_remove_map(), will not remove memblocks with MEMMAP_NOMAP attribute as they may be mapped and accessed later as "device memory." See the commit a571d4eb55d8 ("mm/memblock.c: add new infrastructure to address the mem limit issue"). This function is used, in a succeeding patch in the series of arm64 kdump suuport, to limit the range of usable memory, or System RAM, on crash dump kernel. (Please note that "mem=" parameter is of little use for this purpose.) Signed-off-by: AKASHI Takahiro Reviewed-by: Will Deacon Acked-by: Catalin Marinas Acked-by: Dennis Chen Cc: linux-mm@kvack.org Cc: Andrew Morton --- include/linux/memblock.h | 1 + mm/memblock.c | 44 +++++++++++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 15 deletions(-) -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 5b759c9acf97..fbfcacc50c29 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -333,6 +333,7 @@ phys_addr_t memblock_mem_size(unsigned long limit_pfn); phys_addr_t memblock_start_of_DRAM(void); phys_addr_t memblock_end_of_DRAM(void); void memblock_enforce_memory_limit(phys_addr_t memory_limit); +void memblock_cap_memory_range(phys_addr_t base, phys_addr_t size); void memblock_mem_limit_remove_map(phys_addr_t limit); bool memblock_is_memory(phys_addr_t addr); int memblock_is_map_memory(phys_addr_t addr); diff --git a/mm/memblock.c b/mm/memblock.c index 7608bc305936..fea1688fef60 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1514,11 +1514,37 @@ void __init memblock_enforce_memory_limit(phys_addr_t limit) (phys_addr_t)ULLONG_MAX); } +void __init memblock_cap_memory_range(phys_addr_t base, phys_addr_t size) +{ + int start_rgn, end_rgn; + int i, ret; + + if (!size) + return; + + ret = memblock_isolate_range(&memblock.memory, base, size, + &start_rgn, &end_rgn); + if (ret) + return; + + /* remove all the MAP regions */ + for (i = memblock.memory.cnt - 1; i >= end_rgn; i--) + if (!memblock_is_nomap(&memblock.memory.regions[i])) + memblock_remove_region(&memblock.memory, i); + + for (i = start_rgn - 1; i >= 0; i--) + if (!memblock_is_nomap(&memblock.memory.regions[i])) + memblock_remove_region(&memblock.memory, i); + + /* truncate the reserved regions */ + memblock_remove_range(&memblock.reserved, 0, base); + memblock_remove_range(&memblock.reserved, + base + size, (phys_addr_t)ULLONG_MAX); +} + void __init memblock_mem_limit_remove_map(phys_addr_t limit) { - struct memblock_type *type = &memblock.memory; phys_addr_t max_addr; - int i, ret, start_rgn, end_rgn; if (!limit) return; @@ -1529,19 +1555,7 @@ void __init memblock_mem_limit_remove_map(phys_addr_t limit) if (max_addr == (phys_addr_t)ULLONG_MAX) return; - ret = memblock_isolate_range(type, max_addr, (phys_addr_t)ULLONG_MAX, - &start_rgn, &end_rgn); - if (ret) - return; - - /* remove all the MAP regions above the limit */ - for (i = end_rgn - 1; i >= start_rgn; i--) { - if (!memblock_is_nomap(&type->regions[i])) - memblock_remove_region(type, i); - } - /* truncate the reserved regions */ - memblock_remove_range(&memblock.reserved, max_addr, - (phys_addr_t)ULLONG_MAX); + memblock_cap_memory_range(0, max_addr); } static int __init_memblock memblock_search(struct memblock_type *type, phys_addr_t addr) From patchwork Tue Jan 24 08:49:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 92287 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1612608qgi; Tue, 24 Jan 2017 00:51:07 -0800 (PST) X-Received: by 10.200.35.150 with SMTP id q22mr29148720qtq.237.1485247867534; Tue, 24 Jan 2017 00:51:07 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id h39si12674879qtc.171.2017.01.24.00.51.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:51:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cVwoj-0000EN-1U; Tue, 24 Jan 2017 08:51:05 +0000 Received: from mail-pf0-f172.google.com ([209.85.192.172]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVwo3-00075L-I3 for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2017 08:50:25 +0000 Received: by mail-pf0-f172.google.com with SMTP id e4so48663005pfg.1 for ; Tue, 24 Jan 2017 00:50:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HyfH8919B4iVG50MWIhtqalqSgWnduuRxqCyWdUriXc=; b=PSuEByT/uiBoTaItjnK/rHonIfHF0AYrRmj2YKJzPILVObJYcwMJwzpXnI8aDs/Em9 7QBkwfKy7qfoY7BC+HJIaaVfkTePyGSA1yAbmEm0e0MhKwNNcfFcCdR3Ay361Viumf4c W68md6Uz9R7eGKa9ZIEc+nQmOt3iWOLNqDyDc= 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:in-reply-to :references; bh=HyfH8919B4iVG50MWIhtqalqSgWnduuRxqCyWdUriXc=; b=lT9ZoIY92AinU636SNE9FU1NlNulFqTAVMZ2dr2N0M0ksTawsUZXe0zPGMJCH8bHUb ZSSEYJMa9YirnqFzxTZijQE3ZTxr6O8FinwGioRZ3He0NAto/kvcTb0qM5LbW+Y4TbpM Qbmf0tj0y6+rv8UKKg0aU6vMSxoFJntz92JzcONYa1cSgXthZ4K7kw+MStOI7zKG1nt0 9gZTts2zKoLg6fOuSA6fADQZBX3UPfFO1h2mJ76AWtHvDQUo+mjMKfJRl5N1mfs26FCK guoKhhf1p6gRl3caL7aya/D5Z86USHYgVPLWLsUE/xAsNljBlHQPjKviUBegLTzByXvl nQ9Q== X-Gm-Message-State: AIkVDXLGow0KdKcQ9iGt+P2jd4NtJm1pATD2KfPhsTl2ICvUhOb9mnelMdppC4Wtn0dIObZk X-Received: by 10.84.233.193 with SMTP id m1mr50079215pln.126.1485247743002; Tue, 24 Jan 2017 00:49:03 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id j128sm42622210pfg.73.2017.01.24.00.49.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:49:02 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v30 02/11] arm64: limit memory regions based on DT property, usable-memory-range Date: Tue, 24 Jan 2017 17:49:56 +0900 Message-Id: <20170124085004.3892-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124084638.3770-1-takahiro.akashi@linaro.org> References: <20170124084638.3770-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170124_005023_624037_493C4990 X-CRM114-Status: GOOD ( 13.73 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source [209.85.192.172 listed in dnsbl.sorbs.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.172 listed in list.dnswl.org] -1.2 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.172 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, geoff@infradead.org, kexec@lists.infradead.org, AKASHI Takahiro , james.morse@arm.com, bauerman@linux.vnet.ibm.com, dyoung@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Crash dump kernel utilizes only a subset of available memory as System RAM. On arm64 kdump, This memory range is advertized to crash dump kernel via a device-tree property under /chosen, linux,usable-memory-range = Crash dump kernel reads this property at boot time and calls memblock_cap_memory_range() to limit usable memory ranges which are described as entries in UEFI memory map table or "memory" nodes in a device tree blob. Signed-off-by: AKASHI Takahiro Reviewed-by: Geoff Levand Acked-by: Catalin Marinas --- arch/arm64/mm/init.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 380ebe705093..6cddb566eb21 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -187,10 +187,45 @@ static int __init early_mem(char *p) } early_param("mem", early_mem); +static int __init early_init_dt_scan_usablemem(unsigned long node, + const char *uname, int depth, void *data) +{ + struct memblock_region *usablemem = (struct memblock_region *)data; + const __be32 *reg; + int len; + + usablemem->size = 0; + + if (depth != 1 || strcmp(uname, "chosen") != 0) + return 0; + + reg = of_get_flat_dt_prop(node, "linux,usable-memory-range", &len); + if (!reg || (len < (dt_root_addr_cells + dt_root_size_cells))) + return 1; + + usablemem->base = dt_mem_next_cell(dt_root_addr_cells, ®); + usablemem->size = dt_mem_next_cell(dt_root_size_cells, ®); + + return 1; +} + +static void __init fdt_enforce_memory_region(void) +{ + struct memblock_region reg; + + of_scan_flat_dt(early_init_dt_scan_usablemem, ®); + + if (reg.size) + memblock_cap_memory_range(reg.base, reg.size); +} + void __init arm64_memblock_init(void) { const s64 linear_region_size = -(s64)PAGE_OFFSET; + /* Handle linux,usable-memory-range property */ + fdt_enforce_memory_region(); + /* * Ensure that the linear region takes up exactly half of the kernel * virtual address space. This way, we can distinguish a linear address From patchwork Tue Jan 24 08:49:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 92288 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1612879qgi; Tue, 24 Jan 2017 00:52:01 -0800 (PST) X-Received: by 10.200.46.248 with SMTP id i53mr26986985qta.281.1485247921471; Tue, 24 Jan 2017 00:52:01 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id v13si12691935qta.74.2017.01.24.00.52.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:52:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cVwpa-0000Y4-Jm; Tue, 24 Jan 2017 08:51:58 +0000 Received: from mail-pf0-f175.google.com ([209.85.192.175]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVwoY-0008Lm-Nd for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2017 08:50:56 +0000 Received: by mail-pf0-f175.google.com with SMTP id y143so48795400pfb.0 for ; Tue, 24 Jan 2017 00:50:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zdSCTFV1vLjWZ/hy43E3mmOmPBYvoJ2qydprPZWgmVw=; b=Dm5QGUTuXc25tJz7bn2OWGxBjwIiapXz7FHolusmAFendz1EG5Q5HavonjgDYWeIqm eDpOhmHgYONUy/WlDva5k24HcmgO7OJGV5gPD3gWPba6VYmxQTK3CbZIkl30nZqXgw4s wiOIjE1oU5UlvjQySyT33Oj6GQzI7Sz41Dvyo= 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:in-reply-to :references; bh=zdSCTFV1vLjWZ/hy43E3mmOmPBYvoJ2qydprPZWgmVw=; b=FLKlmeBcaDgoNE5m3vzwFtz4ME7bvMqVeMX0QD/6YGcPP+N7LjCN+p7gYlCSKtQztE PpT9N03SCp+XQ7rLZkCdOPa5il6CinIKbHW1bhd5E76WWF6JJQ0UDMm1KtK7aVFWqGP6 OXB1b0/drmqrJVUBGMy+A9Wbj1jz2455hHoD1fWFgjBo+cgXWfKXhIXmMI/UHlEpinmP mkCMtPE1SA3/5XUCZKFpHPKiz5pVclOC9pz9oAi7h1XIeAg6GJKJKmYh/SnqYIVJMX7y VEkOTpV3ugoJS8LIN1fKS3Dq2L1a0LvoV/K8FIlFGegSsinqnIYxWUoT+anoEkUBHUy9 9TZA== X-Gm-Message-State: AIkVDXJAXn5UgPfzFm1q0fW2amoc03SJJbuCYNVrWgJCg5gGPMbLDOCCUvwmI+DTqqc4/E1h X-Received: by 10.84.215.215 with SMTP id g23mr49197996plj.85.1485247774181; Tue, 24 Jan 2017 00:49:34 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 18sm3589890pgf.28.2017.01.24.00.49.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:49:33 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v30 03/11] arm64: kdump: reserve memory for crash dump kernel Date: Tue, 24 Jan 2017 17:49:57 +0900 Message-Id: <20170124085004.3892-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124084638.3770-1-takahiro.akashi@linaro.org> References: <20170124084638.3770-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170124_005054_800589_8D3C3168 X-CRM114-Status: GOOD ( 16.29 ) X-Spam-Score: -3.9 (---) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-3.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.192.175 listed in list.dnswl.org] -1.2 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.175 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, Pratyush Anand , geoff@infradead.org, kexec@lists.infradead.org, AKASHI Takahiro , james.morse@arm.com, Mark Salter , bauerman@linux.vnet.ibm.com, dyoung@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org "crashkernel=" kernel parameter specifies the size (and optionally the start address) of the system ram used by crash dump kernel. reserve_crashkernel() will allocate and reserve the memory at the startup of primary kernel. This memory range will be exported to userspace via an entry named "Crash kernel" in /proc/iomem. Signed-off-by: AKASHI Takahiro Signed-off-by: Mark Salter Signed-off-by: Pratyush Anand Reviewed-by: James Morse Acked-by: Catalin Marinas --- arch/arm64/kernel/setup.c | 7 +++++- arch/arm64/mm/init.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index b051367e2149..515e9c6696df 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -224,6 +223,12 @@ static void __init request_standard_resources(void) if (kernel_data.start >= res->start && kernel_data.end <= res->end) request_resource(res, &kernel_data); +#ifdef CONFIG_KEXEC_CORE + /* Userspace will find "Crash kernel" region in /proc/iomem. */ + if (crashk_res.end && crashk_res.start >= res->start && + crashk_res.end <= res->end) + request_resource(res, &crashk_res); +#endif } } diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 6cddb566eb21..2aba75dc7720 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -30,12 +30,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include @@ -76,6 +78,63 @@ static int __init early_initrd(char *p) early_param("initrd", early_initrd); #endif +#ifdef CONFIG_KEXEC_CORE +/* + * 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_base, crash_size; + int ret; + + ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), + &crash_size, &crash_base); + /* no crashkernel= or invalid value specified */ + if (ret || !crash_size) + return; + + crash_size = PAGE_ALIGN(crash_size); + + if (crash_base == 0) { + /* Current arm64 boot protocol requires 2MB alignment */ + crash_base = memblock_find_in_range(0, ARCH_LOW_ADDRESS_LIMIT, + crash_size, SZ_2M); + 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 (!IS_ALIGNED(crash_base, SZ_2M)) { + 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; +} +#else +static void __init reserve_crashkernel(void) +{ +} +#endif /* CONFIG_KEXEC_CORE */ + /* * 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 @@ -331,6 +390,9 @@ void __init arm64_memblock_init(void) arm64_dma_phys_limit = max_zone_dma_phys(); else arm64_dma_phys_limit = PHYS_MASK + 1; + + reserve_crashkernel(); + dma_contiguous_reserve(arm64_dma_phys_limit); memblock_allow_resize(); From patchwork Tue Jan 24 08:49:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 92290 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1613109qgi; Tue, 24 Jan 2017 00:52:53 -0800 (PST) X-Received: by 10.200.51.134 with SMTP id c6mr27165397qtb.258.1485247973850; Tue, 24 Jan 2017 00:52:53 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id s85si12674852qke.158.2017.01.24.00.52.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:52:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cVwqS-000155-AX; Tue, 24 Jan 2017 08:52:52 +0000 Received: from mail-pg0-f45.google.com ([74.125.83.45]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVwoh-00007h-VY for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2017 08:51:06 +0000 Received: by mail-pg0-f45.google.com with SMTP id 14so53302977pgg.1 for ; Tue, 24 Jan 2017 00:50:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uTpY851nbALPjidZdIGPYUWvIB4M/H4+8tKfm9F3ihY=; b=Nfs2FLTCzEZc9FmCjkzMWFxH+R8tNRa1d8K9UhVOr9nYz5qwMwBOm5IoAo4Ak6Koym OkRcV84VVR327qbrpYiQU/EbrM+7QIQZ5SFmvbJaNqtu1jfos5Nw946a8jYpbxh15mCd 2vy+onhscc7U0JHb+oZV/BuPG/rYNPfv+b+QQ= 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:in-reply-to :references; bh=uTpY851nbALPjidZdIGPYUWvIB4M/H4+8tKfm9F3ihY=; b=l6kJTEojdg3/FTwb373oPaNQPR5WWXkmtKVPt55vSEo41wElE46QZJMijcdVTvM8E3 Sl3ZnfbyhUXR2aUymDY5SYIpJ0zJOLYhdmDrAna0642Yo0UlsJafOcWyPV40ekXSJEcD OFENz70i0Ntcnep2PMnD6Q0IQiYXAqqSiiriGYuU6odoAm5o8ugJcGd4aRkguP+EapD7 PpFHY9074th03DGrEOq7cDo9ci8KosDs/3gSYEuOJ/heJRq3CVVO+orUYMzS4rAkVWlM JrHyZyUkTOXvRTnSs3FkvfJvID0K1e407pOxdfeHl25nD9xeVznhOPJsCLDxDmOg5wV+ JqNA== X-Gm-Message-State: AIkVDXJi4R0fqhD7k+nSIUaD56unOSjsk3F6ukTK4p1vx3l9nnOdMxzSxCsdgRbMwhDyfTeg X-Received: by 10.84.179.194 with SMTP id b60mr50265187plc.147.1485247783011; Tue, 24 Jan 2017 00:49:43 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id m136sm3596434pga.22.2017.01.24.00.49.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:49:42 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v30 04/11] arm64: mm: allow for unmapping memory region from kernel mapping Date: Tue, 24 Jan 2017 17:49:58 +0900 Message-Id: <20170124085004.3892-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124084638.3770-1-takahiro.akashi@linaro.org> References: <20170124084638.3770-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170124_005104_301126_AD67A08A X-CRM114-Status: GOOD ( 16.17 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [74.125.83.45 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.83.45 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, geoff@infradead.org, kexec@lists.infradead.org, AKASHI Takahiro , james.morse@arm.com, bauerman@linux.vnet.ibm.com, dyoung@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org The current implementation of create_mapping_late() is only allowed to modify permission attributes (read-only or read-write) against the existing kernel mapping. In this patch, PAGE_KERNEL_INVALID protection attribute is introduced. We will now be able to invalidate (or unmap) some part of the existing kernel mapping by specifying PAGE_KERNEL_INVALID to create_mapping_late(). This feature will be used in a suceeding kdump patch to protect the memory reserved for crash dump kernel once after loaded. Signed-off-by: AKASHI Takahiro --- arch/arm64/include/asm/mmu.h | 2 ++ arch/arm64/include/asm/pgtable-hwdef.h | 2 ++ arch/arm64/include/asm/pgtable-prot.h | 1 + arch/arm64/include/asm/pgtable.h | 4 ++++ arch/arm64/mm/mmu.c | 29 ++++++++++++++++++++--------- 5 files changed, 29 insertions(+), 9 deletions(-) -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h index 47619411f0ff..a6c1367527bc 100644 --- a/arch/arm64/include/asm/mmu.h +++ b/arch/arm64/include/asm/mmu.h @@ -36,6 +36,8 @@ extern void init_mem_pgprot(void); extern void create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys, unsigned long virt, phys_addr_t size, pgprot_t prot, bool page_mappings_only); +extern void create_mapping_late(phys_addr_t phys, unsigned long virt, + phys_addr_t size, pgprot_t prot); extern void *fixmap_remap_fdt(phys_addr_t dt_phys); #endif diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h index eb0c2bd90de9..e66efec31ca9 100644 --- a/arch/arm64/include/asm/pgtable-hwdef.h +++ b/arch/arm64/include/asm/pgtable-hwdef.h @@ -119,6 +119,7 @@ #define PUD_TABLE_BIT (_AT(pgdval_t, 1) << 1) #define PUD_TYPE_MASK (_AT(pgdval_t, 3) << 0) #define PUD_TYPE_SECT (_AT(pgdval_t, 1) << 0) +#define PUD_VALID PUD_TYPE_SECT /* * Level 2 descriptor (PMD). @@ -128,6 +129,7 @@ #define PMD_TYPE_TABLE (_AT(pmdval_t, 3) << 0) #define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0) #define PMD_TABLE_BIT (_AT(pmdval_t, 1) << 1) +#define PMD_VALID PMD_TYPE_SECT /* * Section diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h index 2142c7726e76..945d84cd5df7 100644 --- a/arch/arm64/include/asm/pgtable-prot.h +++ b/arch/arm64/include/asm/pgtable-prot.h @@ -54,6 +54,7 @@ #define PAGE_KERNEL_ROX __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_RDONLY) #define PAGE_KERNEL_EXEC __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE) #define PAGE_KERNEL_EXEC_CONT __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_CONT) +#define PAGE_KERNEL_INVALID __pgprot(0) #define PAGE_HYP __pgprot(_PAGE_DEFAULT | PTE_HYP | PTE_HYP_XN) #define PAGE_HYP_EXEC __pgprot(_PAGE_DEFAULT | PTE_HYP | PTE_RDONLY) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index ffbb9a520563..1904a7c07018 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -364,6 +364,8 @@ extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, #define pmd_bad(pmd) (!(pmd_val(pmd) & PMD_TABLE_BIT)) +#define pmd_valid(pmd) (!!(pmd_val(pmd) & PMD_VALID)) + #define pmd_table(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ PMD_TYPE_TABLE) #define pmd_sect(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ @@ -428,6 +430,7 @@ static inline phys_addr_t pmd_page_paddr(pmd_t pmd) #define pud_none(pud) (!pud_val(pud)) #define pud_bad(pud) (!(pud_val(pud) & PUD_TABLE_BIT)) +#define pud_valid(pud) (!!(pud_val(pud) & PUD_VALID)) #define pud_present(pud) (pud_val(pud)) static inline void set_pud(pud_t *pudp, pud_t pud) @@ -481,6 +484,7 @@ static inline phys_addr_t pud_page_paddr(pud_t pud) #define pgd_none(pgd) (!pgd_val(pgd)) #define pgd_bad(pgd) (!(pgd_val(pgd) & 2)) +#define pgd_valid(pgd) (!!(pgd_val(pgd) & 1)) #define pgd_present(pgd) (pgd_val(pgd)) static inline void set_pgd(pgd_t *pgdp, pgd_t pgd) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 17243e43184e..9c7adcce8e4e 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -133,7 +133,8 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr, * Set the contiguous bit for the subsequent group of PTEs if * its size and alignment are appropriate. */ - if (((addr | PFN_PHYS(pfn)) & ~CONT_PTE_MASK) == 0) { + if ((pgprot_val(prot) & PTE_VALID) && + (((addr | PFN_PHYS(pfn)) & ~CONT_PTE_MASK) == 0)) { if (end - addr >= CONT_PTE_SIZE && !page_mappings_only) __prot = __pgprot(pgprot_val(prot) | PTE_CONT); else @@ -147,7 +148,8 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr, * After the PTE entry has been populated once, we * only allow updates to the permission attributes. */ - BUG_ON(!pgattr_change_is_safe(pte_val(old_pte), pte_val(*pte))); + BUG_ON(pte_valid(old_pte) && pte_valid(*pte) && + !pgattr_change_is_safe(pte_val(old_pte), pte_val(*pte))); } while (pte++, addr += PAGE_SIZE, addr != end); @@ -190,7 +192,8 @@ static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end, * Set the contiguous bit for the subsequent group of * PMDs if its size and alignment are appropriate. */ - if (((addr | phys) & ~CONT_PMD_MASK) == 0) { + if ((pgprot_val(prot) | PMD_VALID) && + ((addr | phys) & ~CONT_PMD_MASK) == 0) { if (end - addr >= CONT_PMD_SIZE) __prot = __pgprot(pgprot_val(prot) | PTE_CONT); @@ -203,7 +206,8 @@ static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end, * After the PMD entry has been populated once, we * only allow updates to the permission attributes. */ - BUG_ON(!pgattr_change_is_safe(pmd_val(old_pmd), + BUG_ON(pmd_valid(old_pmd) && pmd_valid(*pmd) && + !pgattr_change_is_safe(pmd_val(old_pmd), pmd_val(*pmd))); } else { alloc_init_pte(pmd, addr, next, __phys_to_pfn(phys), @@ -263,7 +267,8 @@ static void alloc_init_pud(pgd_t *pgd, unsigned long addr, unsigned long end, * After the PUD entry has been populated once, we * only allow updates to the permission attributes. */ - BUG_ON(!pgattr_change_is_safe(pud_val(old_pud), + BUG_ON(pud_valid(old_pud) && pud_valid(*pud) && + !pgattr_change_is_safe(pud_val(old_pud), pud_val(*pud))); } else { alloc_init_pmd(pud, addr, next, phys, prot, @@ -344,8 +349,8 @@ void __init create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys, pgd_pgtable_alloc, page_mappings_only); } -static void create_mapping_late(phys_addr_t phys, unsigned long virt, - phys_addr_t size, pgprot_t prot) +void create_mapping_late(phys_addr_t phys, unsigned long virt, + phys_addr_t size, pgprot_t prot) { if (virt < VMALLOC_START) { pr_warn("BUG: not creating mapping for %pa at 0x%016lx - outside kernel range\n", @@ -791,14 +796,20 @@ int __init arch_ioremap_pmd_supported(void) int pud_set_huge(pud_t *pud, phys_addr_t phys, pgprot_t prot) { BUG_ON(phys & ~PUD_MASK); - set_pud(pud, __pud(phys | PUD_TYPE_SECT | pgprot_val(mk_sect_prot(prot)))); + set_pud(pud, __pud(phys | + ((pgprot_val(prot) & PUD_VALID) ? + PUD_TYPE_SECT : 0) | + pgprot_val(mk_sect_prot(prot)))); return 1; } int pmd_set_huge(pmd_t *pmd, phys_addr_t phys, pgprot_t prot) { BUG_ON(phys & ~PMD_MASK); - set_pmd(pmd, __pmd(phys | PMD_TYPE_SECT | pgprot_val(mk_sect_prot(prot)))); + set_pmd(pmd, __pmd(phys | + ((pgprot_val(prot) & PMD_VALID) ? + PMD_TYPE_SECT : 0) | + pgprot_val(mk_sect_prot(prot)))); return 1; } From patchwork Tue Jan 24 08:49:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 92302 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1617008qgi; Tue, 24 Jan 2017 01:04:57 -0800 (PST) X-Received: by 10.237.39.222 with SMTP id m30mr26463323qtg.118.1485248697697; Tue, 24 Jan 2017 01:04:57 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id v144si12687015qkb.327.2017.01.24.01.04.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 01:04:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cVx26-0001Cu-U2; Tue, 24 Jan 2017 09:04:54 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVx25-000152-Ad for linux-arm-kernel@bombadil.infradead.org; Tue, 24 Jan 2017 09:04:53 +0000 Received: from mail-pf0-x233.google.com ([2607:f8b0:400e:c00::233]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVwor-0000Vm-Si for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2017 08:51:15 +0000 Received: by mail-pf0-x233.google.com with SMTP id e4so48668508pfg.1 for ; Tue, 24 Jan 2017 00:50:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yF10t225wjBuPwfHzgu+QRvB4nO8nfwn8f+En1S8SQE=; b=iAAYGiM1Jc4ygU/9ghQe85OmC698NPr3cco9bLAqihKXc53gJemL+vsaIVgHTjbKR4 dmht1XpAsvf131p+M//ooKn4PKps3/sjR1b/4AM/QDEi7KsorNDmlUlI8VL9++Z/MTra m5+gVHHyeYdN+hY35aXnHIhCVn9BSPxmRGi/0= 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:in-reply-to :references; bh=yF10t225wjBuPwfHzgu+QRvB4nO8nfwn8f+En1S8SQE=; b=r6j0jq/3TtRQtMptzCwER0Z5ZPP+QmVufAEtPKjGMyRoaT4mNgxcgTmRWk2HQnKtbC 8Yazmy62K8LfpEHAuSInNtEx6+OVzhHx31qUvVTCPYSy4UXvsRVpqTPoirrW7Sv4oFKM opeqmX4N0f7intmajDTeJtPh5anVWP9fT4HFXYneA7cJVq+dvRauE2wyHYXF6E8dnNB3 hwplkft1NSMOEE3+Ikydarccv6aj4ZvBMQa6krMsxg0HaLKQM2ZB9goFgM/Gy6nRp2w3 cfNeZIdFzdyvBTpvDV7q1iDHN0fYsQXqfftCg+bLaNUOzDSBUpXpKiSYVAjZ7cCNzopq Sx0A== X-Gm-Message-State: AIkVDXJL9I9fvyXmuyMrTbAKyUXIHuWu6NONuuRFz+95ITm9BA5OIqbwrhBwlxwdIO84fht1 X-Received: by 10.98.252.203 with SMTP id e194mr36745699pfh.8.1485247791716; Tue, 24 Jan 2017 00:49:51 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id o18sm3583538pgn.36.2017.01.24.00.49.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:49:51 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v30 05/11] arm64: kdump: protect crash dump kernel memory Date: Tue, 24 Jan 2017 17:49:59 +0900 Message-Id: <20170124085004.3892-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124084638.3770-1-takahiro.akashi@linaro.org> References: <20170124084638.3770-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170124_085114_094934_E25DEA6E X-CRM114-Status: GOOD ( 20.85 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-2.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c00:0:0:0:233 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, geoff@infradead.org, kexec@lists.infradead.org, AKASHI Takahiro , james.morse@arm.com, bauerman@linux.vnet.ibm.com, dyoung@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org To protect the memory reserved for crash dump kernel once after loaded, arch_kexec_protect_crashres/unprotect_crashres() are meant to deal with permissions of the corresponding kernel mappings. We also have to - put the region in an isolated mapping, and - move copying kexec's control_code_page to machine_kexec_prepare() so that the region will be completely read-only after loading. Note that the region must reside in linear mapping and have corresponding page structures in order to be potentially freed by shrinking it through /sys/kernel/kexec_crash_size. Signed-off-by: AKASHI Takahiro --- arch/arm64/kernel/machine_kexec.c | 68 +++++++++++++++++++++++++-------------- arch/arm64/mm/mmu.c | 34 ++++++++++++++++++++ 2 files changed, 77 insertions(+), 25 deletions(-) -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index bc96c8a7fc79..f7938fecf3ff 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -14,6 +14,7 @@ #include #include +#include #include #include "cpu-reset.h" @@ -22,8 +23,6 @@ extern const unsigned char arm64_relocate_new_kernel[]; extern const unsigned long arm64_relocate_new_kernel_size; -static unsigned long kimage_start; - /** * kexec_image_info - For debugging output. */ @@ -64,7 +63,7 @@ void machine_kexec_cleanup(struct kimage *kimage) */ int machine_kexec_prepare(struct kimage *kimage) { - kimage_start = kimage->start; + void *reboot_code_buffer; kexec_image_info(kimage); @@ -73,6 +72,21 @@ int machine_kexec_prepare(struct kimage *kimage) return -EBUSY; } + reboot_code_buffer = + phys_to_virt(page_to_phys(kimage->control_code_page)); + + /* + * Copy arm64_relocate_new_kernel to the reboot_code_buffer for use + * after the kernel is shut down. + */ + memcpy(reboot_code_buffer, arm64_relocate_new_kernel, + arm64_relocate_new_kernel_size); + + /* Flush the reboot_code_buffer in preparation for its execution. */ + __flush_dcache_area(reboot_code_buffer, arm64_relocate_new_kernel_size); + flush_icache_range((uintptr_t)reboot_code_buffer, + arm64_relocate_new_kernel_size); + return 0; } @@ -143,7 +157,6 @@ static void kexec_segment_flush(const struct kimage *kimage) void machine_kexec(struct kimage *kimage) { phys_addr_t reboot_code_buffer_phys; - void *reboot_code_buffer; /* * New cpus may have become stuck_in_kernel after we loaded the image. @@ -151,7 +164,6 @@ void machine_kexec(struct kimage *kimage) BUG_ON(cpus_are_stuck_in_kernel() || (num_online_cpus() > 1)); reboot_code_buffer_phys = page_to_phys(kimage->control_code_page); - reboot_code_buffer = phys_to_virt(reboot_code_buffer_phys); kexec_image_info(kimage); @@ -159,32 +171,20 @@ void machine_kexec(struct kimage *kimage) kimage->control_code_page); pr_debug("%s:%d: reboot_code_buffer_phys: %pa\n", __func__, __LINE__, &reboot_code_buffer_phys); - pr_debug("%s:%d: reboot_code_buffer: %p\n", __func__, __LINE__, - reboot_code_buffer); pr_debug("%s:%d: relocate_new_kernel: %p\n", __func__, __LINE__, arm64_relocate_new_kernel); pr_debug("%s:%d: relocate_new_kernel_size: 0x%lx(%lu) bytes\n", __func__, __LINE__, arm64_relocate_new_kernel_size, arm64_relocate_new_kernel_size); - /* - * Copy arm64_relocate_new_kernel to the reboot_code_buffer for use - * after the kernel is shut down. - */ - memcpy(reboot_code_buffer, arm64_relocate_new_kernel, - arm64_relocate_new_kernel_size); - - /* Flush the reboot_code_buffer in preparation for its execution. */ - __flush_dcache_area(reboot_code_buffer, arm64_relocate_new_kernel_size); - flush_icache_range((uintptr_t)reboot_code_buffer, - arm64_relocate_new_kernel_size); - - /* Flush the kimage list and its buffers. */ - kexec_list_flush(kimage); + if (kimage != kexec_crash_image) { + /* Flush the kimage list and its buffers. */ + kexec_list_flush(kimage); - /* Flush the new image if already in place. */ - if (kimage->head & IND_DONE) - kexec_segment_flush(kimage); + /* Flush the new image if already in place. */ + if (kimage->head & IND_DONE) + kexec_segment_flush(kimage); + } pr_info("Bye!\n"); @@ -201,7 +201,7 @@ void machine_kexec(struct kimage *kimage) */ cpu_soft_restart(1, reboot_code_buffer_phys, kimage->head, - kimage_start, 0); + kimage->start, 0); BUG(); /* Should never get here. */ } @@ -210,3 +210,21 @@ void machine_crash_shutdown(struct pt_regs *regs) { /* Empty routine needed to avoid build errors. */ } + +void arch_kexec_protect_crashkres(void) +{ + kexec_segment_flush(kexec_crash_image); + + create_mapping_late(crashk_res.start, __phys_to_virt(crashk_res.start), + resource_size(&crashk_res), PAGE_KERNEL_INVALID); + + flush_tlb_all(); +} + +void arch_kexec_unprotect_crashkres(void) +{ + create_mapping_late(crashk_res.start, __phys_to_virt(crashk_res.start), + resource_size(&crashk_res), PAGE_KERNEL); + + flush_tlb_all(); +} diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 9c7adcce8e4e..2d4a0b68a852 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -367,6 +368,39 @@ static void __init __map_memblock(pgd_t *pgd, phys_addr_t start, phys_addr_t end unsigned long kernel_start = __pa(_text); unsigned long kernel_end = __pa(__init_begin); +#ifdef CONFIG_KEXEC_CORE + /* + * While crash dump kernel memory is contained in a single memblock + * for now, it should appear in an isolated mapping so that we can + * independently unmap the region later. + */ + if (crashk_res.end && crashk_res.start >= start && + crashk_res.end <= end) { + if (crashk_res.start != start) + __create_pgd_mapping(pgd, start, __phys_to_virt(start), + crashk_res.start - start, + PAGE_KERNEL, + early_pgtable_alloc, + debug_pagealloc_enabled()); + + /* before kexec_load(), the region can be read-writable. */ + __create_pgd_mapping(pgd, crashk_res.start, + __phys_to_virt(crashk_res.start), + crashk_res.end - crashk_res.start + 1, + PAGE_KERNEL, early_pgtable_alloc, + debug_pagealloc_enabled()); + + if (crashk_res.end != end) + __create_pgd_mapping(pgd, crashk_res.end + 1, + __phys_to_virt(crashk_res.end + 1), + end - crashk_res.end - 1, + PAGE_KERNEL, + early_pgtable_alloc, + debug_pagealloc_enabled()); + return; + } +#endif + /* * Take care not to create a writable alias for the * read-only text and rodata sections of the kernel image. From patchwork Tue Jan 24 08:50:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 92291 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1613449qgi; Tue, 24 Jan 2017 00:54:10 -0800 (PST) X-Received: by 10.237.39.222 with SMTP id m30mr26436309qtg.118.1485248050511; Tue, 24 Jan 2017 00:54:10 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id p11si12662219qkh.213.2017.01.24.00.54.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:54:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cVwrg-0001gd-Vr; Tue, 24 Jan 2017 08:54:08 +0000 Received: from mail-pg0-f41.google.com ([74.125.83.41]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVwoz-0000C6-Hz for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2017 08:51:25 +0000 Received: by mail-pg0-f41.google.com with SMTP id 194so53303157pgd.2 for ; Tue, 24 Jan 2017 00:51:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8K+FHoa9uMqfhAwQZOLOvTMDs4EcE3JSI+l2FEgQ+tE=; b=XWhMvc2jdn2Djt3OEx+acx6U2SFl4Cj4aUy3RjU+KQIkj9RfmkSBw6eYOlk0KtXwpg cGNDuV8Ch4b4MVQjaNkYH+ZwJdy7WDUoiEBQSNvbHUocwYofMg7u0ZSqkqROhKhJW/q0 SpslPfGdG9rTLQv8+Mog9sQIspLccy0hut8r8= 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:in-reply-to :references; bh=8K+FHoa9uMqfhAwQZOLOvTMDs4EcE3JSI+l2FEgQ+tE=; b=pwjlDpaBr4hEpFY++CbgMmWSSfmkY/qTe9EQr75SIu2QEf8QSzsOTs7av7hio6Zazh pZRo+cggtvFKpjb9H0rct+drjKA0S0deG0i4gl/kM0AAfcaOz/g839LwlbgmpBvjdQxc Deh2aNDR30ttCb+DjvW0fzdZGss8RQ6TQOvgoENem+bvLZW89mo14V7Fzf97WRurT1y0 ikr8n8/J8c2gsbvVEnjaeuTSFFFiLFNobDa+hTFO6k5LhyiqB2/vEhljuOEmR7jxsgUN I61VyVza0jLCX2gwP3Cfs/+E0lKf/hZBLwZaNLoNgeU9V2s01cOjhgzehBCFxGIlUDfL ZJ/w== X-Gm-Message-State: AIkVDXI1qiKiCYOHrzoT0teYsggLbRaWbgJw3KuzW5m/xu7ATK3e9kAd+Bdt3UWP0kLSyVEH X-Received: by 10.84.234.1 with SMTP id m1mr49851005plk.155.1485247800366; Tue, 24 Jan 2017 00:50:00 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id r21sm42506603pfd.95.2017.01.24.00.49.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:49:59 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v30 06/11] arm64: kdump: implement machine_crash_shutdown() Date: Tue, 24 Jan 2017 17:50:00 +0900 Message-Id: <20170124085004.3892-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124084638.3770-1-takahiro.akashi@linaro.org> References: <20170124084638.3770-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170124_005121_623892_0E83EE90 X-CRM114-Status: GOOD ( 20.65 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [74.125.83.41 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.83.41 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, geoff@infradead.org, kexec@lists.infradead.org, AKASHI Takahiro , james.morse@arm.com, bauerman@linux.vnet.ibm.com, dyoung@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Primary kernel calls machine_crash_shutdown() to shut down non-boot cpus and save registers' status in per-cpu ELF notes before starting crash dump kernel. See kernel_kexec(). Even if not all secondary cpus have shut down, we do kdump anyway. As we don't have to make non-boot(crashed) cpus offline (to preserve correct status of cpus at crash dump) before shutting down, this patch also adds a variant of smp_send_stop(). Signed-off-by: AKASHI Takahiro Reviewed-by: James Morse Acked-by: Catalin Marinas --- arch/arm64/include/asm/hardirq.h | 2 +- arch/arm64/include/asm/kexec.h | 42 +++++++++++++++++++++++++- arch/arm64/include/asm/smp.h | 2 ++ arch/arm64/kernel/machine_kexec.c | 55 +++++++++++++++++++++++++++++++--- arch/arm64/kernel/smp.c | 63 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 158 insertions(+), 6 deletions(-) -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/include/asm/hardirq.h b/arch/arm64/include/asm/hardirq.h index 8740297dac77..1473fc2f7ab7 100644 --- a/arch/arm64/include/asm/hardirq.h +++ b/arch/arm64/include/asm/hardirq.h @@ -20,7 +20,7 @@ #include #include -#define NR_IPI 6 +#define NR_IPI 7 typedef struct { unsigned int __softirq_pending; diff --git a/arch/arm64/include/asm/kexec.h b/arch/arm64/include/asm/kexec.h index 04744dc5fb61..f40ace1fa21a 100644 --- a/arch/arm64/include/asm/kexec.h +++ b/arch/arm64/include/asm/kexec.h @@ -40,7 +40,47 @@ static inline void crash_setup_regs(struct pt_regs *newregs, struct pt_regs *oldregs) { - /* Empty routine needed to avoid build errors. */ + if (oldregs) { + memcpy(newregs, oldregs, sizeof(*newregs)); + } else { + u64 tmp1, tmp2; + + __asm__ __volatile__ ( + "stp x0, x1, [%2, #16 * 0]\n" + "stp x2, x3, [%2, #16 * 1]\n" + "stp x4, x5, [%2, #16 * 2]\n" + "stp x6, x7, [%2, #16 * 3]\n" + "stp x8, x9, [%2, #16 * 4]\n" + "stp x10, x11, [%2, #16 * 5]\n" + "stp x12, x13, [%2, #16 * 6]\n" + "stp x14, x15, [%2, #16 * 7]\n" + "stp x16, x17, [%2, #16 * 8]\n" + "stp x18, x19, [%2, #16 * 9]\n" + "stp x20, x21, [%2, #16 * 10]\n" + "stp x22, x23, [%2, #16 * 11]\n" + "stp x24, x25, [%2, #16 * 12]\n" + "stp x26, x27, [%2, #16 * 13]\n" + "stp x28, x29, [%2, #16 * 14]\n" + "mov %0, sp\n" + "stp x30, %0, [%2, #16 * 15]\n" + + "/* faked current PSTATE */\n" + "mrs %0, CurrentEL\n" + "mrs %1, SPSEL\n" + "orr %0, %0, %1\n" + "mrs %1, DAIF\n" + "orr %0, %0, %1\n" + "mrs %1, NZCV\n" + "orr %0, %0, %1\n" + /* pc */ + "adr %1, 1f\n" + "1:\n" + "stp %1, %0, [%2, #16 * 16]\n" + : "=&r" (tmp1), "=&r" (tmp2) + : "r" (newregs) + : "memory" + ); + } } #endif /* __ASSEMBLY__ */ diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h index d050d720a1b4..cea009f2657d 100644 --- a/arch/arm64/include/asm/smp.h +++ b/arch/arm64/include/asm/smp.h @@ -148,6 +148,8 @@ static inline void cpu_panic_kernel(void) */ bool cpus_are_stuck_in_kernel(void); +extern void smp_send_crash_stop(void); + #endif /* ifndef __ASSEMBLY__ */ #endif /* ifndef __ASM_SMP_H */ diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index f7938fecf3ff..d56ea8c805a8 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -9,6 +9,9 @@ * published by the Free Software Foundation. */ +#include +#include +#include #include #include @@ -161,7 +164,8 @@ void machine_kexec(struct kimage *kimage) /* * New cpus may have become stuck_in_kernel after we loaded the image. */ - BUG_ON(cpus_are_stuck_in_kernel() || (num_online_cpus() > 1)); + BUG_ON((cpus_are_stuck_in_kernel() || (num_online_cpus() > 1)) && + !WARN_ON(kimage == kexec_crash_image)); reboot_code_buffer_phys = page_to_phys(kimage->control_code_page); @@ -200,15 +204,58 @@ void machine_kexec(struct kimage *kimage) * relocation is complete. */ - cpu_soft_restart(1, reboot_code_buffer_phys, kimage->head, - kimage->start, 0); + cpu_soft_restart(kimage != kexec_crash_image, + reboot_code_buffer_phys, kimage->head, kimage->start, 0); BUG(); /* Should never get here. */ } +static void machine_kexec_mask_interrupts(void) +{ + unsigned int i; + struct irq_desc *desc; + + for_each_irq_desc(i, desc) { + struct irq_chip *chip; + int ret; + + chip = irq_desc_get_chip(desc); + if (!chip) + continue; + + /* + * First try to remove the active state. If this + * fails, try to EOI the interrupt. + */ + ret = irq_set_irqchip_state(i, IRQCHIP_STATE_ACTIVE, false); + + if (ret && irqd_irq_inprogress(&desc->irq_data) && + chip->irq_eoi) + chip->irq_eoi(&desc->irq_data); + + if (chip->irq_mask) + chip->irq_mask(&desc->irq_data); + + if (chip->irq_disable && !irqd_irq_disabled(&desc->irq_data)) + chip->irq_disable(&desc->irq_data); + } +} + +/** + * machine_crash_shutdown - shutdown non-crashing cpus and save registers + */ void machine_crash_shutdown(struct pt_regs *regs) { - /* Empty routine needed to avoid build errors. */ + local_irq_disable(); + + /* shutdown non-crashing cpus */ + smp_send_crash_stop(); + + /* for crashing cpu */ + crash_save_cpu(regs, smp_processor_id()); + machine_kexec_mask_interrupts(); + + pr_info("Starting crashdump kernel...\n"); } void arch_kexec_protect_crashkres(void) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index cb87234cfcf2..446c6d48f8ec 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -74,6 +75,7 @@ enum ipi_msg_type { IPI_RESCHEDULE, IPI_CALL_FUNC, IPI_CPU_STOP, + IPI_CPU_CRASH_STOP, IPI_TIMER, IPI_IRQ_WORK, IPI_WAKEUP @@ -753,6 +755,7 @@ static const char *ipi_types[NR_IPI] __tracepoint_string = { S(IPI_RESCHEDULE, "Rescheduling interrupts"), S(IPI_CALL_FUNC, "Function call interrupts"), S(IPI_CPU_STOP, "CPU stop interrupts"), + S(IPI_CPU_CRASH_STOP, "CPU stop (for crash dump) interrupts"), S(IPI_TIMER, "Timer broadcast interrupts"), S(IPI_IRQ_WORK, "IRQ work interrupts"), S(IPI_WAKEUP, "CPU wake-up interrupts"), @@ -827,6 +830,29 @@ static void ipi_cpu_stop(unsigned int cpu) cpu_relax(); } +#ifdef CONFIG_KEXEC_CORE +static atomic_t waiting_for_crash_ipi; +#endif + +static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs) +{ +#ifdef CONFIG_KEXEC_CORE + crash_save_cpu(regs, cpu); + + atomic_dec(&waiting_for_crash_ipi); + + local_irq_disable(); + +#ifdef CONFIG_HOTPLUG_CPU + if (cpu_ops[cpu]->cpu_die) + cpu_ops[cpu]->cpu_die(cpu); +#endif + + /* just in case */ + cpu_park_loop(); +#endif +} + /* * Main handler for inter-processor interrupts */ @@ -857,6 +883,15 @@ void handle_IPI(int ipinr, struct pt_regs *regs) irq_exit(); break; + case IPI_CPU_CRASH_STOP: + if (IS_ENABLED(CONFIG_KEXEC_CORE)) { + irq_enter(); + ipi_cpu_crash_stop(cpu, regs); + + unreachable(); + } + break; + #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST case IPI_TIMER: irq_enter(); @@ -929,6 +964,34 @@ void smp_send_stop(void) cpumask_pr_args(cpu_online_mask)); } +#ifdef CONFIG_KEXEC_CORE +void smp_send_crash_stop(void) +{ + cpumask_t mask; + unsigned long timeout; + + if (num_online_cpus() == 1) + return; + + cpumask_copy(&mask, cpu_online_mask); + cpumask_clear_cpu(smp_processor_id(), &mask); + + atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); + + pr_crit("SMP: stopping secondary CPUs\n"); + smp_cross_call(&mask, IPI_CPU_CRASH_STOP); + + /* Wait up to one second for other CPUs to stop */ + timeout = USEC_PER_SEC; + while ((atomic_read(&waiting_for_crash_ipi) > 0) && timeout--) + udelay(1); + + if (atomic_read(&waiting_for_crash_ipi) > 0) + pr_warning("SMP: failed to stop secondary CPUs %*pbl\n", + cpumask_pr_args(cpu_online_mask)); +} +#endif + /* * not supported here */ From patchwork Tue Jan 24 08:50:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 92292 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1613572qgi; Tue, 24 Jan 2017 00:54:40 -0800 (PST) X-Received: by 10.55.68.74 with SMTP id r71mr23299028qka.157.1485248080162; Tue, 24 Jan 2017 00:54:40 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id z59si12666562qtc.317.2017.01.24.00.54.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:54:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cVwsA-0001y7-Hw; Tue, 24 Jan 2017 08:54:38 +0000 Received: from mail-pf0-f175.google.com ([209.85.192.175]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVwp7-0000HR-IL for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2017 08:51:32 +0000 Received: by mail-pf0-f175.google.com with SMTP id e4so48670521pfg.1 for ; Tue, 24 Jan 2017 00:51:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iItLECIdcsb47NvzAUmuEPhkUz55+9UqLtX7wRmEARk=; b=Sl2y2Jm4+KWYh1p3SMlttA3vvNQyLPhGrE7v1B38J760RXKBXVcQ+HFKAwpsfPwx5Q Zur3/ndlS32CkDfDJTUFouZWhBVAWGbslFYHEOy4MBQ364L0v90cfb0JjYGE2Dw9FLeU wOC8bh76UGcMfFri7juTRqkRnxzMFU4KHRyfk= 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:in-reply-to :references; bh=iItLECIdcsb47NvzAUmuEPhkUz55+9UqLtX7wRmEARk=; b=feiW//g5WON33azbk7+XHRHc8H7Dyf4Lx7G24NSfxuq+BgjIGRnFamFsS/U7/jcXXi BHHWqZpYjddI6fEVa5t1aR1Z6d2OxStBVMfOVIzvotwxbhDfHV9suWvu0rAvCMa9jMFp 5klLQJoKLXW+k/f32D8ON5UbkIVSxTesPzkkCHKxUSqhq+vdCjSlDwXg6VRalwqFmbuu OT29a0uZ81hoj96p6pGkMziUp4217k71b7QYmJqi7Zso/LWXr24NPzbxwtC9imRU8DUO qEKusuCW0hFEubNgjC4h9367y7fITxX5RB0uvKbNNDSQB5LL9aPQ/QTIjWXHHMG2lZtJ fM2Q== X-Gm-Message-State: AIkVDXLJVtXxqFin+tmd67brHy0fMcegKJIEN8M7NBH1MdD+RPDhZAr8iLiHZGq5gw1wZMLE X-Received: by 10.98.210.3 with SMTP id c3mr36858788pfg.7.1485247808204; Tue, 24 Jan 2017 00:50:08 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id z70sm42706101pff.26.2017.01.24.00.50.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:50:07 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v30 07/11] arm64: kdump: add VMCOREINFO's for user-space tools Date: Tue, 24 Jan 2017 17:50:01 +0900 Message-Id: <20170124085004.3892-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124084638.3770-1-takahiro.akashi@linaro.org> References: <20170124084638.3770-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170124_005129_839356_8E2A7A60 X-CRM114-Status: GOOD ( 10.88 ) X-Spam-Score: -3.9 (---) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-3.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.2 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.175 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.192.175 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, geoff@infradead.org, kexec@lists.infradead.org, AKASHI Takahiro , james.morse@arm.com, bauerman@linux.vnet.ibm.com, dyoung@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org In addition to common VMCOREINFO's defined in crash_save_vmcoreinfo_init(), we need to know, for crash utility, - kimage_voffset - PHYS_OFFSET to examine the contents of a dump file (/proc/vmcore) correctly due to the introduction of KASLR (CONFIG_RANDOMIZE_BASE) in v4.6. - VA_BITS is also required for makedumpfile command. arch_crash_save_vmcoreinfo() appends them to the dump file. More VMCOREINFO's may be added later. Signed-off-by: AKASHI Takahiro Reviewed-by: James Morse Acked-by: Catalin Marinas --- arch/arm64/kernel/machine_kexec.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index d56ea8c805a8..84c5761af336 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -275,3 +276,13 @@ void arch_kexec_unprotect_crashkres(void) flush_tlb_all(); } + +void arch_crash_save_vmcoreinfo(void) +{ + VMCOREINFO_NUMBER(VA_BITS); + /* Please note VMCOREINFO_NUMBER() uses "%d", not "%x" */ + vmcoreinfo_append_str("NUMBER(kimage_voffset)=0x%llx\n", + kimage_voffset); + vmcoreinfo_append_str("NUMBER(PHYS_OFFSET)=0x%llx\n", + PHYS_OFFSET); +} From patchwork Tue Jan 24 08:50:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 92293 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1613898qgi; Tue, 24 Jan 2017 00:55:56 -0800 (PST) X-Received: by 10.55.26.159 with SMTP id l31mr29318059qkh.164.1485248156121; Tue, 24 Jan 2017 00:55:56 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id s49si12684870qtb.234.2017.01.24.00.55.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:55:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cVwtO-0003m9-H2; Tue, 24 Jan 2017 08:55:54 +0000 Received: from mail-pf0-f170.google.com ([209.85.192.170]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVwpG-0000Io-Jo for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2017 08:51:40 +0000 Received: by mail-pf0-f170.google.com with SMTP id y143so48800233pfb.0 for ; Tue, 24 Jan 2017 00:51:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=r7RumiG5q7ZC+xhq06ojzN56YhWI2Gk6+rQDYe/Lt5Y=; b=eiMMkkLeDqwW9Cip42RVoEi7T56DPGunIhUCwQTHmU1wuWNQ8AiXaxHRfq76mniKfo cmI3IbkCE6F7kkZMXCwtL7vWjmmrjsEqnapUNYq98t2gcPXLxGntordG7UR4bvslHQJd rvCqjKCvmxIB3BqRnuH/ZGtis0+Lw5gdHRG0U= 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:in-reply-to :references; bh=r7RumiG5q7ZC+xhq06ojzN56YhWI2Gk6+rQDYe/Lt5Y=; b=KjAFcu005MFU4xpOqS6Ndv/aiocBu/tHEgqkZaDQDr4303WUH8S7XLCKE0KAcoMZik ZZuBf5KHRQnj8uFd7l0pMA6qEHqXL3gr075X6nIwm4OCRYJ3JSMNxN+a7+PR6hXPBmbS h0ocrkuc3JvGhdDHxYO037Ms+qNM3ZVJBVLKf31VrVvSRRt6ZWqEMYMg01CEhYv/IOBR rLmFgqw5M6A7E0d4TdwIZ9Rw1GZuYbql4JHcxRsPRfUYsPev6rlhxFQ6wgxeoA1VvK1g XK01+jAAptgiUEIf3+7pWNEUKIFEYuwrQuFbWgDKgH+5joYzVFB9JIXoM2MKuGDzUQVZ o1RQ== X-Gm-Message-State: AIkVDXIfMzAtUAT3QaLXbRoEoC3Lq1Z/oiYiOEVQe7zrdd6kJOULqbldpAhWVc3RoJV5QB3h X-Received: by 10.84.231.193 with SMTP id g1mr49986590pln.12.1485247817182; Tue, 24 Jan 2017 00:50:17 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id l188sm9963379pfl.28.2017.01.24.00.50.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:50:16 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v30 08/11] arm64: kdump: provide /proc/vmcore file Date: Tue, 24 Jan 2017 17:50:02 +0900 Message-Id: <20170124085004.3892-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124084638.3770-1-takahiro.akashi@linaro.org> References: <20170124084638.3770-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170124_005138_722302_46408F4E X-CRM114-Status: GOOD ( 25.83 ) X-Spam-Score: -3.4 (---) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-3.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source [209.85.192.170 listed in dnsbl.sorbs.net] -1.2 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.170 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.192.170 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, geoff@infradead.org, kexec@lists.infradead.org, AKASHI Takahiro , james.morse@arm.com, bauerman@linux.vnet.ibm.com, dyoung@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Add arch-specific functions to provide a dump file, /proc/vmcore. This file is in ELF format and its ELF header needs to be prepared by userspace tools, like kexec-tools, in adance. The primary kernel is responsible to allocate the region with reserve_elfcorehdr() at boot time and advertize its location to crash dump kernel via a new device-tree property, "linux,elfcorehdr". Then crash dump kernel will access the primary kernel's memory with copy_oldmem_page(), which feeds the data page-by-page by ioremap'ing it since it does not reside in linear mapping on crash dump kernel. We also need our own elfcorehdr_read() here since the header is placed within crash dump kernel's usable memory. Signed-off-by: AKASHI Takahiro Reviewed-by: James Morse Acked-by: Catalin Marinas --- arch/arm64/Kconfig | 11 +++++++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/crash_dump.c | 71 ++++++++++++++++++++++++++++++++++++++++++ arch/arm64/mm/init.c | 53 +++++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 arch/arm64/kernel/crash_dump.c -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 111742126897..2bd6a1a062b9 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -693,6 +693,17 @@ config KEXEC but it is independent of the system firmware. And like a reboot you can start any kernel with it, not just Linux. +config CRASH_DUMP + bool "Build kdump crash kernel" + help + Generate crash dump after being started by kexec. This should + be normally only set in special crash dump kernels which are + loaded in the main kernel with kexec-tools into a specially + reserved region and then later executed after a crash by + kdump/kexec. + + For more details see Documentation/kdump/kdump.txt + config XEN_DOM0 def_bool y depends on XEN diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 7d66bbaafc0c..6a7384eee08d 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -50,6 +50,7 @@ arm64-obj-$(CONFIG_RANDOMIZE_BASE) += kaslr.o arm64-obj-$(CONFIG_HIBERNATION) += hibernate.o hibernate-asm.o arm64-obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o \ cpu-reset.o +arm64-obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-y += $(arm64-obj-y) vdso/ probes/ obj-m += $(arm64-obj-m) diff --git a/arch/arm64/kernel/crash_dump.c b/arch/arm64/kernel/crash_dump.c new file mode 100644 index 000000000000..c3d5a21c081e --- /dev/null +++ b/arch/arm64/kernel/crash_dump.c @@ -0,0 +1,71 @@ +/* + * Routines for doing kexec-based kdump + * + * Copyright (C) 2014 Linaro Limited + * Author: AKASHI Takahiro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include + +/** + * copy_oldmem_page() - copy one page from old kernel memory + * @pfn: page frame number to be copied + * @buf: buffer where the copied page is placed + * @csize: number of bytes to copy + * @offset: offset in bytes into the page + * @userbuf: if set, @buf is in a user address space + * + * This function copies one page from old kernel memory into buffer pointed by + * @buf. If @buf is in userspace, set @userbuf to %1. Returns number of bytes + * copied or negative error in case of failure. + */ +ssize_t copy_oldmem_page(unsigned long pfn, char *buf, + size_t csize, unsigned long offset, + int userbuf) +{ + void *vaddr; + + if (!csize) + return 0; + + vaddr = memremap(__pfn_to_phys(pfn), PAGE_SIZE, MEMREMAP_WB); + if (!vaddr) + return -ENOMEM; + + if (userbuf) { + if (copy_to_user((char __user *)buf, vaddr + offset, csize)) { + memunmap(vaddr); + return -EFAULT; + } + } else { + memcpy(buf, vaddr + offset, csize); + } + + memunmap(vaddr); + + return csize; +} + +/** + * elfcorehdr_read - read from ELF core header + * @buf: buffer where the data is placed + * @csize: number of bytes to read + * @ppos: address in the memory + * + * This function reads @count bytes from elf core header which exists + * on crash dump kernel's memory. + */ +ssize_t elfcorehdr_read(char *buf, size_t count, u64 *ppos) +{ + memcpy(buf, phys_to_virt((phys_addr_t)*ppos), count); + return count; +} diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 2aba75dc7720..323b87197e18 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -135,6 +136,56 @@ static void __init reserve_crashkernel(void) } #endif /* CONFIG_KEXEC_CORE */ +#ifdef CONFIG_CRASH_DUMP +static int __init early_init_dt_scan_elfcorehdr(unsigned long node, + const char *uname, int depth, void *data) +{ + const __be32 *reg; + int len; + + if (depth != 1 || strcmp(uname, "chosen") != 0) + return 0; + + reg = of_get_flat_dt_prop(node, "linux,elfcorehdr", &len); + if (!reg || (len < (dt_root_addr_cells + dt_root_size_cells))) + return 1; + + elfcorehdr_addr = dt_mem_next_cell(dt_root_addr_cells, ®); + elfcorehdr_size = dt_mem_next_cell(dt_root_size_cells, ®); + + return 1; +} + +/* + * reserve_elfcorehdr() - reserves memory for elf core header + * + * This function reserves elf core header given in "elfcorehdr=" kernel + * command line parameter. This region contains all the information about + * primary kernel's core image and is used by a dump capture kernel to + * access the system memory on primary kernel. + */ +static void __init reserve_elfcorehdr(void) +{ + of_scan_flat_dt(early_init_dt_scan_elfcorehdr, NULL); + + if (!elfcorehdr_size) + return; + + if (memblock_is_region_reserved(elfcorehdr_addr, elfcorehdr_size)) { + pr_warn("elfcorehdr is overlapped\n"); + return; + } + + memblock_reserve(elfcorehdr_addr, elfcorehdr_size); + + pr_info("Reserving %lldKB of memory at 0x%llx for elfcorehdr\n", + elfcorehdr_size >> 10, elfcorehdr_addr); +} +#else +static void __init reserve_elfcorehdr(void) +{ +} +#endif /* CONFIG_CRASH_DUMP */ /* * 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 @@ -393,6 +444,8 @@ void __init arm64_memblock_init(void) reserve_crashkernel(); + reserve_elfcorehdr(); + dma_contiguous_reserve(arm64_dma_phys_limit); memblock_allow_resize(); From patchwork Tue Jan 24 08:50:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 92294 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1613931qgi; Tue, 24 Jan 2017 00:56:04 -0800 (PST) X-Received: by 10.200.50.209 with SMTP id a17mr29543300qtb.288.1485248164770; Tue, 24 Jan 2017 00:56:04 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id p125si410667qkd.41.2017.01.24.00.56.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:56:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cVwtV-00044E-Ev; Tue, 24 Jan 2017 08:56:01 +0000 Received: from mail-pf0-f180.google.com ([209.85.192.180]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVwpQ-0000LO-CP for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2017 08:51:49 +0000 Received: by mail-pf0-f180.google.com with SMTP id 189so48846047pfu.3 for ; Tue, 24 Jan 2017 00:51:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mjMk4Ffuf5hOSX+PyeuOznX3qWgyx4oW+H/flFbIPVs=; b=PcHH8IlL6oI96cSokCx5c5NAmZ/lCK8L7HGNWmfay4XYmXrZNhF47RAUBBJNcf2hDQ vYGMFQd67CEJZ8VbcGy/yJNNb2QBmoydSX0q4/uIhxe7i1TQOrvrvBCzwBwrIlHBWuWh DWXK+fa6aaI9Z9/4ZgQ0kYruNA/gvCHAcoPAc= 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:in-reply-to :references; bh=mjMk4Ffuf5hOSX+PyeuOznX3qWgyx4oW+H/flFbIPVs=; b=Tc0HGubhAiftIFACUql5pGxaEryo4tWM7P83vd0K27xuwfRmHWc6nvRxxxggykARnB BNqqilESpRgEiu33osv7Ic+0CT5WkDq67qnXlRkY10Pt1BIKJh1PimUjovH17rIOcR9C 17FVH1YDj54aB8uyPZGR04eCLZQN+UAmbzi4LY3ZbOmi4QzvcYaoPmLQRkiu8b/mYreR X6rpgGFNoQ/WC3X1TmQ0YzxflDSKefWq3dYBBYudNv9ixNBafzCz+oNJjbtdJt1xtHtY 8ziBc1H3BOXF34DLV9NpVeVaoRYp/QHZ8zqP88iuFXnv1k3MlMVCaLzbWsGPieXGMc3M 9URQ== X-Gm-Message-State: AIkVDXIvyAZcZm69MGG2GgMqg9qCJwB9TLgwJAsRma/2BlJl+f+z+pXe2IibsgSeqm/hoWCA X-Received: by 10.98.158.89 with SMTP id s86mr36773657pfd.33.1485247827657; Tue, 24 Jan 2017 00:50:27 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 19sm42687673pft.46.2017.01.24.00.50.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:50:27 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v30 09/11] arm64: kdump: enable kdump in defconfig Date: Tue, 24 Jan 2017 17:50:03 +0900 Message-Id: <20170124085004.3892-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124084638.3770-1-takahiro.akashi@linaro.org> References: <20170124084638.3770-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170124_005148_450561_96BCCD39 X-CRM114-Status: GOOD ( 10.24 ) X-Spam-Score: -3.2 (---) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-3.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.180 listed in list.dnswl.org] -1.2 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.180 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, geoff@infradead.org, kexec@lists.infradead.org, AKASHI Takahiro , james.morse@arm.com, bauerman@linux.vnet.ibm.com, dyoung@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Kdump is enabled by default as kexec is. Signed-off-by: AKASHI Takahiro Acked-by: Catalin Marinas --- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+) -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index 33b744d54739..94c2ea523a8a 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -79,6 +79,7 @@ CONFIG_CMA=y CONFIG_SECCOMP=y CONFIG_XEN=y CONFIG_KEXEC=y +CONFIG_CRASH_DUMP=y # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set CONFIG_COMPAT=y CONFIG_CPU_IDLE=y From patchwork Tue Jan 24 08:50:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 92295 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1614368qgi; Tue, 24 Jan 2017 00:57:44 -0800 (PST) X-Received: by 10.55.97.207 with SMTP id v198mr30243201qkb.242.1485248263970; Tue, 24 Jan 2017 00:57:43 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id c187si6341830qkb.170.2017.01.24.00.57.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:57:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cVwv8-0004hU-GY; Tue, 24 Jan 2017 08:57:42 +0000 Received: from mail-pg0-f44.google.com ([74.125.83.44]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVwpY-0000ZW-TX for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2017 08:51:58 +0000 Received: by mail-pg0-f44.google.com with SMTP id 14so53309780pgg.1 for ; Tue, 24 Jan 2017 00:51:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ttUIQYE/YHiXm1RkkioEAbHqZp5YZFeMA4Gx/fzFtfg=; b=R/Z1qgTZD0O8dPLrr70Kcrnjp7T4wbBBk2MqJA4aMYAzCivo8MRCsXIEw2FqtDL3bU DkLELtEZsBWpwi+ig016JnmwvYKZXEKa5e5CxiX1xC0fIQhqn2tLPAmY1C0FDy+HeK2X AC7ovY9+iukJV4wHebDfZiucZ+1AQcBgML5aM= 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:in-reply-to :references; bh=ttUIQYE/YHiXm1RkkioEAbHqZp5YZFeMA4Gx/fzFtfg=; b=H+OyeQdTdqP+G56lHV4qTLUDqgnMnnD8uRM3uqdlxaCxJLD8IwfDBq8+ubCkRsVUmb yQxExsRs+5/3KuT1sLYeXdwnSFOgXJdWM/p9iQ26CmmR7y1BM88goUJFkOlwcVb+G1r7 4DGpvh+JszapACoLEvGgzecpIrrIsivDpgwqJjeS169IbWItBZjJx/1xzJwEdMxNcSy1 YdHRZ4Hh/a0Nz0f5W31h8InjZ4zo2qhbe2qmL/y3ww0mXKAHzXqZ5qQJ3ewddmAvVJVK KwXbrt/soDkr5P51jlaibYXTAwBU2+70YOABi9cbTlKC/3EvDE2ISdYXP4DK0+63VDZG Guwg== X-Gm-Message-State: AIkVDXLBoKHQkhcba8/gXB3b70pLPZ0t3OeI08/1Vnl74xG9RMrnwS8mYu99EmVJNd/mua8S X-Received: by 10.98.153.155 with SMTP id t27mr37723945pfk.48.1485247836309; Tue, 24 Jan 2017 00:50:36 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id z70sm42710076pff.26.2017.01.24.00.50.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:50:35 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v30 10/11] Documentation: kdump: describe arm64 port Date: Tue, 24 Jan 2017 17:50:04 +0900 Message-Id: <20170124085004.3892-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124084638.3770-1-takahiro.akashi@linaro.org> References: <20170124084638.3770-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170124_005156_990873_78B0893B X-CRM114-Status: GOOD ( 13.17 ) X-Spam-Score: -3.2 (---) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-3.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [74.125.83.44 listed in list.dnswl.org] -1.2 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [74.125.83.44 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, geoff@infradead.org, kexec@lists.infradead.org, AKASHI Takahiro , james.morse@arm.com, bauerman@linux.vnet.ibm.com, dyoung@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Add arch specific descriptions about kdump usage on arm64 to kdump.txt. Signed-off-by: AKASHI Takahiro Reviewed-by: Baoquan He Acked-by: Dave Young Acked-by: Catalin Marinas --- Documentation/kdump/kdump.txt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/Documentation/kdump/kdump.txt b/Documentation/kdump/kdump.txt index b0eb27b956d9..615434d81108 100644 --- a/Documentation/kdump/kdump.txt +++ b/Documentation/kdump/kdump.txt @@ -18,7 +18,7 @@ memory image to a dump file on the local disk, or across the network to a remote system. Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64, -s390x and arm architectures. +s390x, arm and arm64 architectures. When the system kernel boots, it reserves a small section of memory for the dump-capture kernel. This ensures that ongoing Direct Memory Access @@ -249,6 +249,13 @@ Dump-capture kernel config options (Arch Dependent, arm) AUTO_ZRELADDR=y +Dump-capture kernel config options (Arch Dependent, arm64) +---------------------------------------------------------- + +- Please note that kvm of the dump-capture kernel will not be enabled + on non-VHE systems even if it is configured. This is because the CPU + will not be reset to EL2 on panic. + Extended crashkernel syntax =========================== @@ -305,6 +312,8 @@ Boot into System Kernel kernel will automatically locate the crash kernel image within the first 512MB of RAM if X is not given. + On arm64, use "crashkernel=Y[@X]". Note that the start address of + the kernel, X if explicitly specified, must be aligned to 2MiB (0x200000). Load the Dump-capture Kernel ============================ @@ -327,6 +336,8 @@ For s390x: - Use image or bzImage For arm: - Use zImage +For arm64: + - Use vmlinux or Image If you are using a uncompressed vmlinux image then use following command to load dump-capture kernel. @@ -370,6 +381,9 @@ For s390x: For arm: "1 maxcpus=1 reset_devices" +For arm64: + "1 maxcpus=1 reset_devices" + Notes on loading the dump-capture kernel: * By default, the ELF headers are stored in ELF64 format to support From patchwork Tue Jan 24 08:53:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 92289 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1613059qgi; Tue, 24 Jan 2017 00:52:42 -0800 (PST) X-Received: by 10.99.160.84 with SMTP id u20mr37780942pgn.141.1485247962862; Tue, 24 Jan 2017 00:52:42 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d24si18407806plj.113.2017.01.24.00.52.42; Tue, 24 Jan 2017 00:52:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750896AbdAXIwl (ORCPT + 7 others); Tue, 24 Jan 2017 03:52:41 -0500 Received: from mail-pf0-f175.google.com ([209.85.192.175]:32872 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750861AbdAXIwk (ORCPT ); Tue, 24 Jan 2017 03:52:40 -0500 Received: by mail-pf0-f175.google.com with SMTP id y143so48815259pfb.0 for ; Tue, 24 Jan 2017 00:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wCy1oA4FJqwEjNNSBfsy/wL1vp+hublTUwyYoXGlEJQ=; b=Z5416tFy4/K69BNWXoPNnIcXsr36nZ2EVbPl9+9EhWzyguWxsAUcLqTl6YVKKGmKFH O5ypipjL9WL3WFahGoniVusqxPPAg3xz0Xp3+IlZ41Ihrmu1GVnS22IA3BvyLqHRIOHS t9mvOUu2uj0aBwC4zRYXoVUV5B0G+EidmpRpw= 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:in-reply-to :references; bh=wCy1oA4FJqwEjNNSBfsy/wL1vp+hublTUwyYoXGlEJQ=; b=uHhrwaMmaUSj4mrnER7FyjjcPrATyX1XLvGIAde3bYY6mTz5U0SCwbYLW93qvvD3fg ydEyLfW4X24LFEQv2JNwmXXN03CYB1qmTqxatHFIjbaBkVB6yIeZ41zJONuBZQLddFiR Zg4w8Ovl+ezysD6MlQevi1W1uP86d2QcZFJVLcmexnxaF1T+1wXnN0QA9fQ53yVSJYrK doHWUi4VZ18RafatPOj2qLXlKtqULN4nFxFRXRUhM3VPlYqSIhHRxbYwClb5TaPXhfsO 09pBgzFI6lV18k7ATHOMqPSESWNmVTrmGiCxVeY6AdSMRuBpP+Jjfm6Wse5kJcaqvGhk RnLw== X-Gm-Message-State: AIkVDXIMju1ZG01uDhnTsEx009/HYIcW+vQ5mM4F2EhgfNliLdwtFhSFuOBC9g8A1X3gMeTA X-Received: by 10.98.194.153 with SMTP id w25mr37245709pfk.181.1485247946236; Tue, 24 Jan 2017 00:52:26 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id o18sm3604598pgn.36.2017.01.24.00.52.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:52:25 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, robh+dt@kernel.org, mark.rutland@arm.com Cc: james.morse@arm.com, geoff@infradead.org, bauerman@linux.vnet.ibm.com, dyoung@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v30 11/11] Documentation: dt: chosen properties for arm64 kdump Date: Tue, 24 Jan 2017 17:53:20 +0900 Message-Id: <20170124085320.3973-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124084638.3770-1-takahiro.akashi@linaro.org> References: <20170124084638.3770-1-takahiro.akashi@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: James Morse Add documentation for DT properties: linux,usable-memory-range linux,elfcorehdr used by arm64 kdump. Those decribe the usable memory range for crash dump kernel and the elfcorehdr's location within it, respectively. Signed-off-by: James Morse [takahiro.akashi@linaro.org: added "linux,crashkernel-base" and "-size" ] Signed-off-by: AKASHI Takahiro Acked-by: Mark Rutland Cc: devicetree@vger.kernel.org Cc: Rob Herring --- Documentation/devicetree/bindings/chosen.txt | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/Documentation/devicetree/bindings/chosen.txt b/Documentation/devicetree/bindings/chosen.txt index 6ae9d82d4c37..8dc82431acc1 100644 --- a/Documentation/devicetree/bindings/chosen.txt +++ b/Documentation/devicetree/bindings/chosen.txt @@ -52,3 +52,40 @@ This property is set (currently only on PowerPC, and only needed on book3e) by some versions of kexec-tools to tell the new kernel that it is being booted by kexec, as the booting environment may differ (e.g. a different secondary CPU release mechanism) + +linux,usable-memory-range +------------------------- + +This property (arm64 only) holds a base address and size, describing a +limited region in which memory may be considered available for use by +the kernel. Memory outside of this range is not available for use. + +This property describes a limitation: memory within this range is only +valid when also described through another mechanism that the kernel +would otherwise use to determine available memory (e.g. memory nodes +or the EFI memory map). Valid memory may be sparse within the range. +e.g. + +/ { + chosen { + linux,usable-memory-range = <0x9 0xf0000000 0x0 0x10000000>; + }; +}; + +The main usage is for crash dump kernel to identify its own usable +memory and exclude, at its boot time, any other memory areas that are +part of the panicked kernel's memory. + +linux,elfcorehdr +---------------- + +This property (currently used only on arm64) holds the memory range, +the address and the size, of the elf core header which mainly describes +the panicked kernel's memory layout as PT_LOAD segments of elf format. +e.g. + +/ { + chosen { + linux,elfcorehdr = <0x9 0xfffff000 0x0 0x800>; + }; +};