From patchwork Tue Nov 20 17:35:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 151613 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp885348ljp; Tue, 20 Nov 2018 09:35:57 -0800 (PST) X-Google-Smtp-Source: AJdET5fYI6YSoxTuKPu6xXlNZHzZ21RuBdB5WrDhXX4fQ+QvptSbEgBProGayqIXBnYNk9aGMLUH X-Received: by 2002:a62:ca05:: with SMTP id n5mr3136573pfg.154.1542735357576; Tue, 20 Nov 2018 09:35:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542735357; cv=none; d=google.com; s=arc-20160816; b=QEpltziDsuruAhjiNqJgS1gku6fJh9UfvRw9zrzORxvLrtThk+tP2AMqdyoeeJDSW7 kawjVbUa+bQyWollML+dLU1i8Kv6oV5Eb/oi+IDYTs1QjNcewYvQ9ANSrSt/6xvy6ssn ahjV9wKRowze/DGosDnOcGyFzlMl/LgQbLU1BUriUf5RllUV1Att7BDYvXMAiq+eQVdd 5ts6YvFZXL4tPPC+ybgUjWMoZaBiVf7RqqR6gdSsqtkway5M67BfEqknaCBwFCMcZZ7t DHideo/67y2wxotKrYhK84tz+lM2sQgNC+JWBYmvy6AikA/gnARZxteYybnRqfGNzSHA g64w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=0yYZN5Rql0LyDMugixfa9zpVge6xlNLVs2NG1mlphFs=; b=Kfos7M35DgbB602WaRNEmXyDTweMckjpvBDtKCBql3Zf3hEo2/3TqkNJ4ps5V9UmKr WSNDdyah0XmMMzltBlc4ezIe9TMlIJ8UD7AiClHTffJ8PhC9Mi++6Gv2y7aPbKNONsp4 kpZoLzL8V5FE6ATneIR6X0IqIuZAseQ5/xkjdvUjk4t/wUAwQv/LXbWVKi59Z5XwEHvp kNpgL/9YFTZMjtrANF4CJCR2T1GjJfsH87FFFtESjguKld9TnX744U/UF3S64VtKzVIE 0kMlppm0gtZGZJS3efv3o41PSmBekAQ0w39jlQ39QKAFvb6zZF3dtq+p3RFqa1zTfZc+ 7qMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W+f4wDVX; 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 g25si21682946pgm.14.2018.11.20.09.35.57; Tue, 20 Nov 2018 09:35:57 -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=W+f4wDVX; 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 S1727589AbeKUEGO (ORCPT + 3 others); Tue, 20 Nov 2018 23:06:14 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:35810 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727354AbeKUEGO (ORCPT ); Tue, 20 Nov 2018 23:06:14 -0500 Received: by mail-ed1-f66.google.com with SMTP id x30so2660962edx.2 for ; Tue, 20 Nov 2018 09:35:55 -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=0yYZN5Rql0LyDMugixfa9zpVge6xlNLVs2NG1mlphFs=; b=W+f4wDVX4TN+JQwDzA6oOt2179uJMtu17ycro6Xl+G0mf+WPuuWhojreOVQ5zogett gUGw89H6m+F9fO8NHwWfbPITFu24W7Dgv/HGnvXiiwgh3SOw5m66xKaakTR+3kbcu8Oq x2HXVaJDXiNH5FFfKLWtv2Evqo0Dz1rMvGh9c= 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=0yYZN5Rql0LyDMugixfa9zpVge6xlNLVs2NG1mlphFs=; b=ohhIRKm4kiAQ8bO3EjVs3gZN81OYz/UJQ3udSUVkW9+JqD4nyThrafd3JYRbLrEuii 4OOilxq0SjxX/pqCRpwFPnnF6qEs6c53k2E2EjJt2vixFA8IQUEfrjYMWjiQQGxDTbnh Q4/4L7GuLxOPLf8oJNmCMQrWcutWLSGrQ+lUJyibvcD4xCFRFBn+gjyBxG7GWIpGVNAq 5YE5dtm3FC9Y3jt30a/Hl9uHy8CvD5JzDI2dJTsOj8J0J4bd7jCpQgcAAeHHkyqwzonK /MuzjKhEh3ZPTe41uelG2f0zEzX+jAB9QWK9fFQhBXXS+yHf0fGIutiiqpOYAuT4y42B 8bnQ== X-Gm-Message-State: AA+aEWaMOTkeK98NFbvlhHloR4w9iMl1u3J4l5GTmknSM/9cMfHH46Ri fvbYQVV3OqOiAaQwRY3ZvLA0iQ0cpnTxRw== X-Received: by 2002:a50:cc04:: with SMTP id m4mr2972113edi.171.1542735354869; Tue, 20 Nov 2018 09:35:54 -0800 (PST) Received: from mba13.wifi.ns.nl (dhcp-077-251-017-237.chello.nl. [77.251.17.237]) by smtp.gmail.com with ESMTPSA id x38sm5432864edx.24.2018.11.20.09.35.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 09:35:53 -0800 (PST) From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, marc.zyngier@arm.com, Jan.Glauber@cavium.com, john.garry@huawei.com, Ard Biesheuvel Subject: [RFT PATCH] efi: map memreserve table before first use Date: Tue, 20 Nov 2018 18:35:42 +0100 Message-Id: <20181120173542.31444-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Mapping the MEMRESERVE EFI configuration table from an early initcall is too late: the GICv3 ITS code that creates persistent reservations for the boot CPU's LPI tables is invoked from init_IRQ(), which runs much earlier than the handling of the initcalls. So instead, move the initialization performed by the initcall into efi_mem_reserve_persistent() itself. Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/efi.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) -- 2.17.1 Tested-by: Marc Zyngier Tested-by: Jan Glauber Tested-by: John Garry diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index fad7c62cfc0e..40de2f6734cc 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -967,15 +967,23 @@ bool efi_is_table_address(unsigned long phys_addr) } static DEFINE_SPINLOCK(efi_mem_reserve_persistent_lock); -static struct linux_efi_memreserve *efi_memreserve_root __ro_after_init; +static struct linux_efi_memreserve *efi_memreserve_root; int efi_mem_reserve_persistent(phys_addr_t addr, u64 size) { struct linux_efi_memreserve *rsv; - if (!efi_memreserve_root) + if (efi.mem_reserve == EFI_INVALID_TABLE_ADDR) return -ENODEV; + if (!efi_memreserve_root) { + efi_memreserve_root = memremap(efi.mem_reserve, + sizeof(*efi_memreserve_root), + MEMREMAP_WB); + if (WARN_ON_ONCE(!efi_memreserve_root)) + return -ENOMEM; + } + rsv = kmalloc(sizeof(*rsv), GFP_ATOMIC); if (!rsv) return -ENOMEM; @@ -991,20 +999,6 @@ int efi_mem_reserve_persistent(phys_addr_t addr, u64 size) return 0; } -static int __init efi_memreserve_root_init(void) -{ - if (efi.mem_reserve == EFI_INVALID_TABLE_ADDR) - return -ENODEV; - - efi_memreserve_root = memremap(efi.mem_reserve, - sizeof(*efi_memreserve_root), - MEMREMAP_WB); - if (!efi_memreserve_root) - return -ENOMEM; - return 0; -} -early_initcall(efi_memreserve_root_init); - #ifdef CONFIG_KEXEC static int update_efi_random_seed(struct notifier_block *nb, unsigned long code, void *unused)