From patchwork Thu Apr 7 12:03:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 8772201 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 7B4989F39A for ; Thu, 7 Apr 2016 12:17:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B5FA2020F for ; Thu, 7 Apr 2016 12:17:10 +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 6264D201ED for ; Thu, 7 Apr 2016 12:17:09 +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 1ao8q5-0005WS-Qu; Thu, 07 Apr 2016 12:15:09 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ao8q5-0005WL-F2 for xen-devel@lists.xen.org; Thu, 07 Apr 2016 12:15:09 +0000 Received: from [193.109.254.147] by server-5.bemta-14.messagelabs.com id F1/4C-03497-C4F46075; Thu, 07 Apr 2016 12:15:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVSPpHPSdfHny3 cYN43LoslHxezODB6HN39mymAMYo1My8pvyKBNePnLv+CUxoVd3bvYm9gnK/UxcjFISRwhlHi 475H7BDObkaJhtl7mLoYOTnYBHQlPm6cApTg4BARcJE49tkLpIZZ4D6TxKd7zewgNcICfhKrz ixmBbFZBFQkWnv3soDYvAKeErMf7GIDsSUENCRW9k4Ai3MCxdvaJ4LVCwl4SOxomccEUS8ocX LmE7AaZgEJiYMvXjBD9CpKtK0/CTVHUuLgihssIEdICJxilFjZfIsRImEq8frOG+YJjIKzkMy ahWTWAkamVYwaxalFZalFuoZmeklFmekZJbmJmTm6hoYmermpxcWJ6ak5iUnFesn5uZsYgQFa z8DAuIPx62nPQ4ySHExKorzTXdnChfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwPvEDygkWpaanV qRl5gBjBSYtwcGjJMKrBpLmLS5IzC3OTIdInWJUlBLnXQOSEABJZJTmwbXB4vMSo6yUMC8jAw ODEE9BalFuZgmq/CtGcQ5GJWHe1SBTeDLzSuCmvwJazAS0+AI/2OKSRISUVANjUp/PVo45zZI uRq3RPK92L7rG/btfjOfrO6nbeY83X3AymrL5R/jb/7dWp2Z/OKPHN/fn6/K5278/slJ+f//y LaFpvR035X5+ZjGtMMhKiuN/VNd+1KtiyxH+23EVq2e9K5ct79JyPqsa9db7zbKX3YZPzDZcc XoUXd9h1TuhbJnT8pyujyU/lViKMxINtZiLihMBb33ZCMoCAAA= X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1460031303!36151238!1 X-Originating-IP: [119.145.14.66] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NiA9PiA4NTI3\n X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54658 invoked from network); 7 Apr 2016 12:15:07 -0000 Received: from unknown (HELO szxga03-in.huawei.com) (119.145.14.66) by server-16.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 7 Apr 2016 12:15:07 -0000 Received: from 172.24.1.137 (EHLO SZXEML424-HUB.china.huawei.com) ([172.24.1.137]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BZL25459; Thu, 07 Apr 2016 20:04:29 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by SZXEML424-HUB.china.huawei.com (10.82.67.153) with Microsoft SMTP Server id 14.3.235.1; Thu, 7 Apr 2016 20:04:21 +0800 From: Shannon Zhao To: , Date: Thu, 7 Apr 2016 20:03:34 +0800 Message-ID: <1460030614-16112-18-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1460030614-16112-1-git-send-email-zhaoshenglong@huawei.com> References: <1460030614-16112-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090205.57064CD1.00BE, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 1a2650c3309d40c8f0e76fdad7639570 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, xen-devel@lists.xen.org, julien.grall@arm.com, david.vrabel@citrix.com, peter.huangpeng@huawei.com, shannon.zhao@linaro.org Subject: [Xen-devel] [PATCH v11 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 From: Shannon Zhao 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; }