diff mbox series

[2/2] hw/mips/boston: Pack fdt in fdt filter

Message ID 20220813162720.60008-3-jiaxun.yang@flygoat.com
State New
Headers show
Series hw/mips/boston: Initrd support | expand

Commit Message

Jiaxun Yang Aug. 13, 2022, 4:27 p.m. UTC
FDT can be awfully fat after series of modifications in fdt
filter. Just pack it up before add to ram.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 hw/mips/boston.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Jiaxun Yang Aug. 16, 2022, 11:46 a.m. UTC | #1
> 2022年8月16日 01:44,Philippe Mathieu-Daudé <f4bug@amsat.org> 写道:
> 
> On 13/8/22 18:27, Jiaxun Yang wrote:
>> FDT can be awfully fat after series of modifications in fdt
>> filter. Just pack it up before add to ram.
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>> ---
>>  hw/mips/boston.c | 1 +
>>  1 file changed, 1 insertion(+)
>> diff --git a/hw/mips/boston.c b/hw/mips/boston.c
>> index 5145179951..a40f193f78 100644
>> --- a/hw/mips/boston.c
>> +++ b/hw/mips/boston.c
>> @@ -400,6 +400,7 @@ static const void *boston_fdt_filter(void *opaque, const void *fdt_orig,
>>                          1, boston_memmap[BOSTON_HIGHDDR].base + ram_low_sz,
>>                          1, ram_high_sz);
>>  +    fdt_pack(fdt);
>>      fdt = g_realloc(fdt, fdt_totalsize(fdt));
>>      qemu_fdt_dumpdtb(fdt, fdt_sz);
>>  
> 
> Why not pack by default in qemu_fdt_dumpdtb()?

qemu_fdt_dumpdtb() is explicitly a function for debugging purpose.
Donno if it’s wise to hijack it.

Thanks.
---
Jiaxun Yang
David Gibson Aug. 18, 2022, 2:48 a.m. UTC | #2
On Tue, Aug 16, 2022 at 12:46:46PM +0100, Jiaxun Yang wrote:
> 
> 
> > 2022年8月16日 01:44,Philippe Mathieu-Daudé <f4bug@amsat.org> 写道:
> > 
> > On 13/8/22 18:27, Jiaxun Yang wrote:
> >> FDT can be awfully fat after series of modifications in fdt
> >> filter. Just pack it up before add to ram.
> >> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> >> ---
> >>  hw/mips/boston.c | 1 +
> >>  1 file changed, 1 insertion(+)
> >> diff --git a/hw/mips/boston.c b/hw/mips/boston.c
> >> index 5145179951..a40f193f78 100644
> >> --- a/hw/mips/boston.c
> >> +++ b/hw/mips/boston.c
> >> @@ -400,6 +400,7 @@ static const void *boston_fdt_filter(void *opaque, const void *fdt_orig,
> >>                          1, boston_memmap[BOSTON_HIGHDDR].base + ram_low_sz,
> >>                          1, ram_high_sz);
> >>  +    fdt_pack(fdt);
> >>      fdt = g_realloc(fdt, fdt_totalsize(fdt));
> >>      qemu_fdt_dumpdtb(fdt, fdt_sz);
> >>  
> > 
> > Why not pack by default in qemu_fdt_dumpdtb()?
> 
> qemu_fdt_dumpdtb() is explicitly a function for debugging purpose.
> Donno if it’s wise to hijack it.

Agreed.  Having this modify the dtb sounds like a very bad idea.
diff mbox series

Patch

diff --git a/hw/mips/boston.c b/hw/mips/boston.c
index 5145179951..a40f193f78 100644
--- a/hw/mips/boston.c
+++ b/hw/mips/boston.c
@@ -400,6 +400,7 @@  static const void *boston_fdt_filter(void *opaque, const void *fdt_orig,
                         1, boston_memmap[BOSTON_HIGHDDR].base + ram_low_sz,
                         1, ram_high_sz);
 
+    fdt_pack(fdt);
     fdt = g_realloc(fdt, fdt_totalsize(fdt));
     qemu_fdt_dumpdtb(fdt, fdt_sz);