[PATCH v2 08/15] efi/libstub: Have efi_kaslr_relocate_kernel() handle extra_size

Jason Gunthorpe jgg at nvidia.com
Tue Oct 27 08:22:38 PDT 2026


On Wed, Oct 21, 2026 at 10:06:22AM -0700, Jonathan Cameron wrote:

> > @@ -125,16 +164,29 @@ efi_status_t efi_kaslr_relocate_kernel(unsigned long *image_addr,
> >  	}
> >  
> >  	if (status != EFI_SUCCESS) {
> > -		if (!check_image_region(*image_addr, kernel_memsize)) {
> > +		bool image_region_ok =
> > +			check_image_region(*image_addr, kernel_memsize);
> > +
> > +		if (!image_region_ok) {
> 
> Why this change?  I don't particularly mind but seems to be churn that isn't
> necessarily needed.

Ah, I had something else here once, I put it back

> >  			efi_err("FIRMWARE BUG: Image BSS overlaps adjacent EFI memory region\n");
> >  		} else if (IS_ALIGNED(*image_addr, min_kimg_align) &&
> > -			   (unsigned long)_end < EFI_ALLOC_LIMIT) {
> > -			/*
> > -			 * Just execute from wherever we were loaded by the
> > -			 * UEFI PE/COFF loader if the placement is suitable.
> > -			 */
> > -			*reserve_size = 0;
> > -			return EFI_SUCCESS;
> > +			   (unsigned long)_end + extra_size < EFI_ALLOC_LIMIT) {
> > +			if (!extra_size) {
> > +				/*
> > +				 * Just execute from wherever we were loaded by
> > +				 * the UEFI PE/COFF loader if the placement is
> > +				 * suitable.
> > +				 */
> > +				*reserve_size = 0;
> > +				return EFI_SUCCESS;
> > +			}
> > +
> > +			status = allocate_image_tail(*image_addr,
> > +						     kernel_memsize, extra_size,
> > +						     reserve_addr,
> > +						     reserve_size);
> 
> I'd move reserve_size up a line to group it with reserve_addr.

As long as nobody minds the 81 cols that creates..

Thanks,
Jason



More information about the linux-arm-kernel mailing list