Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756716AbbHZSPb (ORCPT ); Wed, 26 Aug 2015 14:15:31 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45262 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751522AbbHZSPI (ORCPT ); Wed, 26 Aug 2015 14:15:08 -0400 Message-ID: <55DE0227.8090905@codeaurora.org> Date: Wed, 26 Aug 2015 14:15:03 -0400 From: Christopher Covington User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Thunderbird/36.0 MIME-Version: 1.0 To: "Gabriel L. Somlo" , Ard Biesheuvel CC: "linux-kernel@vger.kernel.org" , "Richard W.M. Jones" , Jordan Justen , "x86@kernel.org" , QEMU Developers , gleb@cloudius-systems.com, Matt Fleming , kernelnewbies@kernelnewbies.org, Gerd Hoffmann , Paolo Bonzini , Laszlo Ersek , "gregkh@linuxfoundation.org" , ralf@linux-mips.org, zajec5@gmail.com, paul@pwsan.com, galak@codeaurora.org, linux-api@vger.kernel.org, Leif Lindholm Subject: Re: [PATCH v2 0/3] SysFS driver for QEMU fw_cfg device References: <1439977109-20314-1-git-send-email-ard.biesheuvel@linaro.org> <20150819204915.GA6164@GLSMBP.INI.CMU.EDU> In-Reply-To: <20150819204915.GA6164@GLSMBP.INI.CMU.EDU> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2517 Lines: 77 Hi Gabriel, On 08/19/2015 04:49 PM, Gabriel L. Somlo wrote: > Hi Ard, > > On Wed, Aug 19, 2015 at 11:42:02AM +0200, Ard Biesheuvel wrote: >> (missed some cc's) >> >> On 19 August 2015 at 11:38, Ard Biesheuvel wrote: >>> From: "Gabriel L. Somlo" >>>> 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. Regards, Christopher Covington -- Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project -- 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/