From patchwork Thu Oct 29 13:40:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 55772 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp573374lbr; Thu, 29 Oct 2015 06:43:30 -0700 (PDT) X-Received: by 10.50.61.145 with SMTP id p17mr3636799igr.68.1446126210684; Thu, 29 Oct 2015 06:43:30 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id im6si26424842igb.54.2015.10.29.06.43.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Oct 2015 06:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com 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 1ZrnT1-00074F-Um; Thu, 29 Oct 2015 13:42:11 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrnSM-0006oq-VM for linux-arm-kernel@lists.infradead.org; Thu, 29 Oct 2015 13:41:33 +0000 Received: by wmec75 with SMTP id c75so25068986wme.1 for ; Thu, 29 Oct 2015 06:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cSFLGKsgP1f1kXgyCrlRAFULSstYlj0ylK8kfEJPbyM=; b=Cvcf8Jg3hfsHc2kbrrzAkUMMfDHrRWpbbG8Wk0jyjZJwxGpw29fHV8wQUj5BulJbeg bPvmu1ut7GOqqMoU29Jwt4k3aeUDvfSWPN1HgIHY9FuIbrbVyD/1FbUeslMGV56stkCn axVLYfh4T9pXHd4/gDxPHpj8pjrY7fdbEX6w2hPHWPoUOFY0Dq/M4o07Z35S2l8FL3Uc VYv880NLmFm/v324BF5tZtLG9PBBAAEejAQNH4QkJRS/1VqeIVLFa0ZbgKlFPtLPlAo0 E+Zy4lqgdAmhJPAzSyPy+ACBOJotGC2J6LKVtnP6Ajo0h6gLJh/EYVTqS1g6nEIewS05 WsQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cSFLGKsgP1f1kXgyCrlRAFULSstYlj0ylK8kfEJPbyM=; b=FsW8Vh0F6boCoS4ar0so16TaH6Erbxa9pbsYrfJ/gGO3FbrtvbFtLvHfHKbPIHVElE yRuAIDqUK9GfTlxK/6WfvcpzsDFOc35OcyJY0Nkl3pAAIGp+J6kAxPu+JS3IuYO/aW0U 4LUwNrSTd8UogdCZXfLD+mZNJ6BQSysEXCpmkT9LPLYhngVrKDkVB40MCzbHBHdyTFbB gBLZPi4KDCcsOBiugUXThFAzAYUtwAcwgtBAK4L47XdlRwxoA+6a3HfH1GJPYg2YXVz/ HcSSWbf6ry4hrLn6LCLb01N2mQf67Bfrw9izjrsmqRN5CdHEFOUeUltcxSeVuOE23C5V f2cw== X-Gm-Message-State: ALoCoQnCXGpFjNYyQ2UpKKq53qBQZfd3CIh/UPUTotI5wlFz41T0/7ap/94B7KED9BH0bZcA+juv X-Received: by 10.28.5.4 with SMTP id 4mr7171472wmf.22.1446126069257; Thu, 29 Oct 2015 06:41:09 -0700 (PDT) Received: from jessie.localdomain ([85.119.43.29]) by smtp.gmail.com with ESMTPSA id p75sm3578918wmd.22.2015.10.29.06.41.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Oct 2015 06:41:08 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, leif.lindholm@linaro.org, mark.rutland@arm.com, will.deacon@arm.com Subject: [PATCH 3/3] arm64/efi: memblock_remove() rather than _reserve UEFI reserved memory Date: Thu, 29 Oct 2015 14:40:59 +0100 Message-Id: <1446126059-25336-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1446126059-25336-1-git-send-email-ard.biesheuvel@linaro.org> References: <1446126059-25336-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151029_064131_235160_6F4195B8 X-CRM114-Status: GOOD ( 14.17 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: matt@codeblueprint.co.uk, catalin.marinas@arm.com, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Memory regions that are not advertised as being available for general use to the kernel should either never be mapped at all (EfiReservedMemory), since it should not even be accessed speculatively, or they are mapped and unmapped explicitly when used (UEFI runtime services regions), so the linear mapping is never used anyway. This means we are better off removing these regions from the linear mapping entirely, so memblock_remove() rather than memblock_reserve() them. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/efi.c | 22 +++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) -- 2.1.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index 11b59e9a5954..daafa40d1c19 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -171,7 +171,7 @@ static __init void reserve_regions(void) if (efi_enabled(EFI_DBG)) { 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)); } @@ -181,15 +181,17 @@ 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 (efi_enabled(EFI_DBG)) - pr_cont("*"); - } + for_each_efi_memory_desc(&memmap, md) { + paddr = md->phys_addr; + npages = md->num_pages; + + memrange_efi_to_native(&paddr, &npages); + size = npages << PAGE_SHIFT; - if (efi_enabled(EFI_DBG)) - pr_cont("\n"); + if (is_reserve_region(md)) + memblock_remove(paddr, size); } } @@ -203,8 +205,6 @@ void __init efi_init(void) efi_system_table = params.system_table; - memblock_reserve(params.mmap & PAGE_MASK, - PAGE_ALIGN(params.mmap_size + (params.mmap & ~PAGE_MASK))); memmap.phys_map = (void *)params.mmap; memmap.map = early_memremap(params.mmap, params.mmap_size); memmap.map_end = memmap.map + params.mmap_size; @@ -216,6 +216,8 @@ void __init efi_init(void) reserve_regions(); early_memunmap(memmap.map, params.mmap_size); + memblock_remove(params.mmap & PAGE_MASK, + PAGE_ALIGN(params.mmap_size + (params.mmap & ~PAGE_MASK))); } static void __init efi_reserve_iomem_resource(efi_memory_desc_t *md)