[PATCH] efi_loader: Fix loaded image alignment

Ard Biesheuvel ardb at kernel.org
Mon Oct 11 16:07:09 CEST 2021


On Mon, 11 Oct 2021 at 15:51, Ilias Apalodimas
<ilias.apalodimas at linaro.org> wrote:
>
> Hi Heinrich,
>
> On Mon, 11 Oct 2021 at 16:45, Heinrich Schuchardt
> <heinrich.schuchardt at canonical.com> wrote:
> >
> >
> >
> > On 10/11/21 14:10, Ilias Apalodimas wrote:
> > > We are ignoring the alignment communicated via the PE/COFF header.
> > > Starting 5.10 the Linux kernel will loudly complain about it. For more
> > > details look at [1] (in linux kernel).
> > >
> > > So add a function that can allocate aligned EFI memory and use it for our
> > > relocated loaded image.
> > >
> > > [1] c32ac11da3f83 ("efi/libstub: arm64: Double check image alignment at entry")
> > >
> > > Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> > > ---
>
> [...]
>
> > > + */
> > > +void *efi_alloc_aligned_pages(u64 len, int memory_type, size_t align)
> > > +{
> > > +     u64 req_pages = efi_size_in_pages(len);
> > > +     u64 true_pages = req_pages + efi_size_in_pages(align) - 1;
> > > +     u64 free_pages = 0;
> >
> > The assigned value is never used. Please, remove the assignment.
> >
> > > +     u64 aligned_mem;
> > > +     efi_status_t r;
> > > +     u64 mem;
> > > +
> >
> > Please add a comment:
> >
> >         /* Align must be a power of two */
> >
> > I can apply these changes when merging.
>
> Ok the changes seem fine to me.   Wait a few days in case Ard sees
> this, so he can verify the changes are what the kernel expects.
>

Should be fine if it results in the correct alignment, and makes the
error message go away.

Acked-by: Ard Biesheuvel <ardb at kernel.org>


More information about the U-Boot mailing list