From owner-freebsd-arm@freebsd.org Tue Oct 13 19:22:01 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 1A74E449883 for ; Tue, 13 Oct 2020 19:22:01 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic315-55.consmr.mail.gq1.yahoo.com (sonic315-55.consmr.mail.gq1.yahoo.com [98.137.65.31]) (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 4C9lm66gwcz49Mg for ; Tue, 13 Oct 2020 19:21:58 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: RBVjWH4VM1mD8Py0D0rUWOqtHsohQ41TegSzxiRUue7PppBQ7pSrAgMLV5WhG1d AoVKZQ_o76eBiYUZXReLquSNbvPkOxRVXyhOE7GsVRaYRigCq0kn3UwDO8bf1oGRyM645ciIssGK IrjVRbzQu.abOVddGOxsEP_.9Zwg9BThI2Ecleqq6GWtCeyo7KdKOufgFtUbWyKES.GAgDoHVTpg 9efs77T_k32V7FqGNV0w6fkJwbUArd7T_uWGZTdNAH7gBmjRcdzZe7UYKfjksxePDdf4u9dvNbSj p3JTxzk8cT_Jhll_w2smlQ0QJXBtAAix6vtAhcj.PxkLFLXRmiqCQVNEYDbmg_RxR_WhmsEJ7Ky8 kxB2ot3ZPwGu9DBqUoEQIVLWCAJI6Y.lGjqdPEAhzQetQLtk79Eroo4KibDWLlpl7ry4aNUS5AsC R5ABpFLWxdn_COE933NmmrM7ZFKEulUUCNDJ1c6GJK_yoNFSSC2kNX1P5yn3GQ_2jaNELrhLnw4Q qonet8xndW.SzFCvb1juuJiJC1LjnMxpFP1QS1gI0LLUN2Obfm5yzCDkAD.M48LY9kko59J8Vqin d1Md5qNMJQdkJHdr53qMSrIGixK0t_eAdkigYatG6lErORhVveymN3Lnpphq72QFc6h_lugVit6X cYmeWc.yDhgObGKo5y2lm2Nr0JaV8nxiO1vpYJ.atJ_VBCwWUU6oJgBMU2pcB4ltGMGs78Fa3fLX adjnQN3Y4z6mdIpjX5R01gMh1KhuLxrkL80DmZrgW21MRpBbicJAS6ORNbrg5SneMHlW4j44BSco fYpafJtkCbAong0NfGtn3FGjL.V_SC0qpFoY099bYNpNNplbtMk1OBnaNhAGu.lEGHm7ilUou3tO ycYvhUESPgEBIJsOy0tfzPyp7k0lLdaj01HCV_MLLCTXyGxPqwm2FOT5V.shKOT7XDKptixha6t9 mw3ja3BEtYCW4DM_im72bKSRpytASu_rjJnTB9RF0xqEraJdQ5rlROpwrlmF21RVIVvTzMd._r31 MZMfuNY.iPskA3fAkp8g4NkfQxVmuyS8FFgLqcYswTVrnnQX6Jde9WwfOe98nI2PJMgsqoJ6JqVN FGJatnm8U9iq1hwjzz4sUpNLxBu0ojokGcMKO2awIeIQJO1tde1VUVxaMkNcwfAfnJFifdO7F7zI BH25tH9GbqqsfOM980u6oVrqy7H9maF2X_MrX3us_eZ4eFsedWXnmujqv9E1WRZvnDyZjvOBCQ6P 5.PwReoirs4q4.0Ug8Eq8VSD8vZD6lywgjVUsJioWLuKBtTVsAn3pm2wA_AOn3DY2VYxGisZAGSf 80doLGAzlnicotNXIpYnSOKtxU7dOMeKQSWxuxgDqawN11cihzOG69RcT227qAGykJr5etExJNhj JRbgIOvrqZ.M.q6A5w1tLISm4teHPeojpNNJSVJlJrH_Wp0XxHmNFVWgCDMWeB8xeZoIT4gBpqJ3 CnlD1TVJg_PxZ8YR1C.dFGlD2Bcelrs_aPbMVnjuILSF_tpHoJloXmpDjp6mxxGMidgw6HcWX20A IVIVp1yzEjM1nt3yoJ1gcgj87EROWhI_SWxILsaGoJUM- Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.gq1.yahoo.com with HTTP; Tue, 13 Oct 2020 19:21:56 +0000 Received: by smtp405.mail.bf1.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 8eb07a1457f7f889cb74b42acdc5d873; Tue, 13 Oct 2020 19:21:52 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: RPi4B: an example of what RAM u-boot reserves during operation [patches updated] From: Mark Millard In-Reply-To: Date: Tue, 13 Oct 2020 12:21:50 -0700 Cc: Oleksandr Tymoshenko Content-Transfer-Encoding: quoted-printable Message-Id: <8AEC8B5C-F375-4C81-9033-D864B6C47C57@yahoo.com> References: To: Kyle Evans , freebsd-arm X-Mailer: Apple Mail (2.3608.120.23.2.1) X-Rspamd-Queue-Id: 4C9lm66gwcz49Mg X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.12 / 15.00]; FREEMAIL_FROM(0.00)[yahoo.com]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ptr:yahoo.com]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[yahoo.com:+]; DMARC_POLICY_ALLOW(-0.50)[yahoo.com,reject]; NEURAL_HAM_SHORT(-0.62)[-0.619]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[yahoo.com]; ASN(0.00)[asn:36647, ipnet:98.137.64.0/20, country:US]; MID_RHS_MATCH_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[yahoo.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.03)[-1.029]; R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_LONG(-0.97)[-0.971]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[98.137.65.31:from]; RWL_MAILSPIKE_POSSIBLE(0.00)[98.137.65.31:from]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[freebsd-arm] X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Oct 2020 19:22:01 -0000 On 2020-Oct-12, at 17:32, Mark Millard wrote: > On 2020-Oct-12, at 11:19, Mark Millard wrote: >=20 >> . . . >=20 > U-Boot> bdinfo > lmb_dump_all: > . . . > reserved.cnt =3D 0x2 > reserved.size =3D 0x0 > reserved.reg[0x0].base =3D 0x0 > .size =3D 0x2000 > reserved.reg[0x1].base =3D 0x3db47b30 > .size =3D 0x4b84d0 > . . . The above does not cover as much as gonzo's old code did during u-boot's time frame: the reserved space was 0x4000 in size and that figure is supplied via x1 from argstub8-gic.bin code. So the below is about having that reserve also covered (during u-boot's time frame): U-Boot> bdinfo . . . lmb_dump_all: . . . reserved.cnt =3D 0x2 reserved.size =3D 0x0 reserved.reg[0x0].base =3D 0x0 .size =3D 0x4000 reserved.reg[0x1].base =3D 0x3db47b30 .size =3D 0x4b84d0 . . . I doubt that the patches below are appropriate to upstream in some respects. It is more targeted at being a sysutils/u-boot-rpi[34] patch because what armstub8*.bin supplies in x1 seems specific to the armstub8*.bin FreeBSD uses. I'll note that doing this has not changed the current "rainbow stage hangup" when u-boot and modern firmware are used together (usb not needing to be involved). # more = /usr/ports/sysutils/u-boot-rpi4/files/patch-board__raspberrypi__rpi__lowle= vel_init.S=20 --- board/raspberrypi/rpi/lowlevel_init.S.orig 2020-10-05 = 08:15:32.000000000 -0700 +++ board/raspberrypi/rpi/lowlevel_init.S 2020-10-13 = 11:33:39.273950000 -0700 @@ -18,9 +18,22 @@ #ifdef CONFIG_ARM64 adr x8, fw_dtb_pointer str x0, [x8] +#if defined(CONFIG_EFI_LOADER) + /* Setup to allow reserving the stack and such that is */ + /* after the likes of FreeBSD armstub8-gic.bin in RAM. */ + adr x8, armstub_rsrvd + str x1, [x8] +#endif #else ldr r8, =3Dfw_dtb_pointer str r2, [r8] +#if defined(CONFIG_EFI_LOADER) +#error "Before aarch64 does not use armstub*.bin files" + /* Setup to allow reserving the stack and such that is */ + /* after the likes of a armstub*.bin in RAM. */ + ldr r8, =3Darmstub_rsrvd + str r3, [r8] +#endif #endif =20 /* Returns */ # more = /usr/ports/sysutils/u-boot-rpi4/files/patch-board__raspberrypi__rpi__rpi.c= =20 --- board/raspberrypi/rpi/rpi.c.orig 2020-10-05 08:15:32.000000000 = -0700 +++ board/raspberrypi/rpi/rpi.c 2020-10-13 11:02:15.582706000 -0700 @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ * does not get cleared later. */ unsigned long __section(".data") fw_dtb_pointer; +unsigned long __section(".data") armstub_rsrvd; =20 /* TODO(sjg@chromium.org): Move these to the msg.c file */ struct msg_get_arm_mem { @@ -494,4 +496,29 @@ #endif =20 return 0; +} + +void board_lmb_reserve(struct lmb *lmb) +{ +#ifdef CONFIG_EFI_LOADER + /* + * NOTE: lmb_reserve (and more) does not deal with overlaps with + * pre-existing reservations. + * But board_lmb_reserve is called before the original + * first-page is added. So use knowledge of what will = happen + * later to avoid overlaps. + */ + + phys_addr_t base =3D 0x0u; + phys_addr_t size =3D CONFIG_RPI_EFI_NR_SPIN_PAGES << = EFI_PAGE_SHIFT; + if (size < armstub_rsrvd) size =3D armstub_rsrvd; + + if (size <=3D EFI_PAGE_SIZE) return; + + /* Avoid future overlap */ + base +=3D EFI_PAGE_SIZE; + size -=3D EFI_PAGE_SIZE; + + lmb_reserve(lmb, base, size); +#endif } =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)