From owner-freebsd-arm@freebsd.org Thu Feb 13 15:05:46 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 BC32A1C92F4 for ; Thu, 13 Feb 2020 15:05:46 +0000 (UTC) (envelope-from wera0003@hs-karlsruhe.de) Received: from smtp.hs-karlsruhe.de (smtp.HS-Karlsruhe.DE [193.196.64.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48JKZd5fH8z4471; Thu, 13 Feb 2020 15:05:45 +0000 (UTC) (envelope-from wera0003@hs-karlsruhe.de) Received: from iz-wera-new.hs-karlsruhe.de ([193.196.65.47]) by smtp.hs-karlsruhe.de with esmtps (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.80.1) (envelope-from ) id 1j2G3k-005xlo-9N; Thu, 13 Feb 2020 16:05:44 +0100 Received: from wera0003 (helo=iz-wera-new.HS-Karlsruhe.DE) by iz-wera-new.HS-Karlsruhe.DE with local-esmtp (Exim 4.92.3 (FreeBSD)) (envelope-from ) id 1j2G3j-000Mzo-Dw; Thu, 13 Feb 2020 16:05:43 +0100 X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.6 From: Ralf Wenk To: Kyle Evans cc: Andrew Turner , Oleksandr Tymoshenko , freebsd-arm , Emmanuel Vadot Subject: Re: A investigative hack that makes (for example) head -r356529 boot and operate normally an RPi4B (finally!): protect all armstub8-gic.bin's loaded content from replacement by the kernel In-reply-to: References: <7E7605DC-021D-448A-8459-8EC26BA9836D.ref@yahoo.com> <7E7605DC-021D-448A-8459-8EC26BA9836D@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Date: Thu, 13 Feb 2020 16:05:43 +0100 Message-Id: X-Rspamd-Queue-Id: 48JKZd5fH8z4471 X-Spamd-Bar: ++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of wera0003@hs-karlsruhe.de has no SPF policy when checking 193.196.64.25) smtp.mailfrom=wera0003@hs-karlsruhe.de X-Spamd-Result: default: False [2.75 / 15.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MV_CASE(0.50)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[hs-karlsruhe.de]; AUTH_NA(1.00)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; IP_SCORE(0.09)[asn: 553(0.43), country: EU(-0.01)]; TO_DN_ALL(0.00)[]; SUBJECT_HAS_EXCLAIM(0.00)[]; NEURAL_SPAM_LONG(0.66)[0.656,0]; RCVD_IN_DNSWL_NONE(0.00)[25.64.196.193.list.dnswl.org : 127.0.10.0]; NEURAL_SPAM_MEDIUM(0.31)[0.311,0]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[iz-rpi03@hs-karlsruhe.de,wera0003@hs-karlsruhe.de]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:553, ipnet:193.196.64.0/18, country:EU]; FROM_NEQ_ENVFROM(0.00)[iz-rpi03@hs-karlsruhe.de,wera0003@hs-karlsruhe.de] 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: Thu, 13 Feb 2020 15:05:46 -0000 On 2020-02-13 at 15:26 +0100 Ralf Wenk wrote: > On 2020-02-13 at 7:49 -0600 Kyle Evans wrote: > > On Thu, Feb 13, 2020 at 7:43 AM Ralf Wenk wrote: > > > > > > On 2020-02-12 at 18:00 -0800 Mark Millard wrote via freebsd-arm: > > > > =5B...=5D > > > > > > > > =23 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) > > > > =40=40 -485,7 +485,18 =40=40 > > > > > > > > tuples =3D res_len / tuple_size; > > > > reservep =3D (pcell_t *)&reserve; > > > > +=23ifdef __aarch64__ > > > > + //HACK=21=21=21 > > > > + // Reserve the first few pages, for example to > > > > + // preserve armstub8-gic.bin or armstub.bin > > > > + // content. > > > > + mr=5B0=5D.mr_start=3D 0; > > > > + mr=5B0=5D.mr_size=3D 2*4096; > > > > + tuples++; > > > > + for (i =3D 1; i < tuples; i++) =7B > > > > +=23else > > > > for (i =3D 0; i < tuples; i++) =7B > > > > +=23endif > > > > > > > > rv =3D fdt_data_to_res(reservep, addr_cells, size_c= ells, > > > > (u_long *)&mr=5Bi=5D.mr_start, (u_long *)&m= r=5Bi=5D.mr_size); > > > > =40=40 -512,6 +523,11 =40=40 > > > > > > > > root =3D OF_finddevice(=22/reserved-memory=22); > > > > if (root =3D=3D -1) =7B > > > > + // Fail over to checking for and handling memreserv= e, > > > > + // such as for a RPi4B. > > > > + if (0 =3D=3D fdt_get_reserved_regions(reserved,mres= erved)) > > > > + return (0); > > > > + > > > > return (ENXIO); > > > > =7D > > > > > > > > > > I can confirm that with your patch(es) my RPi3 does not freeze any = more > > > when loading mac_ntpd.ko. The patches are applied against r357853M.= An reboot is working again too. > > Have you tested the RPi3 with just this second hunk of patch to > > fallover to memreserve, or is the first hunk definitely required as > > well? >=20 > Good question. I tested both hunks together. > Will try what happens when just applying the second and report back. Here it is: Without the first hunk the system freezes again when loading mac_ntpd.ko.= Also the CPU information during boot for CPUs 1 to 3 looks strange again.= mbox0: mbox response error bcm2835_cpufreq0: can't set clock rate (id=3D8) Release APs...APs not started CPU 0: ARM Cortex-A53 r0p4 affinity: 0 Instruction Set Attributes 0 =3D Instruction Set Attributes 1 =3D <> Processor Features 0 =3D Processor Features 1 =3D <> Memory Model Features 0 =3D Memory Model Features 1 =3D <8bit VMID> Memory Model Features 2 =3D <32bit CCIDX,48bit VA> Debug Features 0 =3D <2 CTX BKPTs,4 Watchpoints,6=20 Breakpoints,PMUv3,Debugv8> Debug Features 1 =3D <> Auxiliary Features 0 =3D <> Auxiliary Features 1 =3D <> CPU 1: (null) (null) r0p0 affinity: 0 CPU 2: (null) (null) r0p0 affinity: 0 CPU 3: (null) (null) r0p0 affinity: 0 WARNING: WITNESS option enabled, expect reduced performance. Ralf