From patchwork Thu Jan 15 12:01:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 43170 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E577F240BA for ; Thu, 15 Jan 2015 12:03:03 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id l15sf7962443wiw.0 for ; Thu, 15 Jan 2015 04:03:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=ebLXz2uDWVT6RrjM16eVjrIFSwtYIKlT3ytqziZVkOM=; b=MNWkc505I1k/eufthMi/dIKFlz/iO7rjX8yHu7eQTNMIlqkdzp8I/6KJguoCvEVJjh jLNZ7in3/OAC+VdyRboZi9715QR6im7zwiG+ObGqzT5EmH4rh1FQy5s/nWkf5gCY6GyR 3MwiVnYkSg9Wc6Pe64gg85HvugJN9lGxkcdgkYkB7Lve2EFHydB4RKeSMWWtMPywUjR8 ASsQRbkkCq/tMBxbDCZEYwH0uAmyoxeaV/bwOWv9Gy1ZxecNMLEcCAYh/FfGhjsFQISi LRU7FCFYpJv8AhoUYgVfmbACIY6Z+dX9SETAz71TsjWoZ2XnTaks0W3GgTwMTTUnig8X kWUQ== X-Gm-Message-State: ALoCoQnqN8n5kg07VKBTjSvtLakYY+q8eiU0DSiQ37l5MMeqmPzaCTocJqkbIuVty9eWSpnZuGjS X-Received: by 10.181.13.147 with SMTP id ey19mr4279798wid.2.1421323383195; Thu, 15 Jan 2015 04:03:03 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.229 with SMTP id v5ls219516lav.11.gmail; Thu, 15 Jan 2015 04:03:03 -0800 (PST) X-Received: by 10.112.150.102 with SMTP id uh6mr9236386lbb.66.1421323383033; Thu, 15 Jan 2015 04:03:03 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id dh3si1237850lac.61.2015.01.15.04.03.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Jan 2015 04:03:02 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id gm9so13177855lab.12 for ; Thu, 15 Jan 2015 04:03:02 -0800 (PST) X-Received: by 10.152.18.135 with SMTP id w7mr9060297lad.47.1421323382906; Thu, 15 Jan 2015 04:03:02 -0800 (PST) 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.9.200 with SMTP id c8csp2009228lbb; Thu, 15 Jan 2015 04:03:01 -0800 (PST) X-Received: by 10.68.211.161 with SMTP id nd1mr13844597pbc.92.1421323381072; Thu, 15 Jan 2015 04:03:01 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id up2si1515132pac.178.2015.01.15.04.03.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jan 2015 04:03:01 -0800 (PST) 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 1YBj7S-0002F1-PT; Thu, 15 Jan 2015 12:01:46 +0000 Received: from mail-wi0-f178.google.com ([209.85.212.178]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YBj7N-00028u-4x for linux-arm-kernel@lists.infradead.org; Thu, 15 Jan 2015 12:01:42 +0000 Received: by mail-wi0-f178.google.com with SMTP id z2so11790991wiv.5 for ; Thu, 15 Jan 2015 04:01:18 -0800 (PST) X-Received: by 10.180.103.6 with SMTP id fs6mr26116579wib.11.1421323278221; Thu, 15 Jan 2015 04:01:18 -0800 (PST) Received: from ards-macbook-pro.local ([197.130.182.59]) by mx.google.com with ESMTPSA id fo2sm7205803wib.10.2015.01.15.04.01.16 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Jan 2015 04:01:17 -0800 (PST) From: Ard Biesheuvel To: mark.rutland@arm.com, msalter@redhat.com, matt.fleming@intel.com, leif.lindholm@linaro.org, roy.franz@linaro.org, linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org Subject: [PATCH] arm64/efi: handle potential failure to remap memory map Date: Thu, 15 Jan 2015 12:01:06 +0000 Message-Id: <1421323266-30973-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150115_040141_344210_5A0AE9EB X-CRM114-Status: GOOD ( 12.53 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.178 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.178 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ard Biesheuvel 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: , MIME-Version: 1.0 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: ard.biesheuvel@linaro.org 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.53 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 When remapping the UEFI memory map using ioremap_cache(), we have to deal with potential failure. Note that, even if the common case is for ioremap_cache() to return the existing linear mapping of the memory map, we cannot rely on that to be always the case, e.g., in the presence of a mem= kernel parameter. At the same time, remove a stale comment and move the memmap code together. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/efi.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index a98415b5979c..c9cb0fbe7aa4 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -229,19 +229,21 @@ static int __init arm64_enable_runtime_services(void) return -1; } - mapsize = memmap.map_end - memmap.map; - if (efi_runtime_disabled()) { pr_info("EFI runtime services will be disabled.\n"); return -1; } pr_info("Remapping and enabling EFI services.\n"); - /* replace early memmap mapping with permanent mapping */ + + mapsize = memmap.map_end - memmap.map; memmap.map = (__force void *)ioremap_cache((phys_addr_t)memmap.phys_map, mapsize); + if (!memmap.map) { + pr_err("Failed to remap EFI memory map\n"); + return -1; + } memmap.map_end = memmap.map + mapsize; - efi.memmap = &memmap; efi.systab = (__force void *)ioremap_cache(efi_system_table,