From 4e314888eb6f67f147dd79b6943d4f16ccac373b Mon Sep 17 00:00:00 2001 From: kn Date: Thu, 30 Mar 2023 15:09:01 +0000 Subject: [PATCH] Map device tree read/write to unbreak root on softraid Since r1.76 "Get rid of pmap_map_early()" the FDT was mapped read-only, but CRYPTO softraid code writes it to zero out the key. Found and tested by me; explanation and fix from kettenis. OK kettenis --- sys/arch/arm64/arm64/machdep.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/arch/arm64/arm64/machdep.c b/sys/arch/arm64/arm64/machdep.c index b44af8d2c79..ff7886b9db7 100644 --- a/sys/arch/arm64/arm64/machdep.c +++ b/sys/arch/arm64/arm64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.79 2023/01/09 20:32:21 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.80 2023/03/30 15:09:01 kn Exp $ */ /* * Copyright (c) 2014 Patrick Wildt * Copyright (c) 2021 Mark Kettenis @@ -845,7 +845,7 @@ initarm(struct arm64_bootparams *abp) startpa = trunc_page((paddr_t)config); endpa = round_page((paddr_t)config + sizeof(struct fdt_head)); for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) - pmap_kenter_cache(va, pa, PROT_READ, PMAP_CACHE_WB); + pmap_kenter_cache(va, pa, PROT_READ | PROT_WRITE, PMAP_CACHE_WB); fh = (void *)(vstart + ((paddr_t)config - startpa)); if (betoh32(fh->fh_magic) != FDT_MAGIC || betoh32(fh->fh_size) == 0) panic("%s: no FDT", __func__); @@ -853,7 +853,7 @@ initarm(struct arm64_bootparams *abp) /* Map the remainder of the FDT. */ endpa = round_page((paddr_t)config + betoh32(fh->fh_size)); for (; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) - pmap_kenter_cache(va, pa, PROT_READ, PMAP_CACHE_WB); + pmap_kenter_cache(va, pa, PROT_READ | PROT_WRITE, PMAP_CACHE_WB); config = (void *)(vstart + ((paddr_t)config - startpa)); vstart = va; -- 2.20.1