From patchwork Fri Apr 1 15:49:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 8726251 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7877DC0553 for ; Fri, 1 Apr 2016 15:54:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 696B8203E3 for ; Fri, 1 Apr 2016 15:54:24 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 61A90203AB for ; Fri, 1 Apr 2016 15:54:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1am1Ml-0005lE-OT; Fri, 01 Apr 2016 15:52:07 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1am1Mj-0005jV-ME for xen-devel@lists.xen.org; Fri, 01 Apr 2016 15:52:05 +0000 Received: from [193.109.254.147] by server-4.bemta-14.messagelabs.com id 6C/1B-03301-5299EF65; Fri, 01 Apr 2016 15:52:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMfSOvq7KzH9 hBt97pC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oz+rbuZCmZrVEzYX9zA+E2xi5GLQ0hgIqPE 5l/TWEAcFoF5zBKXlz1m7GLk5JAQ6GeVWPw0AcKOkfh0bgYbhF0pcfPiaVYQW0hATWLZ4YXME JOeMEp0fdnNBJJgE9CReDFpJ1ADB4eIgIfEno+1IDXMAheYJH71vmQGqREW8JNY++MRmM0ioC px58BdsF5eoPqDG9pYIJbJSZw//hOshhMoPvnfKxaIxe4SD2fNYp/AKLCAkWEVo0ZxalFZapG uoYleUlFmekZJbmJmjq4hkJubWlycmJ6ak5hUrJecn7uJERhY9QwMjDsYv5/2PMQoycGkJMpr OO1fmBBfUn5KZUZicUZ8UWlOavEhRhkODiUJ3qLpQDnBotT01Iq0zBxgiMOkJTh4lER4a0HSv MUFibnFmekQqVOMxhxbfl9by8Sxbeq9tUxCLHn5ealS4ryhIKUCIKUZpXlwg2Cxd4lRVkqYl5 GBgUGIpyC1KDezBFX+FaM4B6OSMMQ9PJl5JXD7XgGdwgR0Soc02CkliQgpqQbGpX/efXtWIJP 39Om1D0+ceyZyyaafuy+dVVpQ7fdlsWFYwcY3G7ed/rxdWPHQ8Z3KC79tujA/qaKvaeeFY9eU fzywK48LjXqkntrTp6tf3lyoM807YPmddz5X3JpE7+1/6rLO7vevlYVlE7rU83KED7/+2dtue UE29Nbla29ecJvu2ur0bksksxJLcUaioRZzUXEiAJVw2EW4AgAA X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-12.tower-27.messagelabs.com!1459525922!35017947!1 X-Originating-IP: [209.85.220.47] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9787 invoked from network); 1 Apr 2016 15:52:03 -0000 Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by server-12.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Apr 2016 15:52:03 -0000 Received: by mail-pa0-f47.google.com with SMTP id fe3so93936291pab.1 for ; Fri, 01 Apr 2016 08:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ai80uLZHDabiUmG0VyvXc9xd+Itf+X3w2KzVC9SPWFc=; b=WrltOitMdkhy9gBoN8uJlt/AQnSn8DQttDu4BIXtwuYKrtHnMWJUXbZrLmmr97wmC3 wn2P4tEgDxCpN/dR9pztwBOWFBmt4WjCrxggARCMvqR75zRcCYdfaIeEydm2TOeKafbY 6QQNkDGM2AceQ76U+0scUocr9JGUQQmFn5ySI= 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=ai80uLZHDabiUmG0VyvXc9xd+Itf+X3w2KzVC9SPWFc=; b=J/lGYhkec/1NjMZ0WBUpRrpIdHRrxQ2BI7zhpq7BL3DjAImxVp92xvMLsV/jDqr23H yYj362wH8X1UW+VIk0H+f7X5UWwLFC0YUgHOqvBoGX62+qev1BYslFFGU8nL0tYiV0Fn 1m/zNwO/fLwHQE0t8D80GX5dxpjvmNoibsSWADTn/r5jGAuE79xdXwniNLFeJlHIM44s 7g9GYnwF3lmgA4CvYjBQV2sUV1TdDasBZM/d0EHzSodbDhuk2Y9dxTvcw3cORUyhqfO5 LurfwCSrPZHcPzekO5lM1ePj3bUrDpTNrcSLEXxbmln6i595hDcIC/M+rIA63OCaClIY q5ww== X-Gm-Message-State: AD7BkJJm4T7HnsTVQx5sTiNfci19iA/OLfFi7wDiJSFiBdeG0ZeFdxbwHJi5rrw7EU/cPseB X-Received: by 10.66.193.161 with SMTP id hp1mr32196228pac.9.1459525922431; Fri, 01 Apr 2016 08:52:02 -0700 (PDT) Received: from localhost.localdomain ([167.160.116.218]) by smtp.gmail.com with ESMTPSA id yj1sm22536791pac.16.2016.04.01.08.51.53 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 01 Apr 2016 08:52:00 -0700 (PDT) From: Shannon Zhao To: linux-arm-kernel@lists.infradead.org, stefano.stabellini@citrix.com Date: Fri, 1 Apr 2016 23:49:15 +0800 Message-Id: <1459525755-36968-18-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1459525755-36968-1-git-send-email-shannon.zhao@linaro.org> References: <1459525755-36968-1-git-send-email-shannon.zhao@linaro.org> Cc: devicetree@vger.kernel.org, linux-efi@vger.kernel.org, Matt Fleming , catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, peter.huangpeng@huawei.com, julien.grall@arm.com, david.vrabel@citrix.com, zhaoshenglong@huawei.com, xen-devel@lists.xen.org, shannon.zhao@linaro.org Subject: [Xen-devel] [PATCH v10 17/17] Xen: EFI: Parse DT parameters for Xen specific UEFI X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a new function to parse DT parameters for Xen specific UEFI just like the way for normal UEFI. Then it could reuse the existing codes. If Xen supports EFI, initialize runtime services. CC: Matt Fleming Signed-off-by: Shannon Zhao Reviewed-by: Matt Fleming Reviewed-by: Stefano Stabellini --- arch/arm/xen/enlighten.c | 6 +++++ drivers/firmware/efi/arm-runtime.c | 17 +++++++++----- drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++------ 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 13e3e9f..e130562 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -261,6 +261,12 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname, !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix))) hyper_node.version = s + strlen(hyper_node.prefix); + if (IS_ENABLED(CONFIG_XEN_EFI)) { + /* Check if Xen supports EFI */ + if (of_get_flat_dt_subnode_by_name(node, "uefi") > 0) + set_bit(EFI_PARAVIRT, &efi.flags); + } + return 0; } diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 6ae21e4..ac609b9 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -27,6 +27,7 @@ #include #include #include +#include extern u64 efi_system_table; @@ -107,13 +108,19 @@ static int __init arm_enable_runtime_services(void) } set_bit(EFI_SYSTEM_TABLES, &efi.flags); - if (!efi_virtmap_init()) { - pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n"); - return -ENOMEM; + if (IS_ENABLED(CONFIG_XEN_EFI) && efi_enabled(EFI_PARAVIRT)) { + /* Set up runtime services function pointers for Xen Dom0 */ + xen_efi_runtime_setup(); + } else { + if (!efi_virtmap_init()) { + pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n"); + return -ENOMEM; + } + + /* Set up runtime services function pointers */ + efi_native_runtime_setup(); } - /* Set up runtime services function pointers */ - efi_native_runtime_setup(); set_bit(EFI_RUNTIME_SERVICES, &efi.flags); efi.runtime_version = efi.systab->hdr.revision; diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 3a69ed5..519c096 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -469,12 +469,14 @@ device_initcall(efi_load_efivars); FIELD_SIZEOF(struct efi_fdt_params, field) \ } -static __initdata struct { +struct params { const char name[32]; const char propname[32]; int offset; int size; -} dt_params[] = { +}; + +static struct params fdt_params[] __initdata = { UEFI_PARAM("System Table", "linux,uefi-system-table", system_table), UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap), UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size), @@ -482,24 +484,45 @@ static __initdata struct { UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver) }; +static struct params xen_fdt_params[] __initdata = { + UEFI_PARAM("System Table", "xen,uefi-system-table", system_table), + UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap), + UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size), + UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size), + UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver) +}; + struct param_info { int found; void *params; + struct params *dt_params; + int size; }; static int __init fdt_find_uefi_params(unsigned long node, const char *uname, int depth, void *data) { struct param_info *info = data; + struct params *dt_params = info->dt_params; const void *prop; void *dest; u64 val; - int i, len; + int i, len, offset; - if (depth != 1 || strcmp(uname, "chosen") != 0) - return 0; + if (efi_enabled(EFI_PARAVIRT)) { + if (depth != 1 || strcmp(uname, "hypervisor") != 0) + return 0; - for (i = 0; i < ARRAY_SIZE(dt_params); i++) { + offset = of_get_flat_dt_subnode_by_name(node, "uefi"); + if (offset < 0) + return 0; + node = offset; + } else { + if (depth != 1 || strcmp(uname, "chosen") != 0) + return 0; + } + + for (i = 0; i < info->size; i++) { prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len); if (!prop) return 0; @@ -530,12 +553,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params) info.found = 0; info.params = params; + if (efi_enabled(EFI_PARAVIRT)) { + info.dt_params = xen_fdt_params; + info.size = ARRAY_SIZE(xen_fdt_params); + } else { + info.dt_params = fdt_params; + info.size = ARRAY_SIZE(fdt_params); + } + ret = of_scan_flat_dt(fdt_find_uefi_params, &info); if (!info.found) pr_info("UEFI not found.\n"); else if (!ret) pr_err("Can't find '%s' in device tree!\n", - dt_params[info.found].name); + info.dt_params[info.found].name); return ret; }