Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Feb 2020 14:43:47 +0100
From:      Ralf Wenk <iz-rpi03@hs-karlsruhe.de>
To:        Mark Millard <marklmi@yahoo.com>
Cc:        freebsd-arm <freebsd-arm@freebsd.org>, Kyle Evans <kevans@FreeBSD.org>, gonzo@freebsd.org, Andrew Turner <andrew@freebsd.org>, Emmanuel Vadot <manu@freebsd.org>
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
Message-ID:  <E1j2EmR-000Mwm-ID@iz-wera-new.HS-Karlsruhe.DE>
In-Reply-To: <7E7605DC-021D-448A-8459-8EC26BA9836D@yahoo.com>
References:  <7E7605DC-021D-448A-8459-8EC26BA9836D.ref@yahoo.com>  <7E7605DC-021D-448A-8459-8EC26BA9836D@yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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.

root@rpi3-b:~ # uname -a
FreeBSD rpi3-b 13.0-CURRENT FreeBSD 13.0-CURRENT #0 r357853M:
 Thu Feb 13 11:46:46 CET 2020
 root@rpi-3b:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC  arm64
root@rpi3-b:~ # kldload mac_ntpd
Security policy loaded: MAC/ntpd (mac_ntpd)
root@rpi3-b:~ # kldstat
Id Refs Address                Size Name
 1   21 0xffff000000000000  1512678 kernel
 2    1 0xffff000001513000   2eedb0 zfs.ko
 3    2 0xffff000001802000    284d8 opensolaris.ko
 4    1 0xffff00005c600000    21000 uhid.ko
 5    1 0xffff00005c621000    21000 wmt.ko
 6    1 0xffff00005c642000    21000 mac_ntpd.ko
root@rpi3-b:~ # 

Thank you.

Ralf




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1j2EmR-000Mwm-ID>