[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <cover.1439220623.git.somlo@cmu.edu>
Date: Mon, 10 Aug 2015 12:31:17 -0400
From: "Gabriel L. Somlo" <somlo@....edu>
To: gregkh@...uxfoundation.org, ralf@...ux-mips.org, zajec5@...il.com,
paul@...an.com, galak@...eaurora.org, linux-api@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: matt.fleming@...el.com, x86@...nel.org, linux-efi@...r.kernel.org,
qemu-devel@...gnu.org, lersek@...hat.com,
jordan.l.justen@...el.com, gleb@...udius-systems.com,
pbonzini@...hat.com, kraxel@...hat.com, eblake@...hat.com,
rjones@...hat.com, kernelnewbies@...nelnewbies.org
Subject: [PATCH 0/3] SysFS driver for QEMU firmware config device (fw_cfg)
From: "Gabriel Somlo" <somlo@....edu>
This patch set makes QEMU fw_cfg blobs available for viewing (read-only)
via SysFS.
Several different architectures supported by QEMU are set up with a
"firmware configuration" (fw_cfg) device, used to pass configuration
"blobs" into the guest by the host running QEMU.
Historically, these config blobs were mostly of interest to the guest
BIOS, but since QEMU v2.4 it is possible to insert arbitrary blobs via
the command line, which makes them potentially interesting to userspace
(e.g. for passing early boot environment variables, etc.).
In addition to cc-ing the people and lists indicated by get-maintainer.pl,
I've added a few extra lists suggested by Matt Fleming on the qemu-devel
list, as well as the qemu-devel list itself.
Also cc-ing kernelnewbies, as this is my very first kenel contribution,
so please go easy on me for whatever silly n00b mistakes I might have still
missed, in spite of trying hard to do all my homework properly... :)
The series consists of three patches:
1/3 - probes for the qemu fw_cfg device in locations known to work on
the supported architectures, in decreasing order of "likelihood".
While it *may* be possible to detect the presence of fw_cfg via
acpi or dtb (on x86 and arm, respectively), there's no way I know
of attempting that on sun4 and ppc/mac, so I've stuck with simply
probing (the fw_cfg_modes[] structure and fw_cfg_io_probe() function)
in fw_cfg.c. I could use some advice on how else that could be
done more elegantly, if needed.
Upon successfully detecting a present fw_cfg device, we set up
/sys/firmware/fw_cfg/by_select entries for each blob available
on the fw_cfg device.
2/3 - export kset_find_obj() (in lib/kobject.c) for use with modules,
which will come in handy in patch #3, below.
3/3 - add a "user friendly" way of listing fw_cfg blobs by name rather
than by unique selector key.
Since fw_cfg blob names are traditionally set up to look like
path names, it would be nice to mirror that fact when displaying
them under /sys/firmware/fw_cfg in a "by_name" subdirectory.
I'm using ksets to reflect subdirectories matching "dirname"
tokens separated by '/' within each fw_cfg blob "filename",
and symlinks into the "by_select" subdirectory for each "basename".
Since the fw_cfg device doesn't enforce that blob names have
well-behaved and non-conflicting names, it is possible (though
unlikely) that there will be blobs named:
"etc/foo/bar"
and
"etc/foo"
where "foo" will try to be both a subdirectory AND a symlink under
/sys/firmware/fw_cfg/by_name/etc/. In such an event, the latter
fw_cfg blob will simply be skipped from having an entry created
under the user-friendly "by_name" subdirectory, remaining listed
only as an entry under the "by_select" subdirectory.
I have tested this on x86_64 and armv7hl+lpae kernels. Builds and installs
OK as both a module and linked directly into the kernel.
TIA for the feedback and advice,
--Gabriel
Gabriel Somlo (3):
firmware: introduce sysfs driver for QEMU's fw_cfg device
kobject: export kset_find_obj() to be used from modules
firmware: fw_cfg: create directory hierarchy for fw_cfg file names
Documentation/ABI/testing/sysfs-firmware-fw_cfg | 211 +++++++++
drivers/firmware/Kconfig | 10 +
drivers/firmware/Makefile | 1 +
drivers/firmware/fw_cfg.c | 542 ++++++++++++++++++++++++
lib/kobject.c | 1 +
5 files changed, 765 insertions(+)
create mode 100644 Documentation/ABI/testing/sysfs-firmware-fw_cfg
create mode 100644 drivers/firmware/fw_cfg.c
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists