From patchwork Mon May 2 10:45:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Fleming X-Patchwork-Id: 8990911 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 88BD8BF29F for ; Mon, 2 May 2016 10:47:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 916FB201FA for ; Mon, 2 May 2016 10:47:26 +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 966B8200E1 for ; Mon, 2 May 2016 10:47:25 +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 1axBM7-0005mr-Ez; Mon, 02 May 2016 10:45:35 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1axBM6-0005ml-A7 for Xen-devel@lists.xensource.com; Mon, 02 May 2016 10:45:34 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id 1B/E6-15045-DCF27275; Mon, 02 May 2016 10:45:33 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGIsWRWlGSWpSXmKPExsXiVRuko3tWXz3 coLmDxeLelPfsDowe2/t2sQcwRrFm5iXlVySwZpw9com14JpMxeXWbYwNjOfEuxi5OIQEZjBK fLhwnBnEYRE4wCox8WQbK4gjIbCbVaJhxh3GLkZOICdGYt/fF+wQdrXE7wvzmUFsIQFVieuzT zBDjOpnkni54xpTFyMH0CgViYf/nEFq2AR0JX6tP80MEhYR0JKYcFQDpJxZYBarxNLZy8DmCw PF9126CjafV8BcomHfQjaImYeYJY6dnckEkRCUODnzCQuIzQzUcOPfS7BdzALSEsv/cYCYnAI aEg//Z4FUiAqYSdxuXMg4gVF4FpLmWUiaZyE0L2BkXsWoUZxaVJZapGtoopdUlJmeUZKbmJmj a2hgqpebWlycmJ6ak5hUrJecn7uJERjmDECwg/Hsac9DjJIcTEqivJOPqYUL8SXlp1RmJBZnx BeV5qQWH2KU4eBQkuDdqqceLiRYlJqeWpGWmQOMOJi0BAePkgivpBxQmre4IDG3ODMdInWKUZ djy9R7a5mEWPLy81KlxHnngcwQACnKKM2DGwGL/kuMslLCvIxARwnxFKQW5WaWoMq/YhTnYFQ S5t0AMoUnM68EbtMroCOYgI7IXq8KckRJIkJKqoHRvUjxR1X8VfPHlfHBtnw1susdBXd/0jD0 MPnzSm92S8fDmyx7jOYeXfb+6MFTV7dsEeozVvsvwchac5HlgOjmTlEdraMJAX6bF07cwhRsd ifV37nnZ97C0z1FXiuEi28Lmlb3uxoo/Ty1y/Onx4nWZZvtf1b4sIu7yVooJrw78V9+crOC6w klluKMREMt5qLiRAB5Rw6T+QIAAA== X-Env-Sender: matt@console-pimps.org X-Msg-Ref: server-4.tower-206.messagelabs.com!1462185932!37498341!1 X-Originating-IP: [74.125.82.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57582 invoked from network); 2 May 2016 10:45:33 -0000 Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by server-4.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 2 May 2016 10:45:33 -0000 Received: by mail-wm0-f44.google.com with SMTP id g17so135599427wme.1 for ; Mon, 02 May 2016 03:45:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeblueprint-co-uk.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=FMS5nU9DgpLd7NifDV3VGo9gdW34NlvmRXEkG7NVu/M=; b=R+gdd/7RTTovxIXpTUM5f9xhW7KUjRrlcb80Uh23dA59o3lQA4jYM5Ai6FjqqLxTea PRXzaX+PFQOPNcjROUQnuY5PDdl8JOqKN9cyqqYn/FFyW2IuCbKGq4/GGjbJ12EjNZHo EhTH4wLUoZ0RYi45TTWR7yKHnasHBHxBbin14vdjxey1UtwlXHPPkDSDpHBK75cYR5T4 2C27pAnxT647nWbxC3zses1G7wChcnvrU01aJHz1uc6H3jiWg+6mX0rK8dlDSmSoZWsi XEgMbpQwwn9aB9yiw5LVtCrI0PIz3F9oguAMbh3KJkji/+JIkOSREIgAPsWpvuhxQBwz xRBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=FMS5nU9DgpLd7NifDV3VGo9gdW34NlvmRXEkG7NVu/M=; b=cc+yrkR8umaI+nhGvoxLwls97JZHNEdxnqjJuy6a5Mh0KQ42C9/dfzQg15p5taR13S 185S7sQsFNz5mWk/59EeeWlzPn6hxYHVxoFMBMSyye7e6GriLfz9mOXBAX4ZtDny0uY/ EBVt2H1iWPG/lJIrih12eMcLgRn/UBdvfkimX5NvQ7IzhxCupYG5QpV8s1LIRjKeDUSG UJNBBBqcApcqXGKzUHcXwejvO+IpaT9omaTxZV3xcw0VWE+/D6ZO2DUKcD/o692YE27B X23GEZT+bu2uWMM0Lx8RcgMXCXXKBCyfnm47M9OY4gPQgQhFYOsA1fxQq51cuGqaTuqV Fyeg== X-Gm-Message-State: AOPr4FXcF7CiO+bhDPWnPDOMAJ/Gcackwt8DnSX3PE9fIrVX5vTpnCIfPj7Uv4XywOKbeg== X-Received: by 10.28.152.212 with SMTP id a203mr18409742wme.95.1462185932674; Mon, 02 May 2016 03:45:32 -0700 (PDT) Received: from localhost (bcdc58e5.skybroadband.com. [188.220.88.229]) by smtp.gmail.com with ESMTPSA id w82sm18135996wmw.5.2016.05.02.03.45.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 May 2016 03:45:31 -0700 (PDT) Date: Mon, 2 May 2016 11:45:30 +0100 From: Matt Fleming To: Shannon Zhao Message-ID: <20160502104530.GV2839@codeblueprint.co.uk> References: <20160429142020.4499e185@canb.auug.org.au> <20160429063936.GA28320@gmail.com> <20160429143931.GG2839@codeblueprint.co.uk> <5724BDD2.5020600@linaro.org> <20160430204420.GM2839@codeblueprint.co.uk> <572576E2.7060508@linaro.org> <20160501132620.GT2839@codeblueprint.co.uk> <57261483.10500@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <57261483.10500@linaro.org> User-Agent: Mutt/1.5.24+41 (02bc14ed1569) (2015-08-30) Cc: Stephen Rothwell , Jeremy Fitzhardinge , Stefano Stabellini , Ard Biesheuvel , Peter Zijlstra , "linux-kernel@vger.kernel.org" , "Luis R. Rodriguez" , Xen Devel , Borislav Petkov , linux-next@vger.kernel.org, Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , Stefano Stabellini Subject: Re: [Xen-devel] efi_enabled(EFI_PARAVIRT) use 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.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 On Sun, 01 May, at 10:36:51PM, Shannon Zhao wrote: > So is there any other way you suggest? Would this work (compile tested but not runtime tested)? diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 3a69ed5ecfcb..13d8be16447a 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 __initdata struct params fdt_params[] = { 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,44 +484,83 @@ static __initdata struct { UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver) }; +static __initdata struct params xen_fdt_params[] = { + 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) +}; + +#define EFI_FDT_PARAMS_SIZE ARRAY_SIZE(fdt_params) + +static __initdata struct { + const char *uname; + struct params *params; +} dt_params[] = { + { "hypervisor", xen_fdt_params }, + { "chosen", fdt_params }, +}; + struct param_info { int found; void *params; + const char *missing; }; -static int __init fdt_find_uefi_params(unsigned long node, const char *uname, - int depth, void *data) +static int __init __find_uefi_params(unsigned long node, + struct param_info *info, + struct params *params) { - struct param_info *info = data; const void *prop; void *dest; u64 val; int i, len; - if (depth != 1 || strcmp(uname, "chosen") != 0) - return 0; - - for (i = 0; i < ARRAY_SIZE(dt_params); i++) { - prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len); - if (!prop) + for (i = 0; i < EFI_FDT_PARAMS_SIZE; i++) { + prop = of_get_flat_dt_prop(node, params[i].propname, &len); + if (!prop) { + info->missing = params[i].name; return 0; - dest = info->params + dt_params[i].offset; + } + + dest = info->params + params[i].offset; info->found++; val = of_read_number(prop, len / sizeof(u32)); - if (dt_params[i].size == sizeof(u32)) + if (params[i].size == sizeof(u32)) *(u32 *)dest = val; else *(u64 *)dest = val; if (efi_enabled(EFI_DBG)) - pr_info(" %s: 0x%0*llx\n", dt_params[i].name, - dt_params[i].size * 2, val); + pr_info(" %s: 0x%0*llx\n", params[i].name, + params[i].size * 2, val); } + return 1; } +static int __init fdt_find_uefi_params(unsigned long node, const char *uname, + int depth, void *data) +{ + struct param_info *info = data; + int i; + + for (i = 0; i < ARRAY_SIZE(dt_params); i++) { + + if (depth != 1 || strcmp(uname, dt_params[i].uname) != 0) { + info->missing = dt_params[i].params[0].name; + continue; + } + + return __find_uefi_params(node, info, dt_params[i].params); + } + + return 0; +} + int __init efi_get_fdt_params(struct efi_fdt_params *params) { struct param_info info; @@ -535,7 +576,7 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params) 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.missing); return ret; }