From owner-freebsd-arm@freebsd.org Fri Feb 14 01:16:51 2020 Return-Path: Delivered-To: freebsd-arm@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9BB9223C39C for ; Fri, 14 Feb 2020 01:16:51 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic303-25.consmr.mail.gq1.yahoo.com (sonic303-25.consmr.mail.gq1.yahoo.com [98.137.64.206]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48Jb7k3QHNz3N5Y for ; Fri, 14 Feb 2020 01:16:50 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: SJwrgKsVM1lBbsqhXXgTsnBJ4nvH4kgTmfmP6O4itQHKqR7ylu3wcZXbDjRe9i_ _KxNZJRVISQtIre48B3AlUZCIAfmMTgZ5ptmSuc68qj93gV.9nPfNy87LYWWQb5pyyH0MoB0Ng4f ky102dfn80e_YUfHdP_ZC1g_6TkpmaxYRrF_f56inqTeyv3QPaf3THBYg7CRLs8b5QbHTa.ngtkV yRFrbU1pahBoqaI950sWDUxlhbHd_h8swpdEvV93b8fKMdzcGDYNUkNxvX9pSxXoK3rwn_LoSLq1 8JRwyCh3v6tA8usBoSLUCLyBWHGqkZSF3nOntnG6sAkfOcimaMVqusjVbjo0vT0Cc5.7m3A7aumK eZz.7Q8.NLrKtWJHycG.ObrtCycbGJspsr.UE7n0X3IXYXAn9xyshEgLcu2vsQ7qXjD8aO4DOnzJ 6GXWSQl.m3RX7cU5NRquRzKv._5.Oonze35R7iMyhsDxC3WviHdIjLTnATbnFCsBX._qq5DZm8P1 ktO0_yiVC8BeQkihrstLXIAuM9IoGuIcOnDF5fbQCYFpTgbN2v0k8FtTRwwuR0KC9gCoQNWJ6azI BA_y1Q0R6qyqn.L1hBrleL8pIL9WEilQpU3iKxgJnFlgtoeezlhFsoSbEDPKRd83c442kTx7Z.P2 LkrGOldvV9NSW4RU1WYzAJ5GBElXPG_WkH4ftCteo_K2MkRxl_oIH4dZMN37TvYGgXtanimQA7mr vDvRlSztj.VE4mVR44CAhVEZAOeWDT97o2VNFi4gPoOdP1XrmGnaG8SVkkiSRMVw8Hvyp9iiqjwW 1b0mimCYQPbEcATupo3SPn8DuMxs7RTJflZAdXpC0uS85NbHr6h_uAyNopgB5zSsY9pYKxTjoG7_ IlFVk3Jtd_fqdlLrH491i_HW77ZepF_51eEsHpO9UnMKGdJl84AhqC2VovcVL0dbZeJJ9XhPdTB2 wqQXjVStfPJr65XZ6cZZzVEYOqXIAPpu1miUZH4GELzTU19PHe.YaetJJhDuDWvA8em5J3OZPmnl 0yajDXiP11E3x63snQIOIVWRM4OrqJpHAHo04qCS7OQB_ODlwix7MZUfXM1rVriYSB8t7MzJj4gV 11qrG8RpjSW_U9x9_Hgdn4xLgEwPZLeHiBKeB12upIGBBTNtP_HCeMk.VpztfHs9.npSEPN6s1lG IYb1vjCINzdl7qXNft6TW.uN9N6OhRTqH5_yKzs3G4auDzXSlcUQOzZGRjuh8yy0CNpT.wqVn19T BN5_TI3H9pmuwr_K50gsc.K1ozg2gVvdmEdfDgEzaZfWt5Zd.UaPvNF2wNot6236p0eGtBoZhmRJ 7GNHdzOxKqZKPr81zLWKednEvmb07T927Kmq0cAm8Cu6NYteM5f2ogyUImgIaTcTy5aFwOBWdT7F TvCQLqCQdW1Eqm2pj6fKmrIKxWfEoaC5WlMwfU00Cu8tuC9KZDt7KRUWgXy.SeJIj20ilV9.NHy4 - Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.gq1.yahoo.com with HTTP; Fri, 14 Feb 2020 01:16:48 +0000 Received: by smtp404.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID ff58bb418e4640ac3ce7dd9c469cb915; Fri, 14 Feb 2020 01:16:43 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\)) 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) From: Mark Millard In-Reply-To: <876C4DBE-A243-425A-9978-209C24387668@yahoo.com> Date: Thu, 13 Feb 2020 17:16:41 -0800 Cc: Ralf Wenk , Andrew Turner , Oleksandr Tymoshenko , freebsd-arm , Emmanuel Vadot , =?utf-8?Q?Klaus_K=C3=BCchemann?= , bob prohaska Content-Transfer-Encoding: quoted-printable Message-Id: <32D0E068-2E1E-46AA-A907-7974BF4DC46D@yahoo.com> References: <7E7605DC-021D-448A-8459-8EC26BA9836D.ref@yahoo.com> <7E7605DC-021D-448A-8459-8EC26BA9836D@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> <876C4DBE-A243-425A-9978-209C24387668@yahoo.com> To: Kyle Evans X-Mailer: Apple Mail (2.3608.60.0.2.5) X-Rspamd-Queue-Id: 48Jb7k3QHNz3N5Y X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.44 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.95)[-0.949,0]; R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ptr:yahoo.com]; FREEMAIL_FROM(0.00)[yahoo.com]; MIME_GOOD(-0.10)[text/plain]; MV_CASE(0.50)[]; NEURAL_HAM_LONG(-0.99)[-0.987,0]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE_FREEMAIL(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[yahoo.com:+]; DMARC_POLICY_ALLOW(-0.50)[yahoo.com,reject]; RCVD_IN_DNSWL_NONE(0.00)[206.64.137.98.list.dnswl.org : 127.0.5.0]; RCPT_COUNT_SEVEN(0.00)[8]; RCVD_TLS_LAST(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[yahoo.com]; ASN(0.00)[asn:36647, ipnet:98.137.64.0/21, country:US]; MID_RHS_MATCH_FROM(0.00)[]; IP_SCORE(0.00)[ip: (1.00), ipnet: 98.137.64.0/21(0.82), asn: 36647(0.66), country: US(-0.05)]; DWL_DNSWL_NONE(0.00)[yahoo.com.dwl.dnswl.org : 127.0.5.0] X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Feb 2020 01:16:51 -0000 [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 wrote: > On 2020-Feb-13, at 12:13, Kyle Evans wrote: >=20 >> On Thu, Feb 13, 2020 at 1:43 PM Mark Millard = 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)