From patchwork Wed Jan 10 10:09:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 10154657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BF74760223 for ; Wed, 10 Jan 2018 10:05:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B21BD282EC for ; Wed, 10 Jan 2018 10:05:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6C7328372; Wed, 10 Jan 2018 10:05:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 277C5282EC for ; Wed, 10 Jan 2018 10:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=DenhVfBiBwZCioRDv4x71CvfAGfagtaO91D1WUogz3Y=; b=Wh6 uCOm5E32cqbL8ORW3eaUyoXxBZ68pezVkjBXQKKjfSOD9VMsSNc0D8dxWwPnT6MiJkCIhMvboiGzt aWI4wu+XWtwkvL6dv4MGW7pIEYyyQp9BuwOI+7uFOM3xw3Cx43w9wEEt7Hd8NPCg5yRfGYdGn2Pi4 G+ZHO6avFaskQvtb9r6KdmvjZ5e0QAnULfi3XHHmxuDabkwSNOay1trP4ueypIy5VmRQ+KsfJZRxG EJoCu1OTcryKSii0NEh6yy6QQoUHemP2CU1RhusFErUwPT+mOr/xsPbakp+/4L58UBrGUyLaGhFGy QQc/5i6cvoV66P/EESBX8BpW36ud8MQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZDGY-000846-Hl; Wed, 10 Jan 2018 10:05:50 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZDGS-0007uL-IP for linux-arm-kernel@lists.infradead.org; Wed, 10 Jan 2018 10:05:46 +0000 Received: by mail-pg0-x243.google.com with SMTP id j4so10445616pgp.1 for ; Wed, 10 Jan 2018 02:05: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; bh=WTC0B6T8mMwUa964mFuLau0nAiHpc1r4GnhU0vQVs1A=; b=SWAAcTU1gtZls3KZWyapJeDO4eU+Pb5vUcS3Tqel/PBXdapANMxr9URdSamzTG8/gy tyftNrrTQidPoDm2A5ZKERyxeqHnZ/0FiRDA+O5/VvSnEpZehkNA8+gI9eGCo0cVnex+ bkGVLwjnPDl/QK4+lcQdxBcwq1RB6lrqjCTSk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=WTC0B6T8mMwUa964mFuLau0nAiHpc1r4GnhU0vQVs1A=; b=mbfGFSy5Z3oJZHNonWNCTfy+f5Wrxt3t9A7UhE+kwIGMBrxxrZM+H8hgeuOT/Wqe8c BCa31X5KYSXjvIWlg1+89GxcvYo0ggsRsz8N1tYgdZ8fG7B+/LtHB+PLeMT816fHZ7Jg DkIzyRfiKAo2kSJdCeMTgAQgdbpVbBFQ6XUJdXsEhk1K6raFPB/GDCYQEftS7lGeD7dn wF/zl4bGxBvF64lIr3Qq60Kk9qRaGSd0/KAInKk+cSWn75suJ72zexW/CRFmUyZek37h YkhSFy/F8N9nd29DKYh6oyB5SDEeddI45oJmmHFrYR4An172oyIjtGYodXCWXo2VUrHx Vnzg== X-Gm-Message-State: AKGB3mJMlCDLANBS8JKKjiro5txbzmCRoX7lu4WuHNgFpXib/JECQAE2 80T9HA2OU4nOmyJwZCYLpLLhvQ== X-Google-Smtp-Source: ACJfBotnNsZlqBjauQQxq7gZgyZSnRo9Fx+KRALD2wMg4m4gLU8deLcFKFGRsxEZBiO/Q8fo4GYl0w== X-Received: by 10.101.80.72 with SMTP id k8mr14227556pgo.6.1515578733511; Wed, 10 Jan 2018 02:05:33 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id q7sm30137464pgf.10.2018.01.10.02.05.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jan 2018 02:05:32 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH] arm64: kdump: retain reserved memory regions Date: Wed, 10 Jan 2018 19:09:43 +0900 Message-Id: <20180110100943.6082-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.15.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180110_020544_602892_A9D1C426 X-CRM114-Status: GOOD ( 16.81 ) 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: ard.biesheuvel@linaro.org, bhsharma@redhat.com, kexec@lists.infradead.org, AKASHI Takahiro , dyoung@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This is a fix against the issue that crash dump kernel may hang up during booting, which can happen on any ACPI-based system with "ACPI Reclaim Memory." Bye! (snip...) ACPI: Core revision 20170728 pud=000000002e7d0003, *pmd=000000002e7c0003, *pte=00e8000039710707 Internal error: Oops: 96000021 [#1] SMP Modules linked in: CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.14.0-rc6 #1 task: ffff000008d05180 task.stack: ffff000008cc0000 PC is at acpi_ns_lookup+0x25c/0x3c0 LR is at acpi_ds_load1_begin_op+0xa4/0x294 (snip...) Process swapper/0 (pid: 0, stack limit = 0xffff000008cc0000) Call trace: (snip...) [] acpi_ns_lookup+0x25c/0x3c0 [] acpi_ds_load1_begin_op+0xa4/0x294 [] acpi_ps_build_named_op+0xc4/0x198 [] acpi_ps_create_op+0x14c/0x270 [] acpi_ps_parse_loop+0x188/0x5c8 [] acpi_ps_parse_aml+0xb0/0x2b8 [] acpi_ns_one_complete_parse+0x144/0x184 [] acpi_ns_parse_table+0x48/0x68 [] acpi_ns_load_table+0x4c/0xdc [] acpi_tb_load_namespace+0xe4/0x264 [] acpi_load_tables+0x48/0xc0 [] acpi_early_init+0x9c/0xd0 [] start_kernel+0x3b4/0x43c Code: b9008fb9 2a000318 36380054 32190318 (b94002c0) ---[ end trace c46ed37f9651c58e ]--- Kernel panic - not syncing: Fatal exception Rebooting in 10 seconds.. (diagnosis) * This fault is a data abort, alignment fault (ESR=0x96000021) during reading out ACPI table. * Initial ACPI tables are normally stored in system ram and marked as "ACPI Reclaim memory" by the firmware. * After the commit f56ab9a5b73c ("efi/arm: Don't mark ACPI reclaim memory as MEMBLOCK_NOMAP"), those regions' attribute were changed removing NOMAP bit and they are instead "memblock-reserved". * When crash dump kernel boots up, it tries to accesses ACPI tables by ioremap'ing them (through acpi_os_ioremap()). * Since those regions are not included in device tree's "usable-memory-range" and so not recognized as part of crash dump kernel's system ram, ioremap() will create a non-cacheable mapping here. * ACPI accessor/helper functions are compiled in without unaligned access support (ACPI_MISALIGNMENT_NOT_SUPPORTED), eventually ending up a fatal panic when accessing ACPI tables. With this patch, all the reserved memory regions, as well as NOMAP- attributed ones which are presumably ACPI runtime code and data, are set to be retained in system ram even if they are outside of usable memory range specified by device tree blob. Accordingly, ACPI tables are mapped as cacheable and can be safely accessed without causing unaligned access faults. Reported-by: Bhupesh Sharma Signed-off-by: AKASHI Takahiro --- arch/arm64/mm/init.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 2d5a443b205c..e4a8b64a09b1 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -352,11 +352,23 @@ static void __init fdt_enforce_memory_region(void) struct memblock_region reg = { .size = 0, }; + u64 idx; + phys_addr_t start, end; of_scan_flat_dt(early_init_dt_scan_usablemem, ®); - if (reg.size) - memblock_cap_memory_range(reg.base, reg.size); + if (reg.size) { +retry: + /* exclude usable & !reserved memory */ + for_each_free_mem_range(idx, NUMA_NO_NODE, MEMBLOCK_NONE, + &start, &end, NULL) { + memblock_remove(start, end - start); + goto retry; + } + + /* add back fdt's usable memory */ + memblock_add(reg.base, reg.size); + } } void __init arm64_memblock_init(void)