From patchwork Wed Aug 26 08:06:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 52709 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id E99D622E8B for ; Wed, 26 Aug 2015 08:08:52 +0000 (UTC) Received: by labip2 with SMTP id ip2sf11627336lab.1 for ; Wed, 26 Aug 2015 01:08:51 -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:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=z60QP4Ob4+k8+WdA04+qX17gxcbx6ujECDn1HrQUYqk=; b=D7bxUOfznuHqdgw2SjVkl+ALiyXZEC2NcHtD7PmT0cNka4YbCUIlrk5NlJUIC6f2mh RHlBrBgXkGTbMhUk/KKYifOV1JMxgs6G4G7zR4eRFqJ8+HosIZprnl1qvZPrwEo6ZypM 6shDdWFUgQnNa1USIJuH60F3MGlX1wE6JhbqPNmVao8u1hzKgsn+y+XyzpsWJoahjHA0 O45cIe8tiv1Z1NuCw+BBd0VzevTZZuRMlp8RxRMj8DM4F0lU3+YUOPzbB8/Z0FMHzeys XnFZg08AQTTpat7rhxpa7i+pmp8niMlbX3JEH/fXjXRvtSeKSv0o2hrCoZoOXU94DrXh n6gg== X-Gm-Message-State: ALoCoQkrtYQzA1JrvXcwO4dRsB7y++LaS/PkvkRHYwYjQMg4ZmoVT4Q/GsaHas/q2okJbMd3x7gA X-Received: by 10.180.8.74 with SMTP id p10mr2118227wia.3.1440576531920; Wed, 26 Aug 2015 01:08:51 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.170 with SMTP id x10ls342520lal.61.gmail; Wed, 26 Aug 2015 01:08:51 -0700 (PDT) X-Received: by 10.152.219.172 with SMTP id pp12mr29597908lac.17.1440576531608; Wed, 26 Aug 2015 01:08:51 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id pr5si18180876lbb.140.2015.08.26.01.08.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 01:08:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by labia3 with SMTP id ia3so49661476lab.3 for ; Wed, 26 Aug 2015 01:08:51 -0700 (PDT) X-Received: by 10.152.28.193 with SMTP id d1mr29461110lah.72.1440576531484; Wed, 26 Aug 2015 01:08:51 -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.162.200 with SMTP id yc8csp3739826lbb; Wed, 26 Aug 2015 01:08:50 -0700 (PDT) X-Received: by 10.55.201.220 with SMTP id m89mr51508000qkl.87.1440576529782; Wed, 26 Aug 2015 01:08:49 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 101si37499046qgi.29.2015.08.26.01.08.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 01:08:49 -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; 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 1ZUVk7-00081Y-7i; Wed, 26 Aug 2015 08:07:35 +0000 Received: from mail-wi0-f170.google.com ([209.85.212.170]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUVjg-0007hq-T8 for linux-arm-kernel@lists.infradead.org; Wed, 26 Aug 2015 08:07:10 +0000 Received: by widdq5 with SMTP id dq5so38107244wid.1 for ; Wed, 26 Aug 2015 01:06:47 -0700 (PDT) X-Received: by 10.194.103.130 with SMTP id fw2mr59186961wjb.121.1440576406937; Wed, 26 Aug 2015 01:06:46 -0700 (PDT) Received: from localhost.localdomain (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by smtp.gmail.com with ESMTPSA id gm20sm2569597wjc.17.2015.08.26.01.06.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Aug 2015 01:06:45 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, leif.lindholm@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, msalter@redhat.com Subject: [PATCH v2 3/5] arm64/efi: move EFI init before early FDT processing Date: Wed, 26 Aug 2015 10:06:29 +0200 Message-Id: <1440576391-25725-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440576391-25725-1-git-send-email-ard.biesheuvel@linaro.org> References: <1440576391-25725-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150826_010709_289795_188DF0FE X-CRM114-Status: GOOD ( 22.61 ) 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 [209.85.212.170 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.170 listed in wl.mailspike.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 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: Ard Biesheuvel , haojian.zhuang@linaro.org, Ganapatrao.Kulkarni@caviumnetworks.com, leo.yan@linaro.org 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.215.49 as permitted sender) smtp.mailfrom=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/efi-fdt.c | 74 ++++++++------------ include/linux/efi.h | 3 +- 5 files changed, 40 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 9d4aa18f2a82..0e3dbe2cb752 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) { @@ -205,14 +198,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 fddae2c15ad2..8fdde97c975c 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -298,6 +298,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" @@ -366,7 +369,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/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 85ef051ac6fb..faafa1ad6ea7 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -690,6 +690,7 @@ struct efi_fdt_params { u32 mmap_size; u32 desc_size; u32 desc_ver; + bool verbose; }; typedef struct { @@ -901,7 +902,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 struct kobject *efi_kobj;