From owner-freebsd-hackers@freebsd.org Wed Oct 28 21:38:35 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DEDC5A20640 for ; Wed, 28 Oct 2015 21:38:35 +0000 (UTC) (envelope-from rpaulo@me.com) Received: from mr11p00im-asmtp004.me.com (mr11p00im-asmtp004.me.com [17.110.69.135]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C75BF1637 for ; Wed, 28 Oct 2015 21:38:35 +0000 (UTC) (envelope-from rpaulo@me.com) MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset=UTF-8 Received: from akita.hsd1.ca.comcast.net (c-73-162-13-215.hsd1.ca.comcast.net [73.162.13.215]) by mr11p00im-asmtp004.me.com (Oracle Communications Messaging Server 7.0.5.35.0 64bit (built Mar 31 2015)) with ESMTPSA id <0NWY00NOT6O4JV10@mr11p00im-asmtp004.me.com> for freebsd-hackers@freebsd.org; Wed, 28 Oct 2015 20:38:29 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2015-10-28_15:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 kscore.is_bulkscore=0 kscore.compositescore=1 compositescore=0.9 suspectscore=0 phishscore=0 bulkscore=0 kscore.is_spamscore=0 rbsscore=0 spamscore=0 urlsuspectscore=0.9 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1510090000 definitions=main-1510280351 Message-id: <1446064708.28809.77.camel@me.com> Subject: Re: EFI Variables From: Rui Paulo To: Ganael Laplanche , Emmanuel Vadot Cc: freebsd-hackers@freebsd.org Date: Wed, 28 Oct 2015 13:38:28 -0700 In-reply-to: <201510280727.19357.ganael.laplanche@corp.ovh.com> References: <6ce779725aab266bc85e92f0ee2186b6@megadrive.org> <201510280727.19357.ganael.laplanche@corp.ovh.com> X-Mailer: Evolution 3.18.0-2 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Oct 2015 21:38:36 -0000 On Wed, 2015-10-28 at 07:27 +0100, Ganael Laplanche wrote: > On Tuesday, October 27, 2015 07:24:23 PM Emmanuel Vadot wrote: > > Hi Emmanuel, > > >   I'm currently hacking around the loader.efi > > Great :) > > >   I've also added the list and get command to the not working > > "nvram" > > command. > > I had myself posted a PR to fix that command as well as add a verbose > switch > and the ability to specify a variable name, see : > > https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=202614 > > >   For the "set" subcommand I think that the best way to handle it > > is : > >   "nvram set myvar data" -> This will set the variable myvar to > > data with > > the freebsd guid (if there is any) > > > >   and > > > >   "nvram set myvar guid data" -> This will force the guid to > > It can be useful to set variables containing *strings*, but will > hardly handle > binary stuff :/ > > I am not sure whether it should be the loader's job to set > variables... I can > think of changing the boot order, but it may be difficult to get it > right by > hand and would probably require an upper-level tool, such as > efibootmgr on > Linux. > > >   I'll look tomorrow how to access efivars once the kernel is > > booted so > > we can set some from some userland tool (especially the boot > > related > > one). > > Yes, this is interesting as the current kernel (amd64) does not > provide access > to EFI variables at all. > > 10.x/ia64 provided access to EFI variables through libefi(3) and > io(4). It > should be possible to import that code to other archs too, but you'll > have to > save the entry point to the Runtime Services Tables and maybe set a > Virtual > Address Map too (not sure about that point). > It would be nice to set some EFI variables in the loader, but you can't expect to handle binary data from the loader.  Like you said, we need a special tool to change EFI variables on a system already running FreeBSD. -- Rui Paulo