Bli: fix hidden module dependency
cover Bli: fix hidden module dependency
The bli module has a hidden/implicit dependency on the part_gpt module. The part_gpt module has to be loaded before the bli module. This dependency is not picked up automatically by the build system because the bli module does not use any function of part_gpt. It just expects Grub to be able to parse GPT formatted disks.
This series introduces a mechanism that allows specifying module dependencies explicitly in a new file called explicit_dependencies.lst.
An explicit dependency is then added for the bli module on the part_gpt module.
Oliver Steffen (2):
Allow explicit module dependencies
bli: Add explicit dependency on the part_gpt module
grub-core/Makefile.am | 4 ++-- grub-core/explicit_dependencies.lst | 1 + grub-core/genmoddep.awk | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 grub-core/explicit_dependencies.lst
Signature · 7 lines
2.41.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 1/2 Allow explicit module dependencies
The build system deduces inter-module dependencies from the symbols required and exported by the modules. This works well, except for some rare cases where the dependency is indirect or hidden. A module might not make use of any function of some other module, but still expect its functionality to be available to Grub.
To solve this, introduce a new file (currently empty) called explicit_depdendencies.lst to track these cases manually. This file gets processed in the same way as the (automatically generated) syminfo.lst, making it possible to inject data into the dependency resolver.
Additionally, introduce a new keyword for the syminfo.lst syntax:
"depends" allows specifying a module dependency directly:
depends <module> <depdendency>...
--- grub-core/Makefile.am | 4 ++-- grub-core/explicit_dependencies.lst | 0 grub-core/genmoddep.awk | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 grub-core/explicit_dependencies.lst
grub-core/Makefile.am +2 -2
@@ -452,8 +452,8 @@ crypto.lst: $(srcdir)/lib/libgcrypt-grub/cipher/crypto.lst platform_DATA += crypto.lst CLEANFILES += crypto.lst -syminfo.lst: gensyminfo.sh kernel_syms.lst $(MODULE_FILES) - cat kernel_syms.lst > [email protected] +syminfo.lst: gensyminfo.sh kernel_syms.lst explicit_dependencies.lst $(MODULE_FILES) + cat kernel_syms.lst explicit_dependencies.lst > [email protected] for m in $(MODULE_FILES); do \ sh $< $$m >> [email protected] || exit 1; \ done
grub-core/explicit_dependencies.lst new file +0 -0
grub-core/genmoddep.awk +4 -0
@@ -31,6 +31,10 @@ BEGIN { printf "%s in %s is not defined\n", $3, $2 >"/dev/stderr"; error++; } + } else if ($1 == "depends") { + for (i = 3; i <= NF; i++) { + modtab[$2] = modtab[$2] " " $i; + } } else { printf "error: %u: unrecognized input format\n", NR >"/dev/stderr";
Signature · 7 lines
2.41.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 2/2 bli: Add explicit dependency on the part_gpt module
In reply to Oliver SteffenThe bli module has a "hidden" dependency on the part_gpt module, which is not picked up automatically by the build system. Without the part_gpt module, bli does not function correctly. Since bli does its work in the module initialization function, the order in which the modules are loaded is also important:part_gpt needs to be loaded before the bli module.
To solve this, track this dependency explicitly.
--- grub-core/explicit_dependencies.lst | 1 + 1 file changed, 1 insertion(+)
grub-core/explicit_dependencies.lst +1 -0
@@ -0,0 +1 @@ +depends bli part_gpt
Signature · 7 lines
2.41.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
In general series looks good. Few comments:
* I'm unsure about the name. It seems to suggest that people put the dependencies there by default while in fact it's the last place for it. Maybe extra_deps.lst?
* EFI supports both GPT and msdos. GPT is a more common choice but I still think that a dependency on part_msdos is warranted
* Please elaborate commit message as to why bli needs those mods rather than "not functions properly". Detail that it needs to identify partitions.
Quoted 16 lines · Oliver Steffen
The bli module has a hidden/implicit dependency on the
part_gptmodule. Thepart_gptmodule has to be loaded before the bli module. This dependency is not picked up automatically by the build system because the bli module does not use any function ofpart_gpt. It just expects Grub to be able to parse GPT formatted disks.This series introduces a mechanism that allows specifying module dependencies explicitly in a new file called explicit_dependencies.lst.
An explicit dependency is then added for the bli module on the
part_gptmodule.Oliver Steffen (2):
Allow explicit module dependencies
bli: Add explicit dependency on thepart_gptmodule
Quoted 10 lines
grub-core/Makefile.am | 4 ++-- grub-core/explicit_dependencies.lst | 1 + grub-core/genmoddep.awk | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 grub-core/explicit_dependencies.lst--
2.41.0
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoting Vladimir 'phcoder' Serbinenko (2023-11-14 19:21:49)
Quoted 5 lines
In general series looks good. Few comments:
* I'm unsure about the name. It seems to suggest that people put the dependencies there by default while in fact it's the last place for it. Maybe extra_deps.lst?
Sounds good to me.
Are we ok with the '.lst' extension? Files of this type are listed in .gitignore and this would be an exception.
Quoted 2 lines
* EFI supports both GPT and msdos. GPT is a more common choice but I still think that a dependency on
part_msdosis warranted
bli does not make use of msdos partitions. It ignores them.
bli implements a small part of the Boot Loader Interface spec [1], by setting some EFI variables that are later consumed by systemd. One of them contains the GPT UUID of the ESP/the partition used during boot. This is needed to make systemd's partition autodetection work [2,3]. All of this is build around GPT and uses the UUIDs of GPTm and does not work with msdos formatted disks.
[1] https://systemd.io/BOOT_LOADER_INTERFACE/
[2] https://www.freedesktop.org/software/systemd/man/systemd-gpt-auto-generator.html
[3] https://uapi-group.org/specifications/specs/discoverable_partitions_specification
Quoted 2 lines
* Please elaborate commit message as to why bli needs those mods rather than "not functions properly". Detail that it needs to identify partitions.
I can do that.
bli tries to read the UUID of the ESP/the partition Grub was loaded from. If that is not GPT or otherwise not reachable, then it does not set the corresponding EFI variable, but c
Quoted 18 lines
Le mar. 14 nov. 2023, 17:45, Oliver Steffen <[email protected]> a écrit :
The bli module has a hidden/implicit dependency on the
part_gptmodule. Thepart_gptmodule has to be loaded before the bli module. This dependency is not picked up automatically by the build system because the bli module does not use any function ofpart_gpt. It just expects Grub to be able to parse GPT formatted disks.This series introduces a mechanism that allows specifying module dependencies explicitly in a new file called explicit_dependencies.lst.
An explicit dependency is then added for the bli module on the
part_gptmodule.Oliver Steffen (2):
Allow explicit module dependencies
bli: Add explicit dependency on thepart_gptmodule
Quoted 10 lines
grub-core/Makefile.am | 4 ++-- grub-core/explicit_dependencies.lst | 1 + grub-core/genmoddep.awk | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 grub-core/explicit_dependencies.lst
--
2.41.0
Thank you for the comments!
Oliver
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 10 lines · Oliver Steffen
Quoting Vladimir 'phcoder' Serbinenko (2023-11-14 19:21:49)
Quoted 5 lines
In general series looks good. Few comments:
* I'm unsure about the name. It seems to suggest that people put the dependencies there by default while in fact it's the last place for it. Maybe extra_deps.lst?Sounds good to me.
Are we ok with the '.lst' extension? Files of this type are listed in .gitignore and this would be an exception.
I think we can live with lst extension if we do not come up with something better.
Quoted 12 lines
Quoted 2 lines
* EFI supports both GPT and msdos. GPT is a more common choice but I still think that a dependency on
part_msdosis warrantedbli does not make use of msdos partitions. It ignores them.
bli implements a small part of the Boot Loader Interface spec [1], by setting some EFI variables that are later consumed by systemd. One of them contains the GPT UUID of the ESP/the partition used during boot. This is needed to make systemd's partition autodetection work [2,3]. All of this is build around GPT and uses the UUIDs of GPTm and does not work with msdos formatted disks.
Quoted 3 lines
[1] https://systemd.io/BOOT_LOADER_INTERFACE/
[2] https://www.freedesktop.org/software/systemd/man/systemd-gpt-auto-generator.html
[3] https://uapi-group.org/specifications/specs/discoverable_partitions_specification
I expected that Boot Loader Interface does not use MBR at all and rely entirely on GPT. However, I think we should make it clear in the GRUB documentation to avoid complaints/confusion/... in the future. Oliver, could you add relevant blurb to docs?
Quoted 7 lines
Quoted 2 lines
* Please elaborate commit message as to why bli needs those mods rather than "not functions properly". Detail that it needs to identify partitions.
I can do that.
bli tries to read the UUID of the ESP/the partition Grub was loaded from. If that is not GPT or otherwise not reachable, then it does not set the corresponding EFI variable, but c
Yeah, more or less like that makes sense for me.
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoting Daniel Kiper (2023-11-15 15:14:50)
Quoted 7 lines · Oliver Steffen
Quoted 6 lines
Quoting Vladimir 'phcoder' Serbinenko (2023-11-14 19:21:49)
Quoted 5 lines
In general series looks good. Few comments:
* I'm unsure about the name. It seems to suggest that people put the dependencies there by default while in fact it's the last place for it. Maybe extra_deps.lst?
Quoted 7 lines
Quoted 4 lines
Sounds good to me.
Are we ok with the '.lst' extension? Files of this type are listed in .gitignore and this would be an exception.
I think we can live with lst extension if we do not come up with something better.
Ok.
Quoted 13 lines
Quoted 13 lines
Quoted 3 lines
* EFI supports both GPT and msdos. GPT is a more common choice but I still think that a dependency on
part_msdosis warrantedbli does not make use of msdos partitions. It ignores them.
bli implements a small part of the Boot Loader Interface spec [1], by setting some EFI variables that are later consumed by systemd. One of them contains the GPT UUID of the ESP/the partition used during boot. This is needed to make systemd's partition autodetection work [2,3]. All of this is build around GPT and uses the UUIDs of GPTm and does not work with msdos formatted disks.
Quoted 8 lines
Quoted 3 lines
[1] https://systemd.io/BOOT_LOADER_INTERFACE/
[2] https://www.freedesktop.org/software/systemd/man/systemd-gpt-auto-generator.html
[3] https://uapi-group.org/specifications/specs/discoverable_partitions_specificationI expected that Boot Loader Interface does not use MBR at all and rely entirely on GPT. However, I think we should make it clear in the GRUB documentation to avoid complaints/confusion/... in the future. Oliver, could you add relevant blurb to docs?
I'll include it in v2.
Quoted 12 lines
Quoted 7 lines
Quoted 2 lines
* Please elaborate commit message as to why bli needs those mods rather than "not functions properly". Detail that it needs to identify partitions.
I can do that.
bli tries to read the UUID of the ESP/the partition Grub was loaded from. If that is not GPT or otherwise not reachable, then it does not set the corresponding EFI variable, but cYeah, more or less like that makes sense for me.
Daniel
Oliver
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel