From patchwork Tue May 3 18:33:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 9007791 Return-Path: X-Original-To: patchwork-qemu-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 D1FB2BF29F for ; Tue, 3 May 2016 18:34:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2BCCD2034B for ; Tue, 3 May 2016 18:34:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1B5CB2027D for ; Tue, 3 May 2016 18:34:45 +0000 (UTC) Received: from localhost ([::1]:42845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axf9d-0003nv-4E for patchwork-qemu-devel@patchwork.kernel.org; Tue, 03 May 2016 14:34:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axf9P-0003Ze-QY for qemu-devel@nongnu.org; Tue, 03 May 2016 14:34:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axf9E-0004IR-3W for qemu-devel@nongnu.org; Tue, 03 May 2016 14:34:22 -0400 Received: from smtp.andrew.cmu.edu ([128.2.105.203]:60313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axf9D-00045K-VX for qemu-devel@nongnu.org; Tue, 03 May 2016 14:34:16 -0400 Received: from HEDWIG.INI.CMU.EDU (HEDWIG.INI.CMU.EDU [128.2.16.51]) (user=somlo mech=LOGIN (0 bits)) by smtp.andrew.cmu.edu (8.15.2/8.15.1) with ESMTPSA id u43IXmgd026934 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 3 May 2016 14:33:52 -0400 Date: Tue, 3 May 2016 14:33:48 -0400 From: Gabriel Somlo To: linux-kernel@vger.kernel.org Message-ID: <20160503183340.GD18050@HEDWIG.INI.CMU.EDU> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-PMX-Version: 6.3.0.2556906, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2016.5.3.182716 X-SMTP-Spam-Clean: 8% ( MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, FROM_EDU_TLD 0, NO_URI_HTTPS 0, __ANY_URI 0, __CD 0, __CT 0, __CT_TEXT_PLAIN 0, __HAS_FROM 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0) X-SMTP-Spam-Score: 8% X-Scanned-By: MIMEDefang 2.78 on 128.2.105.203 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 128.2.105.203 Subject: [Qemu-devel] [RFC PATCH] firmware: qemu_fw_cfg.c: default to listing user-facing items only X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mst@redhat.com, matt@codeblueprint.co.uk, gregkh@linuxfoundation.org, armbru@redhat.com, luto@amacapital.net, kraxel@redhat.com, pbonzini@redhat.com, lersek@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Per the QEMU fw_cfg documentation, items targeted at guest-side userspace should have names beginning with the string "opt/". This patch limits the default sysfs fw_cfg listing to items named "opt/*". The "opt/" prefix on a fw_cfg item name may be interpreted as being analogous to bit 2 in ACPI's _STA object return value (i.e., "show in UI"). A full listing of all fw_cfg items can still be made available by enabling the 'list_all' module parameter, also introduced by this patch. Suggested-by: Michael S. Tsirkin Signed-off-by: Gabriel Somlo --- Sorry it took me this long to whip together the few lines of code below -- end-of-semester craziness happened, and I'm just beginning to recover... :) I've (somewhat reluctantly) modified the fw-cfg sysfs driver to only show blobs named "opt/*" by default, at Michael's request. Even though my instinct tells me hardcoding "opt/" in the source feels a bit like mixing in policy, the argument that "opt/" is analogous to the ACPI "hide from u/i" bit does make a lot of sense. Personally, I can live with non-"opt/" blobs being hidden by default, particularly since I'm still allowing them to be listed via the "list-all" module parameter. I'm cc-ing everyone I can remember showing any interest in this driver and/or offering help and feedback, for a chance to comment (with apologies if I left out anyone). Absent any further objections, I'm personally OK with defaulting to "opt/"-only blobs being shown to userspace. Thanks again for all the help and feedback, --Gabriel drivers/firmware/qemu_fw_cfg.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c index d999fe3..c580b73 100644 --- a/drivers/firmware/qemu_fw_cfg.c +++ b/drivers/firmware/qemu_fw_cfg.c @@ -37,6 +37,10 @@ MODULE_AUTHOR("Gabriel L. Somlo "); MODULE_DESCRIPTION("QEMU fw_cfg sysfs support"); MODULE_LICENSE("GPL"); +static int modparam_list_all; +module_param_named(list_all, modparam_list_all, int, 0444); +MODULE_PARM_DESC(list_all, "List all fw-cfg items under by_name sysfs folder."); + /* selector key values for "well-known" fw_cfg entries */ #define FW_CFG_SIGNATURE 0x00 #define FW_CFG_ID 0x01 @@ -452,6 +456,10 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f) int err; struct fw_cfg_sysfs_entry *entry; + /* skip listing item if name does not begin with "opt/" */ + if (!modparam_list_all && strncmp(f->name, "opt/", 4)) + return 0; + /* allocate new entry */ entry = kzalloc(sizeof(*entry), GFP_KERNEL); if (!entry)