From: "Gabriel L. Somlo" <somlo@cmu.edu>
To: gregkh@linuxfoundation.org, paul@pwsan.com, galak@codeaurora.org,
will.deacon@arm.com, agross@codeaurora.org, mark.rutland@arm.com,
zajec5@gmail.com, hanjun.guo@linaro.org, catalin.marinas@arm.com,
linux-api@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: peter.maydell@linaro.org, matt.fleming@intel.com, mst@redhat.com,
jordan.l.justen@intel.com, kernelnewbies@kernelnewbies.org,
qemu-devel@nongnu.org, leif.lindholm@linaro.org,
ard.biesheuvel@linaro.org, kraxel@redhat.com,
pbonzini@redhat.com, lersek@redhat.com
Subject: [PATCH v3 0/4] SysFS driver for QEMU fw_cfg device
Date: Sat, 3 Oct 2015 19:28:05 -0400 [thread overview]
Message-ID: <1443914889-9619-1-git-send-email-somlo@cmu.edu> (raw)
From: "Gabriel Somlo" <somlo@cmu.edu>
Allow access to QEMU firmware blobs, passed into the guest VM via
the fw_cfg device, through SysFS entries. Blob meta-data (e.g. name,
size, and fw_cfg key), as well as the raw binary blob data may be
accessed.
The SysFS access location is /sys/firmware/qemu_fw_cfg/... and was
selected based on overall similarity to the type of information
exposed under /sys/firmware/dmi/entries/...
NEW (since v2): Using ACPI to detect the presence and details of the
fw_cfg virtual hardware device.
Device Tree has been suggested by Ard as a comment on v2 of this
patch, but after some deliberation I decided to go with ACPI,
since it's supported on both x86 and some (uefi-enabled) versions
of aarch64. I really don't see how I'd reasonably use *both* DT (on
ARM) *and* ACPI (on x86), and after all I'm mostly concerned with
x86, but originally wanted to maximize portability (which is where
the register probing in earlier versions came from).
A patch set generating an ACPI device node for qemu's fw_cfg is
currently under review on the qemu-devel list:
http://lists.nongnu.org/archive/html/qemu-devel/2015-09/msg06946.html
(sorry, gmane appears down at the moment...)
In consequence:
- Patch 1/4 is mostly the same as in v2;
- Patch 2/4 switches device initialization from register
probing to using ACPI; this is a separate patch only to
illustrate the transition from probing to ACPI, and I'm
assuming it will end up squashed on top of patch 1/4 in
the final version.
- Patches 3/4 and 4/4 add a "human-readable" directory
hierarchy built from tokenizing fw_cfg blob names into
'/'-separated components, with symlinks to each 'by_key'
blob folder (same as in earlier versions). At Greg's
suggestion I tried to build this folder hierarchy and
leaf symlinks using udev rules, but so far I haven't been
successful in figuring that out. If udev turns out to
be applicable after all, these two patches can be dropped
from this series.
In other words, patches 1 and 2 give us the following "by_key" listing
of blobs contained in the qemu fw_cfg device (example pulled from a PC
qemu guest running Fedora 22), with the value of each "name" attribute
shown on the right:
$ tree /sys/firmware/qemu_fw_cfg/
/sys/firmware/qemu_fw_cfg/
|-- by_key
| |-- 32
| | |-- key
| | |-- name ("etc/boot-fail-wait")
| | |-- raw
| | `-- size
| |-- 33
| | |-- key
| | |-- name ("etc/smbios/smbios-tables")
| | |-- raw
| | `-- size
| |-- 34
| | |-- key
| | |-- name ("etc/smbios/smbios-anchor")
| | |-- raw
| | `-- size
| |-- 35
| | |-- key
| | |-- name ("etc/e820")
| | |-- raw
| | `-- size
| |-- 36
| | |-- key
| | |-- name ("genroms/kvmvapic.bin")
| | |-- raw
| | `-- size
| |-- 37
| | |-- key
| | |-- name ("etc/system-states")
| | |-- raw
| | `-- size
| |-- 38
| | |-- key
| | |-- name ("etc/acpi/tables")
| | |-- raw
| | `-- size
| |-- 39
| | |-- key
| | |-- name ("etc/table-loader")
| | |-- raw
| | `-- size
| |-- 40
| | |-- key
| | |-- name ("etc/tpm/log")
| | |-- raw
| | `-- size
| |-- 41
| | |-- key
| | |-- name ("etc/acpi/rsdp")
| | |-- raw
| | `-- size
| `-- 42
| |-- key
| |-- name ("bootorder")
| |-- raw
| `-- size
|
...
Additionally, patches 3 and 4 (mostly 4) give us the following
"user friendly" directory hierarchy as a complement to the above,
based on tokenizing each blob name into symlink-tipped (sub)directories:
...
|-- by_name
| |-- bootorder -> ../by_key/42
| |-- etc
| | |-- acpi
| | | |-- rsdp -> ../../../by_key/41
| | | `-- tables -> ../../../by_key/38
| | |-- boot-fail-wait -> ../../by_key/32
| | |-- e820 -> ../../by_key/35
| | |-- smbios
| | | |-- smbios-anchor -> ../../../by_key/34
| | | `-- smbios-tables -> ../../../by_key/33
| | |-- system-states -> ../../by_key/37
| | |-- table-loader -> ../../by_key/39
| | `-- tpm
| | `-- log -> ../../../by_key/40
| `-- genroms
| `-- kvmvapic.bin -> ../../by_key/36
`-- rev
The trick is to figure out how to replace patches 3 and 4 with a
udev rule that would read the contents of each "name" attribute,
and build the "by_name" hierarchy and symlinks in userspace.
I tried:
$ udevadm info -a -p /sys/firmware/qemu_fw_cfg/by_key/33
looking at device '/firmware/qemu_fw_cfg/by_key/33':
KERNEL=="33"
SUBSYSTEM==""
DRIVER==""
ATTR{key}=="33"
ATTR{name}=="etc/smbios/smbios-tables"
ATTR{size}=="388"
looking at parent device '/firmware/qemu_fw_cfg/by_key':
KERNELS=="by_key"
SUBSYSTEMS==""
DRIVERS==""
looking at parent device '/firmware/qemu_fw_cfg':
KERNELS=="qemu_fw_cfg"
SUBSYSTEMS==""
DRIVERS==""
ATTRS{rev}=="1"
Then I tried creating a file, /usr/lib/udev/rules.d/99-qemu-fw-cfg.rules
containing the following line:
KERNELS=="qemu_fw_cfg", ATTRS{rev}=="1", SYMLINK="%p/%s{name}"
but NOTHING happens when I insert/remove qemu_fw_cfg.ko. I also tried:
KERNELS=="qemu_fw_cfg", ATTRS{rev}=="1", PROGRAM="/foo %k"
where "/foo" basically did "echo $* > /tmp/bar", but no /tmp/bar file ever
showed up as a consequence of inserting/removing the qemu_fw_cfg.ko module.
At this point, I need help figuring out whether udev is really what would
get the second, user-friendly, "by_name" /sysfs directory tree created,
and how I'd go about that...
Thanks much,
--Gabriel
Gabriel Somlo (4):
firmware: introduce sysfs driver for QEMU's fw_cfg device
firmware: use acpi to detect QEMU fw_cfg device for sysfs fw_cfg
driver
kobject: export kset_find_obj() for module use
firmware: create directory hierarchy for sysfs fw_cfg entries
.../ABI/testing/sysfs-firmware-qemu_fw_cfg | 213 ++++++++
drivers/firmware/Kconfig | 10 +
drivers/firmware/Makefile | 1 +
drivers/firmware/qemu_fw_cfg.c | 575 +++++++++++++++++++++
lib/kobject.c | 1 +
5 files changed, 800 insertions(+)
create mode 100644 Documentation/ABI/testing/sysfs-firmware-qemu_fw_cfg
create mode 100644 drivers/firmware/qemu_fw_cfg.c
--
2.4.3
next reply other threads:[~2015-10-03 23:28 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-03 23:28 Gabriel L. Somlo [this message]
2015-10-03 23:28 ` [PATCH v3 1/4] firmware: introduce sysfs driver for QEMU's fw_cfg device Gabriel L. Somlo
2015-10-04 1:34 ` kbuild test robot
2015-10-06 8:40 ` [Qemu-devel] " Stefan Hajnoczi
[not found] ` <1443914889-9619-2-git-send-email-somlo-D+Gtc/HYRWM@public.gmane.org>
2015-10-06 12:53 ` Laszlo Ersek
2015-10-06 17:54 ` Andy Lutomirski
[not found] ` <CALCETrXdTf-85zzGYN28iGhcUMwE-h0o_GQ1XSFK-6q0AZNvgw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-06 18:17 ` Gabriel L. Somlo
2015-10-03 23:28 ` [PATCH v3 2/4] firmware: use acpi to detect QEMU fw_cfg device for sysfs fw_cfg driver Gabriel L. Somlo
[not found] ` <1443914889-9619-3-git-send-email-somlo-D+Gtc/HYRWM@public.gmane.org>
2015-10-04 7:54 ` Michael S. Tsirkin
2015-10-04 20:24 ` Gabriel L. Somlo
[not found] ` <20151004202400.GD1977-h65ZQ0r4j6KKUezXOiBB2eW1CriLhL8O@public.gmane.org>
2015-10-04 20:27 ` Gabriel L. Somlo
2015-10-03 23:28 ` [PATCH v3 3/4] kobject: export kset_find_obj() for module use Gabriel L. Somlo
2015-10-03 23:28 ` [PATCH v3 4/4] firmware: create directory hierarchy for sysfs fw_cfg entries Gabriel L. Somlo
[not found] ` <1443914889-9619-1-git-send-email-somlo-D+Gtc/HYRWM@public.gmane.org>
2015-10-05 10:00 ` [PATCH v3 0/4] SysFS driver for QEMU fw_cfg device Mark Rutland
2015-10-05 11:48 ` Paolo Bonzini
2015-10-05 12:23 ` Mark Rutland
2015-10-05 12:43 ` Gabriel L. Somlo
[not found] ` <20151005124346.GG1977-h65ZQ0r4j6KKUezXOiBB2eW1CriLhL8O@public.gmane.org>
2015-10-05 12:56 ` Mark Rutland
2015-10-05 13:21 ` Gabriel L. Somlo
2015-10-05 12:40 ` Gabriel L. Somlo
[not found] ` <20151005124042.GF1977-h65ZQ0r4j6KKUezXOiBB2eW1CriLhL8O@public.gmane.org>
2015-10-05 12:50 ` Peter Maydell
[not found] ` <CAFEAcA9qVSsmPW_s3wRSBykGYWU-2PS2ZNCagnoe0FGCg8mqzQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-05 13:13 ` Gabriel L. Somlo
2015-10-05 13:18 ` Paolo Bonzini
[not found] ` <5612788D.2090504-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-11-04 20:48 ` Gabriel L. Somlo
2015-10-05 13:05 ` Mark Rutland
2015-10-06 7:18 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443914889-9619-1-git-send-email-somlo@cmu.edu \
--to=somlo@cmu.edu \
--cc=agross@codeaurora.org \
--cc=ard.biesheuvel@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=galak@codeaurora.org \
--cc=gregkh@linuxfoundation.org \
--cc=hanjun.guo@linaro.org \
--cc=jordan.l.justen@intel.com \
--cc=kernelnewbies@kernelnewbies.org \
--cc=kraxel@redhat.com \
--cc=leif.lindholm@linaro.org \
--cc=lersek@redhat.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=matt.fleming@intel.com \
--cc=mst@redhat.com \
--cc=paul@pwsan.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=will.deacon@arm.com \
--cc=zajec5@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).