From patchwork Mon Jan 29 08:12:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 10189387 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 0107D60388 for ; Mon, 29 Jan 2018 08:13:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFF65287C1 for ; Mon, 29 Jan 2018 08:13:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D45AC287C3; Mon, 29 Jan 2018 08:13:25 +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 B7E5A287C1 for ; Mon, 29 Jan 2018 08:13:24 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PdV+M1nDKehZg//tz7d8AYROf7J5DCPIj1+uo7u3qHc=; b=gxpTyHs+6KGngB zZvfG3Ki3gt7ksvOvwBtODHQXIPj7Rc9r4Nq/BC74vwLTcUnwi1kl6oPz1NYv/OKaWqlOo4041QUe JFfXV8w/5sbTSgDHWza7OfmMPnaScq2ZAHy2ERJB5AGTwgnTJeVEiTNdD7dHKQbfYLyL70EMV5Ow5 SCA16dsTwDXBN0GmdHcZuvs8p/CH1sFHZ83teESLR1eC3ujzwo9Es81G6JbE9Lnh/mDh7EAmZ+zk6 CVnBjVRICqhVa0c7GWSf41Z8vK6Glm7NAmx8GV1r+FbWVgKD+dOjyEJj9/Zg35tRsPeosGgjvJioW yoClN2AqNM69RYrAu0RA==; 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 1eg4Z6-0007Tv-TD; Mon, 29 Jan 2018 08:13:20 +0000 Received: from mail-io0-x242.google.com ([2607:f8b0:4001:c06::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eg4Z3-0007Sr-9K for linux-arm-kernel@lists.infradead.org; Mon, 29 Jan 2018 08:13:19 +0000 Received: by mail-io0-x242.google.com with SMTP id b198so6694189iof.6 for ; Mon, 29 Jan 2018 00:13:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=r4rLgK42O7yQ1yWgn6pniWog4zuxJbAb2Eip4kOWZ+g=; b=PCyDUly3XVBJEtc3nRaOF4KFsK7Vre2b6d/X4hStcJej8q3hDMl6zSKaLXhnILOn3G bGQD8Oww88n8iHsEH2ZrAtyhS+Vz4o8Mh9tncqFLdSJce+KoBoJx9K/JNsYL6LEqq3xH eRBO5s6jFq/5s9tMIJ4r3w42qeCcLcDQBte+M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=r4rLgK42O7yQ1yWgn6pniWog4zuxJbAb2Eip4kOWZ+g=; b=mQJfdC4UUa8IdMsG39DeQpXS95G4ChFnvUUAKrhTd9X2m+Lfi4Ppzy0aN+W3Sx3A2y +uwtVGTRBXUngFduPF5On4gvXqFjpQCwcM+j/O0SrWrKbrz+8e+RrP1ic9Kdcho1Jbm5 dQH4yoK66E2kpN3rP/wp3nRyaYbz9MfsPk9GFDgR7isDZt5/XHu1zh+goiT18cIuW7d1 cEJBveeKJIsWMzZ2x4WFWxImS7deKhzGxeUrqX9fUa4oMG7AeOyd0jihmBTeixeVyqkX 8qsPqxQDixbuYk/Ud8EQjHCRIotwhC357w51JuitUWgyP3Vwj19N8G+KvnjBBhOkcnZW xTCA== X-Gm-Message-State: AKwxyteBSs+PCasQOl28Woj8rJlHOK3qMOwxMbO4TIQv1ZhpKGZapncK yurnycfeSdYBkqmRbKcB+KbyKw== X-Google-Smtp-Source: AH8x225i4H6Y7MXU85bm743U8zjhEY4tsWF8Joj8YF72kXEQp1mxj4qP5/kDq6vMzVhbvHhvVA5Hrg== X-Received: by 10.107.147.87 with SMTP id v84mr11620151iod.293.1517213585029; Mon, 29 Jan 2018 00:13:05 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id l63sm3913951ita.44.2018.01.29.00.13.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jan 2018 00:13:04 -0800 (PST) Date: Mon, 29 Jan 2018 17:12:27 +0900 From: AKASHI Takahiro To: James Morse Subject: Re: [PATCH] arm64: kdump: retain reserved memory regions Message-ID: <20180129081225.GA23847@linaro.org> Mail-Followup-To: AKASHI Takahiro , James Morse , catalin.marinas@arm.com, will.deacon@arm.com, ard.biesheuvel@linaro.org, bhsharma@redhat.com, kexec@lists.infradead.org, dyoung@redhat.com, linux-arm-kernel@lists.infradead.org References: <20180110100943.6082-1-takahiro.akashi@linaro.org> <5A55F87F.2080501@arm.com> <20180111113840.GF18820@linaro.org> <5A61D90E.1000907@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5A61D90E.1000907@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) 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, catalin.marinas@arm.com, bhsharma@redhat.com, will.deacon@arm.com, dyoung@redhat.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org 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 James, On Fri, Jan 19, 2018 at 11:39:58AM +0000, James Morse wrote: > Hi Akashi, > > On 11/01/18 11:38, AKASHI Takahiro wrote: > > On Wed, Jan 10, 2018 at 11:26:55AM +0000, James Morse wrote: > >> On 10/01/18 10:09, AKASHI Takahiro wrote: > >>> 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." > > >>> (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. > >> > >> Ugh, because acpi_os_ioremap() looks at the efi memory map through the prism of > >> what we pulled into memblock, which is different during kdump. > >> > >> Is an alternative to teach acpi_os_ioremap() to ask > >> efi_mem_attributes() directly for the attributes to use? > >> (e.g. arch_apei_get_mem_attribute()) > > > > I didn't think of this approach. > > Do you mean a change like the patch below? > > Yes. Aha, you can pretty much re-use the helper directly. > > It was just a suggestion, removing the extra abstraction that is causing the bug > could be cleaner ... > > > (I'm still debugging this code since the kernel fails to boot.) > > ... but might be too fragile. > > There are points during boot when the EFI memory map isn't mapped. Right, this was a problem for my patch. Attached is the revised and workable one. Efi_memmap_init_late() may alternatively be called in acpi_early_init() or even in acpi_os_ioremap(), but either way it looks a bit odd. Thanks, -Takahiro AKASHI > I think that > helper will return 'device memory' for everything when this happens. > > > Thanks, > > James ===8<=== From c88f4c8106ba7a918c835b1cdf538b1d21019863 Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Mon, 29 Jan 2018 15:07:43 +0900 Subject: [PATCH] arm64: kdump: make acpi_os_ioremap() more generic --- arch/arm64/include/asm/acpi.h | 23 ++++++++++++++++------- arch/arm64/kernel/acpi.c | 7 ++----- init/main.c | 4 ++++ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index 32f465a80e4e..d53c95f4e1a9 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -12,10 +12,12 @@ #ifndef _ASM_ACPI_H #define _ASM_ACPI_H +#include #include #include #include +#include #include #include @@ -29,18 +31,22 @@ /* Basic configuration for ACPI */ #ifdef CONFIG_ACPI +pgprot_t __acpi_get_mem_attribute(phys_addr_t addr); + /* ACPI table mapping after acpi_permanent_mmap is set */ static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size) { + /* For normal memory we already have a cacheable mapping. */ + if (memblock_is_map_memory(phys)) + return (void __iomem *)__phys_to_virt(phys); + /* - * EFI's reserve_regions() call adds memory with the WB attribute - * to memblock via early_init_dt_add_memory_arch(). + * We should still honor the memory's attribute here because + * crash dump kernel possibly excludes some ACPI (reclaim) + * regions from memblock list. */ - if (!memblock_is_memory(phys)) - return ioremap(phys, size); - - return ioremap_cache(phys, size); + return __ioremap(phys, size, __acpi_get_mem_attribute(phys)); } #define acpi_os_ioremap acpi_os_ioremap @@ -125,7 +131,10 @@ static inline const char *acpi_get_enable_method(int cpu) * for compatibility. */ #define acpi_disable_cmcff 1 -pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr); +static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr) +{ + return __acpi_get_mem_attribute(addr); +} #endif /* CONFIG_ACPI_APEI */ #ifdef CONFIG_ACPI_NUMA diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index b3162715ed78..f94bdf7be439 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -31,10 +31,9 @@ #include #include -#ifdef CONFIG_ACPI_APEI +/* CONFIG_ACPI_APEI */ # include # include -#endif int acpi_noirq = 1; /* skip ACPI IRQ initialization */ int acpi_disabled = 1; @@ -239,8 +238,7 @@ void __init acpi_boot_table_init(void) } } -#ifdef CONFIG_ACPI_APEI -pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr) +pgprot_t __acpi_get_mem_attribute(phys_addr_t addr) { /* * According to "Table 8 Map: EFI memory types to AArch64 memory @@ -261,4 +259,3 @@ pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr) return __pgprot(PROT_NORMAL_NC); return __pgprot(PROT_DEVICE_nGnRnE); } -#endif diff --git a/init/main.c b/init/main.c index a8100b954839..a479ece2bae9 100644 --- a/init/main.c +++ b/init/main.c @@ -674,6 +674,10 @@ asmlinkage __visible void __init start_kernel(void) debug_objects_mem_init(); setup_per_cpu_pageset(); numa_policy_init(); +#if defined(CONFIG_ARM64) && defined(CONFIG_EFI) + efi_memmap_init_late(efi.memmap.phys_map, + efi.memmap.nr_map * efi.memmap.desc_size); +#endif acpi_early_init(); if (late_time_init) late_time_init();