From owner-freebsd-arm@freebsd.org Thu Feb 13 15:22:38 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 63D1F1CA176 for ; Thu, 13 Feb 2020 15:22:38 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48JKy6242Qz45mV; Thu, 13 Feb 2020 15:22:38 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 356682D27; Thu, 13 Feb 2020 15:22:38 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-qk1-f176.google.com with SMTP id d11so5984632qko.8; Thu, 13 Feb 2020 07:22:38 -0800 (PST) X-Gm-Message-State: APjAAAUO5NiGIOzeUfz8NXWYPadsoC/ekCS3PFJ4H4TlWsLhBr+W2mm0 gQeSEg+yKYSF6bZb9rENAD0BWOwoG1mMUzu/c50= X-Google-Smtp-Source: APXvYqzR+A+Sjas5W6h9s9XAn1q079wGK+b+Qcg6YrrAZR9Z7QI2XRLSKgVT1Bfh4gGypheFpNj/2MO9SID/tePG/1o= X-Received: by 2002:ae9:e10e:: with SMTP id g14mr16608963qkm.430.1581607357657; Thu, 13 Feb 2020 07:22:37 -0800 (PST) MIME-Version: 1.0 References: <7E7605DC-021D-448A-8459-8EC26BA9836D.ref@yahoo.com> <7E7605DC-021D-448A-8459-8EC26BA9836D@yahoo.com> In-Reply-To: From: Kyle Evans Date: Thu, 13 Feb 2020 09:22:26 -0600 X-Gmail-Original-Message-ID: Message-ID: 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 To: Ralf Wenk Cc: Andrew Turner , Oleksandr Tymoshenko , freebsd-arm , Emmanuel Vadot Content-Type: text/plain; charset="UTF-8" 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:22:38 -0000 On Thu, Feb 13, 2020 at 9:05 AM Ralf Wenk wrote: > > 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: > > > > > [...] > > > > > > > > > > # 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); > > > > > } > > > > > > > > > > > > > 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? > > > > 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. > Yeah- I see it now; both armstubs are about 5k. I've raised an issue[0] with upstream for armstub/rpi bits to work out the proper solution, because I don't necessarily want to commit the workaround. I'll throw up the second hunk on phabricator for review by #arm/#arm64 folks, because that seems to me the proper fallback. I also discovered some issues when trying to read /memreserve/ with our dtc and filed a PR[1] to fix those. Thanks, Kyle Evans [0] https://github.com/raspberrypi/tools/issues/107 [1] https://github.com/davidchisnall/dtc/pull/59