Good morning Heinrich,

thanks for pointing this out, I overlooked it.
I enabled GRUB2 logs and I also see that DTB is loaded aligned.

devicetree <target_name>.dtb
kern/disk.c:196:disk: Opening `tftp,128.0.0.1'...
disk/efi/efidisk.c:482:efidisk: opening tftp
kern/disk.c:281:disk: Opening `tftp,128.0.0.1' failed.
kern/disk.c:299:disk: Closing `tftp'.
tpm/grub_tpm.c:95:tpm: extending pcr#15 from file type 44
??mmands/efi/tpm.c:281:tpm: log_event, pcr = 15, size = 0x43b3, ?
kern/verifiers.c:88:verify: file: <target_name>.dtb type: 44
commands/efi/tpm.c:281:tpm: log_event, pcr = 9, size = 0x43b3,
<target_name>.dtb
loader/efi/linux.c:689:linux: filename <target_name>.dtb, size 17331
loader/efi/linux.c:649:loader: load_dtbloader/efi/linux.c:654:loader:
Loading
device tree to 0x6fbbd600

Still I get FDT_ERR_ALIGNMENT in fdt_check_header when booting...
Unfortunately my Grub2 comes as binary from BSP and I can't recompile nor
really debug it.

I'll update my CR if I find anything or close it if not.

Best regards,
Mikhail

On Thu, Feb 26, 2026 at 9:31 AM Heinrich Schuchardt <
[email protected]> wrote:

> On 2/26/26 09:14, Mikle Lappo wrote:
> > Add maintainers into CC
> >
> > On Wed, Feb 25, 2026 at 2:07 PM <[email protected]
> > <mailto:[email protected]>> wrote:
> >
> >     From: Mikhail Lappo <[email protected] <mailto:
> [email protected]>>
> >
> >     libfdt requires the FDT blob to be 8-byte aligned. The alignment is
> >     validated in fdt_check_header(), and misaligned blobs may be rejected
> >     or cause failures on architectures that enforce strict alignment.
> >
> >     Currently the blob is allocated with grub_malloc(), which does not
> >     guarantee 8-byte alignment. Replace it with grub_memalign(8, size)
> >     to ensure the required alignment.
> >
> >     Signed-off-by: Mikhail Lappo <[email protected]
> >     <mailto:[email protected]>>
> >     ---
> >       grub-core/loader/efi/fdt.c | 3 ++-
> >       1 file changed, 2 insertions(+), 1 deletion(-)
> >
> >     diff --git a/grub-core/loader/efi/fdt.c b/grub-core/loader/efi/fdt.c
> >     index e510b3491..f25d362d3 100644
> >     --- a/grub-core/loader/efi/fdt.c
> >     +++ b/grub-core/loader/efi/fdt.c
> >     @@ -38,6 +38,7 @@ static void *fdt;
> >       #define FDT_ADDR_SIZE_EXTRA ((2 * grub_fdt_prop_entry_size
> >     (sizeof(grub_uint32_t))) + \
> >                                    sizeof (FDT_ADDR_CELLS_STRING) + \
> >                                    sizeof (FDT_SIZE_CELLS_STRING))
> >     +#define FDT_BLOB_ALIGNMENT 8
> >
> >       static const struct grub_arg_option options_fdtdump[] = {
> >         {"prop",     'p', 0, N_("Get property."), N_("prop"),
> >     ARG_TYPE_STRING},
> >     @@ -145,7 +146,7 @@ grub_cmd_devicetree (grub_command_t cmd
> >     __attribute__ ((unused)),
> >           goto out;
> >
> >         size = grub_file_size (dtb);
> >     -  blob = grub_malloc (size);
> >     +  blob = grub_memalign (FDT_BLOB_ALIGNMENT, size);
> >         if (!blob)
> >           goto out;
> >
> >     --
> >     2.44.0
> >
>
> Isn't #define GRUB_MM_ALIGN_LOG2 setting a minimum alignment of 16 bytes
> on 32-bit and 32 bytes on 64-bit systems?
>
> Please, have a look at the code starting here:
>
> grub-core/kern/mm.c:478:  align = (align >> GRUB_MM_ALIGN_LOG2);
>
> Best regards
>
> Heinrich
>
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to