From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934082AbcECSeV (ORCPT ); Tue, 3 May 2016 14:34:21 -0400 Received: from SMTP.ANDREW.CMU.EDU ([128.2.105.203]:34903 "EHLO smtp.andrew.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933398AbcECSeU (ORCPT ); Tue, 3 May 2016 14:34:20 -0400 Date: Tue, 3 May 2016 14:33:48 -0400 From: Gabriel Somlo To: linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, mst@redhat.com, lersek@redhat.com, kraxel@redhat.com, matt@codeblueprint.co.uk, luto@amacapital.net, pbonzini@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org Subject: [RFC PATCH] firmware: qemu_fw_cfg.c: default to listing user-facing items only Message-ID: <20160503183340.GD18050@HEDWIG.INI.CMU.EDU> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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% Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 2.4.11