All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/1] efi_loader: expose the device-tree file name
@ 2023-10-22  8:47 Heinrich Schuchardt
  2023-10-22 15:55 ` Tom Rini
  0 siblings, 1 reply; 7+ messages in thread
From: Heinrich Schuchardt @ 2023-10-22  8:47 UTC (permalink / raw)
  To: Ilias Apalodimas; +Cc: u-boot, Simon Glass, Tom Rini, Heinrich Schuchardt

Forward and backward compatibility of Linux kernel device-trees is
sometimes missing. One solution approach is to load a kernel specific
device-tree. This can either be done via a U-Boot scripts (like the one
generated by Debian package flash-kernel or by a boot loader like GRUB.
The boot loader approach currently requires to know the device-tree name
before first boot which makes it unusable for generic images.

Expose the device-tree file name as EFI variable FdtFile.
This will allow bootloaders to load a kernel specific device-tree.

The variable will not be exposed on ACPI based systems or if the
environment variable fdtfile is not defined.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v3:
	Add documentation
v2:
	Use a unique GUID to enable future U-Boot independent
	standardization.
	Do not try to add the variable on ACPI based systems.
---
 doc/develop/uefi/uefi.rst  | 17 +++++++++++++++++
 include/efi_loader.h       |  5 +++++
 lib/efi_loader/efi_setup.c | 30 ++++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+)

diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst
index fb16ac743a..a81d09ae81 100644
--- a/doc/develop/uefi/uefi.rst
+++ b/doc/develop/uefi/uefi.rst
@@ -916,6 +916,23 @@ So our final format of the FilePathList[] is::
 
     Loaded image - end node (0xff) - VenMedia - initrd_1 - [end node (0x01) - initrd_n ...] - end node (0xff)
 
+EFI variable FdtFile
+~~~~~~~~~~~~~~~~~~~~
+
+Ideally U-Boot would always expose a device-tree that can be used for booting
+any operating systems. Unfortunately operating systems like Linux sometimes
+break forward and backward compatibility. In this case there is a need to load
+an operating system version specific device-tree.
+
+U-Boot has an environment variable fdtfile identifying the device-tree file to
+load. The content of this variable is exposed as EFI variable Fdtfile, vendor
+GUID d45dde69-3bd6-40e0-90d5-6b606aa57730. It contains the device-tree path
+name as a NUL terminated ASCII string.
+
+On 32bit ARM this is currently only a file name, e.g. 'imx6dl-wandboard.dtb'.
+On other architectures the file name is preceded by the vendor directory, e.g.
+'rockchip/rk3326-odroid-go2.dtb'.
+
 Links
 -----
 
diff --git a/include/efi_loader.h b/include/efi_loader.h
index e24410505f..146e7f1bce 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -152,6 +152,11 @@ static inline efi_status_t efi_launch_capsules(void)
 	EFI_GUID(0x8108ac4e, 0x9f11, 0x4d59, \
 		 0x85, 0x0e, 0xe2, 0x1a, 0x52, 0x2c, 0x59, 0xb2)
 
+/* Vendor GUID for the FdtFile variable */
+#define VENDOR_FDTFILE_GUID \
+	EFI_GUID(0xd45dde69, 0x3bd6, 0x40e0, \
+		 0x90, 0xd5, 0x6b, 0x60, 0x6a, 0xa5, 0x77, 0x30)
+
 /* Use internal device tree when starting UEFI application */
 #define EFI_FDT_USE_INTERNAL NULL
 
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index e6de685e87..71bcde645b 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -17,6 +17,8 @@
 
 efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED;
 
+efi_guid_t vendor_fdtfile_guid = VENDOR_FDTFILE_GUID;
+
 /*
  * Allow unaligned memory access.
  *
@@ -26,6 +28,27 @@ void __weak allow_unaligned(void)
 {
 }
 
+/**
+ * efi_init_fdtfile() - set EFI variable FdtFile
+ *
+ * Return:	status code
+ */
+static efi_status_t efi_init_fdtfile(void)
+{
+	char *val;
+
+	val = env_get("fdtfile");
+	if (!val)
+		return EFI_SUCCESS;
+
+	return efi_set_variable_int(u"FdtFile",
+				    &vendor_fdtfile_guid,
+				    EFI_VARIABLE_BOOTSERVICE_ACCESS |
+				    EFI_VARIABLE_RUNTIME_ACCESS |
+				    EFI_VARIABLE_READ_ONLY,
+				    strlen(val) + 1, val, false);
+}
+
 /**
  * efi_init_platform_lang() - define supported languages
  *
@@ -250,6 +273,13 @@ efi_status_t efi_init_obj_list(void)
 	if (ret != EFI_SUCCESS)
 		goto out;
 
+	/* Define EFI variable FdtFile */
+	if (!CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)) {
+		ret = efi_init_fdtfile();
+		if (ret != EFI_SUCCESS)
+			goto out;
+	}
+
 	/* Indicate supported features */
 	ret = efi_init_os_indications();
 	if (ret != EFI_SUCCESS)
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/1] efi_loader: expose the device-tree file name
  2023-10-22  8:47 [PATCH v3 1/1] efi_loader: expose the device-tree file name Heinrich Schuchardt
@ 2023-10-22 15:55 ` Tom Rini
  2023-10-22 16:34   ` Heinrich Schuchardt
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Rini @ 2023-10-22 15:55 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: Ilias Apalodimas, u-boot, Simon Glass

[-- Attachment #1: Type: text/plain, Size: 2538 bytes --]

On Sun, Oct 22, 2023 at 10:47:33AM +0200, Heinrich Schuchardt wrote:

> Forward and backward compatibility of Linux kernel device-trees is
> sometimes missing. One solution approach is to load a kernel specific
> device-tree. This can either be done via a U-Boot scripts (like the one
> generated by Debian package flash-kernel or by a boot loader like GRUB.
> The boot loader approach currently requires to know the device-tree name
> before first boot which makes it unusable for generic images.
> 
> Expose the device-tree file name as EFI variable FdtFile.
> This will allow bootloaders to load a kernel specific device-tree.
> 
> The variable will not be exposed on ACPI based systems or if the
> environment variable fdtfile is not defined.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v3:
> 	Add documentation
> v2:
> 	Use a unique GUID to enable future U-Boot independent
> 	standardization.
> 	Do not try to add the variable on ACPI based systems.
> ---
>  doc/develop/uefi/uefi.rst  | 17 +++++++++++++++++
>  include/efi_loader.h       |  5 +++++
>  lib/efi_loader/efi_setup.c | 30 ++++++++++++++++++++++++++++++
>  3 files changed, 52 insertions(+)
> 
> diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst
> index fb16ac743a..a81d09ae81 100644
> --- a/doc/develop/uefi/uefi.rst
> +++ b/doc/develop/uefi/uefi.rst
> @@ -916,6 +916,23 @@ So our final format of the FilePathList[] is::
>  
>      Loaded image - end node (0xff) - VenMedia - initrd_1 - [end node (0x01) - initrd_n ...] - end node (0xff)
>  
> +EFI variable FdtFile
> +~~~~~~~~~~~~~~~~~~~~
> +
> +Ideally U-Boot would always expose a device-tree that can be used for booting
> +any operating systems. Unfortunately operating systems like Linux sometimes
> +break forward and backward compatibility. In this case there is a need to load
> +an operating system version specific device-tree.
> +
> +U-Boot has an environment variable fdtfile identifying the device-tree file to
> +load. The content of this variable is exposed as EFI variable Fdtfile, vendor
> +GUID d45dde69-3bd6-40e0-90d5-6b606aa57730. It contains the device-tree path
> +name as a NUL terminated ASCII string.
> +
> +On 32bit ARM this is currently only a file name, e.g. 'imx6dl-wandboard.dtb'.
> +On other architectures the file name is preceded by the vendor directory, e.g.
> +'rockchip/rk3326-odroid-go2.dtb'.

The Linux Kernel has split 32bit ARM up by directory now, too.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/1] efi_loader: expose the device-tree file name
  2023-10-22 15:55 ` Tom Rini
@ 2023-10-22 16:34   ` Heinrich Schuchardt
  2023-10-22 17:08     ` Tom Rini
  0 siblings, 1 reply; 7+ messages in thread
From: Heinrich Schuchardt @ 2023-10-22 16:34 UTC (permalink / raw)
  To: Tom Rini; +Cc: Ilias Apalodimas, u-boot, Simon Glass

On 10/22/23 17:55, Tom Rini wrote:
> On Sun, Oct 22, 2023 at 10:47:33AM +0200, Heinrich Schuchardt wrote:
> 
>> Forward and backward compatibility of Linux kernel device-trees is
>> sometimes missing. One solution approach is to load a kernel specific
>> device-tree. This can either be done via a U-Boot scripts (like the one
>> generated by Debian package flash-kernel or by a boot loader like GRUB.
>> The boot loader approach currently requires to know the device-tree name
>> before first boot which makes it unusable for generic images.
>>
>> Expose the device-tree file name as EFI variable FdtFile.
>> This will allow bootloaders to load a kernel specific device-tree.
>>
>> The variable will not be exposed on ACPI based systems or if the
>> environment variable fdtfile is not defined.
>>
>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
>> ---
>> v3:
>> 	Add documentation
>> v2:
>> 	Use a unique GUID to enable future U-Boot independent
>> 	standardization.
>> 	Do not try to add the variable on ACPI based systems.
>> ---
>>   doc/develop/uefi/uefi.rst  | 17 +++++++++++++++++
>>   include/efi_loader.h       |  5 +++++
>>   lib/efi_loader/efi_setup.c | 30 ++++++++++++++++++++++++++++++
>>   3 files changed, 52 insertions(+)
>>
>> diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst
>> index fb16ac743a..a81d09ae81 100644
>> --- a/doc/develop/uefi/uefi.rst
>> +++ b/doc/develop/uefi/uefi.rst
>> @@ -916,6 +916,23 @@ So our final format of the FilePathList[] is::
>>   
>>       Loaded image - end node (0xff) - VenMedia - initrd_1 - [end node (0x01) - initrd_n ...] - end node (0xff)
>>   
>> +EFI variable FdtFile
>> +~~~~~~~~~~~~~~~~~~~~
>> +
>> +Ideally U-Boot would always expose a device-tree that can be used for booting
>> +any operating systems. Unfortunately operating systems like Linux sometimes
>> +break forward and backward compatibility. In this case there is a need to load
>> +an operating system version specific device-tree.
>> +
>> +U-Boot has an environment variable fdtfile identifying the device-tree file to
>> +load. The content of this variable is exposed as EFI variable Fdtfile, vendor
>> +GUID d45dde69-3bd6-40e0-90d5-6b606aa57730. It contains the device-tree path
>> +name as a NUL terminated ASCII string.
>> +
>> +On 32bit ARM this is currently only a file name, e.g. 'imx6dl-wandboard.dtb'.
>> +On other architectures the file name is preceded by the vendor directory, e.g.
>> +'rockchip/rk3326-odroid-go2.dtb'.
> 
> The Linux Kernel has split 32bit ARM up by directory now, too.

Since Linux v6.5. That is why I wrote "currently". Once we migrate the 
values of $fdtfile in U-Boot we may want to change 
distro_efi_try_bootflow_files() to search both with and without vendor 
directory.

Are there already plans for that migration?

Best regards

Heinrich

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/1] efi_loader: expose the device-tree file name
  2023-10-22 16:34   ` Heinrich Schuchardt
@ 2023-10-22 17:08     ` Tom Rini
  2023-10-22 21:31       ` Heinrich Schuchardt
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Rini @ 2023-10-22 17:08 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: Ilias Apalodimas, u-boot, Simon Glass

[-- Attachment #1: Type: text/plain, Size: 3434 bytes --]

On Sun, Oct 22, 2023 at 06:34:08PM +0200, Heinrich Schuchardt wrote:
> On 10/22/23 17:55, Tom Rini wrote:
> > On Sun, Oct 22, 2023 at 10:47:33AM +0200, Heinrich Schuchardt wrote:
> > 
> > > Forward and backward compatibility of Linux kernel device-trees is
> > > sometimes missing. One solution approach is to load a kernel specific
> > > device-tree. This can either be done via a U-Boot scripts (like the one
> > > generated by Debian package flash-kernel or by a boot loader like GRUB.
> > > The boot loader approach currently requires to know the device-tree name
> > > before first boot which makes it unusable for generic images.
> > > 
> > > Expose the device-tree file name as EFI variable FdtFile.
> > > This will allow bootloaders to load a kernel specific device-tree.
> > > 
> > > The variable will not be exposed on ACPI based systems or if the
> > > environment variable fdtfile is not defined.
> > > 
> > > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> > > ---
> > > v3:
> > > 	Add documentation
> > > v2:
> > > 	Use a unique GUID to enable future U-Boot independent
> > > 	standardization.
> > > 	Do not try to add the variable on ACPI based systems.
> > > ---
> > >   doc/develop/uefi/uefi.rst  | 17 +++++++++++++++++
> > >   include/efi_loader.h       |  5 +++++
> > >   lib/efi_loader/efi_setup.c | 30 ++++++++++++++++++++++++++++++
> > >   3 files changed, 52 insertions(+)
> > > 
> > > diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst
> > > index fb16ac743a..a81d09ae81 100644
> > > --- a/doc/develop/uefi/uefi.rst
> > > +++ b/doc/develop/uefi/uefi.rst
> > > @@ -916,6 +916,23 @@ So our final format of the FilePathList[] is::
> > >       Loaded image - end node (0xff) - VenMedia - initrd_1 - [end node (0x01) - initrd_n ...] - end node (0xff)
> > > +EFI variable FdtFile
> > > +~~~~~~~~~~~~~~~~~~~~
> > > +
> > > +Ideally U-Boot would always expose a device-tree that can be used for booting
> > > +any operating systems. Unfortunately operating systems like Linux sometimes
> > > +break forward and backward compatibility. In this case there is a need to load
> > > +an operating system version specific device-tree.
> > > +
> > > +U-Boot has an environment variable fdtfile identifying the device-tree file to
> > > +load. The content of this variable is exposed as EFI variable Fdtfile, vendor
> > > +GUID d45dde69-3bd6-40e0-90d5-6b606aa57730. It contains the device-tree path
> > > +name as a NUL terminated ASCII string.
> > > +
> > > +On 32bit ARM this is currently only a file name, e.g. 'imx6dl-wandboard.dtb'.
> > > +On other architectures the file name is preceded by the vendor directory, e.g.
> > > +'rockchip/rk3326-odroid-go2.dtb'.
> > 
> > The Linux Kernel has split 32bit ARM up by directory now, too.
> 
> Since Linux v6.5. That is why I wrote "currently". Once we migrate the
> values of $fdtfile in U-Boot we may want to change
> distro_efi_try_bootflow_files() to search both with and without vendor
> directory.
> 
> Are there already plans for that migration?

Right, v6.5 is out and has this change and v6.6 will be out soon enough,
so the documentation we're adding here and now should be worded such
that doesn't get stuck on these specifics.

And then how this kind of breaking change will be handled by
distros and everyone else is something I wonder about.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/1] efi_loader: expose the device-tree file name
  2023-10-22 17:08     ` Tom Rini
@ 2023-10-22 21:31       ` Heinrich Schuchardt
  2023-10-23 16:57         ` Tom Rini
  2023-10-26 15:43         ` Rob Herring
  0 siblings, 2 replies; 7+ messages in thread
From: Heinrich Schuchardt @ 2023-10-22 21:31 UTC (permalink / raw)
  To: Tom Rini; +Cc: Ilias Apalodimas, u-boot, Simon Glass

On 10/22/23 19:08, Tom Rini wrote:
> On Sun, Oct 22, 2023 at 06:34:08PM +0200, Heinrich Schuchardt wrote:
>> On 10/22/23 17:55, Tom Rini wrote:
>>> On Sun, Oct 22, 2023 at 10:47:33AM +0200, Heinrich Schuchardt wrote:
>>>
>>>> Forward and backward compatibility of Linux kernel device-trees is
>>>> sometimes missing. One solution approach is to load a kernel specific
>>>> device-tree. This can either be done via a U-Boot scripts (like the one
>>>> generated by Debian package flash-kernel or by a boot loader like GRUB.
>>>> The boot loader approach currently requires to know the device-tree name
>>>> before first boot which makes it unusable for generic images.
>>>>
>>>> Expose the device-tree file name as EFI variable FdtFile.
>>>> This will allow bootloaders to load a kernel specific device-tree.
>>>>
>>>> The variable will not be exposed on ACPI based systems or if the
>>>> environment variable fdtfile is not defined.
>>>>
>>>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
>>>> ---
>>>> v3:
>>>> 	Add documentation
>>>> v2:
>>>> 	Use a unique GUID to enable future U-Boot independent
>>>> 	standardization.
>>>> 	Do not try to add the variable on ACPI based systems.
>>>> ---
>>>>    doc/develop/uefi/uefi.rst  | 17 +++++++++++++++++
>>>>    include/efi_loader.h       |  5 +++++
>>>>    lib/efi_loader/efi_setup.c | 30 ++++++++++++++++++++++++++++++
>>>>    3 files changed, 52 insertions(+)
>>>>
>>>> diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst
>>>> index fb16ac743a..a81d09ae81 100644
>>>> --- a/doc/develop/uefi/uefi.rst
>>>> +++ b/doc/develop/uefi/uefi.rst
>>>> @@ -916,6 +916,23 @@ So our final format of the FilePathList[] is::
>>>>        Loaded image - end node (0xff) - VenMedia - initrd_1 - [end node (0x01) - initrd_n ...] - end node (0xff)
>>>> +EFI variable FdtFile
>>>> +~~~~~~~~~~~~~~~~~~~~
>>>> +
>>>> +Ideally U-Boot would always expose a device-tree that can be used for booting
>>>> +any operating systems. Unfortunately operating systems like Linux sometimes
>>>> +break forward and backward compatibility. In this case there is a need to load
>>>> +an operating system version specific device-tree.
>>>> +
>>>> +U-Boot has an environment variable fdtfile identifying the device-tree file to
>>>> +load. The content of this variable is exposed as EFI variable Fdtfile, vendor
>>>> +GUID d45dde69-3bd6-40e0-90d5-6b606aa57730. It contains the device-tree path
>>>> +name as a NUL terminated ASCII string.
>>>> +
>>>> +On 32bit ARM this is currently only a file name, e.g. 'imx6dl-wandboard.dtb'.
>>>> +On other architectures the file name is preceded by the vendor directory, e.g.
>>>> +'rockchip/rk3326-odroid-go2.dtb'.
>>>
>>> The Linux Kernel has split 32bit ARM up by directory now, too.
>>
>> Since Linux v6.5. That is why I wrote "currently". Once we migrate the
>> values of $fdtfile in U-Boot we may want to change
>> distro_efi_try_bootflow_files() to search both with and without vendor
>> directory.
>>
>> Are there already plans for that migration?
> 
> Right, v6.5 is out and has this change and v6.6 will be out soon enough,
> so the documentation we're adding here and now should be worded such
> that doesn't get stuck on these specifics.

Should I add a sentence:

Linux v6.5 has added vendor directories on 32bit ARM and U-Boot is 
expected to follow suit.

Best regards

Heinrich

> 
> And then how this kind of breaking change will be handled by
> distros and everyone else is something I wonder about.
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/1] efi_loader: expose the device-tree file name
  2023-10-22 21:31       ` Heinrich Schuchardt
@ 2023-10-23 16:57         ` Tom Rini
  2023-10-26 15:43         ` Rob Herring
  1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2023-10-23 16:57 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: Ilias Apalodimas, u-boot, Simon Glass

[-- Attachment #1: Type: text/plain, Size: 3992 bytes --]

On Sun, Oct 22, 2023 at 11:31:52PM +0200, Heinrich Schuchardt wrote:
> On 10/22/23 19:08, Tom Rini wrote:
> > On Sun, Oct 22, 2023 at 06:34:08PM +0200, Heinrich Schuchardt wrote:
> > > On 10/22/23 17:55, Tom Rini wrote:
> > > > On Sun, Oct 22, 2023 at 10:47:33AM +0200, Heinrich Schuchardt wrote:
> > > > 
> > > > > Forward and backward compatibility of Linux kernel device-trees is
> > > > > sometimes missing. One solution approach is to load a kernel specific
> > > > > device-tree. This can either be done via a U-Boot scripts (like the one
> > > > > generated by Debian package flash-kernel or by a boot loader like GRUB.
> > > > > The boot loader approach currently requires to know the device-tree name
> > > > > before first boot which makes it unusable for generic images.
> > > > > 
> > > > > Expose the device-tree file name as EFI variable FdtFile.
> > > > > This will allow bootloaders to load a kernel specific device-tree.
> > > > > 
> > > > > The variable will not be exposed on ACPI based systems or if the
> > > > > environment variable fdtfile is not defined.
> > > > > 
> > > > > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> > > > > ---
> > > > > v3:
> > > > > 	Add documentation
> > > > > v2:
> > > > > 	Use a unique GUID to enable future U-Boot independent
> > > > > 	standardization.
> > > > > 	Do not try to add the variable on ACPI based systems.
> > > > > ---
> > > > >    doc/develop/uefi/uefi.rst  | 17 +++++++++++++++++
> > > > >    include/efi_loader.h       |  5 +++++
> > > > >    lib/efi_loader/efi_setup.c | 30 ++++++++++++++++++++++++++++++
> > > > >    3 files changed, 52 insertions(+)
> > > > > 
> > > > > diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst
> > > > > index fb16ac743a..a81d09ae81 100644
> > > > > --- a/doc/develop/uefi/uefi.rst
> > > > > +++ b/doc/develop/uefi/uefi.rst
> > > > > @@ -916,6 +916,23 @@ So our final format of the FilePathList[] is::
> > > > >        Loaded image - end node (0xff) - VenMedia - initrd_1 - [end node (0x01) - initrd_n ...] - end node (0xff)
> > > > > +EFI variable FdtFile
> > > > > +~~~~~~~~~~~~~~~~~~~~
> > > > > +
> > > > > +Ideally U-Boot would always expose a device-tree that can be used for booting
> > > > > +any operating systems. Unfortunately operating systems like Linux sometimes
> > > > > +break forward and backward compatibility. In this case there is a need to load
> > > > > +an operating system version specific device-tree.
> > > > > +
> > > > > +U-Boot has an environment variable fdtfile identifying the device-tree file to
> > > > > +load. The content of this variable is exposed as EFI variable Fdtfile, vendor
> > > > > +GUID d45dde69-3bd6-40e0-90d5-6b606aa57730. It contains the device-tree path
> > > > > +name as a NUL terminated ASCII string.
> > > > > +
> > > > > +On 32bit ARM this is currently only a file name, e.g. 'imx6dl-wandboard.dtb'.
> > > > > +On other architectures the file name is preceded by the vendor directory, e.g.
> > > > > +'rockchip/rk3326-odroid-go2.dtb'.
> > > > 
> > > > The Linux Kernel has split 32bit ARM up by directory now, too.
> > > 
> > > Since Linux v6.5. That is why I wrote "currently". Once we migrate the
> > > values of $fdtfile in U-Boot we may want to change
> > > distro_efi_try_bootflow_files() to search both with and without vendor
> > > directory.
> > > 
> > > Are there already plans for that migration?
> > 
> > Right, v6.5 is out and has this change and v6.6 will be out soon enough,
> > so the documentation we're adding here and now should be worded such
> > that doesn't get stuck on these specifics.
> 
> Should I add a sentence:
> 
> Linux v6.5 has added vendor directories on 32bit ARM and U-Boot is expected
> to follow suit.

No, please re-word the section to be more generic.  Some architectures
use vendor directories, some don't.  I really don't know what we're
going to do in U-Boot.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/1] efi_loader: expose the device-tree file name
  2023-10-22 21:31       ` Heinrich Schuchardt
  2023-10-23 16:57         ` Tom Rini
@ 2023-10-26 15:43         ` Rob Herring
  1 sibling, 0 replies; 7+ messages in thread
From: Rob Herring @ 2023-10-26 15:43 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: Tom Rini, Ilias Apalodimas, u-boot, Simon Glass

On Sun, Oct 22, 2023 at 4:32 PM Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> On 10/22/23 19:08, Tom Rini wrote:
> > On Sun, Oct 22, 2023 at 06:34:08PM +0200, Heinrich Schuchardt wrote:
> >> On 10/22/23 17:55, Tom Rini wrote:
> >>> On Sun, Oct 22, 2023 at 10:47:33AM +0200, Heinrich Schuchardt wrote:
> >>>
> >>>> Forward and backward compatibility of Linux kernel device-trees is
> >>>> sometimes missing. One solution approach is to load a kernel specific
> >>>> device-tree. This can either be done via a U-Boot scripts (like the one
> >>>> generated by Debian package flash-kernel or by a boot loader like GRUB.
> >>>> The boot loader approach currently requires to know the device-tree name
> >>>> before first boot which makes it unusable for generic images.
> >>>>
> >>>> Expose the device-tree file name as EFI variable FdtFile.
> >>>> This will allow bootloaders to load a kernel specific device-tree.
> >>>>
> >>>> The variable will not be exposed on ACPI based systems or if the
> >>>> environment variable fdtfile is not defined.
> >>>>
> >>>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> >>>> ---
> >>>> v3:
> >>>>    Add documentation
> >>>> v2:
> >>>>    Use a unique GUID to enable future U-Boot independent
> >>>>    standardization.
> >>>>    Do not try to add the variable on ACPI based systems.
> >>>> ---
> >>>>    doc/develop/uefi/uefi.rst  | 17 +++++++++++++++++
> >>>>    include/efi_loader.h       |  5 +++++
> >>>>    lib/efi_loader/efi_setup.c | 30 ++++++++++++++++++++++++++++++
> >>>>    3 files changed, 52 insertions(+)
> >>>>
> >>>> diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst
> >>>> index fb16ac743a..a81d09ae81 100644
> >>>> --- a/doc/develop/uefi/uefi.rst
> >>>> +++ b/doc/develop/uefi/uefi.rst
> >>>> @@ -916,6 +916,23 @@ So our final format of the FilePathList[] is::
> >>>>        Loaded image - end node (0xff) - VenMedia - initrd_1 - [end node (0x01) - initrd_n ...] - end node (0xff)
> >>>> +EFI variable FdtFile
> >>>> +~~~~~~~~~~~~~~~~~~~~
> >>>> +
> >>>> +Ideally U-Boot would always expose a device-tree that can be used for booting
> >>>> +any operating systems. Unfortunately operating systems like Linux sometimes
> >>>> +break forward and backward compatibility. In this case there is a need to load
> >>>> +an operating system version specific device-tree.
> >>>> +
> >>>> +U-Boot has an environment variable fdtfile identifying the device-tree file to
> >>>> +load. The content of this variable is exposed as EFI variable Fdtfile, vendor
> >>>> +GUID d45dde69-3bd6-40e0-90d5-6b606aa57730. It contains the device-tree path
> >>>> +name as a NUL terminated ASCII string.
> >>>> +
> >>>> +On 32bit ARM this is currently only a file name, e.g. 'imx6dl-wandboard.dtb'.
> >>>> +On other architectures the file name is preceded by the vendor directory, e.g.
> >>>> +'rockchip/rk3326-odroid-go2.dtb'.
> >>>
> >>> The Linux Kernel has split 32bit ARM up by directory now, too.
> >>
> >> Since Linux v6.5. That is why I wrote "currently". Once we migrate the
> >> values of $fdtfile in U-Boot we may want to change
> >> distro_efi_try_bootflow_files() to search both with and without vendor
> >> directory.
> >>
> >> Are there already plans for that migration?
> >
> > Right, v6.5 is out and has this change and v6.6 will be out soon enough,
> > so the documentation we're adding here and now should be worded such
> > that doesn't get stuck on these specifics.
>
> Should I add a sentence:
>
> Linux v6.5 has added vendor directories on 32bit ARM and U-Boot is
> expected to follow suit.

Note that while this is correct, the install (make dtbs_install) still
uses a flat directory. That was to not break existing users. It is
currently not a visible config option. Perhaps it should be if there's
a desire to move to having sub-directories for the install?

Rob

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-10-26 15:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-22  8:47 [PATCH v3 1/1] efi_loader: expose the device-tree file name Heinrich Schuchardt
2023-10-22 15:55 ` Tom Rini
2023-10-22 16:34   ` Heinrich Schuchardt
2023-10-22 17:08     ` Tom Rini
2023-10-22 21:31       ` Heinrich Schuchardt
2023-10-23 16:57         ` Tom Rini
2023-10-26 15:43         ` Rob Herring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.