u-boot-rpi* has the existing "make first page reserved" code (shown); this appears to be where any fix would go (it works without FreeBSD changes)
Mark Millard
marklmi at yahoo.com
Fri Feb 14 01:16:51 UTC 2020
[The sysutils/u-boot-rpi* change is sufficient to
be a work around allowing existing FreeBSD versions
to be used (up to other separate problems).]
On 2020-Feb-13, at 13:22, Mark Millard <marklmi at yahoo.com> wrote:
> On 2020-Feb-13, at 12:13, Kyle Evans <kevans at freebsd.org> wrote:
>
>> On Thu, Feb 13, 2020 at 1:43 PM Mark Millard <marklmi at yahoo.com> wrote:
>>> [ ... trim ...]
>>>
>>> int ft_board_setup(void *blob, bd_t *bd)
>>> {
>>> /*
>>> * For now, we simply always add the simplefb DT node. Later, we
>>> * should be more intelligent, and e.g. only do this if no enabled DT
>>> * node exists for the "real" graphics driver.
>>> */
>>> lcd_dt_simplefb_add_node(blob);
>>>
>>> #ifdef CONFIG_EFI_LOADER
>>> /* Reserve the spin table */
>>> efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);
>>> #endif
>>> return 0;
>>> }
>>>
>>> [... more trim ...]
>>
>> This is largely irrelevant unless we're consulting either or both of
>> /reserved-memory and the EFI memory map. memreserve and the memory map
>> from U-Boot should likely both be fixed to reflect reality.
>>
>
> That is the only code causing the first page to have
> its exsting Reserved status. Otherwise it too would
> be replaced by the kernel.
>
> The Reeserved status is from the EFI interface,
> not the FDT/DTB one.
So I've reverted armstub8-gic.bin to the normal
one ffrom sysutils/rpi-firmware and reverted
the kernel investigative HACKs, including the
one that enabled booting and operating:
# svnlite diff /usr/src/sys/dev/fdt/fdt_common.c
Index: /usr/src/sys/dev/fdt/fdt_common.c
===================================================================
--- /usr/src/sys/dev/fdt/fdt_common.c (revision 357529)
+++ /usr/src/sys/dev/fdt/fdt_common.c (working copy)
@@ -485,7 +485,18 @@
tuples = res_len / tuple_size;
reservep = (pcell_t *)&reserve;
+#ifdef __aarch64__
+ //HACK!!!
+ // Reserve the first few pages, for example to
+ // preserve armstub8-gic.bin or armstub.bin
+ // content.
+ mr[0].mr_start= 0;
+ mr[0].mr_size= 2*4096;
+ tuples++;
+ for (i = 1; i < tuples; i++) {
+#else
for (i = 0; i < tuples; i++) {
+#endif
rv = fdt_data_to_res(reservep, addr_cells, size_cells,
(u_long *)&mr[i].mr_start, (u_long *)&mr[i].mr_size);
@@ -512,6 +523,11 @@
root = OF_finddevice("/reserved-memory");
if (root == -1) {
+ // Fail over to checking for and handling memreserve,
+ // such as for a RPi4B.
+ if (0 == fdt_get_reserved_regions(reserved,mreserved))
+ return (0);
+
return (ENXIO);
}
# svnlite revert /usr/src/sys/dev/fdt/fdt_common.c
Reverted 'sys/dev/fdt/fdt_common.c'
So sysutils/rpi-firmware/ and FreeBSD itself are no
longer tailored to the problem.
But I've also switched to a sysutils/u-boot-rpi4 based on:
# diff ./board/raspberrypi/rpi/rpi.c.orig ./board/raspberrypi/rpi/rpi.c
485c485
< efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);
---
> efi_add_memory_map(0, 2, EFI_RESERVED_MEMORY_TYPE, 0);
And the result is that head -r357529
boots and operates just fine.
So FreeBSD itself does not need to change just to have
a work-around.
(I make no claim to know the best direction for a
long term fix.)
FYI: boot -v on the RPi4B used for testing now shows:
Type Physical Virtual #Pages Attr
Reserved 000000000000 0 00000002 WB
ConventionalMemory 000000002000 2000 00007ef0 WB
BootServicesData 000007ef2000 7ef2000 0000001c WB
ConventionalMemory 000007f0e000 7f0e000 00029f93 WB
BootServicesData 000031ea1000 31ea1000 00000001 WB
LoaderData 000031ea2000 31ea2000 00008001 WB
LoaderCode 000039ea3000 39ea3000 000000a6 WB
Reserved 000039f49000 39f49000 00000007 WB
BootServicesData 000039f50000 39f50000 00000001 WB
Reserved 000039f51000 39f51000 00000002 WB
RuntimeServicesData 000039f53000 39f53000 00000001 WB RUNTIME
Reserved 000039f54000 39f54000 00000001 WB
BootServicesData 000039f55000 39f55000 00000002 WB
RuntimeServicesData 000039f57000 39f57000 00000001 WB RUNTIME
LoaderData 000039f58000 39f58000 00001408 WB
RuntimeServicesCode 00003b360000 3b360000 00000010 WB RUNTIME
LoaderData 00003b370000 3b370000 00000090 WB
BootServicesData 000040000000 40000000 000bc000 WB
MemoryMappedIO 0000fe100000 fe100000 00000001 RUNTIME
Physical memory chunk(s):
0x00002000 - 0x39f48fff, 927 MB ( 237383 pages)
0x39f50000 - 0x39f50fff, 0 MB ( 1 pages)
0x39f53000 - 0x39f53fff, 0 MB ( 1 pages)
0x39f55000 - 0x3b35ffff, 20 MB ( 5131 pages)
0x3b370000 - 0x3b3fffff, 0 MB ( 144 pages)
0x40000000 - 0xfbffffff, 3008 MB ( 770048 pages)
Excluded memory regions:
0x00000000 - 0x00001fff, 0 MB ( 2 pages) NoAlloc
0x32000000 - 0x33795fff, 23 MB ( 6038 pages) NoAlloc
0x39f49000 - 0x39f4ffff, 0 MB ( 7 pages) NoAlloc
0x39f51000 - 0x39f54fff, 0 MB ( 4 pages) NoAlloc
0x39f57000 - 0x39f57fff, 0 MB ( 1 pages) NoAlloc
0x3b360000 - 0x3b36ffff, 0 MB ( 16 pages) NoAlloc
0x3e513000 - 0x3ebebfff, 6 MB ( 1753 pages) NoAlloc
0xfe100000 - 0xfe100fff, 0 MB ( 1 pages) NoAlloc
===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)
More information about the freebsd-arm
mailing list