Re: [PATCH] of_reserved_mem: Save region name string into struct reserved_mem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




在2024年8月26日八月 下午3:09,Rob Herring写道:
> On Wed, Aug 21, 2024 at 8:51 AM Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx> wrote:
>>
>> Previously only a pointer to fdt string pool is saved to struct
>> reserved_mem as region name.
>>
>> As on some architectures booting FDT will be wiped at later initialisation
>> stages, this is breaking reserved_mem users.
>
> What architectures? Be specific.

It's LoongArch and MIPS, I'll expand commit message.

FDT might be placed in .init sections or memory not managed by kernel, thus
it may be wiped out.

>
> Why is the FDT wiped? It should be preserved and you need it later to
> implement kexec.

So KEXEC is using kernel's self copy of FDT created by unflatten_and_copy_device_tree(),
while reserved-mem scan is performed before copy to ensure that reserved memory
are being tracked by memblock before possible memblock_alloc in unflatten_and_copy_device_tree().

Thanks
- Jiaxun

>
>>
>> Copy and save the whole string into struct reserved_mem to avoid
>> FDT lifecycle problem.
>>
>> Reported-by: Kevin Wheatfox <enkerewpo@xxxxxxxxxxx>
>> Closes: https://lore.kernel.org/loongarch/ME4P282MB1397447C3C094554C7AF2E37B58E2@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx>
>> ---
>>  drivers/of/of_reserved_mem.c    | 2 +-
>>  include/linux/of_reserved_mem.h | 4 +++-
>>  2 files changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
>> index 46e1c3fbc769..22841599cd83 100644
>> --- a/drivers/of/of_reserved_mem.c
>> +++ b/drivers/of/of_reserved_mem.c
>> @@ -70,7 +70,7 @@ static void __init fdt_reserved_mem_save_node(unsigned long node, const char *un
>>         }
>>
>>         rmem->fdt_node = node;
>> -       rmem->name = uname;
>> +       strscpy(rmem->name, uname, RESERVED_MEM_NAME_LEN);
>>         rmem->base = base;
>>         rmem->size = size;
>>
>> diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
>> index e338282da652..ed9de36c9cc9 100644
>> --- a/include/linux/of_reserved_mem.h
>> +++ b/include/linux/of_reserved_mem.h
>> @@ -8,8 +8,10 @@
>>  struct of_phandle_args;
>>  struct reserved_mem_ops;
>>
>> +#define RESERVED_MEM_NAME_LEN  128
>> +
>>  struct reserved_mem {
>> -       const char                      *name;
>> +       char                            name[RESERVED_MEM_NAME_LEN];
>>         unsigned long                   fdt_node;
>>         const struct reserved_mem_ops   *ops;
>>         phys_addr_t                     base;
>>
>> ---
>> base-commit: bb1b0acdcd66e0d8eedee3570d249e076b89ab32
>> change-id: 20240821-save_resv_name-4f2e2cb8883b
>>
>> Best regards,
>> --
>> Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx>
>>

-- 
- Jiaxun





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux