From patchwork Mon Nov 16 18:32:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 56680 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1484786lbb; Mon, 16 Nov 2015 10:40:37 -0800 (PST) X-Received: by 10.50.78.101 with SMTP id a5mr17085910igx.42.1447699236947; Mon, 16 Nov 2015 10:40:36 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id w33si18761243ioi.162.2015.11.16.10.40.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Nov 2015 10:40:36 -0800 (PST) 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 1ZyOg2-0005G2-1a; Mon, 16 Nov 2015 18:38:54 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZyOaq-0007Z4-My for linux-arm-kernel@lists.infradead.org; Mon, 16 Nov 2015 18:33:39 +0000 Received: by wmww144 with SMTP id w144so122760556wmw.1 for ; Mon, 16 Nov 2015 10:33:11 -0800 (PST) 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=59wxZmDyHMdcljQNy26jPzqijc+NIu5pkCEOR+9SHe0=; b=JOq3QRiFWoNWGUegjpJTd33ha6UkVfNl1GAgVHCg8cgD6yBKnZG2w0Xu2ZYVJ26oGO bV8LHfKFZ1XYR2D1BH7JXZUEs+3QL4bnvvTd0QyQP5E6qGOd3++sy65ak1/mWv0Mbv5j s4H194EnbHKupdPhYT255Tbs/DfHwhpjyiXJ3NIqF3vfJHJ56IdsfgjozeDf/BzeM49l Nhdu7jZRzTM2t7XMr1VT4N3zdm6Gllq4FpRv3RrkKPkXlvJX4FBxXWyuUoc5j+jbH05n qyiLHCCLrsJsx0FqglOIsi/kaBlXBv/QzmRrfqD2jPiKxs+1i+MWM6SxTNc8TLwgwwY7 OwPw== 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=59wxZmDyHMdcljQNy26jPzqijc+NIu5pkCEOR+9SHe0=; b=E7G6oyjuO4rzpq0/6VRCoPPsPCghT2Wl27qBAgGZInI9tdKKu3LWnOO4IcoI+9b+bP 57QKD9J3teek5fo2nPaQrtMDNvZLWsxMQHH+iLyo1PdS/ILB0leaNuuQlgIz1hH0DQUV 7rLLZMXRwVfGxxIxoVyZAGz5HbMw1iL0uL1AIKMP58bKsjdwy9WqCPZfgkd4hXftX01P 03Pgo+QQG33xZcJVb9Io18G4oncAd+KG38UHi4DHqOBAHe7NyxqmcPmpwENrIuqDYw7B L0LqSbfZ7Mh7utM/3sDPy15s+V6SpVPUgd22BqLqprUPZtnc9ullK+Gf6QXULr4p8wIh RTCA== X-Gm-Message-State: ALoCoQl5u0Ggcghh01Pk2n1UvgiIagpEKAsteIUpXlZErB78zBxFt2IiZPSokKAY4NxbxC8B4O+c X-Received: by 10.194.108.103 with SMTP id hj7mr37773913wjb.143.1447698791158; Mon, 16 Nov 2015 10:33:11 -0800 (PST) Received: from ards-macbook-pro.lan (2-237-3-18.ip236.fastwebnet.it. [2.237.3.18]) by smtp.gmail.com with ESMTPSA id he3sm35796779wjc.48.2015.11.16.10.33.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Nov 2015 10:33:10 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, matt.fleming@intel.com, linux@arm.linux.org.uk, will.deacon@arm.com, grant.likely@linaro.org, catalin.marinas@arm.com, mark.rutland@arm.com, leif.lindholm@linaro.org, roy.franz@linaro.org Subject: [PATCH v2 11/12] ARM: wire up UEFI init and runtime support Date: Mon, 16 Nov 2015 19:32:36 +0100 Message-Id: <1447698757-8762-12-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447698757-8762-1-git-send-email-ard.biesheuvel@linaro.org> References: <1447698757-8762-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151116_103333_245267_C45C2C57 X-CRM114-Status: GOOD ( 20.37 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22b listed in] [list.dnswl.org] -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: linux-mm@kvack.org, ryan.harkin@linaro.org, Ard Biesheuvel , akpm@linux-foundation.org, msalter@redhat.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org This adds support to the kernel proper for booting via UEFI. It shares most of the code with arm64, so this patch mostly just wires it up for use with ARM. Note that this does not include the EFI stub, it is added in a subsequent patch. Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/efi.h | 67 ++++++++++++++++++++ arch/arm/kernel/Makefile | 1 + arch/arm/kernel/efi.c | 38 +++++++++++ arch/arm/kernel/setup.c | 3 + drivers/firmware/efi/Makefile | 1 + 5 files changed, 110 insertions(+) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h new file mode 100644 index 000000000000..96cac28a6a24 --- /dev/null +++ b/arch/arm/include/asm/efi.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2015 Linaro Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ASM_ARM_EFI_H +#define __ASM_ARM_EFI_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_EFI +void efi_init(void); + +int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md); + +#define efi_call_virt(f, ...) \ +({ \ + efi_##f##_t *__f; \ + efi_status_t __s; \ + \ + efi_virtmap_load(); \ + __f = efi.systab->runtime->f; \ + __s = __f(__VA_ARGS__); \ + efi_virtmap_unload(); \ + __s; \ +}) + +#define __efi_call_virt(f, ...) \ +({ \ + efi_##f##_t *__f; \ + \ + efi_virtmap_load(); \ + __f = efi.systab->runtime->f; \ + __f(__VA_ARGS__); \ + efi_virtmap_unload(); \ +}) + +static inline void efi_set_pgd(struct mm_struct *mm) +{ + if (unlikely(mm->context.vmalloc_seq != init_mm.context.vmalloc_seq)) + __check_vmalloc_seq(mm); + + cpu_switch_mm(mm->pgd, mm); + + flush_tlb_all(); + if (icache_is_vivt_asid_tagged()) + __flush_icache_all(); +} + +void efi_virtmap_load(void); +void efi_virtmap_unload(void); + +#else +#define efi_init() +#endif /* CONFIG_EFI */ + +#endif /* _ASM_ARM_EFI_H */ diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index af9e59bf3831..c90f4a70d646 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -77,6 +77,7 @@ CFLAGS_pj4-cp0.o := -marm AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt obj-$(CONFIG_ARM_CPU_TOPOLOGY) += topology.o obj-$(CONFIG_VDSO) += vdso.o +obj-$(CONFIG_EFI) += efi.o ifneq ($(CONFIG_ARCH_EBSA110),y) obj-y += io.o diff --git a/arch/arm/kernel/efi.c b/arch/arm/kernel/efi.c new file mode 100644 index 000000000000..743806dfdacc --- /dev/null +++ b/arch/arm/kernel/efi.c @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2015 Linaro Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include + +int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md) +{ + struct map_desc desc = { + .virtual = md->virt_addr, + .pfn = __phys_to_pfn(md->phys_addr), + .length = md->num_pages * EFI_PAGE_SIZE, + }; + + /* + * Order is important here: memory regions may have all of the + * bits below set (and usually do), so we check them in order of + * preference. + */ + if (md->attribute & EFI_MEMORY_WB) + desc.type = MT_MEMORY_RWX; + else if (md->attribute & EFI_MEMORY_WT) + desc.type = MT_MEMORY_RWX_NONCACHED; + else if (md->attribute & EFI_MEMORY_WC) + desc.type = MT_DEVICE_WC; + else + desc.type = MT_DEVICE; + + create_mapping_late(mm, &desc); + return 0; +} diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 5df2bca57c42..b341b1c3b2fa 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -7,6 +7,7 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ +#include #include #include #include @@ -37,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -966,6 +968,7 @@ void __init setup_arch(char **cmdline_p) early_paging_init(mdesc); #endif setup_dma_zone(mdesc); + efi_init(); sanity_check_meminfo(); arm_memblock_init(mdesc); diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile index f292917b00e7..62e654f255f4 100644 --- a/drivers/firmware/efi/Makefile +++ b/drivers/firmware/efi/Makefile @@ -20,4 +20,5 @@ obj-$(CONFIG_EFI_STUB) += libstub/ obj-$(CONFIG_EFI_FAKE_MEMMAP) += fake_mem.o arm-obj-$(CONFIG_EFI) := arm-init.o arm-runtime.o +obj-$(CONFIG_ARM) += $(arm-obj-y) obj-$(CONFIG_ARM64) += $(arm-obj-y)