From owner-freebsd-hackers@freebsd.org Sun Nov 1 15:54:54 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 6B784A233E0 for ; Sun, 1 Nov 2015 15:54:54 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.blih.net", Issuer "mail.blih.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id B82281B38 for ; Sun, 1 Nov 2015 15:54:52 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) by mail.blih.net (OpenSMTPD) with ESMTP id 0161aae6 for ; Sun, 1 Nov 2015 16:54:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bidouilliste.com; h=date :from:to:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=mail; bh=pCsXnrerQVPX ps/PnMqCceD93TA=; b=lu60Xoxgty7h1h9nRVk+GZe+TCT+woVdJpNUrfXWF6cr sDfmbMYeIPc8A/bhPrTZVFD4fAdRiYsku+jf3P9XHgO/F+ooSZw0wF2k/oKe9huF KLVjkKsyx5tkZpvI2zMR9xCgg87oCavU3o3w6/i0Yz9g3mnJ5dRLtXlXLTzJcfs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=bidouilliste.com; h=date :from:to:subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; q=dns; s=mail; b=RZUX1d ssUTae9F2O4wqD7hVEZYxsWKy6Ly4PDzo4SKDF3r/5UVWQMPY5MplHcm6IDUIgwm pj7HF1MEwvpWYbBxyNB+urwPCACJejTCylNr5rsUc1zNgAPZS+YwfIdcjl/S6wIv e2LwyN61CItWwhMaLj4wqPkAO3PiwZ2Y6IyvY= Received: from atlantis.staff.bocal.org (163.5.251.125 [163.5.251.125]) by mail.blih.net (OpenSMTPD) with ESMTPSA id 5b83e818 TLS version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO for ; Sun, 1 Nov 2015 16:54:42 +0100 (CET) Date: Sun, 1 Nov 2015 16:54:41 +0100 From: Emmanuel Vadot To: freebsd-hackers@freebsd.org Subject: Re: EFI Variables Message-Id: <20151101165441.ee31e416fa004637879561c7@bidouilliste.com> In-Reply-To: <201510280727.19357.ganael.laplanche@corp.ovh.com> References: <6ce779725aab266bc85e92f0ee2186b6@megadrive.org> <201510280727.19357.ganael.laplanche@corp.ovh.com> X-Mailer: Sylpheed 3.4.3 (GTK+ 2.24.28; amd64-portbld-freebsd10.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: Sun, 01 Nov 2015 15:54:54 -0000 On Wed, 28 Oct 2015 07:27:19 +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). > > Best regards, > The entry point for the runtime service isn't a problem, I set it as a metadata in loader.efi (this is done the same way for the graphic output protocol and efifb). I don't know if there is a way to call a function from it's physical addresses (doing it directly kernel panic), if not we need to set a Virtual Address Map and Convert all the addresses. -- Emmanuel Vadot