From patchwork Thu Mar 24 14:44:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 8661841 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6C6429F36E for ; Thu, 24 Mar 2016 14:51:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 654B6201FE for ; Thu, 24 Mar 2016 14:51:12 +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 48D2A2017D for ; Thu, 24 Mar 2016 14:51:11 +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 1aj6ZB-00047A-EL; Thu, 24 Mar 2016 14:48:53 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aj6ZA-00045o-5a for xen-devel@lists.xen.org; Thu, 24 Mar 2016 14:48:52 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 5E/F0-29237-35EF3F65; Thu, 24 Mar 2016 14:48:51 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-7.tower-21.messagelabs.com!1458830929!5851955!1 X-Originating-IP: [209.85.192.180] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43043 invoked from network); 24 Mar 2016 14:48:50 -0000 Received: from mail-pf0-f180.google.com (HELO mail-pf0-f180.google.com) (209.85.192.180) by server-7.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 24 Mar 2016 14:48:50 -0000 Received: by mail-pf0-f180.google.com with SMTP id x3so59471249pfb.1 for ; Thu, 24 Mar 2016 07:48:50 -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=/BK15UT9Vc6i2grO32NY0pNbF57wW5rAHsSgzVpaufc=; b=SJxKtGE5kpXr0N0QJrQPnAGjf9/sTcM70kNy6skk/NTdGCYHC8JRPoG4T1/SdF2Pdv cCEwoUImJ3dotMMUIWxkyHqnW7jsPV85ZDL76MTSlxVIXYoXpApTG7xQewPVuArEuNPm hRQkq2kKD1R1kSySEMbJY9VZXbIPrAUJ+V9gA= 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=/BK15UT9Vc6i2grO32NY0pNbF57wW5rAHsSgzVpaufc=; b=WMjSOggjh9eJy9RykjXXPu4J+FctDuSRMPmDN06xh9DiF4ITlOtd4qYz7QNyOubDAf /raWRCIv/a0UAz5JZKBO3Gvm1saUQqO/dGhw0gnPrMmlCKSdgKeXaEQPZCZcf7wTq74E fsLVjHvLUBYxpSd3pvnlDue4ij+iY980n2xcVt2g8i2erSrM07gL2fnpsqyw3I8IGdKH qlhMt9G4M+pd4ltihCsP+q5tffEVLCp7wNkRGWHId/9dJOoWirL+h8vJ2mQuLp1eOGPO MvZSZ/q5OMFdjvs4aVhRpMvQvupiO1EuFi8M7Yxm33m0k5lJ3vqDeRi1xV0RSJKtq9eh CTvw== X-Gm-Message-State: AD7BkJKdG+YGV0dRJqgJtiTkQlrbzi2yI7zCa69bnhXDFWIr+Eu+54K7hD0+0Pq3I58hgFyA X-Received: by 10.98.72.218 with SMTP id q87mr13442826pfi.117.1458830929431; Thu, 24 Mar 2016 07:48:49 -0700 (PDT) Received: from localhost.localdomain ([104.238.45.135]) by smtp.gmail.com with ESMTPSA id lq10sm10780673pab.36.2016.03.24.07.48.39 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Mar 2016 07:48:48 -0700 (PDT) From: Shannon Zhao To: linux-arm-kernel@lists.infradead.org, stefano.stabellini@citrix.com, david.vrabel@citrix.com Date: Thu, 24 Mar 2016 22:44:36 +0800 Message-Id: <1458830676-27075-18-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458830676-27075-1-git-send-email-shannon.zhao@linaro.org> References: <1458830676-27075-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, shannon.zhao@linaro.org, zhaoshenglong@huawei.com, xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH v7 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 c43617f..9d52342b 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 2cd37da..1328cb7 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -500,12 +500,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), @@ -513,24 +515,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; @@ -561,12 +584,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; }