Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Feb 2020 17:16:41 -0800
From:      Mark Millard <marklmi@yahoo.com>
To:        Kyle Evans <kevans@freebsd.org>
Cc:        Ralf Wenk <iz-rpi03@hs-karlsruhe.de>, Andrew Turner <andrew@freebsd.org>, Oleksandr Tymoshenko <gonzo@freebsd.org>, freebsd-arm <freebsd-arm@freebsd.org>, Emmanuel Vadot <manu@freebsd.org>, =?utf-8?Q?Klaus_K=C3=BCchemann?= <maciphone2@googlemail.com>, bob prohaska <fbsd@www.zefox.net>
Subject:   Re: 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)
Message-ID:  <32D0E068-2E1E-46AA-A907-7974BF4DC46D@yahoo.com>
In-Reply-To: <876C4DBE-A243-425A-9978-209C24387668@yahoo.com>
References:  <7E7605DC-021D-448A-8459-8EC26BA9836D.ref@yahoo.com> <7E7605DC-021D-448A-8459-8EC26BA9836D@yahoo.com> <E1j2EmR-000Mwm-ID@iz-wera-new.HS-Karlsruhe.DE> <CACNAnaHVYeuoK=4f7XzokpAVjcqd6ovD58-0LdP_vPGjiXQgdw@mail.gmail.com> <E1j2FRX-000MyR-1O@iz-wera-new.HS-Karlsruhe.DE> <E1j2G3j-000Mzo-Dw@iz-wera-new.HS-Karlsruhe.DE> <CACNAnaHUwu0GmqW9QZRhS2sMK0HpsjdYRz3YouL5FMBdWBCW-Q@mail.gmail.com> <B64C6065-D804-4D6F-8660-F8DBB9946DEB@yahoo.com> <36CF6E4B-5607-4752-B2DF-C265BCFB95BA@yahoo.com> <1BE59567-E669-4A88-8389-2E321B0AC1AE@yahoo.com> <27BE7BAF-FD2C-41C6-B270-4BAF77D1FB0C@yahoo.com> <7465BC0D-3F4C-4CD9-B614-0DF321C94331@yahoo.com> <CACNAnaE-SdeqLKwnodPTFNyWY1sWDNhrt4=5WKjUG_FeH4%2B0-Q@mail.gmail.com> <876C4DBE-A243-425A-9978-209C24387668@yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
[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:
>=20
>> On Thu, Feb 13, 2020 at 1:43 PM Mark Millard <marklmi@yahoo.com> =
wrote:
>>> [ ... trim ...]
>>>=20
>>> 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);
>>>=20
>>> #ifdef CONFIG_EFI_LOADER
>>>       /* Reserve the spin table */
>>>       efi_add_memory_map(0, 1, EFI_RESERVED_MEMORY_TYPE, 0);
>>> #endif
>>>       return 0;
>>> }
>>>=20
>>> [... more trim ...]
>>=20
>> 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.
>>=20
>=20
> That is the only code causing the first page to have
> its exsting Reserved status. Otherwise it too would
> be replaced by the kernel.
>=20
> 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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- /usr/src/sys/dev/fdt/fdt_common.c	(revision 357529)
+++ /usr/src/sys/dev/fdt/fdt_common.c	(working copy)
@@ -485,7 +485,18 @@
=20
 	tuples =3D res_len / tuple_size;
 	reservep =3D (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=3D 0;
+	mr[0].mr_size=3D 2*4096;
+	tuples++;
+	for (i =3D 1; i < tuples; i++) {
+#else
 	for (i =3D 0; i < tuples; i++) {
+#endif
=20
 		rv =3D 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 @@
=20
 	root =3D OF_finddevice("/reserved-memory");
 	if (root =3D=3D -1) {
+		// Fail over to checking for and handling memreserve,
+		// such as for a RPi4B.
+		if (0 =3D=3D =
fdt_get_reserved_regions(reserved,mreserved))
+			return (0);
+
 		return (ENXIO);
 	}
=20
# 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=20
     ConventionalMemory 000000002000         2000 00007ef0 WB=20
       BootServicesData 000007ef2000      7ef2000 0000001c WB=20
     ConventionalMemory 000007f0e000      7f0e000 00029f93 WB=20
       BootServicesData 000031ea1000     31ea1000 00000001 WB=20
             LoaderData 000031ea2000     31ea2000 00008001 WB=20
             LoaderCode 000039ea3000     39ea3000 000000a6 WB=20
               Reserved 000039f49000     39f49000 00000007 WB=20
       BootServicesData 000039f50000     39f50000 00000001 WB=20
               Reserved 000039f51000     39f51000 00000002 WB=20
    RuntimeServicesData 000039f53000     39f53000 00000001 WB RUNTIME
               Reserved 000039f54000     39f54000 00000001 WB=20
       BootServicesData 000039f55000     39f55000 00000002 WB=20
    RuntimeServicesData 000039f57000     39f57000 00000001 WB RUNTIME
             LoaderData 000039f58000     39f58000 00001408 WB=20
    RuntimeServicesCode 00003b360000     3b360000 00000010 WB RUNTIME
             LoaderData 00003b370000     3b370000 00000090 WB=20
       BootServicesData 000040000000     40000000 000bc000 WB=20
         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=20
  0x32000000 - 0x33795fff,    23 MB (   6038 pages) NoAlloc=20
  0x39f49000 - 0x39f4ffff,     0 MB (      7 pages) NoAlloc=20
  0x39f51000 - 0x39f54fff,     0 MB (      4 pages) NoAlloc=20
  0x39f57000 - 0x39f57fff,     0 MB (      1 pages) NoAlloc=20
  0x3b360000 - 0x3b36ffff,     0 MB (     16 pages) NoAlloc=20
  0x3e513000 - 0x3ebebfff,     6 MB (   1753 pages) NoAlloc=20
  0xfe100000 - 0xfe100fff,     0 MB (      1 pages) NoAlloc=20




=3D=3D=3D
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?32D0E068-2E1E-46AA-A907-7974BF4DC46D>