[PATCH] arm64: setup: Check for overlapping dtb and Image load addresses

Chandra Sekhar Lingutla clingutla at codeaurora.org
Fri Jan 19 02:33:02 PST 2018


Hi Julien,
On 1/19/2018 3:19 PM, Julien Thierry wrote:
> Hi Lingutla,
>
> On 19/01/18 06:56, Lingutla Chandrasekhar wrote:
>> Sometime kernel image and dtb load offsets can overlap due to
>> dynamically increased Image or dtb size if both load addresses
>> are near to each other, which leads to bootup failures.
>>
>> So validate dtb load address and kernel image, if they overlap
>> do not proceed to boot.
>>
>> Signed-off-by: Lingutla Chandrasekhar <clingutla at codeaurora.org>
>>
>> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
>> index 30ad2f085d1f..c9dd699f09ab 100644
>> --- a/arch/arm64/kernel/setup.c
>> +++ b/arch/arm64/kernel/setup.c
>> @@ -181,11 +181,17 @@ static void __init smp_build_mpidr_hash(void)
>>   static void __init setup_machine_fdt(phys_addr_t dt_phys)
>>   {
>>       void *dt_virt = fixmap_remap_fdt(dt_phys);
>> +    u64 end_phys = __pa_symbol(_end);
>> +    u64 start_phys = __pa_symbol(_text);
>>       const char *name;
>>   -    if (!dt_virt || !early_init_dt_scan(dt_virt)) {
>> +    if (!dt_virt || ((dt_phys < start_phys) &&
>> +        ((dt_phys + fdt_totalsize(dt_virt)) > start_phys)) ||
>> +        ((dt_phys > start_phys) && (dt_phys < end_phys)) ||
>> +        !early_init_dt_scan(dt_virt)) {
>>           pr_crit("\n"
>>               "Error: invalid device tree blob at physical address 
>> %pa (virtual address 0x%p)\n"
>> +            "The dtb load address should not overlap with kernel 
>> image\n"
>>               "The dtb must be 8-byte aligned and must not exceed 2 
>> MB in size\n"
>>               "\nPlease check your bootloader.",
>>               &dt_phys, dt_virt);
>>
>
> Could this be checked separately?
>
> When you get that error message you don't know whether the issue is an 
> ill formed dtb or overlapping with the kernel.
>
> So it'd be nice to have a separate message (and maybe add info of how 
> many bytes are overlapping?).
>
Sure, will do.
> Cheers,
>




More information about the linux-arm-kernel mailing list