Hi Daniel,

On Sun, Dec 28, 2025 at 10:16:01AM +0900, Daniel Palmer wrote:
> Hi Kuan-Wei,
> 
> On Sat, 27 Dec 2025 at 02:54, Kuan-Wei Chiu <[email protected]> wrote:
> > diff --git a/board/emulation/qemu-m68k/qemu-m68k.c 
> > b/board/emulation/qemu-m68k/qemu-m68k.c
> 
> > +int dram_init(void)
> > +{
> 
> > +       /* QEMU places bootinfo after _end, aligned to 2 bytes */
> > +       addr = (ulong)&_end;
> > +       if (addr & 1)
> > +               addr++;
> 
> Maybe ALIGN() or round_up() could be used here instead of manually coding it?

Ack. Using ALIGN() is indeed cleaner.
I will update this in the next version.

> 
> > +       record = (struct bi_record *)addr;
> > +
> > +       if (record->tag != BI_MACHTYPE)
> > +               return 0;
> > +
> > +       while (record->tag != BI_LAST) {
> > +               if (record->tag == BI_MEMCHUNK) {
> > +                       gd->ram_size = record->data[1];
> > +                       break;
> > +               }
> > +               record = (struct bi_record *)((ulong)record + record->size);
> > +       }
> 
> One thing I found when I did the bootinfo parsing in my version is if
> I corrupted (during relocation etc) the bootinfo this type of loop
> would often get stuck forever.
> I'm not sure what the technical limit of the number of bootinfo
> entries is but bounding this to something reasonable feels like a good
> idea.

In that scenario, I assume the correct error handling would be to add a
loop limit and trigger a panic() if exceeded?

Regards,
Kuan-Wei

Reply via email to