From patchwork Wed Nov 7 14:16:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10672425 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0308914E2 for ; Wed, 7 Nov 2018 14:17:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4C6E2BF68 for ; Wed, 7 Nov 2018 14:16:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8CB92C089; Wed, 7 Nov 2018 14:16:59 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 60E292BF68 for ; Wed, 7 Nov 2018 14:16:59 +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:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=rlm70q6QKI131OeHGk3+4cFVRYbZYZsBH1A9045qkc0=; b=KtRWQvmdpzM1xx 8LbhBXTgq6Upv2wrlTB1xHpvgJ4/wURtWC8lKINJmmheyPnZKLBj0OR4t6abeOkfpWunQ5+lt5bzT KhCNAv6MWJszKwKglUu/DtOr55fCWTXbVZWnOrlKIJQ37waZ1ULUniBqX8vIePqejvvBhcuF6khTb v9lWhBB50Ino1CFr8+BlPwOvwKm5CN+3P6wtSMRyLbVRJrqfpMCNhkw1v5fU8K2BqvH4s9PXCwCGj XjMJR79Dd6jraXs8hOXIm4xDmdiSbfMD3pRN2/qGNKo2ZJHzjM4mCTmis+wpjyXMB8mialh4TgrpL zgQPlTJ4OZkm/zgiE3pg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKOdc-0004PW-K0; Wed, 07 Nov 2018 14:16:56 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKOdH-00040w-Pd for linux-arm-kernel@lists.infradead.org; Wed, 07 Nov 2018 14:16:37 +0000 Received: by mail-wr1-x443.google.com with SMTP id z13-v6so15201416wrs.3 for ; Wed, 07 Nov 2018 06:16:30 -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 :mime-version:content-transfer-encoding; bh=Tr8foXw6aq0MQflYxCLzmVJC0ciVK12b4fFVOOhpxSY=; b=MF8ico6PXrA2BhPxBQFFbW8jAGJMJ/k7IUknMbUPu1cM/oB2GUV5WrFhyVtL7OBmwR NVo10MF3EdpoPJzxuDTeechLP0Pu/gqbGlukZ38s3v+tiFoyH71+0LbQQxohvnW+KPvR pkMiceInWTKziMUfXGrrXZnI9sjZ5jvnvNC24= 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:mime-version:content-transfer-encoding; bh=Tr8foXw6aq0MQflYxCLzmVJC0ciVK12b4fFVOOhpxSY=; b=tm+M1JYIoAF5xiOXEb1dqXoBo0lmyy5P/NWRP2P5rsJO/0l+h0jZFGQ4TUnppCiliZ JdUAihV65dQoob6Q6IycadUpiDNo6dKFGgzTU/5K5W7NSp52EAnZpCKMsvrNB3R7ajDz oZ5DomDlCyZdG2AsnYvIoutlkB9STPsv8nGGy4LFAcuvpDyzmsbt4FwrHkB1RV9SejJM bp07peL4WH4KKTdYqtn/PN6H6dDgmHVnI/WtNRwk9hg9WEPgquGI33BA+rJ0IGHz1fgq JqciJsQ12NdwheRANl6ojX3ukiUdhUfTQ7FVVrIShuxOzlQyMvLXlbUW4pgy23GKprbs MuHg== X-Gm-Message-State: AGRZ1gJOG+y86yqvq+URIiZ8u3Wfz3rh5EKr1E8vdq2+L1UNy4VHZNEJ XPkVfoZoDY1NwYqS9EBPGW3Iy+KSYbg= X-Google-Smtp-Source: AJdET5c0mnEXM1VmMMG1v6PCi9+C/0KAeEoVZNmCihl0qHkRaEsENlwTjvVErKRTwx9ywnhHYxeqoQ== X-Received: by 2002:adf:f68e:: with SMTP id v14-v6mr330447wrp.261.1541600188603; Wed, 07 Nov 2018 06:16:28 -0800 (PST) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id q2sm948447wrx.77.2018.11.07.06.16.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 06:16:27 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk Subject: [PATCH v2 4/6] efi/arm: defer persistent reservations until after paging_init() Date: Wed, 7 Nov 2018 15:16:09 +0100 Message-Id: <20181107141611.12076-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181107141611.12076-1-ard.biesheuvel@linaro.org> References: <20181107141611.12076-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181107_061635_828968_0F37D46F X-CRM114-Status: GOOD ( 14.37 ) 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: marc.zyngier@arm.com, bhsharma@redhat.com, linux-efi@vger.kernel.org, will.deacon@arm.com, Ard Biesheuvel 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 The new memory EFI reservation feature we introduced to allow memory reservations to persist across kexec may trigger an unbounded number of calls to memblock_reserve(). The memblock subsystem can deal with this fine, but not before memblock resizing is enabled, which we can only do after paging_init(), when the memory we reallocate the array into is actually mapped. So break out the memreserve table processing into a separate function and call if after paging_init() on arm64, and from paging_init() on ARM, after memblock resizing has been enabled but before the early memremap support that we rely on has been taken down. Tested-by: Marc Zyngier Signed-off-by: Ard Biesheuvel --- arch/arm/mm/mmu.c | 2 ++ arch/arm64/kernel/setup.c | 1 + drivers/firmware/efi/efi.c | 4 ++++ include/linux/efi.h | 7 +++++++ 4 files changed, 14 insertions(+) diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 078f82f89fe5..8ecffb8c0c0b 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -9,6 +9,7 @@ */ #include #include +#include #include #include #include @@ -1629,6 +1630,7 @@ void __init paging_init(const struct machine_desc *mdesc) memblock_set_current_limit(arm_lowmem_limit); memblock_allow_resize(); dma_contiguous_remap(); + efi_apply_persistent_mem_reservations(); early_ioremap_reset(); early_fixmap_shutdown(); devicemaps_init(mdesc); diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 953e316521fc..f4fc1e0544b7 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p) arm64_memblock_init(); paging_init(); + efi_apply_persistent_mem_reservations(); acpi_table_upgrade(); diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 249eb70691b0..72a4da76d274 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -592,7 +592,11 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, early_memunmap(tbl, sizeof(*tbl)); } + return 0; +} +int __init efi_apply_persistent_mem_reservations(void) +{ if (efi.mem_reserve != EFI_INVALID_TABLE_ADDR) { unsigned long prsv = efi.mem_reserve; diff --git a/include/linux/efi.h b/include/linux/efi.h index 845174e113ce..100ce4a4aff6 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1167,6 +1167,8 @@ static inline bool efi_enabled(int feature) extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused); extern bool efi_is_table_address(unsigned long phys_addr); + +extern int efi_apply_persistent_mem_reservations(void); #else static inline bool efi_enabled(int feature) { @@ -1185,6 +1187,11 @@ static inline bool efi_is_table_address(unsigned long phys_addr) { return false; } + +static inline int efi_apply_persistent_mem_reservations(void) +{ + return 0; +} #endif extern int efi_status_to_err(efi_status_t status);