Re: [PATCHv10 04/11] efi/x86: Implement support for unaccepted memory

From: Ard Biesheuvel
Date: Fri May 12 2023 - 07:02:02 EST


On Fri, 12 May 2023 at 12:59, Kirill A. Shutemov
<kirill.shutemov@xxxxxxxxxxxxxxx> wrote:
>
> On Fri, May 12, 2023 at 09:39:30AM +0200, Ard Biesheuvel wrote:
> > Please replace PMD_SIZE with something along the lines of
> > EFI_UNACCEPTED_UNIT_SIZE and #define it to PMD_SIZE in
> > arch/x86/include/asm/efi.h.
> >
> > The comment below about the size of the bitmap vs the size of the
> > address space should probably move there as well.
>
> Okay, will do.
>
> > > +void accept_memory(phys_addr_t start, phys_addr_t end)
> > > +{
> > > + unsigned long range_start, range_end;
> > > + unsigned long bitmap_size;
> > > + u64 unit_size;
> > > +
> > > + if (!unaccepted_table)
> > > + return;
> > > +
> > > + unit_size = unaccepted_table->unit_size;
> > > +
> > > + /*
> > > + * Only care for the part of the range that is represented
> > > + * in the bitmap.
> > > + */
> > > + if (start < unaccepted_table->phys_base)
> > > + start = unaccepted_table->phys_base;
> > > + if (end < unaccepted_table->phys_base)
> > > + return;
> > > +
> > > + /* Translate to offsets from the beginning of the bitmap */
> > > + start -= unaccepted_table->phys_base;
> > > + end -= unaccepted_table->phys_base;
> > > +
> > > + /* Make sure not to overrun the bitmap */
> > > + if (end > unaccepted_table->size * unit_size * BITS_PER_BYTE)
> > > + end = unaccepted_table->size * unit_size * BITS_PER_BYTE;
> > > +
> >
> > Should we warn here?
>
> No. accept_memory() is nop for conventional memory (memblock calls it
> unconditionally).
>
> With the fixup, we only allocate bitmap for the range of physical address
> space where we have unaccepted memory. So if there's conventional memory
> after unaccepted, bitmap will not cover it.
>

Fair enough.