From patchwork Wed Oct 22 17:06:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 5135911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 053D69F3ED for ; Wed, 22 Oct 2014 17:09:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9C23201F4 for ; Wed, 22 Oct 2014 17:09:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C129D2017E for ; Wed, 22 Oct 2014 17:09:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XgzNm-0001W5-0w; Wed, 22 Oct 2014 17:07:34 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XgzNh-0001QL-Rg for linux-arm-kernel@lists.infradead.org; Wed, 22 Oct 2014 17:07:30 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9MH6vni015479 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 22 Oct 2014 13:06:58 -0400 Received: from [10.3.113.54] (ovpn-113-54.phx2.redhat.com [10.3.113.54]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9MH6uP4009019; Wed, 22 Oct 2014 13:06:56 -0400 Message-ID: <1413997616.2985.74.camel@deneb.redhat.com> Subject: Re: [PATCH 06/10] arm64/efi: use UEFI memory map unconditionally if available From: Mark Salter To: Ard Biesheuvel Date: Wed, 22 Oct 2014 13:06:56 -0400 In-Reply-To: <1413987713-30528-7-git-send-email-ard.biesheuvel@linaro.org> References: <1413987713-30528-1-git-send-email-ard.biesheuvel@linaro.org> <1413987713-30528-7-git-send-email-ard.biesheuvel@linaro.org> Organization: Red Hat, Inc Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141022_100730_035565_4DD78D65 X-CRM114-Status: GOOD ( 21.96 ) X-Spam-Score: -6.5 (------) Cc: mark.rutland@arm.com, matt.fleming@intel.com, yi.li@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, leif.lindholm@linaro.org, roy.franz@linaro.org, linux-efi@vger.kernel.org, dyoung@redhat.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 2014-10-22 at 16:21 +0200, Ard Biesheuvel wrote: > On systems that boot via UEFI, all memory nodes are deleted from the > device tree, and instead, the size and location of system RAM is derived > from the UEFI memory map. This is handled by reserve_regions, which not only > reserves parts of memory that UEFI declares as reserved, but also installs > the memblocks that cover the remaining usable memory. > > Currently, reserve_regions() is only called if uefi_init() succeeds. > However, it does not actually depend on anything that uefi_init() does, > and not calling reserve_regions() results in a broken boot, so it is > better to just call it unconditionally. > > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/kernel/efi.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c > index 51522ab0c6da..4cec21b1ecdd 100644 > --- a/arch/arm64/kernel/efi.c > +++ b/arch/arm64/kernel/efi.c > @@ -313,8 +313,7 @@ void __init efi_init(void) > memmap.desc_size = params.desc_size; > memmap.desc_version = params.desc_ver; > > - if (uefi_init() < 0) > - return; > + WARN_ON(uefi_init() < 0); > > reserve_regions(); > } It also looks like EFI_BOOT flag will be set even if uefi_init fails. If uefi_init fails, we only need reserve_regions() for the purpose of adding memblocks. Otherwise, we end up wasting a lot of memory. So, something like this would also be needed: > @@ -374,15 +373,13 @@ static int __init arm64_enter_virtual_mode(void) > int count = 0; > unsigned long flags; > > - if (!efi_enabled(EFI_BOOT)) { > - pr_info("EFI services will not be available.\n"); > - return -1; > - } > + if (!efi_enabled(EFI_MEMMAP)) > + return 0; > > mapsize = memmap.map_end - memmap.map; > early_memunmap(memmap.map, mapsize); > > - if (efi_runtime_disabled()) { > + if (!efi_enabled(EFI_BOOT) || efi_runtime_disabled()) { > pr_info("EFI runtime services will be disabled.\n"); > return -1; > } diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index 03aaa99..5a6e189 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -81,9 +81,6 @@ static int __init uefi_init(void) return -ENOMEM; } - set_bit(EFI_BOOT, &efi.flags); - set_bit(EFI_64BIT, &efi.flags); - /* * Verify the EFI Table */ @@ -109,6 +106,9 @@ static int __init uefi_init(void) efi.systab->hdr.revision >> 16, efi.systab->hdr.revision & 0xffff, vendor); + set_bit(EFI_BOOT, &efi.flags); + set_bit(EFI_64BIT, &efi.flags); + retval = efi_config_init(NULL); if (retval == 0) set_bit(EFI_CONFIG_TABLES, &efi.flags); @@ -177,9 +177,10 @@ static __init void reserve_regions(void) if (is_normal_ram(md)) early_init_dt_add_memory_arch(paddr, size); - if (is_reserve_region(md) || - md->type == EFI_BOOT_SERVICES_CODE || - md->type == EFI_BOOT_SERVICES_DATA) { + if (efi_enabled(EFI_BOOT) && + (is_reserve_region(md) || + md->type == EFI_BOOT_SERVICES_CODE || + md->type == EFI_BOOT_SERVICES_DATA)) { memblock_reserve(paddr, size); if (uefi_debug) pr_cont("*");