[Bug 226974] kernel DSI read trap at boot

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Apr 16 21:24:27 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=226974

--- Comment #12 from Leandro Lupori <leandro.lupori at gmail.com> ---
I have an update on this. I think I've found what is causing this issue.

When ofw_mem_regions() is called during initialization, it looks for
/chosen/fdtmemreserv property in the device tree. When FDT is enabled, this
property will always exist, as it's a "fake" property returned by OFW FDT
getprop itself.

Then, if the fdtmemreserv property exists, excise_fdt_reserved() is called, and
it does 2 main things:
1- Excludes reserved memory from available memory regions
2- Excludes FDT memory region itself from available memory

In my case, it's the second item that causes a problem later, at
moea64_early_bootstrap().
There is one part of this function that checks for overlaps between available
memory regions and the region where the kernel was loaded. When this overlap is
found, the available memory list is supposed to be adjusted to exclude kernel
memory.
But this code doesn't work correctly for some available memory regions, like
the one that is produced by excise_fdt_reserved() when there is an overlap
between FDT and kernel end.

This is the relevant part of the available regions in my case:
0x00004000 - 0x01800074 (~24MB)
0x0180b04c - 0x02c00000 (~20MB)
0x0344d3f0 - 0x7dbe0000 (~2GB)

kernelstart = 0x0100100
kernelend   = 0x1b60000
fdt         = 0x1b5b000 - 0x1b5f000 (upper bound rounded to page size)

When FDT is not used, moea64_early_bootstrap() will adjust the regions like
this:

0x00004000 - 0x01000000
0x01b60000 - 0x02c00000
0x0344d3f0 - 0x7dbe0000

And everything works fine.
However, when FDT is used, excise_fdt_reserved() will change the available
regions to this:

0x00004000 - 0x01800074
0x0180b04c - 0x01b5b000
0x01b5f000 - 0x02c00000
0x0344d3f0 - 0x7dbe0000

And then moea64_early_bootstrap() will adjust the regions and produce this:

0x00004000 - 0x01000000
0x0180b04c - 0x01b5b000
0x01b61000 - 0x02c00000
0x0344d3f0 - 0x7dbe0000

Which turns a large part of the kernel memory (0x0180b04c - 0x01b5b000) into
available memory, causing the issue when this region starts being used as such.


I'm not sure about the best way to fix this. Maybe one (or more) of the
following:
1- Change moea64_early_bootstrap() to make it able to detect and adjust regions
such as (0x0180b04c - 0x01b5b000), in which case the whole region should be
removed from available list.
2- Change the boot loader to place the FDT after kernelend.


And one last thing that I noticed and seems odd to me is that region
(0x01800074 - 0x0180b04c) is not reported as available, but even so the kernel
is loaded at (0x0100100 - 0x1b60000), which includes the not available region.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-ppc mailing list