From patchwork Mon Nov 10 16:51:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 40518 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C65AC203C0 for ; Mon, 10 Nov 2014 16:52:05 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id l18sf4322622wgh.4 for ; Mon, 10 Nov 2014 08:52:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=b9ugDQ1gusZZWk1kkEhepIvjxg/2swGHNcJQlXL4Qzk=; b=TsNSLpqLP5Svj7s92qdyVzP1X1S9uRBhvKvRxAoLwFcEGWuImPCQdy4v9eWXD0iBso ktAZxCnHBBZ67HzhwftCeYnMQi9fBJE9e/JP3wWLdkmgnjoHa6rauj1Nw1xNfb1quDLj ChJbjCpmIYFnBiYp1xC7kpeTTbu1hWqmOxfAp9F3iwfP3MXsYakZHV47MjhqrXMOHE5u vudeW7EZnVmfp3zN/NaJYEYtUQwWSTozlR/WW/pBpFP0d5/CGM4LBTlvENwhvehQPffy PxagsDqOPgShxg9FNnUx6BZ4QZYhZbFBastQNWAGqxLg7YusR3yyxW0/GHjPwYDN2yu3 6yjg== X-Gm-Message-State: ALoCoQlPCKhZuLZyhtYIsQEE43sVaNSoc9bmWkqUPnc7e6mSlXykxHTa4JqQjZw9CMil6CmHFAbO X-Received: by 10.152.246.40 with SMTP id xt8mr3828417lac.0.1415638320804; Mon, 10 Nov 2014 08:52:00 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.227 with SMTP id e3ls488203laa.69.gmail; Mon, 10 Nov 2014 08:52:00 -0800 (PST) X-Received: by 10.112.63.70 with SMTP id e6mr3470056lbs.93.1415638320664; Mon, 10 Nov 2014 08:52:00 -0800 (PST) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id da2si27838080lad.41.2014.11.10.08.52.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Nov 2014 08:52:00 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id u10so6222298lbd.11 for ; Mon, 10 Nov 2014 08:52:00 -0800 (PST) X-Received: by 10.112.235.196 with SMTP id uo4mr21160708lbc.66.1415638320213; Mon, 10 Nov 2014 08:52:00 -0800 (PST) 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.184.201 with SMTP id ew9csp122802lbc; Mon, 10 Nov 2014 08:51:59 -0800 (PST) X-Received: by 10.66.166.109 with SMTP id zf13mr2995474pab.157.1415638318660; Mon, 10 Nov 2014 08:51:58 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bl11si12324512pdb.125.2014.11.10.08.51.58 for ; Mon, 10 Nov 2014 08:51:58 -0800 (PST) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751807AbaKJQv5 (ORCPT + 4 others); Mon, 10 Nov 2014 11:51:57 -0500 Received: from mail-wi0-f170.google.com ([209.85.212.170]:42887 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750993AbaKJQv4 (ORCPT ); Mon, 10 Nov 2014 11:51:56 -0500 Received: by mail-wi0-f170.google.com with SMTP id r20so10671017wiv.3 for ; Mon, 10 Nov 2014 08:51:55 -0800 (PST) X-Received: by 10.194.171.201 with SMTP id aw9mr45301861wjc.67.1415638313436; Mon, 10 Nov 2014 08:51:53 -0800 (PST) Received: from ards-macbook-pro.local ([83.153.85.71]) by mx.google.com with ESMTPSA id cz3sm23861632wjb.23.2014.11.10.08.51.51 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Nov 2014 08:51:52 -0800 (PST) From: Ard Biesheuvel To: grant.likely@linaro.org, leif.lindholm@linaro.org, geoff.levand@linaro.org, mark.rutland@arm.com, rob.herring@linaro.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel Subject: [PATCH] of/fdt: export fdt blob as /sys/firmware/fdt Date: Mon, 10 Nov 2014 17:51:45 +0100 Message-Id: <1415638305-24463-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.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.217.180 as permitted sender) smtp.mail=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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Create a new /sys entry '/sys/firmware/fdt' to export the FDT blob that was passed to the kernel by the bootloader. This allows userland applications such as kexec to access the raw binary. The fact that this node does not reside under /sys/firmware/device-tree is deliberate: FDT is also used on arm64 UEFI/ACPI systems to communicate just the UEFI and ACPI entry points, but the FDT is never unflattened and used to configure the system. Signed-off-by: Ard Biesheuvel --- Resending with CC LAKML and devicetree@vger.kernel.org added. Apologies for the noise. drivers/of/fdt.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index d1ffca8b34ea..60f9c67dc52a 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -22,6 +22,7 @@ #include #include #include +#include #include /* for COMMAND_LINE_SIZE */ #include @@ -1103,4 +1104,23 @@ static int __init of_flat_dt_debugfs_export_fdt(void) module_init(of_flat_dt_debugfs_export_fdt); #endif +#ifdef CONFIG_SYSFS +static ssize_t of_fdt_raw_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buf, loff_t off, size_t count) +{ + memcpy(buf, initial_boot_params + off, count); + return count; +} + +static int __init of_fdt_raw_init(void) +{ + static struct bin_attribute of_fdt_raw_attr = + __BIN_ATTR(fdt, S_IRUSR, of_fdt_raw_read, NULL, 0); + of_fdt_raw_attr.size = fdt_totalsize(initial_boot_params); + return sysfs_create_bin_file(firmware_kobj, &of_fdt_raw_attr); +} +module_init(of_fdt_raw_init); +#endif + #endif /* CONFIG_OF_EARLY_FLATTREE */