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: 39329 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5078C202DB for ; Wed, 22 Oct 2014 17:08:59 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf2313681lab.3 for ; Wed, 22 Oct 2014 10:08:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:subject:from:to:date :in-reply-to:references:organization:mime-version:cc:precedence :list-id:list-unsubscribe:list-archive:list-post:list-help :list-subscribe:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=Z9LaeS3sQyCgD5y2iQfg/llmy6O1xZN8MC7yH27/rlQ=; b=cjgliBf73NFpRUEbD+47LQxQKVx7FX8TMucfJMqwkEubY/+xz6MlSJdvivOxGaJViL OFDnqdXbKkOmo2N8uf6NCFTie0xE/723RGLHb5Tq0Qzc+DNMY0+NeK7ANPr/4g2dUy+L y8h6Viv7GyDHa/KxCsy7pMTB4qcKAJ7qpNAjoMGfPtKckHkVtXyU6DGvBEgz0DxIbPbj Gi+9SmJoMRv1VCLAGeWTQBSkgIHYT3CTLeV9/asvUsNLFzHzCbpXs1czY77dxb076Mkl NRFIsLle2QLqXqo4ejwjbImmSZVQ85sjudYhvy3mKx9z4y3n/CN68eQ9DZ2PJk3w23tM 0Ywg== X-Gm-Message-State: ALoCoQnM5HCKykMMC6l0sDKH+s6GU/nNXunxQJXykDpAFZfE0M3D1G4xZm2VuOhPVbG7GN1rCgyt X-Received: by 10.112.32.163 with SMTP id k3mr405554lbi.17.1413997738048; Wed, 22 Oct 2014 10:08:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.44 with SMTP id kv12ls211991lac.44.gmail; Wed, 22 Oct 2014 10:08:57 -0700 (PDT) X-Received: by 10.112.52.33 with SMTP id q1mr44152457lbo.42.1413997737868; Wed, 22 Oct 2014 10:08:57 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id f6si12606625lbc.6.2014.10.22.10.08.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Oct 2014 10:08:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id gi9so3272444lab.5 for ; Wed, 22 Oct 2014 10:08:57 -0700 (PDT) X-Received: by 10.112.221.197 with SMTP id qg5mr42566229lbc.32.1413997737761; Wed, 22 Oct 2014 10:08:57 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp115245lbz; Wed, 22 Oct 2014 10:08:56 -0700 (PDT) X-Received: by 10.70.134.197 with SMTP id pm5mr43653589pdb.90.1413997736066; Wed, 22 Oct 2014 10:08:56 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id bl3si14742188pbd.52.2014.10.22.10.08.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Oct 2014 10:08:56 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; 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 (------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-6.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [209.132.183.28 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.132.183.28 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: msalter@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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("*");