From patchwork Mon May 11 06:41:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 48204 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EF2EB2121F for ; Mon, 11 May 2015 06:47:03 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf36102060lbc.1 for ; Sun, 10 May 2015 23:47:03 -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 :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=ZLNOhj1t1EF02E4eWJlBrxcu2/cnsMFY6JQMlyUbzdc=; b=ZqAzSBhHUFsCsSBehC5T++lLCaAd3IJ61W5+wr7fnBhcMRqVcx1MF5Edm764P6aENO mJdvun80qFObIbG8nxtDwFG90PjWq8S05q0PcKhYJdqwFtTU/Mp7FTHWJLSKMKpBRjQL UuWD+rETpNz4fgiIuAUNwMNTEUwQdJsRM+D4eqCwcISCfO2eQAlPadIvFlphb6i75pRr VADKrbxcz+sfjwHOUhr0Xrj/9FidP8QLUfVlXkt5hf4Y4f3MIq74ikEATZP0tc/LLMtJ 3GsiQ2k3ZijxHnxZvn+YekWGcK2jNokLFcqcTgwnxMavy3R63RuPecKimhYowM/i/951 oXag== X-Gm-Message-State: ALoCoQkSwg8B7YJLMmLgxN7/H57MFxhGhwTd0gUFw8q52WOwjEOjYxHhBQdr8nQUDI2d7+k4rdWD X-Received: by 10.112.42.236 with SMTP id r12mr6554010lbl.2.1431326823000; Sun, 10 May 2015 23:47:03 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.184.8 with SMTP id eq8ls662859lac.91.gmail; Sun, 10 May 2015 23:47:02 -0700 (PDT) X-Received: by 10.152.206.75 with SMTP id lm11mr6849275lac.41.1431326822855; Sun, 10 May 2015 23:47:02 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id lu5si7840803lac.6.2015.05.10.23.47.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 May 2015 23:47:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbbzk7 with SMTP id zk7so87189709lbb.0 for ; Sun, 10 May 2015 23:47:02 -0700 (PDT) X-Received: by 10.112.204.104 with SMTP id kx8mr6861157lbc.72.1431326822707; Sun, 10 May 2015 23:47:02 -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.108.230 with SMTP id hn6csp1335339lbb; Sun, 10 May 2015 23:47:01 -0700 (PDT) X-Received: by 10.70.88.170 with SMTP id bh10mr16859711pdb.62.1431326820564; Sun, 10 May 2015 23:47:00 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id w4si16767969pdj.155.2015.05.10.23.46.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 May 2015 23:47:00 -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 1YrhRS-0007n3-30; Mon, 11 May 2015 06:43:54 +0000 Received: from mail-wg0-f51.google.com ([74.125.82.51]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YrhQG-0007F0-3L for linux-arm-kernel@lists.infradead.org; Mon, 11 May 2015 06:42:41 +0000 Received: by wgbhc8 with SMTP id hc8so18121036wgb.2 for ; Sun, 10 May 2015 23:42:18 -0700 (PDT) X-Received: by 10.180.86.234 with SMTP id s10mr16333687wiz.50.1431326537919; Sun, 10 May 2015 23:42:17 -0700 (PDT) Received: from localhost.localdomain (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id wr2sm21173009wjb.45.2015.05.10.23.42.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 10 May 2015 23:42:17 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, grant.likely@linaro.org, leif.lindholm@linaro.org, roy.franz@linaro.org, catalin.marinas@arm.com, mark.rutland@arm.com, matt.fleming@intel.com Subject: [PATCH 5/8] arm64/efi: move EFI init before early FDT processing Date: Mon, 11 May 2015 08:41:57 +0200 Message-Id: <1431326520-17331-6-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431326520-17331-1-git-send-email-ard.biesheuvel@linaro.org> References: <1431326520-17331-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150510_234240_481001_77CFDE8B X-CRM114-Status: GOOD ( 22.10 ) 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.51 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.51 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ganapatrao.Kulkarni@caviumnetworks.com, 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.173 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 The early FDT processing is responsible for enumerating the DT memory nodes and installing them as memblocks. This should only be done if we are not booting via EFI, but at this point, we don't know yet if that is the case or not. So move the EFI init to before the early FDT processing. This involves making some changes to the way EFI discovers the locations of the EFI system table and the memory map, since those values are retrieved from the FDT as well. Instead the of_scan infrastructure, it now uses libfdt directly to access the /chosen node. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/efi.h | 4 +-- arch/arm64/kernel/efi.c | 14 +++----- arch/arm64/kernel/setup.c | 4 ++- drivers/firmware/efi/Makefile | 1 + drivers/firmware/efi/efi-fdt.c | 74 +++++++++++++++++------------------------- include/linux/efi.h | 3 +- 6 files changed, 41 insertions(+), 59 deletions(-) diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h index ef572206f1c3..635101f36720 100644 --- a/arch/arm64/include/asm/efi.h +++ b/arch/arm64/include/asm/efi.h @@ -5,9 +5,9 @@ #include #ifdef CONFIG_EFI -extern void efi_init(void); +extern void efi_init_fdt(void *fdt); #else -#define efi_init() +#define efi_init_fdt(x) #endif #define efi_call_virt(f, ...) \ diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index ab21e0d58278..5369b4f96dd1 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -51,14 +51,7 @@ static struct mm_struct efi_mm = { INIT_MM_CONTEXT(efi_mm) }; -static int uefi_debug __initdata; -static int __init uefi_debug_setup(char *str) -{ - uefi_debug = 1; - - return 0; -} -early_param("uefi_debug", uefi_debug_setup); +static bool uefi_debug __initdata; static int __init is_normal_ram(efi_memory_desc_t *md) { @@ -204,14 +197,15 @@ static __init void reserve_regions(void) set_bit(EFI_MEMMAP, &efi.flags); } -void __init efi_init(void) +void __init efi_init_fdt(void *fdt) { struct efi_fdt_params params; /* Grab UEFI information placed in FDT by stub */ - if (!efi_get_fdt_params(¶ms, uefi_debug)) + if (!efi_get_fdt_params(fdt, ¶ms)) return; + uefi_debug = params.verbose; efi_system_table = params.system_table; memblock_reserve(params.mmap & PAGE_MASK, diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 770ae9dc5a75..36ffd0a21a78 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -316,6 +316,9 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys) { void *dt_virt = fixmap_remap_fdt(dt_phys); + if (dt_virt) + efi_init_fdt(dt_virt); + if (!dt_virt || !early_init_dt_scan(dt_virt)) { pr_crit("\n" "Error: invalid device tree blob at physical address %pa (virtual address 0x%p)\n" @@ -384,7 +387,6 @@ void __init setup_arch(char **cmdline_p) */ local_async_enable(); - efi_init(); arm64_memblock_init(); /* Parse the ACPI tables for possible boot-time configuration */ diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile index 9967dde52174..7b408a4cfc8a 100644 --- a/drivers/firmware/efi/Makefile +++ b/drivers/firmware/efi/Makefile @@ -9,3 +9,4 @@ obj-$(CONFIG_EFI_RUNTIME_MAP) += runtime-map.o obj-$(CONFIG_EFI_RUNTIME_WRAPPERS) += runtime-wrappers.o obj-$(CONFIG_EFI_STUB) += libstub/ obj-$(CONFIG_EFI_PARAMS_FROM_FDT) += efi-fdt.o +CFLAGS_efi-fdt.o := -I$(srctree)/scripts/dtc/libfdt/ diff --git a/drivers/firmware/efi/efi-fdt.c b/drivers/firmware/efi/efi-fdt.c index f0e7ef2ae0e9..2e0e1a5a3fbb 100644 --- a/drivers/firmware/efi/efi-fdt.c +++ b/drivers/firmware/efi/efi-fdt.c @@ -8,8 +8,7 @@ #include #include -#include -#include +#include #define UEFI_PARAM(name, prop, field) \ { \ @@ -32,62 +31,47 @@ static __initdata struct { UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver) }; -struct param_info { - int verbose; - int found; - void *params; -}; - -static int __init fdt_find_uefi_params(unsigned long node, const char *uname, - int depth, void *data) +bool __init efi_get_fdt_params(void *fdt, struct efi_fdt_params *params) { - struct param_info *info = data; const void *prop; - void *dest; - u64 val; - int i, len; + int node, i; + + pr_info("Getting EFI parameters from FDT:\n"); - if (depth != 1 || strcmp(uname, "chosen") != 0) - return 0; + node = fdt_path_offset(fdt, "/chosen"); + if (node < 0) { + pr_err("/chosen node not found!\n"); + return false; + } + + prop = fdt_getprop(fdt, node, "bootargs", NULL); + params->verbose = prop && strstr(prop, "uefi_debug"); for (i = 0; i < ARRAY_SIZE(dt_params); i++) { - prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len); - if (!prop) - return 0; - dest = info->params + dt_params[i].offset; - info->found++; + void *dest; + int len; + u64 val; - val = of_read_number(prop, len / sizeof(u32)); + prop = fdt_getprop(fdt, node, dt_params[i].propname, &len); + if (!prop) + goto not_found; + dest = (void *)params + dt_params[i].offset; if (dt_params[i].size == sizeof(u32)) - *(u32 *)dest = val; + val = *(u32 *)dest = be32_to_cpup(prop); else - *(u64 *)dest = val; + val = *(u64 *)dest = be64_to_cpup(prop); - if (info->verbose) + if (params->verbose) pr_info(" %s: 0x%0*llx\n", dt_params[i].name, dt_params[i].size * 2, val); } - return 1; -} - -int __init efi_get_fdt_params(struct efi_fdt_params *params, int verbose) -{ - struct param_info info; - int ret; + return true; - pr_info("Getting EFI parameters from FDT:\n"); - - info.verbose = verbose; - info.found = 0; - info.params = params; - - ret = of_scan_flat_dt(fdt_find_uefi_params, &info); - if (!info.found) +not_found: + if (i == 0) pr_info("UEFI not found.\n"); - else if (!ret) - pr_err("Can't find '%s' in device tree!\n", - dt_params[info.found].name); - - return ret; + else + pr_err("Can't find '%s' in device tree!\n", dt_params[i].name); + return false; } diff --git a/include/linux/efi.h b/include/linux/efi.h index af5be0368dec..c2be93d6156c 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -684,6 +684,7 @@ struct efi_fdt_params { u32 mmap_size; u32 desc_size; u32 desc_ver; + bool verbose; }; typedef struct { @@ -886,7 +887,7 @@ extern void efi_initialize_iomem_resources(struct resource *code_resource, struct resource *data_resource, struct resource *bss_resource); extern void efi_get_time(struct timespec *now); extern void efi_reserve_boot_services(void); -extern int efi_get_fdt_params(struct efi_fdt_params *params, int verbose); +extern bool efi_get_fdt_params(void *fdt, struct efi_fdt_params *params); extern struct efi_memory_map memmap; extern int efi_reboot_quirk_mode;