From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mx.groups.io with SMTP id smtpd.web09.5715.1626947826227529411 for ; Thu, 22 Jul 2021 02:57:06 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CXLQy2pq; spf=pass (domain: kernel.org, ip: 198.145.29.99, mailfrom: ardb@kernel.org) Received: by mail.kernel.org (Postfix) with ESMTPSA id B882F61287 for ; Thu, 22 Jul 2021 09:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626947825; bh=v51Ppv3hLballf13jfGxBBtZo+cxTXsJZ9iM/AQcDLs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=CXLQy2pqeLil02ac1foMiveAsiIbUxtVulsmfwmexqzhd+04koQWhYyN7VyNxV6zd yfmB8FNrDubLrZv7LVz38soI/rI2Cu+c9YbunMCYN4oHM2MzWBg/gF/iOKxuLAiYr/ UMy/yyO9jzTD2AM+WtfVjJkcezMjbjY7rjTIBrHqxeJnVBI0prvdBowvQcHAxC7whK jlgKCDW4wHiEHHvVTkBHkrYBp0gNNr0KtpfdUPw0VHLRrDomrrq3rbpc7Lc4qq4mK+ +toc3Jz9Tlm3VWTXX9ZJGyDjo7jogSKz2KOI8eXXqCsDbfyOCXqYsgwfLfMe5vZrZH kNXHtO5iXgF0g== Received: by mail-ot1-f51.google.com with SMTP id o17-20020a9d76510000b02903eabfc221a9so4811230otl.0 for ; Thu, 22 Jul 2021 02:57:05 -0700 (PDT) X-Gm-Message-State: AOAM533u1uFjvP6fYSGic+1aTkSzdPRB3PPP+YGd9y739tD8Wch1lTgC 5XTuN9IkHjfsmbg3f/2rzSv0rbPrHFw3GkIngSM= X-Google-Smtp-Source: ABdhPJxdZA6uPFIq1O8LjLQhmTwxSGU2KoL/75obeTv6ZMo2FFU0ECQx7f8AdrBnFkF3r65rfgMNjo+AGMNh4qncnAo= X-Received: by 2002:a05:6830:2316:: with SMTP id u22mr28898885ote.90.1626947825057; Thu, 22 Jul 2021 02:57:05 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Ard Biesheuvel" Date: Thu, 22 Jul 2021 11:56:48 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH 1/1] MdePkg: add definition of LINUX_EFI_INITRD_MEDIA_GUID To: "Kinney, Michael D" Cc: Jeff Brasen , "devel@edk2.groups.io" , "ardb+tianocore@kernel.org" , "Justen, Jordan L" , "gaoliming@byosoft.com.cn" , "Liu, Zhiguang" , Samer El-Haj-Mahmoud Content-Type: multipart/alternative; boundary="0000000000002e44e405c7b34fa2" --0000000000002e44e405c7b34fa2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 21 Jul 2021 at 20:04, Kinney, Michael D wrote: > Hi Jeff, > > > > I see. I missed the file rename line in the git patch. > > > > I think the description needs to be expanded to clearly describe the > production and consumption of this device path with this GUID. > > > > 1. What component creates the UEFI handle with the Device Path > Protocol and the LoadFile2 Protocol with the initrd image? Is it the > platform FW or the OS Loader? If it is the platform FW, then how does > the platform FW know which initrd image to publish if there are > multiple Linux OSes installed? > > This is really the firmware/loader's problem. In the ARM / RISC-V world, the distinction between firmware and pre-OS loader is not as clear cut, and for instance, U-boot in EFI mode can either boot the kernel directly (and expose the initrd via this method), or invoke GRUB as an EFI app using LoadImage/StartImage, in which case GRUB can load the kernel and/or initrd via whichever interface it desires. It is therefore also the platform FW's problem to decide which initrd goes with which kernel - it is highly platform dependent whether a certain initrd is compatible with only a single kernel, or can be combined with any kernel (e.g., when the kernel has all drivers builtin, and the initrd only contains the user space) > > 1. > 2. What component locates the UEFI handle with the Device Path > Protocol and the LoadFile2 Protocol with the initrd image? It is > another stage of the OS Loader or the OS Kernel? Given that these > handles are only available before ExitBootServices, I think this means > that the component that locates the initrd image has to do so before > ExitBootServices is called. > > > The consumer of the protocol is the EFI stub loader in Linux, i.e., the OS loader that is built into the OS kernel. It is the agent that calls ExitBootServices(), and it indeed consumes the protocol beforehand. In summary, I think it should be sufficient to describe the consumer's expectations with respect to the API. I don't think it makes sense to be normative about how platform firmware or intermediate loaders keep track of which file to expose, as long as it complies with the consumer's requirements. > *To:* Kinney, Michael D ; Ard Biesheuvel < > ardb@kernel.org> > *Cc:* devel@edk2.groups.io; ardb+tianocore@kernel.org; Justen, Jordan L < > jordan.l.justen@intel.com>; gaoliming@byosoft.com.cn; Liu, Zhiguang < > zhiguang.liu@intel.com>; Samer El-Haj-Mahmoud < > Samer.El-Haj-Mahmoud@arm.com> > *Subject:* Re: [edk2-devel] [PATCH 1/1] MdePkg: add definition of > LINUX_EFI_INITRD_MEDIA_GUID > > > > Does this look good for text to add > > > > "Linux distro boot generally relies on an initial ramdisk (initrd) > which is provided by the loader, and which contains additional kernel > modules (for storage and network, for instance), and the initial user > space startup code, i.e., the code which brings up the user space side > of the entire OS. > > In order to provide a standard method to locate this file, > > the GUID defined in this file is used to describe the device path > > for a LoadFile2 Protocol instance that is responsible for loading the > initrd file" > > > > > > Also, the patch does have > > {OvmfPkg =3D> MdePkg}/Include/Guid/LinuxEfiInitrdMedia.h | 0 > 3 files changed, 5 insertions(+), 1 deletion(-) > rename {OvmfPkg =3D> MdePkg}/Include/Guid/LinuxEfiInitrdMedia.h (100%) > [snip] > diff --git a/OvmfPkg/Include/Guid/LinuxEfiInitrdMedia.h > b/MdePkg/Include/Guid/LinuxEfiInitrdMedia.h > similarity index 100% > rename from OvmfPkg/Include/Guid/LinuxEfiInitrdMedia.h > rename to MdePkg/Include/Guid/LinuxEfiInitrdMedia.h > > > > > > Thanks, > > Jeff > ------------------------------ > > *From:* Kinney, Michael D > *Sent:* Wednesday, July 21, 2021 9:38 AM > *To:* Jeff Brasen ; Ard Biesheuvel ; > Kinney, Michael D > *Cc:* devel@edk2.groups.io ; > ardb+tianocore@kernel.org ; Justen, Jordan L < > jordan.l.justen@intel.com>; gaoliming@byosoft.com.cn < > gaoliming@byosoft.com.cn>; Liu, Zhiguang ; Samer > El-Haj-Mahmoud > *Subject:* RE: [edk2-devel] [PATCH 1/1] MdePkg: add definition of > LINUX_EFI_INITRD_MEDIA_GUID > > > > *External email: Use caution opening links or attachments* > > > > Hi Ard, > > > > If this device path node is considered as part of the standard interface > between the Linux kernel and > > firmware, then it does make sense for it to be in the MdePkg. We usually > try to reference a public > > specification in the include file that defines the interface. > > > > In this case, since there is no public document, but it is part of the > Linux kernel assumptions, > > can the include file for the GUID provide pointers to the Linux kernel > that uses the GUID and > > describe how the GUID is produced by the FW and consumed by the Linux > kernel? > > > > I also see that this patch appears to be incomplete. There is an OvmfPkg > /Include/Guid/LinuxEfiInitrdMedia.h > > file in the OvmfPkg. Shouldn=E2=80=99t that file also be moved to the Md= ePkg as > part of this patch? > > > > Thanks, > > > > Mike > > > > *From:* Jeff Brasen > *Sent:* Tuesday, July 20, 2021 9:59 AM > *To:* Ard Biesheuvel ; Kinney, Michael D < > michael.d.kinney@intel.com> > *Cc:* devel@edk2.groups.io; ardb+tianocore@kernel.org; Justen, Jordan L < > jordan.l.justen@intel.com>; gaoliming@byosoft.com.cn; Liu, Zhiguang < > zhiguang.liu@intel.com>; Samer El-Haj-Mahmoud < > Samer.El-Haj-Mahmoud@arm.com> > *Subject:* Re: [edk2-devel] [PATCH 1/1] MdePkg: add definition of > LINUX_EFI_INITRD_MEDIA_GUID > > > > In my opinion MdePkg is where this should be as it is meant to be used by > multiple software entities (linux kernel, grub, edk2, coreboot w/ uefi > binding) and probably should be documented in some spec (Although, I am n= ot > sure which one would make sense) > > > > I am fine with MdeModulePkg as well though. > > > > Thanks, > > Jeff > ------------------------------ > > *From:* Ard Biesheuvel > *Sent:* Friday, July 16, 2021 9:56 AM > *To:* Kinney, Michael D > *Cc:* Jeff Brasen ; devel@edk2.groups.io < > devel@edk2.groups.io>; ardb+tianocore@kernel.org < > ardb+tianocore@kernel.org>; Justen, Jordan L ; > gaoliming@byosoft.com.cn ; Liu, Zhiguang < > zhiguang.liu@intel.com>; Samer El-Haj-Mahmoud < > Samer.El-Haj-Mahmoud@arm.com> > *Subject:* Re: [edk2-devel] [PATCH 1/1] MdePkg: add definition of > LINUX_EFI_INITRD_MEDIA_GUID > > > > External email: Use caution opening links or attachments > > > On Fri, 16 Jul 2021 at 17:00, Kinney, Michael D > wrote: > > > > Hi Ard, > > > > I see you were involved in the OS side changes. > > > > Can you explain what is required for the FW <-> OS interface with > respect to Load File Protocol and this media device path node. > > > > What happens if this media device path node is not present? What break= s? > > > > Trying to figure out if this is a required interop feature (MdePkg > candidate) or an EDK II specific extension (MdeModulePkg candidate). > > > > Let me give some context first: > > Linux distro boot generally relies on an initial ramdisk (initrd) > which is provided by the loader, and which contains additional kernel > modules (for storage and netwerk, for instance), and the initial user > space startup code, ie., the code which brings up the user space side > of the entire OS. > > Before we introduced this media path, the only way for a EFI pre-OS > loader (such as GRUB) to provide this initrd was to copy it into DRAM > somewhere, and use a arch-specific method of passing the DRAM address > and size to the OS (x86 uses struct bootparam, whereas ARM uses device > tree). It also requires knowledge on the part of GRUB regarding which > parts of DRAM are suitable for holding an initrd image. For measured > boot scenarios, it may be an advantage not to have the initrd linger > in DRAM for longer that necessary, and we actually intend to measure > the initrd loaded via the new method right after it has been loaded > this way. > > To avoid extending this to other architectures such as RISC-V, I > decided to introduce a special vendor media path for Linux initrd > images, which GRUB et al can implement, which provides the initrd > image when the OS loader that consumes it asks for it. > > So for Linux on x86 or ARM, this is optional, given that support for > the old method is not going away any time soon. For RISC-V, I > suggested that only the new method be implemented, but I am not sure > what the status is there. Note that many embedded style systems don't > use GRUB, and may not use initrds to begin with. OTOH, U-Boot also > implements support for the Linux initrd vendor media path, and work is > ongoing to add measured boot support as well. > > In any case, I don't have a strong preference where this should live, > as long as it is in a generic place where all architectures can use > it. > > -- > Ard. > --0000000000002e44e405c7b34fa2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Wed, 21 Jul 2021 at 20:04, Kinney,= Michael D <michael.d.kinn= ey@intel.com> wrote:

Hi Jeff,

=C2=A0

I see.=C2=A0 I missed the file rename line in the git patch.=

=C2=A0

I think the description needs to be expanded t= o clearly describe the production and consumption of this device path with = this GUID.

=C2=A0

  1. What component creates the UEFI handle with the Device Path = Protocol and the LoadFile2 Protocol with the initrd image?=C2=A0 Is it the platform FW or the OS Loader?=C2=A0 If it is the platform FW, then how does the platform FW know which initrd image to publish if there are multiple Linux OSes installed?<= /span>

This is really= the firmware/loader's problem. In the ARM / RISC-V world, the distinct= ion between firmware and pre-OS loader is not as clear cut, and for instanc= e, U-boot in EFI mode can either boot the kernel directly (and expose the i= nitrd via this method), or invoke GRUB as an EFI app using LoadImage/StartI= mage, in which case GRUB can load the kernel and/or initrd via whichever in= terface it desires.

It is therefore also the platf= orm FW's problem to decide which initrd goes with which kernel - it is = highly platform dependent whether a certain initrd is compatible with only = a single kernel, or can be combined with any kernel (e.g., when the kernel = has all drivers builtin, and the initrd only contains the user space)
=
=C2=A0
  1. What compone= nt locates the UEFI handle with the Device Path Protocol and the LoadFile2 Protocol with the initrd image?=C2=A0 It is another stage of the OS Loader or the OS Kernel?=C2=A0 Given that these handles are only available before ExitBootServices, I think this mean= s that the component that locates the initrd image has t= o do so before ExitBootServices is called.

=C2=A0


The consumer of the protocol is the EFI stub loader = in Linux, i.e., the OS loader that is built into the OS kernel. It is the a= gent that calls ExitBootServices(), and it indeed consumes the protocol bef= orehand.

In summary, I think it should be sufficie= nt to describe the consumer's expectations with respect to the API. I d= on't think it makes sense to be normative about how platform firmware o= r intermediate loaders keep track of which file to expose, as long as it co= mplies with the consumer's requirements.

=C2= =A0

To: Kinney, Michael D <michael.d.kinney@intel.com>; Ard Biesheuvel &l= t;ardb@kernel.org&= gt;
Cc: devel@= edk2.groups.io; ardb+tianocore@kernel.org; Justen, Jordan L <jordan.l.justen@intel.c= om>; g= aoliming@byosoft.com.cn; Liu, Zhiguang <zhiguang.liu@intel.com>; Samer El-Ha= j-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Subject: Re: [edk2-devel] [PATCH 1/1] MdePkg: add definition of LINU= X_EFI_INITRD_MEDIA_GUID

=C2=A0

Does this= look good for text to add

= =C2=A0

"Linux distro boot generall= y relies on an initial ramdisk (initrd)
which is provided by th= e loader, and which contains additional kernel
modules (for storage and network, for inst= ance), and the initial user
space startup code, i.e., the code which b= rings up the user space side
of the entire OS.

In order to provide a standard method to locate this file,

the GUID = defined in this file is used to describe the device path

for a Loa= dFile2 Protocol instance that is responsible for loading the initrd file&qu= ot;

= =C2=A0

= =C2=A0

Also, the= patch does have

=C2=A0{OvmfPkg =3D> MdePkg}= /Include/Guid/LinuxEfiInitrdMedia.h | 0
=C2=A03 files changed, 5 insertions(+), 1 dele= tion(-)
=C2=A0rename {OvmfPkg =3D> MdePkg}/Incl= ude/Guid/LinuxEfiInitrdMedia.h (100%)
[snip]
diff --git a/OvmfPkg/Include/Guid/LinuxEfi= InitrdMedia.h b/MdePkg/Include/Guid/LinuxEfiInitrdMedia.h
similarity index 100%
rename from OvmfPkg/Include/Guid/LinuxEfiI= nitrdMedia.h
rename to MdePkg/Include/Guid/LinuxEfiInit= rdMedia.h

= =C2=A0

= =C2=A0

Thanks,

Jeff


From: Kinney, Michael D <michael.d.kinney@intel.com>
Sent: Wednesday, July 21, 2021 9:38 AM
To: Jeff Brasen <jbrasen@nvidia.com>; Ard Biesheuvel <ardb@kernel.org>; Kinney, Michael D= <michae= l.d.kinney@intel.com>
Cc: devel@= edk2.groups.io <devel@edk2.groups.io>; ardb+tianoco= re@kernel.org <ardb+tianocore@kernel.org>; Justen, Jordan L <jordan.l.justen@int= el.com>; gaoliming@byo= soft.com.cn <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>;= Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Subject: RE: [edk2-devel] [PATCH 1/1] MdePkg: add definition of LINU= X_EFI_INITRD_MEDIA_GUID

=C2=A0

External email: Use caution opening links or atta= chments

=C2=A0

Hi Ard,

=C2=A0

If this device path node= is considered as part of the standard interface between the Linux kernel a= nd

firmware, then it does m= ake sense for it to be in the MdePkg.=C2=A0 We usually try to reference a public

specification in the inc= lude file that defines the interface.

=C2=A0

In this case, since ther= e is no public document, but it is part of the Linux kernel assumptions,=

can the include file for= the GUID provide pointers to the Linux kernel that uses the GUID and

describe how the GUID is= produced by the FW and consumed by the Linux kernel?

=C2=A0

I also see that this pat= ch appears to be incomplete.=C2=A0 There is an OvmfPkg/Include/<= span class=3D"gmail-m_2152091238747558005xspelle">Guid/LinuxEfiInitrdMedia.h=

file in the OvmfPkg.=C2=A0 Shouldn=E2=80= =99t that file also be moved to the MdePkg as part of= this patch?

=C2=A0

Thanks,

=C2=A0

Mike

=C2=A0

From: Jeff Brasen= <jbrasen@nvidia= .com>
Sent: Tuesday, July 20, 2021 9:59 AM
To: Ard Biesheuvel <ardb@kernel.org>; Kinney, Michael D <michael.d.kinney@intel.com&= gt;
Cc: devel@= edk2.groups.io; ardb+tianocore@kernel.org; Justen, Jordan L <jordan.l.justen@intel.com>; gaoliming@byo= soft.com.cn; Liu, Zhiguang <zhiguang.liu@intel.com>; Samer El-Haj-Mahmoud &l= t;Samer.E= l-Haj-Mahmoud@arm.com>
Subject: Re: [edk2-devel] [PATCH 1/1] MdePkg: add definition of LINU= X_EFI_INITRD_MEDIA_GUID

=C2=A0

In my opinion MdePkg is where this should be as it is me= ant to be used by multiple software entities (linux kernel, grub, edk2, cor= eboot w/ uefi binding) and probably should be documented in some spec (Although, I am not sure which one would make sense)=

=C2=A0

I am fine with MdeModulePkg as well though.

=C2=A0

Thanks,

Jeff


From: Ard Biesheuvel <ardb@kernel.org> Sent: Friday, July 16, 2021 9:56 AM
To: Kinney, Michael D <michael.d.kinney@intel.com>
Cc: Jeff Brasen <jbrasen@nvidia.com>; devel@edk2.groups= .io <devel= @edk2.groups.io>; ardb+tianoco= re@kernel.org <ardb+tianocore@kernel.org>; Justen, Jordan L <jordan.l.justen@int= el.com>; gaoliming@byo= soft.com.cn <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>;= Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>
Subject: Re: [edk2-devel] [PATCH 1/1] MdePkg: add definition of LINU= X_EFI_INITRD_MEDIA_GUID

=C2=A0

External email: Use caut= ion opening links or attachments


On Fri, 16 Jul 2021 at 17:00, Kinney, Michael D
<michael= .d.kinney@intel.com> wrote:
>
> Hi Ard,
>
> I see you were involved in the OS side changes.
>
> Can you explain what is required for the FW <-> OS interface wit= h respect to Load File Protocol and this media device path node.
>
> What happens if this media device path node is not present?=C2=A0 What= breaks?
>
> Trying to figure out if this is a required interop feature (MdePkg can= didate) or an EDK II specific extension (MdeModulePkg candidate).
>

Let me give some context first:

Linux distro boot generally relies on an initial ramdisk (initrd)
which is provided by the loader, and which contains additional kernel
modules (for storage and netwerk, for instance), and the initial user
space startup code, ie., the code which brings up the user space side
of the entire OS.

Before we introduced this media path, the only way for a EFI pre-OS
loader (such as GRUB) to provide this initrd was to copy it into DRAM
somewhere, and use a arch-specific method of passing the DRAM address
and size to the OS (x86 uses struct bootparam, whereas ARM uses device
tree). It also requires knowledge on the part of GRUB regarding which
parts of DRAM are suitable for holding an initrd image. For measured
boot scenarios, it may be an advantage not to have the initrd linger
in DRAM for longer that necessary, and we actually intend to measure
the initrd loaded via the new method right after it has been loaded
this way.

To avoid extending this to other architectures such as RISC-V, I
decided to introduce a special vendor media path for Linux initrd
images, which GRUB et al can implement, which provides the initrd
image when the OS loader that consumes it asks for it.

So for Linux on x86 or ARM, this is optional, given that support for
the old method is not going away any time soon. For RISC-V, I
suggested that only the new method be implemented, but I am not sure
what the status is there. Note that many embedded style systems don't use GRUB, and may not use initrds to begin with. OTOH, U-Boot also
implements support for the Linux initrd vendor media path, and work is
ongoing to add measured boot support as well.

In any case, I don't have a strong preference where this should live, as long as it is in a generic place where all architectures can use
it.

--
Ard.

--0000000000002e44e405c7b34fa2--