From patchwork Mon Dec 22 19:08:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 42545 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9C6E725BA1 for ; Mon, 22 Dec 2014 19:13:45 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id c13sf3287897eek.2 for ; Mon, 22 Dec 2014 11:13:44 -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 :in-reply-to:references: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=VTI50yK1LxZ5+BNT08GO9rdXs8cEGe2ffxIapO1oiIw=; b=kuUNclRjFSy91Z4Q5uI8JmKyk3rcJb6cXmH7SAv2hmbLX8dHcPT03mBOamSjki6SYk 28l6WnKHKahHmMHYQrf24rLtxXk5ffvACUTlV1YOuUh4NJmpuejSwu/tktqvshM3Gwbk pqPd941dD16siYnGc7/eJzi9e+UQLHuBu0oaVkrAWzGTVDbtBQ1Rsoa4bTD5gZk+hQ74 TKjLUVTBsORxQwKxAVD+CYoTcuhlyZ5IWrgDWEa4EP6MT1UTikjXwNtw5QNhOrDeK9dL pk/i+Qw0fMb6SXf3StKYkXzcxNIaS4e8xO//9Ocx7oNmWFNGCgTGpzrVpmjnEcSKiJ6A 0X3A== X-Gm-Message-State: ALoCoQkAcgd9MCQ9b1rTswUo6ESwUhP1e6R5cQsKoNLkRzvvkNkfAUi0d0n58m065zIhm96MfRgJ X-Received: by 10.112.235.231 with SMTP id up7mr2983205lbc.0.1419275624477; Mon, 22 Dec 2014 11:13:44 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.36 with SMTP id n4ls551820laj.65.gmail; Mon, 22 Dec 2014 11:13:44 -0800 (PST) X-Received: by 10.152.27.8 with SMTP id p8mr23771655lag.69.1419275624328; Mon, 22 Dec 2014 11:13:44 -0800 (PST) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id ai4si19423977lbc.10.2014.12.22.11.13.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Dec 2014 11:13:44 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id l4so4287681lbv.39 for ; Mon, 22 Dec 2014 11:13:44 -0800 (PST) X-Received: by 10.152.7.229 with SMTP id m5mr23740353laa.80.1419275624244; Mon, 22 Dec 2014 11:13:44 -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.142.69 with SMTP id ru5csp1119048lbb; Mon, 22 Dec 2014 11:13:43 -0800 (PST) X-Received: by 10.70.49.99 with SMTP id t3mr37534280pdn.105.1419275622443; Mon, 22 Dec 2014 11:13:42 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id b11si26474303pdm.29.2014.12.22.11.13.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Dec 2014 11:13:42 -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 1Y38Op-0000RT-Fl; Mon, 22 Dec 2014 19:12:11 +0000 Received: from mail-wg0-f45.google.com ([74.125.82.45]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y38MW-0006TZ-Sd for linux-arm-kernel@lists.infradead.org; Mon, 22 Dec 2014 19:09:49 +0000 Received: by mail-wg0-f45.google.com with SMTP id b13so7485782wgh.18 for ; Mon, 22 Dec 2014 11:09:29 -0800 (PST) X-Received: by 10.194.178.231 with SMTP id db7mr43655116wjc.112.1419275369178; Mon, 22 Dec 2014 11:09:29 -0800 (PST) Received: from ards-macbook-pro.local ([41.248.55.245]) by mx.google.com with ESMTPSA id t6sm24758726wjf.49.2014.12.22.11.09.26 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Dec 2014 11:09:28 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, leif.lindholm@linaro.org, roy.franz@linaro.org, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, matt.fleming@intel.com, bp@alien8.de, dyoung@redhat.com, msalter@redhat.com, grant.likely@linaro.org Subject: [PATCH 8/8] arm64/efi: memblock_remove rather than _reserve UEFI reserved RAM Date: Mon, 22 Dec 2014 19:08:42 +0000 Message-Id: <1419275322-29811-9-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1419275322-29811-1-git-send-email-ard.biesheuvel@linaro.org> References: <1419275322-29811-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141222_110949_108219_37D01B00 X-CRM114-Status: GOOD ( 11.12 ) 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 [74.125.82.45 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.45 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.217.180 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 Now that we have the 'physmem' memblock table to keep track of physical RAM regions, we can start using memblock_remove() to eliminate UEFI reserved regions from the 'memory' memblock table and the kernel direct linear mapping entirely. This makes these regions inaccessible entirely, unless they are remapped explicitly by the UEFI Runtime Services layer, UEFI configuration table drivers or the ACPI layer. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/efi.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index b1b816ecf3b3..d0efd9df6216 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -167,7 +167,7 @@ static __init void reserve_regions(void) if (uefi_debug) { char buf[64]; - pr_info(" 0x%012llx-0x%012llx %s", + pr_info(" 0x%012llx-0x%012llx %s\n", paddr, paddr + (npages << EFI_PAGE_SHIFT) - 1, efi_md_typeattr_format(buf, sizeof(buf), md)); } @@ -177,15 +177,6 @@ static __init void reserve_regions(void) if (is_normal_ram(md)) early_init_dt_add_memory_arch(paddr, size); - - if (is_reserve_region(md)) { - memblock_reserve(paddr, size); - if (uefi_debug) - pr_cont("*"); - } - - if (uefi_debug) - pr_cont("\n"); } /* @@ -196,7 +187,18 @@ static __init void reserve_regions(void) for_each_memblock(memory, r) memblock_add_phys(r->base, r->size); + for_each_efi_memory_desc(&memmap, md) { + if (is_reserve_region(md)) { + paddr = md->phys_addr; + npages = md->num_pages; + memrange_efi_to_native(&paddr, &npages); + memblock_remove(paddr, npages << PAGE_SHIFT); + } + } + set_bit(EFI_MEMMAP, &efi.flags); + if (uefi_debug) + __memblock_dump_all(); } void __init efi_init(void)