Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1216948

Re: [PATCH v2 0/3] SysFS driver for QEMU fw_cfg device

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From "Gabriel L. Somlo" <somlo@cmu.edu>
Newsgroups linux.kernel
Subject Re: [PATCH v2 0/3] SysFS driver for QEMU fw_cfg device
Date Tue, 01 Sep 2015 18:20:03 +0200
Message-ID <q3WrU-3db-19@gated-at.bofh.it> (permalink)
References <pWmMx-5cz-5@gated-at.bofh.it> <pZ80F-1Xp-11@gated-at.bofh.it> <pZ8am-28S-29@gated-at.bofh.it> <pZiCK-hP-15@gated-at.bofh.it> <q1NsK-55Y-13@gated-at.bofh.it>
X-Original-To Christopher Covington <cov@codeaurora.org>
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.5.23 (2014-03-12)
X-Pmx-Version 6.0.3.2322014, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.9.1.160617
X-SMTP-Spam-Clean 8% ( MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, FROM_EDU_TLD 0, NO_URI_HTTPS 0, REFERENCES 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CD 0, __CT 0, __CT_TEXT_PLAIN 0, __FORWARDED_MSG 0, __HAS_FROM 0, __HAS_MSGID 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __URI_NO_PATH 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0)
X-SMTP-Spam-Score 8%
X-Scanned-By MIMEDefang 2.74 on 128.2.157.38
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 89
Organization linux.* mail to news gateway
X-Original-Cc Ard Biesheuvel <ard.biesheuvel@linaro.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "Richard W.M. Jones" <rjones@redhat.com>, Jordan Justen <jordan.l.justen@intel.com>, "x86@kernel.org" <x86@kernel.org>, QEMU Developers <qemu-devel@nongnu.org>, gleb@cloudius-systems.com, Matt Fleming <matt.fleming@intel.com>, kernelnewbies@kernelnewbies.org, Gerd Hoffmann <kraxel@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Laszlo Ersek <lersek@redhat.com>, "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>, ralf@linux-mips.org, zajec5@gmail.com, paul@pwsan.com, galak@codeaurora.org, linux-api@vger.kernel.org, Leif Lindholm <leif.lindholm@linaro.org>
X-Original-Date Tue, 1 Sep 2015 12:11:44 -0400
X-Original-Message-ID <20150901161144.GB13375@HEDWIG.INI.CMU.EDU>
X-Original-References <cover.1439315079.git.somlo@cmu.edu> <1439977109-20314-1-git-send-email-ard.biesheuvel@linaro.org> <CAKv+Gu-BOKTHb24LnemKmvCwZn0W-NOT=avY94wkkRTx2ViW=Q@mail.gmail.com> <20150819204915.GA6164@GLSMBP.INI.CMU.EDU> <55DE0227.8090905@codeaurora.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1216948

Show key headers only | View raw


Hi Christopher,

On Wed, Aug 26, 2015 at 02:15:03PM -0400, Christopher Covington wrote:
> On 08/19/2015 04:49 PM, Gabriel L. Somlo wrote:
> > On Wed, Aug 19, 2015 at 11:42:02AM +0200, Ard Biesheuvel wrote:
> >> On 19 August 2015 at 11:38, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> >>> From: "Gabriel L. Somlo" <somlo@cmu.edu>
> >>>> 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.).
> >>>>
> >>>
> >>> Does 'potentially interesting' mean you have a use case? Could you elaborate?
> > 
> > My personal one would be something like:
> > 
> > cat > guestinfo.txt << EOT
> >   KEY1="val1"
> >   KEY2="val2"
> >   ...
> > EOT
> > 
> > qemu-system-x86_64 ... -fw-cfg name="opt/guestinfo",file=./guestinfo.txt ...
> > 
> > Then, from inside the guest:
> > 
> >   . /sys/firmware/qemu_fw_cfg/by_name/opt/guestinfo/raw
> > 
> >   do_something_with $KEY1 $KEY2
> >   ...
> > 
> > But I'm thinking this is only one of the many positive things one
> > could do with the ability to access random host-supplied blobs from
> > guest userspace :)
> 
> I do this with kernel parameters:
> 
> host:
> qemu-system-aarch64 -append="KEY1=val1 KEY2=val2"
> 
> guest:
> KEY1=`sed -nr s/.*KEY1=([^ ]+).*/\1/ /proc/cmdline`
> KEY2=`sed -nr s/.*KEY2=([^ ]+).*/\1/ /proc/cmdline`
> 
> do_something_with $KEY1 $KEY2
> 
> In practice it's just script=hostfile, where hostfile is available to the
> guest via a 9P passthrough filesystem mount.
> 
> While quite architecture specific, I've also previously used an
> "angel-cmdline" tool for similar purposes. Peter's recent semihosting patches
> support such a tool for AArch64. (On AArch32 upstream QEMU disallows
> semihosting from userspace.)
> 
> Before I had 9P on all the simulators I regularly ran, I used a semihosting
> based "angel-load" tool.

Someone (maybe it was you) did suggest this during an early thread on
the QEMU dev list. I had considered this, then thought about
piggybacking on smbios (e.g. the type 40 "additional information"
table), but then realized "wait, smbios is currently being inserted
into the guest via fw_cfg, so maybe direct fw_cfg blob transfer *is*
the most asynchronous and out-of-band way I can do this... :)

True, writing a fw_cfg driver is still Linux-specific (leaves out
Windows, which is something I still care about), but dumping a fw_cfg
blob using 'cat' or 'cp' on linux has a certain appeal :)

Yeah, the immediate use case I have personally can be worked around
with kernel command line args, in a slightly less out-of-band, but
still quite serviceable way. I'm thinking a fw_cfg driver is just a
flexible way to make other use cases possible in a (IMHO) neat and
clean way...

Plus, it got me to learn about kobjects, now studying DTs on ARM, so
it's fun ;)

Thanks,
--Gabriel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: [PATCH v2 0/3] SysFS driver for QEMU fw_cfg device "Gabriel L. Somlo" <somlo@cmu.edu> - 2015-08-19 23:00 +0200
  Re: [PATCH v2 0/3] SysFS driver for QEMU fw_cfg device Leif Lindholm <leif.lindholm@linaro.org> - 2015-08-20 01:10 +0200
  Re: [PATCH v2 0/3] SysFS driver for QEMU fw_cfg device Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2015-08-20 07:30 +0200
    Re: [PATCH v2 0/3] SysFS driver for QEMU fw_cfg device "Gabriel L. Somlo" <somlo@cmu.edu> - 2015-08-21 06:00 +0200
      Re: [PATCH v2 0/3] SysFS driver for QEMU fw_cfg device Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2015-08-24 10:00 +0200
  Re: [PATCH v2 0/3] SysFS driver for QEMU fw_cfg device Christopher Covington <cov@codeaurora.org> - 2015-08-26 20:20 +0200
    Re: [PATCH v2 0/3] SysFS driver for QEMU fw_cfg device "Gabriel L. Somlo" <somlo@cmu.edu> - 2015-09-01 18:20 +0200

csiph-web