From patchwork Tue Oct 28 16:18:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 39680 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 76D3A24026 for ; Tue, 28 Oct 2014 16:22:06 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf908926eek.5 for ; Tue, 28 Oct 2014 09:22:05 -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:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=pH/ZTa0BYErSmnZ8JveohAOhBoPWBllNThc0HA1VEzE=; b=Ki3sfgml/0L5W774Pn9xA+pAXPprb2D9q46qf18Q1bBZieRbBaQEWB1giIHoykIAQy moe0/034K56tbiCzzRgoxqwpaOMBqMRLgr2C07cTS9RzGDhb1UsNFBU218dxf/Uf01IP 6woT4bx6o+ckTiDCIxqb1/e4uyvFPr1SK6gE4izvFgKOcRVwVFFKuum0Bfqmao91h9PJ JpWa1ecda/5hsDWc/+z27t9XU9pxQsRb5w5xJQVVrVSr8uI5SoVE7dVJ9o1EW2xWxnQS xvXG0v/NjrGzdH7TgZOaFJu7rUjssopGN2hcsQc8D7hio/vpY0zpgAV3djGV7Rtl0U07 z2BQ== X-Gm-Message-State: ALoCoQloa6Gv3F3lrxTi9Gd2b8+dXS5u+azyo7IJ8GXivfzpKSAq/6l1uEa87m7o9ybSdO/ei7bv X-Received: by 10.181.27.135 with SMTP id jg7mr918959wid.5.1414513325638; Tue, 28 Oct 2014 09:22:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.194 with SMTP id t2ls82516laa.14.gmail; Tue, 28 Oct 2014 09:22:05 -0700 (PDT) X-Received: by 10.112.162.105 with SMTP id xz9mr5047402lbb.49.1414513325387; Tue, 28 Oct 2014 09:22:05 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id ll8si3320920lac.9.2014.10.28.09.22.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Oct 2014 09:22:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id f15so1034523lbj.9 for ; Tue, 28 Oct 2014 09:22:05 -0700 (PDT) X-Received: by 10.152.87.98 with SMTP id w2mr5078471laz.27.1414513325301; Tue, 28 Oct 2014 09:22:05 -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 c5csp510529lbz; Tue, 28 Oct 2014 09:22:04 -0700 (PDT) X-Received: by 10.66.151.202 with SMTP id us10mr4548468pab.78.1414513323082; Tue, 28 Oct 2014 09:22:03 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id e10si1783182pdm.49.2014.10.28.09.22.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Oct 2014 09:22:03 -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 1Xj9Vj-0005xc-KE; Tue, 28 Oct 2014 16:20:43 +0000 Received: from mail-wi0-f172.google.com ([209.85.212.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xj9UO-00040w-8e for linux-arm-kernel@lists.infradead.org; Tue, 28 Oct 2014 16:19:20 +0000 Received: by mail-wi0-f172.google.com with SMTP id d1so6300621wiv.11 for ; Tue, 28 Oct 2014 09:18:57 -0700 (PDT) X-Received: by 10.194.84.10 with SMTP id u10mr5589853wjy.67.1414513137234; Tue, 28 Oct 2014 09:18:57 -0700 (PDT) Received: from ards-macbook-pro.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id wc7sm2357578wjc.8.2014.10.28.09.18.55 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Oct 2014 09:18:56 -0700 (PDT) From: Ard Biesheuvel To: leif.lindholm@linaro.org, roy.franz@linaro.org, msalter@redhat.com, mark.rutland@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, matt.fleming@intel.com, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dyoung@redhat.com, yi.li@linaro.org Subject: [PATCH v2 04/10] arm64/efi: invert UEFI memory region reservation logic Date: Tue, 28 Oct 2014 17:18:37 +0100 Message-Id: <1414513123-20400-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1414513123-20400-1-git-send-email-ard.biesheuvel@linaro.org> References: <1414513123-20400-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141028_091920_484941_05A3E91A X-CRM114-Status: GOOD ( 14.35 ) 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.172 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.172 listed in wl.mailspike.net] -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.217.178 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 Instead of reserving the memory regions based on which types we know need to be reserved, consider only regions of the following types as free for general use by the OS: EFI_LOADER_CODE EFI_LOADER_DATA EFI_BOOT_SERVICES_CODE EFI_BOOT_SERVICES_DATA EFI_CONVENTIONAL_MEMORY Note that this also fixes a problem with the original code, which would misidentify a EFI_RUNTIME_SERVICES_DATA region as not reserved if it does not have the EFI_MEMORY_RUNTIME attribute set. However, it is perfectly legal for the firmware not to request a virtual mapping for EFI_RUNTIME_SERVICES_DATA regions that contain configuration tables, in which case the EFI_MEMORY_RUNTIME attribute would not be set. Signed-off-by: Ard Biesheuvel Acked-by: Roy Franz --- arch/arm64/kernel/efi.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index 95c49ebc660d..2e829148fb36 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -125,17 +125,17 @@ out: */ static __init int is_reserve_region(efi_memory_desc_t *md) { - if (!is_normal_ram(md)) + switch (md->type) { + case EFI_LOADER_CODE: + case EFI_LOADER_DATA: + case EFI_BOOT_SERVICES_CODE: + case EFI_BOOT_SERVICES_DATA: + case EFI_CONVENTIONAL_MEMORY: return 0; - - if (md->attribute & EFI_MEMORY_RUNTIME) - return 1; - - if (md->type == EFI_ACPI_RECLAIM_MEMORY || - md->type == EFI_RESERVED_TYPE) - return 1; - - return 0; + default: + break; + } + return is_normal_ram(md); } static __init void reserve_regions(void)