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: 150394 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp5221071ljp; Wed, 7 Nov 2018 06:16:31 -0800 (PST) X-Google-Smtp-Source: AJdET5cEqE6w6SnZcutGKd6haFTPTFZMf7fBzsRLblzn2ooghv94Yecb/4CS0feLmpgKT7NdJ/AA X-Received: by 2002:a17:902:3e3:: with SMTP id d90-v6mr411957pld.118.1541600191123; Wed, 07 Nov 2018 06:16:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541600191; cv=none; d=google.com; s=arc-20160816; b=zs7XoXrk0WOHFtQ/PDtVYnH6OYFcuEy3o6feJCtzvkwuLX/LfwfsfcBm25l0zxhPUw pkiQzxy/YzKOqgnWJbjIW/j+aVmGQBqmTW9V/Dwg1y4CplilJ9R6g6olcH7JeRsCIjNS MrgA1T0ySlMZ7YUjoId2X8mdCAcr7uGm72XJWXcPFjixkJjqy/a1sF0aenk9DCutOOMl csJYmtTha7xgDlLHlsSK6z/b42AQD4yaPxqP0LHH/Uyn4Ey6DqQV3oFCklxjk4TTuu00 xFtJvBv9rSze3MikLkT0mZw9pAjlrPRsZNpNLdrgKAX/zxvgPLE4PUIBB1WO0aGbJOuf 5Ahw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Tr8foXw6aq0MQflYxCLzmVJC0ciVK12b4fFVOOhpxSY=; b=RXUII7GdeORyuIjJxilzT928Tirv5bGzGETfk/apD/NKuip514a417WjT8Bo5+e48I 1/Ti+G4pV4qr63I8ffIhgMj0cXrhEioz//HuTaf7wa5l+AY6hOYZ7XXlssWFuptbxTUI uasJqK8Qq+4hNY9jmjZfd5Oz+BxeibuiI6kMVe96dF4vqY9bRrJ/Kthj4dAhUfbdUqs4 zsAgrjvbxvldCXP2X1b4pSZZRHVumdDaDQVZXKmgRVE1xkGHQHlWSUUnEG9GTInEiQxX aI9vQhjsVfN0Pd0Vws80zGCuLkcZ+IxJE5Sud8Ga7zOZaL6pOu0RESwqSS5GWq9r8TzJ IVvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MF8ico6P; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r3-v6si703022pgn.313.2018.11.07.06.16.30; Wed, 07 Nov 2018 06:16:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MF8ico6P; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727698AbeKGXrD (ORCPT + 3 others); Wed, 7 Nov 2018 18:47:03 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45208 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726825AbeKGXrD (ORCPT ); Wed, 7 Nov 2018 18:47:03 -0500 Received: by mail-wr1-f65.google.com with SMTP id k15-v6so14594595wre.12 for ; Wed, 07 Nov 2018 06:16:29 -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=Ta7/in2dM3m2/kYhK5AW0kruY64mcutAadXbUrgbqNAUrnYMRqw9Nd24XmU+YkMXb2 RgY25trS2trelwbvkXJSBjGRomCE46EC53AbL1t/nPCYCDLciqWZdek4t6MYsXFJ6iCd NT+OLZ6ALOCg0ufW10egVhuuPJqmjM9sTo7WtCcaBu2bKn2BsCxfEbw1+pRhiKIpaB8c EYQt9+8cMNHWnrUQtiDxs9Qn518FYbViabo9bQJxEetcic808VdlaSL0lTUMe0y5Dtio kjQX+jDQlme6Mrd8mnlnrJoZ28Cv+o7MVF6C/QS9H/5XggPnaOUj/WVq2iang5ME6/ht Ssgw== X-Gm-Message-State: AGRZ1gI1Sw+CJPG+HEAWiZn+Mp6SvmBnupwyB7KrWHtluOssSWTaLKov 1OAqiIr1r5JKR/opwR/U89ICx3McCsk= 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 Cc: marc.zyngier@arm.com, will.deacon@arm.com, bhsharma@redhat.com, linux-efi@vger.kernel.org, Ard Biesheuvel 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 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org 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(+) -- 2.19.1 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);