Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Mar 2019 14:01:59 -0700
From:      John Baldwin <jhb@FreeBSD.org>
To:        Warner Losh <imp@bsdimp.com>
Cc:        "Rodney W. Grimes" <freebsd-rwg@gndrsh.dnsmgr.net>, Konstantin Belousov <kostikbel@gmail.com>, "freebsd-arch@freebsd.org" <arch@freebsd.org>, FreeBSD Hackers <freebsd-hackers@freebsd.org>, Rebecca Cran <rebecca@bluestop.org>
Subject:   Re: Adding a new efi-update-loader script: need help understanding Makefile.inc1 for "make installworld"
Message-ID:  <df2e24ac-2486-9657-d818-6acda5c85ee4@FreeBSD.org>
In-Reply-To: <CANCZdfpAhOLJZTsLZcM330GSkA460u3MCgWb5GwEfvX5cVSzAg@mail.gmail.com>
References:  <20190324090103.GO1923@kib.kiev.ua> <201903250926.x2P9QgYK078736@gndrsh.dnsmgr.net> <CANCZdfqpyf%2BPNMjQG2KQLY_a2a8_2Syu0_kTanc4ARmB97JTMg@mail.gmail.com> <2c1aef87-5408-7736-9039-7fc6a1214102@FreeBSD.org> <CANCZdfrcO2vgD=t76kmgZW0w9At41wg9iyJyEma1THTaH%2BkD1g@mail.gmail.com> <ffdde530-b6e7-c455-2b60-9f490eac8cf3@FreeBSD.org> <CANCZdfpAhOLJZTsLZcM330GSkA460u3MCgWb5GwEfvX5cVSzAg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 3/25/19 1:41 PM, Warner Losh wrote:
> On Mon, Mar 25, 2019 at 2:30 PM John Baldwin <jhb@freebsd.org> wrote:
> 
>> On 3/25/19 12:27 PM, Warner Losh wrote:
>>> On Mon, Mar 25, 2019, 12:34 PM John Baldwin <jhb@freebsd.org> wrote:
>>>
>>>> On 3/25/19 8:05 AM, Warner Losh wrote:
>>>>> We started installing /boot/loader with install world in FreeBSD -3.x
>> and
>>>>> it has affected the boot ability that whole time... in the early days
>> of
>>>>> loader, the kernel loader handoff protocol was immature enough to need
>> a
>>>>> matched kernel. But that period lasted only a few months...  loader has
>>>>> also been weird in other ways as well, since some embedded systems used
>>>> the
>>>>> one in its, while others needed an extra step. As UEFI support has
>>>> matured
>>>>> we're finding there are several issues around it as well where updating
>>>> the
>>>>> ESP needs to be tied to updating /boot for the system to work
>> sometimes.
>>>> It
>>>>> has grown more complex over time, so we should separate. It's been a
>>>> little
>>>>> weird on all the non x86 platforms to different degrees, but now that
>> our
>>>>> main platform is affected it's become clear we may need to change.
>>>>>
>>>>> But we need to do so carefully as this violates POLA in a huge way, as
>>>> well
>>>>> as needing doc changes in a bajillion places.
>>>>
>>>> I think we should treat files on the ESP the same way we treat other
>> boot
>>>> blocks.  installworld should continue to install the latest version into
>>>> /boot (e.g. /boot/boot that holds UFS boot1 + boot2), but then some
>> other
>>>> tool is used by the user to copy the updated loader.efi into the ESP.
>>>>
>>>> I think the main difference here is that traditionally other boot blocks
>>>> didn't change very often, so no one really needed to update it them
>>>> post-install.  loader.efi changes often enough we probably need to
>> document
>>>> updating the ESP as an optional step in the upgrade process.  I think
>>>> having an automagical script will probably go sideways, but
>> standardizing
>>>> where to mounting the ESP (or ESPs when doing RAID mirroring, etc.)
>> means
>>>> we can provide a script with defaults (or instructions) that work with
>>>> the standardized approach.
>>>>
>>>
>>> I think we need to have some automation in place. Something very specific
>>> and concrete. Otherwise we run the risk of updating the support files
>>> without updating loader.efi, possibly breaking boot if we wanted to add a
>>> new API to lua that the startup scripts call. Without an update of
>>> loader.efi, this generates an error.
>>>
>>> I view /efi/boot/* as boot blocks, for these purposes, bit /efi/freebsd
>> as
>>> fair game to update. So there is some nuance here we need to take into
>>> account and avoid absolutes about the BSP.
>>
>> Hmm, I guess we considered it a bad idea to store all the support scripts
>> (not loader.conf, but all the 4th/lua) on the esp beside the loader?  That
>> would make the ESP bits be a self-contained, consistent snapshot.
>> loader.efi
>> could perhaps prefer to find those files on the partition it was loaded
>> from
>> (you know that IIRC since when you are executed as an EFI app you get a
>> pointer to your Image and it has a backpointer to the device you came from
>> I thought) before looking for them on the root filesystem?  This would let
>> it still work when boot1.efi lives on the ESP instead, and also in the case
>> that you just copied loader.efi into the ESP without the support scripts.
>>
> 
> Yea, now we're far into the weeds of dynamic design, and I'm not sure this
> is a good idea at all. Every time we've tried to pivot with a "just do X"
> it's burned us on this stuff. I hate the idea of just adding one ore layer
> of complexity as well, though to be honest, there may be some need to have
> some standardized fallback for the horrific UEFI implementations that are
> out there which are deficient in a number of ways that would lead us to
> needing some not uefi variable fallack mechanism. I'd hate to design that
> and then have another wart looking for this stuff, as well as users needing
> to do weird stuff to read in loader.conf and modifying it (more POLA
> violation if we move it to the ESP, for example). I've not had a chance to
> connect all the dots, but the few I've tried strong suggest this idea may
> not hunt.
> 
> Let's step back and do a complete design doc. I've started writing one up
> and will post it when I'm done.

I think a design doc makes sense.  FWIW, I was only suggesting that the support
scripts and perhaps /boot/defaults be on the ESP, but the actual loader.conf
would still only be read from the rootfs.  Right now loader has two
special variables: currdev and rootdev.  You could imagine a 'bootdev' and that
for certain path lookups we try bootdev before currdev, but still fall back
to currdev if the open on bootdev fails.  But I think it's worth stepping
back and walking through the design.  My point about installworld is that
today it is pretty straight forward what it means in terms of just installing
files into / and that works fine for cross-release installs via DESTDIR,
etc.  Updating the ESP seems to be a bit more fraught with peril such that
I'm not really sure I want installworld to try to do that vs having a
separate step.  The thought about having the "support scripts" live on the
ESP is an orthogonal point about trying to have the loader be self-contained
when it lives on the ESP.  In this case I think of self-contained as being
"what are the things equivalent to shared libraries that it needs to run",
but not user-editable config files like loader.conf.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?df2e24ac-2486-9657-d818-6acda5c85ee4>