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: 10690961 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 61A4D5A4 for ; Tue, 20 Nov 2018 17:39:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48D022ACDE for ; Tue, 20 Nov 2018 17:39:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36FED2ACE3; Tue, 20 Nov 2018 17:39:21 +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 244A22ACDE for ; Tue, 20 Nov 2018 17:39:20 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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:In-Reply-To: References:List-Owner; bh=QziGFkBKVy1b04ci358HRs7M9i98Pyf9h+CrWQvVUjY=; b=Nw1 +sK6cJD2ZqMikUgMc2cmorclvrvowcCFz30rU4cwu1LknTbcSZO1pAAEQNLrcthbjakjr02HrBG0G 2pH48DhoAy+SL68ErbeO87Vbjfz/5R55pFWdKJg6LtRwvy80kOQBaYMHe4kzZ6FdTr61d3g2Volhr Fwh4dYBRSMzGULc+q3LG5OX7DUFwNEAXCGod6aubJO+5dzEcZRGttO0DTc6hDKP8qVrPPkvjHvUpj HH0wpxrnJvoeFuP79eA5tTYNqcCtkgSYB+fF5VC41+CJw/9W57WB4UZQuabe0aNa9jBW61jF3KY/g iYbNRyyyNEgv7mZa6pvc3/AjQO+8Z2g==; 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 1gP9zV-0003Bi-87; Tue, 20 Nov 2018 17:39:13 +0000 Received: from mail-ed1-f66.google.com ([209.85.208.66]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gP9zP-0002Nw-9Q for linux-arm-kernel@lists.infradead.org; Tue, 20 Nov 2018 17:39:11 +0000 Received: by mail-ed1-f66.google.com with SMTP id b3so2670013ede.1 for ; Tue, 20 Nov 2018 09:36:56 -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=hfOQqfCiJ6DCUFljJ8NboM26/KQC78PVF1abyVP6aSVU9qtiOh5GTwqhZXXl7Cux19 kKoHxCcGzrt8BM994mnDv1e2Ld7qHqZp6Elrw8nPsPli9VGp0EvH9oUFj8HT1mHbKKFM H7Ljsm4M2y/6Gq4iuTvSgZhD6HrMIda2DL0xJ8vAv72oFThL57JGZdh7BNL1Nbt3ET5g 13InhyRfKrkK4AA53Or8zXfQWWgE1FeG6ckcEBMZMITSTth23v0QaB2EKCoZBr26MKsn atMaSCTO2XmS5wgPgqt5Kb6eVpDS4LMh2ctFtq2cB9gI7/gYK3RvQPOferpXOK2oTxiE AubA== X-Gm-Message-State: AA+aEWYfOg7mDi3uQ64YY5kMHLAtSYy9ODHY68yqn7Q7WdJDgvcb3v6B VvHlak4gVEDvuj2nOI1CilrWSQ== X-Google-Smtp-Source: AFSGD/WxtHQ5cxOOVvr/YRXl/3O/+5XF0BZuqvc35+4DcNMk54BwCbLekkP8E3xnNug6VWa0HBJp3w== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181120_093907_334792_6EB52CD3 X-CRM114-Status: GOOD ( 12.47 ) 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, john.garry@huawei.com, Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, Jan.Glauber@cavium.com MIME-Version: 1.0 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 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 Tested-by: Marc Zyngier Tested-by: Jan Glauber Tested-by: John Garry --- drivers/firmware/efi/efi.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) 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)