Re: [PATCH] of/fdt: Don't calculate initrd_start from the DT if 'linux,initrd-end' is 0

From: Rob Herring
Date: Sun Aug 28 2022 - 21:13:01 EST


On Fri, Aug 26, 2022 at 5:00 PM Marek Bykowski <marek.bykowski@xxxxxxxxx> wrote:
>
> If the 'linux,initrd-end' property is 0 and 'linux,initrd-start' property
> is other than 0, then phys_initrd_size calculated from 'linux,initrd-end'
> - 'linux,initrd-start' is negative, that subsequently gets converted to
> a high positive value as being u64.
>
> For example if 'linux,initrd-start' is 8800_0000, 'linux,initrd-end' is 0,
> then the phys_initrd_size calculated is ffff_ffff_7800_0000 (= 0 -
> 8800_0000 = -8800_0000 + ULLONG_MAX + 1). On my system, FVP ARM64,
> the intird memory region with the (wrong) size is added to the bootmem and
> then attempted to being paged in paging_init() that results in the kernel
> oops as shown below.

Shouldn't we just check that start < end?

Can we check this somewhere not DT specific (and also not arch
specific)? Then we don't have to worry if any other method of setting
initrd could have the same error.

Rob