Skip to contentSkip to conversation

arm/efi: Add dom0less support to UEFI boot

PATCH Superseded Luca Fancellu 5 participants 12 messages Oct 11, 2021

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover arm/efi: Add dom0less support to UEFI boot

This serie introduces a way to start a dom0less setup when Xen is booting as EFI application.
Using the device tree it's now possible to fetch from the disk and load in memory all the modules needed to start any domU defined in the DT. Dom0less for now is supported only by the arm architecture.

This serie was originally formed by 3 patch, the first one was merged.

Luca Fancellu (2):
arm/efi: Use dom0less configuration when using EFI boot arm/efi: load dom0 modules from DT using UEFI

 docs/misc/arm/device-tree/booting.txt |  29 +++
 docs/misc/efi.pandoc                  | 261 +++++++++++++++++++
 xen/arch/arm/efi/efi-boot.h           | 344 +++++++++++++++++++++++++-
 xen/common/efi/boot.c                 |  55 ++--
 4 files changed, 672 insertions(+), 17 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v5 1/2 arm/efi: Use dom0less configuration when using EFI boot

This patch introduces the support for dom0less configuration when using UEFI boot on ARM, it permits the EFI boot to continue if no dom0 kernel is specified but at least one domU is found.

Introduce the new property "xen,uefi-binary" for device tree boot module nodes that are subnode of "xen,domain" compatible nodes. The property holds a string containing the file name of the binary that shall be loaded by the uefi loader from the filesystem.

Introduce a new call efi_check_dt_boot(...) called during EFI boot that checks for module to be loaded using device tree. Architectures that don't support device tree don't have to provide this function.

Update efi documentation about how to start a dom0less setup using UEFI

---
Changes in v5:
- Removed unneeded variable initialization
- Fixed comment
- Fixed error message for the absence of an initial domain kernel
- changed efi_arch_check_dt_boot to efi_check_dt_boot and add a stub if CONFIG_HAS_DEVICE_TREE is not declared, updated commit message about the call introduction in the EFI boot flow. Changes in v4:
- update uefi,cfg-load to xen,uefi-cfg-load in documentation
- fixed comments and code style
- changed variable name from dt_module_found to dt_modules_found in boot.c
- removed stub efi_arch_check_dt_boot from x86 code because the architecture does not support DT, protected call with #ifdef in the common code.
- add comment to explain the result from efi_arch_check_dt_boot just looking the common code
- Add space before comment in boot.c
- renamed uefi,binary property to xen,uefi-binary Changes in v3:
- fixed documentation
- fixed name len in strlcpy
- fixed some style issues
- closed filesystem handle before calling blexit
- passed runtime errors up to the stack instead
of calling blexit
- renamed names and function to make them more
general in prevision to load also Dom0 kernel
and ramdisk from DT
Changes in v2:
- remove array of struct file
- fixed some int types
- Made the code use filesystem even when configuration file is skipped.
- add documentation of uefi,binary in booting.txt
- add documentation on how to boot all configuration for Xen using UEFI in efi.pandoc

---
 docs/misc/arm/device-tree/booting.txt |  21 ++
 docs/misc/efi.pandoc                  | 203 +++++++++++++++++
 xen/arch/arm/efi/efi-boot.h           | 305 +++++++++++++++++++++++++-
 xen/common/efi/boot.c                 |  39 +++-
 4 files changed, 556 insertions(+), 12 deletions(-)
docs/misc/arm/device-tree/booting.txt +21 -0
index 352b0ec43a..7258e7e1ec 100644
@@ -190,6 +190,13 @@ The kernel sub-node has the following properties:
 
     Command line parameters for the guest kernel.
 
+- xen,uefi-binary (UEFI boot only)
+
+    String property that specifies the file name to be loaded by the UEFI boot
+    for this module. If this is specified, there is no need to specify the reg
+    property because it will be created by the UEFI stub on boot.
+    This option is needed only when UEFI boot is used.
+
 The ramdisk sub-node has the following properties:
 
 - compatible
@@ -201,6 +208,13 @@ The ramdisk sub-node has the following properties:
     Specifies the physical address of the ramdisk in RAM and its
     length.
 
+- xen,uefi-binary (UEFI boot only)
+
+    String property that specifies the file name to be loaded by the UEFI boot
+    for this module. If this is specified, there is no need to specify the reg
+    property because it will be created by the UEFI stub on boot.
+    This option is needed only when UEFI boot is used.
+
 
 Example
 =======
@@ -265,6 +279,13 @@ The dtb sub-node should have the following properties:
     Specifies the physical address of the device tree binary fragment
     RAM and its length.
 
+- xen,uefi-binary (UEFI boot only)
+
+    String property that specifies the file name to be loaded by the UEFI boot
+    for this module. If this is specified, there is no need to specify the reg
+    property because it will be created by the UEFI stub on boot.
+    This option is needed only when UEFI boot is used.
+
 As an example:
 
         module@0xc000000 {
docs/misc/efi.pandoc +203 -0

206 lines not on this page · raw message

xen/arch/arm/efi/efi-boot.h +304 -1

329 lines not on this page · raw message

xen/common/efi/boot.c +28 -11
index 758f9d74d2..7879b93f93 100644
@@ -166,6 +166,13 @@ static void __init PrintErr(const CHAR16 *s)
     StdErr->OutputString(StdErr, (CHAR16 *)s );
 }
 
+#ifndef CONFIG_HAS_DEVICE_TREE
+static inline int __init efi_check_dt_boot(EFI_FILE_HANDLE dir_handle)
+{
+    return 0;
+}
+#endif
+
 /*
  * Include architecture specific implementation here, which references the
  * static globals defined above.
@@ -1136,6 +1143,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
     bool base_video = false;
     const char *option_str;
     bool use_cfg_file;
+    int dt_modules_found;
+    EFI_FILE_HANDLE dir_handle;
 
     __set_bit(EFI_BOOT, &efi_flags);
     __set_bit(EFI_LOADER, &efi_flags);
@@ -1216,9 +1225,11 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
 
     efi_arch_relocate_image(0);
 
+    /* Get the file system interface. */
+    dir_handle = get_parent_handle(loaded_image, &file_name);
+
     if ( use_cfg_file )
     {
-        EFI_FILE_HANDLE dir_handle;
         UINTN depth, cols, rows, size;
 
         size = cols = rows = depth = 0;
@@ -1229,9 +1240,6 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
 
         gop = efi_get_gop();
 
-        /* Get the file system interface. */
-        dir_handle = get_parent_handle(loaded_image, &file_name);
-
         /* Read and parse the config file. */
         if ( read_section(loaded_image, L"config", &cfg, NULL) )
             PrintStr(L"Using builtin config file\r\n");
@@ -1285,14 +1293,12 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
             efi_bs->FreePool(name.w);
         }
 
-        if ( !name.s )
-            blexit(L"No Dom0 kernel image specified.");
-
         efi_arch_cfg_file_early(loaded_image, dir_handle, section.s);
 
-        option_str = split_string(name.s);
+        option_str = name.s ? split_string(name.s) : NULL;
 
-        if ( !read_section(loaded_image, L"kernel", &kernel, option_str) )
+        if ( !read_section(loaded_image, L"kernel", &kernel, option_str) &&
+             name.s )
         {
             read_file(dir_handle, s2w(&name), &kernel, option_str);
             efi_bs->FreePool(name.w);
@@ -1361,12 +1367,23 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
         efi_bs->FreePages(cfg.addr, PFN_UP(cfg.size));
         cfg.addr = 0;
 
-        dir_handle->Close(dir_handle);
-
         if ( gop && !base_video )
             gop_mode = efi_find_gop_mode(gop, cols, rows, depth);
     }
 
+    /* Get the number of boot modules specified on the DT or an error (<0) */
+    dt_modules_found = efi_check_dt_boot(dir_handle);
+
+    dir_handle->Close(dir_handle);
+
+    if ( dt_modules_found < 0 )
+        /* efi_check_dt_boot throws some error */
+        blexit(L"Error processing boot modules on DT.");
+
+    /* Check if at least one of Dom0 or DomU(s) is specified */
+    if ( !dt_modules_found && !kernel.ptr )
+        blexit(L"No initial domain kernel specified.");
+
     efi_arch_edd();
 
     /* XXX Collect EDID info. */
Signature · 1 line
2.17.1
Acked-by on v5 1/2
#2 lore raw

Re: [PATCH v5 1/2] arm/efi: Use dom0less configuration when using EFI boot

Quoted 15 lines · Luca Fancellu

This patch introduces the support for dom0less configuration when using UEFI boot on ARM, it permits the EFI boot to continue if no dom0 kernel is specified but at least one domU is found.

Introduce the new property "xen,uefi-binary" for device tree boot module nodes that are subnode of "xen,domain" compatible nodes. The property holds a string containing the file name of the binary that shall be loaded by the uefi loader from the filesystem.

Introduce a new call efi_check_dt_boot(...) called during EFI boot that checks for module to be loaded using device tree. Architectures that don't support device tree don't have to provide this function.

Quoted 6 lines

Update efi documentation about how to start a dom0less setup using UEFI

Did you get indication that these are fine to retain with ...

Quoted 8 lines

---
Changes in v5:
- Removed unneeded variable initialization
- Fixed comment
- Fixed error message for the absence of an initial domain kernel
- changed efi_arch_check_dt_boot to efi_check_dt_boot and add a stub if CONFIG_HAS_DEVICE_TREE is not declared, updated commit message about the call introduction in the EFI boot flow.

... all of these changes? Every individual change may be minor enough, but their sum makes me wonder. If so (or if at least one of the two gets re-offered)

albeit preferably with ...

xen/common/efi/boot.c static void __init PrintErr(const CHAR16 *s) · line 170

Quoted 8 lines
xen/common/efi/boot.c +2 -0
@@ -166,6 +166,13 @@ static void __init PrintErr(const CHAR16 *s)
     StdErr->OutputString(StdErr, (CHAR16 *)s );
 }
 
+#ifndef CONFIG_HAS_DEVICE_TREE
+static inline int __init efi_check_dt_boot(EFI_FILE_HANDLE dir_handle)

... the "inline" here dropped. We don't normally add this outside of headers, leaving it to the compiler to decide. In headers it's wanted to avoid "defined by never used" style warnings.

Jan

#3 lore raw

Re: [PATCH v5 1/2] arm/efi: Use dom0less configuration when using EFI boot

Quoted 50 lines · Jan Beulich
Quoted 15 lines · Luca Fancellu

This patch introduces the support for dom0less configuration when using UEFI boot on ARM, it permits the EFI boot to continue if no dom0 kernel is specified but at least one domU is found.

Introduce the new property "xen,uefi-binary" for device tree boot module nodes that are subnode of "xen,domain" compatible nodes. The property holds a string containing the file name of the binary that shall be loaded by the uefi loader from the filesystem.

Introduce a new call efi_check_dt_boot(...) called during EFI boot that checks for module to be loaded using device tree. Architectures that don't support device tree don't have to provide this function.

Quoted 6 lines

Update efi documentation about how to start a dom0less setup using UEFI

Did you get indication that these are fine to retain with ...

Quoted 8 lines

---
Changes in v5:
- Removed unneeded variable initialization
- Fixed comment
- Fixed error message for the absence of an initial domain kernel
- changed efi_arch_check_dt_boot to efi_check_dt_boot and add a stub if CONFIG_HAS_DEVICE_TREE is not declared, updated commit message about the call introduction in the EFI boot flow.

... all of these changes? Every individual change may be minor enough, but their sum makes me wonder. If so (or if at least one of the two gets re-offered)

albeit preferably with ...

Quoted 6 lines
xen/common/efi/boot.c +0 -0
@@ -166,6 +166,13 @@ static void __init PrintErr(const CHAR16 *s)
    StdErr->OutputString(StdErr, (CHAR16 *)s );
 }
 
Quoted 6 lines

xen/common/efi/boot.c static void __init PrintErr(const CHAR16 *s) · line 170

Quoted 2 lines
xen/common/efi/boot.c +2 -0
+#ifndef CONFIG_HAS_DEVICE_TREE
+static inline int __init efi_check_dt_boot(EFI_FILE_HANDLE dir_handle)

... the "inline" here dropped. We don't normally add this outside of headers, leaving it to the compiler to decide. In headers it's wanted to avoid "defined by never used" style warnings.

Hi Jan,

Ok I can drop it in a next serie and retain your Ack, or is it something that can be done on commit?

Cheers,
Luca

Quoted 2 lines

Jan

#4 lore raw

Re: [PATCH v5 1/2] arm/efi: Use dom0less configuration when using EFI boot

Quoted 54 lines · Luca Fancellu
Quoted 47 lines · Jan Beulich
Quoted 15 lines · Luca Fancellu

This patch introduces the support for dom0less configuration when using UEFI boot on ARM, it permits the EFI boot to continue if no dom0 kernel is specified but at least one domU is found.

Introduce the new property "xen,uefi-binary" for device tree boot module nodes that are subnode of "xen,domain" compatible nodes. The property holds a string containing the file name of the binary that shall be loaded by the uefi loader from the filesystem.

Introduce a new call efi_check_dt_boot(...) called during EFI boot that checks for module to be loaded using device tree. Architectures that don't support device tree don't have to provide this function.

Quoted 6 lines

Update efi documentation about how to start a dom0less setup using UEFI

Did you get indication that these are fine to retain with ...

Quoted 8 lines

---
Changes in v5:
- Removed unneeded variable initialization
- Fixed comment
- Fixed error message for the absence of an initial domain kernel
- changed efi_arch_check_dt_boot to efi_check_dt_boot and add a stub if CONFIG_HAS_DEVICE_TREE is not declared, updated commit message about the call introduction in the EFI boot flow.

... all of these changes? Every individual change may be minor enough, but their sum makes me wonder. If so (or if at least one of the two gets re-offered)

albeit preferably with ...

Quoted 6 lines
xen/common/efi/boot.c +0 -0
@@ -166,6 +166,13 @@ static void __init PrintErr(const CHAR16 *s)
    StdErr->OutputString(StdErr, (CHAR16 *)s );
 }
 
Quoted 6 lines

xen/common/efi/boot.c static void __init PrintErr(const CHAR16 *s) · line 170

Quoted 2 lines
xen/common/efi/boot.c +2 -0
+#ifndef CONFIG_HAS_DEVICE_TREE
+static inline int __init efi_check_dt_boot(EFI_FILE_HANDLE dir_handle)

... the "inline" here dropped. We don't normally add this outside of headers, leaving it to the compiler to decide. In headers it's wanted to avoid "defined by never used" style warnings.

Quoted 2 lines

Ok I can drop it in a next serie and retain your Ack, or is it something that can be done on commit?

I guess that's easy enough to do while committing. Provided of course the two R-b get confirmed.

Jan

#5 lore raw

Re: [PATCH v5 1/2] arm/efi: Use dom0less configuration when using EFI boot

Hi Jan,

Quoted 57 lines · Jan Beulich
Quoted 54 lines · Luca Fancellu
Quoted 53 lines · Jan Beulich
Quoted 15 lines · Luca Fancellu

This patch introduces the support for dom0less configuration when using UEFI boot on ARM, it permits the EFI boot to continue if no dom0 kernel is specified but at least one domU is found.

Introduce the new property "xen,uefi-binary" for device tree boot module nodes that are subnode of "xen,domain" compatible nodes. The property holds a string containing the file name of the binary that shall be loaded by the uefi loader from the filesystem.

Introduce a new call efi_check_dt_boot(...) called during EFI boot that checks for module to be loaded using device tree. Architectures that don't support device tree don't have to provide this function.

Quoted 6 lines

Update efi documentation about how to start a dom0less setup using UEFI

Did you get indication that these are fine to retain with ...

Quoted 8 lines

---
Changes in v5:
- Removed unneeded variable initialization
- Fixed comment
- Fixed error message for the absence of an initial domain kernel
- changed efi_arch_check_dt_boot to efi_check_dt_boot and add a stub if CONFIG_HAS_DEVICE_TREE is not declared, updated commit message about the call introduction in the EFI boot flow.

... all of these changes? Every individual change may be minor enough, but their sum makes me wonder. If so (or if at least one of the two gets re-offered)

albeit preferably with ...

xen/common/efi/boot.c static void __init PrintErr(const CHAR16 *s) · line 170

Quoted 8 lines
xen/common/efi/boot.c +2 -0
@@ -166,6 +166,13 @@ static void __init PrintErr(const CHAR16 *s)
   StdErr->OutputString(StdErr, (CHAR16 *)s );
 }
 
+#ifndef CONFIG_HAS_DEVICE_TREE
+static inline int __init efi_check_dt_boot(EFI_FILE_HANDLE dir_handle)

... the "inline" here dropped. We don't normally add this outside of headers, leaving it to the compiler to decide. In headers it's wanted to avoid "defined by never used" style warnings.

Quoted 5 lines
Quoted 2 lines

Ok I can drop it in a next serie and retain your Ack, or is it something that can be done on commit?

I guess that's easy enough to do while committing. Provided of course the two R-b get confirmed.

I confirm my R-b.

Cheers
Bertrand

Quoted 2 lines

Jan

#6 lore raw

Re: [PATCH v5 1/2] arm/efi: Use dom0less configuration when using EFI boot

Quoted 59 lines · Bertrand Marquis

Hi Jan,

Quoted 57 lines · Jan Beulich
Quoted 54 lines · Luca Fancellu
Quoted 53 lines · Jan Beulich
Quoted 15 lines · Luca Fancellu

This patch introduces the support for dom0less configuration when using UEFI boot on ARM, it permits the EFI boot to continue if no dom0 kernel is specified but at least one domU is found.

Introduce the new property "xen,uefi-binary" for device tree boot module nodes that are subnode of "xen,domain" compatible nodes. The property holds a string containing the file name of the binary that shall be loaded by the uefi loader from the filesystem.

Introduce a new call efi_check_dt_boot(...) called during EFI boot that checks for module to be loaded using device tree. Architectures that don't support device tree don't have to provide this function.

Quoted 6 lines

Update efi documentation about how to start a dom0less setup using UEFI

Did you get indication that these are fine to retain with ...

Quoted 8 lines

---
Changes in v5:
- Removed unneeded variable initialization
- Fixed comment
- Fixed error message for the absence of an initial domain kernel
- changed efi_arch_check_dt_boot to efi_check_dt_boot and add a stub if CONFIG_HAS_DEVICE_TREE is not declared, updated commit message about the call introduction in the EFI boot flow.

... all of these changes? Every individual change may be minor enough, but their sum makes me wonder. If so (or if at least one of the two gets re-offered)

albeit preferably with ...

xen/common/efi/boot.c static void __init PrintErr(const CHAR16 *s) · line 170

Quoted 8 lines
xen/common/efi/boot.c +2 -0
@@ -166,6 +166,13 @@ static void __init PrintErr(const CHAR16 *s)
   StdErr->OutputString(StdErr, (CHAR16 *)s );
 }
 
+#ifndef CONFIG_HAS_DEVICE_TREE
+static inline int __init efi_check_dt_boot(EFI_FILE_HANDLE dir_handle)

... the "inline" here dropped. We don't normally add this outside of headers, leaving it to the compiler to decide. In headers it's wanted to avoid "defined by never used" style warnings.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Ok I can drop it in a next serie and retain your Ack, or is it something that can be done on commit?

I guess that's easy enough to do while committing. Provided of course the two R-b get confirmed.

I confirm my R-b.

I also confirm my reviewed-by. Also, I am aware of the change suggested by Julien about using multiboot,module for the is_boot_module check and I am fine with it too.

#7 lore raw

Re: [PATCH v5 1/2] arm/efi: Use dom0less configuration when using EFI boot

In reply to Luca Fancellu

Hi Luca,

xen/arch/arm/efi/efi-boot.h static void __init efi_arch_handle_module(const struct file *file, · line 757

Quoted 9 lines · Luca Fancellu
xen/arch/arm/efi/efi-boot.h +9 -0
+static bool __init is_boot_module(int dt_module_offset)
+{
+    if ( (fdt_node_check_compatible(fdt, dt_module_offset,
+                                    "multiboot,kernel") == 0) ||
+         (fdt_node_check_compatible(fdt, dt_module_offset,
+                                    "multiboot,ramdisk") == 0) ||
+         (fdt_node_check_compatible(fdt, dt_module_offset,
+                                    "multiboot,device-tree") == 0) )
+        return true;

A boot module *must* have the compatible "multiboot,module". I would prefer if we simply check that "multiboot,module" is present.

This will also make easier to add new boot module in the future.

xen/arch/arm/efi/efi-boot.h static void __init efi_arch_handle_module(const struct file *file, · line 761

Quoted 4 lines
xen/arch/arm/efi/efi-boot.h +4 -0
+
+    return false;
+}
+

Cheers,

Signature · 1 line
Julien Grall
#8 lore raw

Re: [PATCH v5 1/2] arm/efi: Use dom0less configuration when using EFI boot

Quoted 6 lines · Julien Grall

Hi Luca,

Hi Julien,

Quoted 13 lines · Luca Fancellu

xen/arch/arm/efi/efi-boot.h static void __init efi_arch_handle_module(const struct file *file, · line 757

Quoted 9 lines
xen/arch/arm/efi/efi-boot.h +9 -0
+static bool __init is_boot_module(int dt_module_offset)
+{
+    if ( (fdt_node_check_compatible(fdt, dt_module_offset,
+                                    "multiboot,kernel") == 0) ||
+         (fdt_node_check_compatible(fdt, dt_module_offset,
+                                    "multiboot,ramdisk") == 0) ||
+         (fdt_node_check_compatible(fdt, dt_module_offset,
+                                    "multiboot,device-tree") == 0) )
+        return true;

A boot module *must* have the compatible "multiboot,module". I would prefer if we simply check that "multiboot,module" is present.

Quoted 1 line

This will also make easier to add new boot module in the future.

I thought that also the XSM policy was a multiboot,module so I checked explicitly for kernel, ramdisk, device-tree that are supported by domU.

Do you still think that I should check just for multiboot,module instead?

Cheers,
Luca

Quoted 9 lines

xen/arch/arm/efi/efi-boot.h static void __init efi_arch_handle_module(const struct file *file, · line 761

Quoted 5 lines
xen/arch/arm/efi/efi-boot.h +4 -0
+
+    return false;
+}
+

Cheers,

Signature · 1 line
Julien Grall
#9 lore raw

Re: [PATCH v5 1/2] arm/efi: Use dom0less configuration when using EFI boot

Hi Luca,

Quoted 22 lines · Luca Fancellu
Quoted 6 lines · Julien Grall

Hi Luca,

Hi Julien,

Quoted 13 lines · Luca Fancellu

xen/arch/arm/efi/efi-boot.h static void __init efi_arch_handle_module(const struct file *file, · line 757

Quoted 9 lines
xen/arch/arm/efi/efi-boot.h +9 -0
+static bool __init is_boot_module(int dt_module_offset)
+{
+    if ( (fdt_node_check_compatible(fdt, dt_module_offset,
+                                    "multiboot,kernel") == 0) ||
+         (fdt_node_check_compatible(fdt, dt_module_offset,
+                                    "multiboot,ramdisk") == 0) ||
+         (fdt_node_check_compatible(fdt, dt_module_offset,
+                                    "multiboot,device-tree") == 0) )
+        return true;

A boot module *must* have the compatible "multiboot,module". I would prefer if we simply check that "multiboot,module" is present.

Quoted 4 lines
Quoted 1 line

This will also make easier to add new boot module in the future.

I thought that also the XSM policy was a multiboot,module so I checked explicitly for kernel, ramdisk, device-tree that are supported by domU.

The XSM policy is indeed a multiboot module and should not be used by the domU.

Quoted 2 lines

Do you still think that I should check just for multiboot,module instead?

Yes please. I think this is not the EFI stub job to check that the most specific compatible is correct.

Cheers,

Signature · 1 line
Julien Grall
#10 lore raw

Re: [PATCH v5 1/2] arm/efi: Use dom0less configuration when using EFI boot

Quoted 26 lines · Julien Grall

Hi Luca,

Quoted 19 lines · Luca Fancellu
Quoted 4 lines · Julien Grall

Hi Luca,

Hi Julien,

Quoted 14 lines · Luca Fancellu

xen/arch/arm/efi/efi-boot.h static void __init efi_arch_handle_module(const struct file *file, · line 757

Quoted 9 lines
xen/arch/arm/efi/efi-boot.h +9 -0
+static bool __init is_boot_module(int dt_module_offset)
+{
+    if ( (fdt_node_check_compatible(fdt, dt_module_offset,
+                                    "multiboot,kernel") == 0) ||
+         (fdt_node_check_compatible(fdt, dt_module_offset,
+                                    "multiboot,ramdisk") == 0) ||
+         (fdt_node_check_compatible(fdt, dt_module_offset,
+                                    "multiboot,device-tree") == 0) )
+        return true;

A boot module *must* have the compatible "multiboot,module". I would prefer if we simply check that "multiboot,module" is present.

This will also make easier to add new boot module in the future.

Quoted 8 lines
Quoted 2 lines

I thought that also the XSM policy was a multiboot,module so I checked explicitly for kernel, ramdisk, device-tree that are supported by domU.

The XSM policy is indeed a multiboot module and should not be used by the domU.

Quoted 1 line

Do you still think that I should check just for multiboot,module instead?

Yes please. I think this is not the EFI stub job to check that the most specific compatible is correct.

Ok, I will push the v6 with this change.

Cheers,
Luca

Quoted 5 lines

Cheers,

Signature · 1 line
Julien Grall
#11 lore raw

PATCH v5 2/2 arm/efi: load dom0 modules from DT using UEFI

In reply to Luca Fancellu

Add support to load Dom0 boot modules from the device tree using the xen,uefi-binary property.

Update documentation about that.

---
Changes in v5:
- renamed missing uefi,binary string
- used kernel.ptr instead of kernel.addr to be consistent to the surrounding code
- Changed a comment referring to efi_arch_check_dt_boot that now is efi_check_dt_boot
Changes in v4:
- Add check to avoid double definition of Dom0 ramdisk from cfg file and DT
- Fix if conditions indentation in boot.c
- Moved Dom0 kernel verification code after check for presence for Dom0 or DomU(s)
- Changed uefi,binary property to xen,uefi-binary Changes in v3:
- new patch

---
 docs/misc/arm/device-tree/booting.txt |  8 ++++
 docs/misc/efi.pandoc                  | 64 +++++++++++++++++++++++++--
 xen/arch/arm/efi/efi-boot.h           | 47 ++++++++++++++++++--
 xen/common/efi/boot.c                 | 16 ++++---
 4 files changed, 123 insertions(+), 12 deletions(-)
docs/misc/arm/device-tree/booting.txt +8 -0
index 7258e7e1ec..c6a775f4e8 100644
@@ -70,6 +70,14 @@ Each node contains the following properties:
 	priority of this field vs. other mechanisms of specifying the
 	bootargs for the kernel.
 
+- xen,uefi-binary (UEFI boot only)
+
+	String property that specifies the file name to be loaded by the UEFI
+	boot for this module. If this is specified, there is no need to specify
+	the reg property because it will be created by the UEFI stub on boot.
+	This option is needed only when UEFI boot is used, the node needs to be
+	compatible with multiboot,kernel or multiboot,ramdisk.
+
 Examples
 ========
 
docs/misc/efi.pandoc +61 -3

81 lines not on this page · raw message

xen/arch/arm/efi/efi-boot.h +43 -4

91 lines not on this page · raw message

xen/common/efi/boot.c +11 -5
index 7879b93f93..531975326f 100644
@@ -1302,11 +1302,6 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
         {
             read_file(dir_handle, s2w(&name), &kernel, option_str);
             efi_bs->FreePool(name.w);
-
-            if ( !EFI_ERROR(efi_bs->LocateProtocol(&shim_lock_guid, NULL,
-                            (void **)&shim_lock)) &&
-                 (status = shim_lock->Verify(kernel.ptr, kernel.size)) != EFI_SUCCESS )
-                PrintErrMesg(L"Dom0 kernel image could not be verified", status);
         }
 
         if ( !read_section(loaded_image, L"ramdisk", &ramdisk, NULL) )
@@ -1384,6 +1379,17 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
     if ( !dt_modules_found && !kernel.ptr )
         blexit(L"No initial domain kernel specified.");
 
+    /*
+     * The Dom0 kernel can be loaded from the configuration file or by the
+     * device tree through the efi_check_dt_boot function, in this stage
+     * verify it.
+     */
+    if ( kernel.ptr &&
+         !EFI_ERROR(efi_bs->LocateProtocol(&shim_lock_guid, NULL,
+                                           (void **)&shim_lock)) &&
+         (status = shim_lock->Verify(kernel.ptr, kernel.size)) != EFI_SUCCESS )
+        PrintErrMesg(L"Dom0 kernel image could not be verified", status);
+
     efi_arch_edd();
 
     /* XXX Collect EDID info. */
Signature · 1 line
2.17.1