From patchwork Tue Nov 6 11:37:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 150256 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3775331ljp; Tue, 6 Nov 2018 03:37:45 -0800 (PST) X-Google-Smtp-Source: AJdET5ck3zSz0SXT22ZgD04o5G5DrIGjvrwV/v4S4LBNYtFVv5TTKcz+KYxyLW6VP9b9o5fYH3Ae X-Received: by 2002:a63:3d03:: with SMTP id k3mr17914868pga.191.1541504265659; Tue, 06 Nov 2018 03:37:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541504265; cv=none; d=google.com; s=arc-20160816; b=AN+YnZy1a/kNaNCrgNO/7Q2CyL9EPPLthd2a6id+Vf6Vm/moEHGVbj8fYDq+K2UexC EDYykTFFwGJXT4ToOcXj6KOHij+/5OUaBvNhGZJfOlgQevNY6D7Uu6sCxXN1AHksdkRI 4zlqzQZzOdLcERXb7kxRjJiv2IrmLAcEzW0AiiCpdt6ewb77E7kuFjbUEq98XfKijWbO 48MRzvmOicYZiCbuOszRLfcjoY1XLVyYExMoMXaHC4Ri409sDqInd0eDLt4OcIzaNtzE P77zcaG/bt7wI2109S+uuyZdJbaul3Fw37QKit/wW/iH1trgFbye8sMJL4nPXDu0Yeiw j0og== 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=JxerrVzSB3nQMNgEEqnbh4b0SvNJgKQEb0pTSsx3VlE=; b=BYZI/ipMe/GBOUcMcCim0XygXKa2XhxKNBKhYbXx0DL+4FcllY24yIIVAer0OBRpfQ KdV5sWaN8/muCuLhvDIUBeW6keN8uBBbwGoC4YSbf9Q+VxE6tor3C6vaIQigbwQqj1df cZkc10EdduA8HELsCIwKiNDhh8cfQqFBEX6sJVjKjyxHbkPChOFrhHQ073oZAIHLjNbI Jgacf5ARCZZywl8mKkqv1Q8+uuodCGMM8eKxKgRsW2CqhSNFTym6Kvz+yMoGOacmBM9g V/gdIhSPuYVw20E/tXty9un0hbgXJXpBZlB2bWSaAadUZEvdRmo5fBh5sQtKhsVKs5ht BlRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LEkis6Ib; 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 q10-v6si44073084pls.344.2018.11.06.03.37.45; Tue, 06 Nov 2018 03:37:45 -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=LEkis6Ib; 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 S1730444AbeKFVCb (ORCPT + 3 others); Tue, 6 Nov 2018 16:02:31 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:40392 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730358AbeKFVCb (ORCPT ); Tue, 6 Nov 2018 16:02:31 -0500 Received: by mail-wm1-f66.google.com with SMTP id b203-v6so11381249wme.5 for ; Tue, 06 Nov 2018 03:37: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 :mime-version:content-transfer-encoding; bh=JxerrVzSB3nQMNgEEqnbh4b0SvNJgKQEb0pTSsx3VlE=; b=LEkis6IbqL13P9CYwk0pSb3DMuyibP8zOWT0xJQkjqheSP+YuIxivZH9wFPPr30nA3 n1FEhjV6SlrxNUHB8pXZ/eqtGjL+trEycYiTubzOAfLM/ZCQDl37uHszNLM+2qSo5Jr2 +1/F9gnVTqlrTJ/AY1AKCbRvpp8zcEOWcaYN0= 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=JxerrVzSB3nQMNgEEqnbh4b0SvNJgKQEb0pTSsx3VlE=; b=oGGgJoq5JsSSio7Pd5alQpX4FdnysJTj7qQCnQei4k41gFhLYIzojHBbduPVNka/e9 0O3RUVKLi8dYnHOR3qeU1lPnYofJmAjUAPLRnwNNgjWbTpGf1hWY36dPQrQA+0DsJKxh V+GX7gJBqXGFYTHSq+osF4KwuXITPO2hzGARWEBSg7ECQfnyySscEfVLc7Nj/O65utaT zwmMR4H3iDFMjnFOsjbAI5KUHRKneQobDFBDZ0n+ie/6/bmhKcV09sfHF5jqkFI65UqT UA4lT2DF6gb5jj5yPTe1/wtexlpSUcBD8NY7vOi0lVsyxh31lTmOFTGhOj3tgwmXkhOW nTRg== X-Gm-Message-State: AGRZ1gJHlfKl2apb0hUp5AZtPOrp9csb5vgHvu/H3rVkF6bgcvojdn+K UvlOvXnLlHreGN3YyCSbM6BKYQ== X-Received: by 2002:a1c:187:: with SMTP id 129-v6mr1635260wmb.55.1541504262987; Tue, 06 Nov 2018 03:37:42 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:3117:2b29:5ef7:a9e5]) by smtp.gmail.com with ESMTPSA id t187-v6sm1431529wmt.45.2018.11.06.03.37.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 03:37:42 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: bhsharma@redhat.com, linux-efi@vger.kernel.org, will.deacon@arm.com, mark.rutland@arm.com, marc.zyngier@arm.com, Ard Biesheuvel , Russell King Subject: [PATCH 2/4] efi/arm: defer persistent reservations until after paging_init() Date: Tue, 6 Nov 2018 12:37:30 +0100 Message-Id: <20181106113732.16351-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181106113732.16351-1-ard.biesheuvel@linaro.org> References: <20181106113732.16351-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 both arm64 and ARM. Cc: Russell King Signed-off-by: Ard Biesheuvel --- arch/arm/kernel/setup.c | 1 + arch/arm64/kernel/setup.c | 1 + drivers/firmware/efi/efi.c | 8 ++++++-- include/linux/efi.h | 7 +++++++ 4 files changed, 15 insertions(+), 2 deletions(-) -- 2.19.1 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index ac7e08886863..e99f12eaf390 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -1117,6 +1117,7 @@ void __init setup_arch(char **cmdline_p) early_ioremap_reset(); paging_init(mdesc); + efi_apply_persistent_mem_reservations(); request_standard_resources(mdesc); if (mdesc->restart) 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..55e4ea20bdc3 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; @@ -602,7 +606,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, /* reserve the entry itself */ memblock_reserve(prsv, sizeof(*rsv)); - rsv = early_memremap(prsv, sizeof(*rsv)); + rsv = memremap(prsv, sizeof(*rsv), MEMREMAP_WB); if (rsv == NULL) { pr_err("Could not map UEFI memreserve entry!\n"); return -ENOMEM; @@ -612,7 +616,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, memblock_reserve(rsv->base, rsv->size); prsv = rsv->next; - early_memunmap(rsv, sizeof(*rsv)); + memunmap(rsv); } } 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);